This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLiveBeacon.py
executable file
·161 lines (114 loc) · 3.02 KB
/
LiveBeacon.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/python
"""
===============================================================
++++++++++++++++++++++++ READ ME ++++++++++++++++++++++++++++++
===============================================================
This Script Is Part Of
+++++++++++++++++++++++++++++++++++++
Simple Wireless Framework
+++++++++++++++++++++++++++++++++++++
Author :
Suraj Singh
Admin
S.S.B Group
www.bitforestinfo.com
Note: We Feel Proud To Be Indian
This Script Created Only For Practise And Educational Purpose Only
The Author Will Not Take Any Responsibility Of Any illegal Activity.
"""
#
# Live Beacon Packets Analyser
#
# This Script is Based On Pyshark
#
#
#
# import module
import pyshark
import sys
# Required Data Feild
Feild = {
# Key Value Required
'interface' : (None, True),
}
# Format For Printing Beacon Data
BEACON_FORMAT = '\t {bssid} {type} {subtype} {data_rate} {frequency} {channel} {signal} {addr} {ssid} {num}'
# Label
print '\t BSSID #Type #Subtype #Rate #Frequency #Channel #Signal #ADDR #ESSID #Beacon'
def display_info(data):
line = 0
for a,b in data.iteritems():
print BEACON_FORMAT.format(**b)
line+=1
# Backspace Trick
sys.stdout.write("\033[{}A".format(line))
return
# Function For Extracting From pyshark Packets
def ap_info_extractor(pkt):
'''
Extracting Various Values.
Labels :
bssid
type
subtype
addr
channel
frequency
signal
data_rate
phy
ssid
'''
ref = {}
ref['bssid'] = pkt.wlan.bssid
ref['type'] = pkt.wlan.fc_type
ref['subtype'] = pkt.wlan.fc_type_subtype
ref['addr'] = pkt.wlan.addr
ref['channel'] = pkt.wlan_radio.channel
ref['frequency']= pkt.wlan_radio.frequency
ref['signal'] = pkt.wlan_radio.signal_dbm
ref['data_rate']= pkt.wlan_radio.data_rate
ref['phy'] = pkt.wlan_radio.phy
ref['ssid'] = pkt.wlan_mgt.ssid
#ref['psk'] = pkt.wlan_mgt.rsn_akms_list
return ref
# Live Sniffing Function
def wlan_sniffer(cap):
"""
Function For Sniffing Live Beacon Packets From Interface
Based On Pyshark LiveCapture.
"""
# Captured Bssid List
bssid_list = {}
# Get Packets
for num, packets in enumerate(cap):
# Extract Information From Packet
data = ap_info_extractor(packets)
# Packet Num
data['num'] = num
# Append Data In Captured Bssid List
bssid_list[data['bssid']]=data
# Display Captured Packets Information
display_info(bssid_list)
return
# Main Function
def main(**kwargs):
"""
creating pyshark.LiveCapture Object With Beacon Filter Engaged.
"""
cap = pyshark.LiveCapture(display_filter="wlan.fc.type_subtype == 0x0008",**kwargs)
# Live Sniffing Function
wlan_sniffer(cap)
return
if __name__=='__main__':
# Get Arguments
args = sys.argv
if len(args)!=2:
# Check Interface Name Condition
print "[*] Please Provide Interface Name :\n :~# python {} [Interface_name]".format(args[0])
sys.exit(0)
# Interface Name
interface = args[1]
# Trigger Main
main(interface=interface)