Nmap Scan (pip: python-nmap): scanner = nmap.PortScanner()
scanner.scan('target_ip', '1-1024', ' -v -sV -sC -O -oN report.txt')
Scapy http-request (pip: scapy):
HEAD = "HTTP/1.1 200 OK\r\nServer: target-server\r\nContent-Length: 6\r\n\r\nbody"
IP(src="192.168.0.2", dst="192.168.0.1")/TCP(sport=80, dport=5000, flags="A", seq=ACK.ack, ack=ACK.seq)/HEAD
Scapy ARP Discovery: request = ARP(pdst='192.168.1.1') "THEN" answer = sr1(request) "FINALLY" print(answer.hwsrc)
Scapy Spoof IP & MAC:
packet = IP(src='10.0.0.1', dst='10.0.0.2')/ICMP()
ether = Ether(src='00:00:00:00:00:00')
spoofed_packet = ether/packet
sendp(spoofed_packet)
Requests (pip: requests): url = 'https://httpbin.org/get'
headers = {'User-Agent': 'Bing'}
response = requests.get(url, headers=headers)
print(response.headers)
OS Library
List Files/Folders: os.listdir()
Make Directory: os.mkdir('new_folder')
Delete File: os.remove('file_name')
Execute System Commands: os.system("your_command")
Subprocess Library
Run a Command:
output = subprocess.run(["command", "arg1", "arg2"], capture_output=True, text=True).stdout
Send Input: input = "some data"
output = subprocess.run(["command", "arg1", "arg2"], input=input, capture_output=True, text=True).stdout
Run/Display Command: process = subprocess.Popen(['command_1', 'command_2'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
print(stdout)