-
Notifications
You must be signed in to change notification settings - Fork 4
/
beacon_flood_raw.py
executable file
·150 lines (115 loc) · 2.92 KB
/
beacon_flood_raw.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
#
# beacon_flood_raw.py - Simple IEEE 802.11
# beacon flooder using pylorcon2's raw
# sending capabilities.
#
# brad.antoniewicz@foundstone.com
#
#
import getopt
import sys
import string
from time import sleep
import PyLorcon2
def usage():
print "\t-i <int> \tInterface"
print "\t-c <channel> \tChannel"
print "\nExample: "
print "\t",sys.argv[0],"-i wlan0 -c 11\n"
'''
main
'''
print sys.argv[0]," - Simple 802.11 beacon flooder"
print "-----------------------------------------------------\n"
# Beacon interval
interval = 100
# Raw packet bytes (from capture_example.c included within LORCON)
packet = "\x80\x00\xff\xff\xff\xff\xff\xff" \
"\xff\xff\x00\x0f\x66\xe3\xe4\x03" \
"\x00\x0f\x66\xe3\xe4\x03\x00\x00" \
"\xff\xff\xff\xff\xff\xff\xff\xff" \
"\x64\x00\x11\x00\x00\x0f\x73\x6f" \
"\x6d\x65\x74\x68\x69\x6e\x67\x63" \
"\x6c\x65\x76\x65\x72\x01\x08\x82" \
"\x84\x8b\x96\x24\x30\x48\x6c\x03" \
"\x01\x01\x05\x04\x00\x01\x00\x00" \
"\x2a\x01\x05\x2f\x01\x05\x32\x04" \
"\x0c\x12\x18\x60\xdd\x05\x00\x10" \
"\x18\x01\x01\xdd\x16\x00\x50\xf2" \
"\x01\x01\x00\x00\x50\xf2\x02\x01" \
"\x00\x00\x50\xf2\x02\x01\x00\x00" \
"\x50\xf2\x02"
interface = channel = None
'''
This handles all of the command line arguments
'''
try:
opts, args = getopt.getopt(sys.argv[1:], "i:c:h",[])
except getopt.GetoptError:
usage()
sys.exit(-1)
for o,a in opts:
if o == "-i":
interface = a
if o == "-c":
channel = string.atoi(a)
if o == "-h":
usage()
if ( (interface is None) or (channel is None) ):
print "ERROR: Interface or channel not set (see -h for more info)"
sys.exit(-1)
print "[+] Using interface",interface
'''
The following is all of the standard interface, driver, and context setup
'''
# Automatically determine the driver of the interface
try:
driver, description = PyLorcon2.auto_driver(interface)
if driver is not None:
print "[+]\t Driver:",driver
except:
print "[!] Could not determine the driver for",interface
sys.exit(-1)
# Create LORCON context
try:
ctx = PyLorcon2.Context(interface)
except:
print "[!]\t Failed to create context"
sys.exit(-1)
# Create Monitor Mode Interface
try:
ctx.open_injmon()
vap = ctx.get_vap()
if vap is not None:
print "[+]\t Monitor Mode VAP:",vap
except:
print "[!]\t Could not create Monitor Mode interface!"
sys.exit(-1)
# Set the channel we'll be injecting on
try:
ctx.set_channel(channel)
print "[+]\t Using channel:",channel,"\n"
except:
print "[!]\t Could not set channel!"
sys.exit(-1)
'''
The following is the packet creation and sending code
'''
# Keep sending frames until interrupted
count = 0
while 1:
try:
ctx.send_bytes(packet)
sleep(interval/1000.0)
print "[+] Sent",count,"frames, Hit CTRL + C to stop...\r",
sys.stdout.flush()
except:
print "\n[!] Exiting..."
sys.exit(0)
count+=1
'''
The following is all of the standard cleanup stuff
'''
# Close the interface
ctx.close()