Network Attackers Documentation
Arp spoofer
check_args(target_ip, spoof_ip)
checks if arguments fetched are valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_ip |
str
|
IP address of the target |
required |
spoof_ip |
str
|
spoofed IP address which should be binded with your MAC address |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | True if all args are valid else exit |
Source code in pyhtools\attackers\Network\arpspoofer.py
generate_packet(pdst, hwdst, psrc)
generates spoof packets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pdst |
str
|
IP address of destination |
required |
hwdst |
str
|
MAC address of destination |
required |
psrc |
str
|
IP address of source |
required |
Returns:
Type | Description |
---|---|
scapy.ARP: spoofed ARP packet with specified configuration |
Source code in pyhtools\attackers\Network\arpspoofer.py
get_args()
get arguments from command line
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
get_mac(ip)
retrieves mac address from the ip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ip |
str
|
IP address |
required |
Returns:
Name | Type | Description |
---|---|---|
str | MAC address of specified IP address |
Source code in pyhtools\attackers\Network\arpspoofer.py
mitm(target_ip, spoof_ip, args_status)
performs man in the middle attack by arp poisoning
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_ip |
str
|
IP address of target machine |
required |
spoof_ip |
str
|
IP address to be spoofed by attacker's machine |
required |
args_status |
bool
|
True if cli args are valid else False |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
restore_default_table(dst_ip, src_ip)
restore default arp table of spoofed targets
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dst_ip |
str
|
IP address of destination machine |
required |
src_ip |
str
|
IP address to be spoofed by src machine |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
run_spoofer(target_ip, spoof_ip, perform_mitm)
start spoofer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dst_ip |
str
|
IP address of destination machine |
required |
src_ip |
str
|
IP address to be spoofed by src machine |
required |
perform_mitm |
bool
|
True if MITM has to be performed else False |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
spoof(target_ip, spoof_ip, args_status)
spoof target with spoof ip mac
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_ip |
str
|
IP address of target machine |
required |
spoof_ip |
str
|
IP address to be spoofed by attacker's machine |
required |
args_status |
bool
|
True if cli args are valid else False |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
spoof_only(target_ip, spoof_ip, args_status)
only spoofs the specified target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_ip |
str
|
IP address of target machine |
required |
spoof_ip |
str
|
IP address to be spoofed by attacker's machine |
required |
args_status |
bool
|
True if cli args are valid else False |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\arpspoofer.py
DNS Spoofer
forward_packets()
configures the mitm for incoming request packets into a queue
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\dnsspoofer.py
process_packet(packet)
process received packet, everytime a packet is received. prints the packet received in the queue and it changes the DNS response dest ip with your desired ip
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
IP packet from netfilterqueue/iptables |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\dnsspoofer.py
reset_config()
resets the configurations changed while exectution of the program to its original configuration
Returns:
Type | Description |
---|---|
None |
run()
Starts DNS spoofer
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\dnsspoofer.py
Downloads Replacer
forward_packets()
configures the mitm for incoming request packets into a queue.
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\downloads_replacer.py
process_packet(packet)
process received packet, everytime a packet is received. prints the packet received in the queue and it changes the DNS response dest ip with your desired ip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
packet from netfilterqueue/iptables |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\downloads_replacer.py
reset_config()
resets the configurations changed while exectution of the program to its original configuration
Returns:
Type | Description |
---|---|
None |
run()
Starts download replacer
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\downloads_replacer.py
set_load(packet, load)
sets the packet raw layer load value to the passed load value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
scapy IP packet |
required |
load |
bytes
|
payload data as bytes |
required |
Returns:
Type | Description |
---|---|
scapy.IP: returns packet with load |
Source code in pyhtools\attackers\Network\downloads_replacer.py
Mac Changer
change_mac(intrfc, new_mac)
changes mac address of the interface. returns True if mac changes successfully.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfc |
str
|
network interface whose MAC address needs to be changed |
required |
new_mac |
str
|
new MAC address for the network interface |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | Returns True if MAC address is changed successfully else exits program |
Source code in pyhtools\attackers\Network\machngr.py
check_args(intrfc, new_mac)
checks if args are valid, prints appropriate error and exit
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfc |
str
|
network interface whose MAC address needs to be changed |
required |
new_mac |
str
|
new MAC address for the network interface |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | Returns True if all parsed arguments are valid |
Source code in pyhtools\attackers\Network\machngr.py
check_mac_change(intrfc, new_mac, mac_change_status)
checks if mac address has been changed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfc |
str
|
network interface whose MAC address needs to be changed |
required |
new_mac |
str
|
new MAC address for the network interface |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | Returns True if MAC address was changed successfully else False |
Source code in pyhtools\attackers\Network\machngr.py
generate_random_mac()
generates and returns a random mac address
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
New MAC Address |
Source code in pyhtools\attackers\Network\machngr.py
get_arguments()
get arguments from the cli
Returns:
Name | Type | Description |
---|---|---|
tuple | contains (interface, new_mac) |
Source code in pyhtools\attackers\Network\machngr.py
run_macchanger(interface, new_mac)
run mac changer commands based on OS
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfc |
str
|
network interface whose MAC address needs to be changed |
required |
new_mac |
str
|
new MAC address for the network interface |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\machngr.py
Network Jammer
forward_packets()
configures the mitm for incoming request packets into a queue.
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\network_jammer.py
process_packet(packet)
process received packet, everytime a packet is received. prints the packet received in the queue and drops packet
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
IP packet from netfiterqueue/iptables |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\network_jammer.py
reset_config()
resets the configurations changed while exectution of the program to its original configuration
Returns:
Type | Description |
---|---|
None |
run()
Start network jammer
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\network_jammer.py
Network Scanner
get_args()
get arguments from the command line.
Returns:
Name | Type | Description |
---|---|---|
str | IP address/range |
Source code in pyhtools\attackers\Network\nwscan.py
print_clients(clients)
prints discovered clients on the network ip range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clients |
list
|
list of discovered ip addresses |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\nwscan.py
run_nwscan(ip)
starts network scanner for specified ip range or ip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ip |
str
|
IP address/range of scan target |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\nwscan.py
scan(ip)
scans ip range for clients and returns discovered clients list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ip |
str
|
IP address/range of client to be discovered |
required |
Returns:
Name | Type | Description |
---|---|---|
list | IP addresses of discovered network clients |
Source code in pyhtools\attackers\Network\nwscan.py
Packet Sniffer
check_args(intrfce)
checks if the passed arguments are valid. if valid returns True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfce |
str
|
network inferface on which sniffing action is be performed |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | returns True if args are valid else False |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
get_args()
get arguments from the command line.
Returns:
Name | Type | Description |
---|---|---|
str | network interface |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
get_login_info(packet)
extract login information from the sniffed packet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
scapy packet |
required |
Returns:
Name | Type | Description |
---|---|---|
str | URL with login information |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
get_url(packet)
extract url from the packet
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
scapy packet |
required |
Returns:
Name | Type | Description |
---|---|---|
str | URL inside the HTTP packet |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
process_sniffed_pkt(packet)
analyze the captured packet for login information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
scapy.IP
|
scapy packet |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
sniffer(intrfce, args_status)
sniffs packets over the network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intrfce |
str
|
network interface for sniffing action |
required |
args_status |
bool
|
True if cli args are valid else False |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\pkt_sniffer.py
TCP proxy
This is still work in progress, It might be unstable.
TCProxy
TCP proxy
Source code in pyhtools\attackers\Network\tcp_proxy.py
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
__init__(filepath=None)
TCProxy class constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
path to file for storing captured data |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyhtools\attackers\Network\tcp_proxy.py
__write_data(data)
Write Data to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
data to be written to the file |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\tcp_proxy.py
handler(func)
staticmethod
decorator used for packet modification
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
function
|
method function to be wrapped |
required |
Returns:
Name | Type | Description |
---|---|---|
function | wrapped function with error handling |
Source code in pyhtools\attackers\Network\tcp_proxy.py
proxy_handler(client_sock, remote_host, remote_port, receive_first, v4=True)
handles proxy connections
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_sock |
socket.socket
|
client TCP socket connection |
required |
remote_host |
str
|
IP address of the remote host |
required |
remote_port |
int
|
port of remote host |
required |
receive_first |
bool
|
if True proxy will start receiving data else it'll send |
required |
v4 |
bool
|
if True uses IP v4 address else IP v6 |
True
|
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\Network\tcp_proxy.py
receive_from(conn)
Accepts socket data and returns data from the buffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conn |
socket.socket
|
socket connection for reception |
required |
Returns:
Name | Type | Description |
---|---|---|
bytes | returns received data |
Source code in pyhtools\attackers\Network\tcp_proxy.py
request_handler(buff)
manipulate buffer data before sending request to remote host
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff |
bytes
|
received data |
required |
Returns:
Name | Type | Description |
---|---|---|
bytes | received data after handling request |
Source code in pyhtools\attackers\Network\tcp_proxy.py
response_handler(buff)
manipulate buffer data after receiving from remote host
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff |
bytes
|
received data |
required |
Returns:
Name | Type | Description |
---|---|---|
bytes | received data after handling request |
serve_proxy(remote_host, remote_port, host='0.0.0.0', port=8080, max_conns=5, receive_first=False, v4=True)
Starts Proxy Server
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remote_host |
str
|
IP address of the remote host |
required |
remote_port |
int
|
port of remote host |
required |
host |
str
|
ip address of binding interface (default = '0.0.0.0', listens on all interfaces) |
'0.0.0.0'
|
port |
int
|
port address of binding interface |
8080
|
max_conns |
int
|
maximum number of connections to listen for |
5
|
receive_first |
bool
|
if True proxy will start receiving data else it'll send |
False
|
v4 |
bool
|
if True uses IP v4 address else IP v6 |
True
|
Returns:
Type | Description |
---|---|
None |