@@ -37,6 +37,15 @@ def run(self):
37
37
replay_file = None
38
38
airodump_target = None
39
39
40
+ previous_ivs = 0
41
+ current_ivs = 0
42
+ total_ivs = 0
43
+ keep_ivs = Configuration .wep_keep_ivs
44
+
45
+ # Clean up previous WEP sessions
46
+ if keep_ivs :
47
+ Airodump .delete_airodump_temp_files ('wep' )
48
+
40
49
attacks_remaining = list (Configuration .wep_attacks )
41
50
while len (attacks_remaining ) > 0 :
42
51
attack_name = attacks_remaining .pop (0 )
@@ -47,7 +56,8 @@ def run(self):
47
56
target_bssid = self .target .bssid ,
48
57
ivs_only = True , # Only capture IVs packets
49
58
skip_wps = True , # Don't check for WPS-compatibility
50
- output_file_prefix = 'wep' ) as airodump :
59
+ output_file_prefix = 'wep' ,
60
+ delete_existing_files = not keep_ivs ) as airodump :
51
61
52
62
Color .clear_line ()
53
63
Color .p ('\r {+} {O}waiting{W} for target to appear...' )
@@ -81,7 +91,7 @@ def run(self):
81
91
replay_file = replay_file )
82
92
83
93
time_unchanged_ivs = time .time () # Timestamp when IVs last changed
84
- previous_ivs = 0
94
+ last_ivs_count = 0
85
95
86
96
# Loop until attack completes.
87
97
@@ -91,7 +101,12 @@ def run(self):
91
101
if client_mac is None and len (airodump_target .clients ) > 0 :
92
102
client_mac = airodump_target .clients [0 ].station
93
103
94
- total_ivs = airodump_target .ivs
104
+ if keep_ivs and current_ivs > airodump_target .ivs :
105
+ # We now have less IVS than before; A new attack must have started.
106
+ # Track how many we have in-total.
107
+ previous_ivs += total_ivs
108
+ current_ivs = airodump_target .ivs
109
+ total_ivs = previous_ivs + current_ivs
95
110
96
111
status = "%d/{C}%d{W} IVs" % (total_ivs , Configuration .wep_crack_at_ivs )
97
112
if fakeauth_proc :
@@ -118,6 +133,9 @@ def run(self):
118
133
self .crack_result = CrackResultWEP (self .target .bssid ,
119
134
self .target .essid , hex_key , ascii_key )
120
135
self .crack_result .dump ()
136
+
137
+ Airodump .delete_airodump_temp_files ('wep' )
138
+
121
139
self .success = True
122
140
return self .success
123
141
@@ -127,31 +145,26 @@ def run(self):
127
145
128
146
# Check number of IVs, crack if necessary
129
147
if total_ivs > Configuration .wep_crack_at_ivs :
130
- if not aircrack :
148
+ if not aircrack or not aircrack . is_running () :
131
149
# Aircrack hasn't started yet. Start it.
132
150
ivs_files = airodump .find_files (endswith = '.ivs' )
151
+ ivs_files .sort ()
133
152
if len (ivs_files ) > 0 :
134
- aircrack = Aircrack (ivs_files [- 1 ])
135
-
136
- elif not aircrack .is_running ():
137
- # Aircrack stopped running.
138
- #Color.pl('\n{+} {C}aircrack{W} stopped, restarting...')
139
- ivs_files = airodump .find_files (endswith = 'ivs' )
140
- if len (ivs_files ) > 0 :
141
- aircrack = Aircrack (ivs_files [- 1 ])
142
- # TODO: Why do we need fakeauth when aircrack stops?
143
- #self.fake_auth()
153
+ if not keep_ivs :
154
+ ivs_files = ivs_files [- 1 ] # Use most-recent .ivs file
155
+ aircrack = Aircrack (ivs_files )
144
156
145
- '''
146
157
elif Configuration .wep_restart_aircrack > 0 and \
147
158
aircrack .pid .running_time () > Configuration .wep_restart_aircrack :
148
159
# Restart aircrack after X seconds
160
+ #Color.pl('\n{+} {C}aircrack{W} ran for more than {C}%d{W} seconds, restarting' % Configuration.wep_restart_aircrack)
149
161
aircrack .stop ()
150
162
ivs_files = airodump .find_files (endswith = '.ivs' )
151
- Color.pl(' \n {+} {C}aircrack{W} ran for more than {C}%d{W} seconds, restarting' % Configuration.wep_restart_aircrack )
163
+ ivs_files . sort ( )
152
164
if len (ivs_files ) > 0 :
153
- aircrack = Aircrack(ivs_files[-1])
154
- '''
165
+ if not keep_ivs :
166
+ ivs_files = ivs_files [- 1 ] # Use most-recent .ivs file
167
+ aircrack = Aircrack (ivs_files )
155
168
156
169
157
170
if not aireplay .is_running ():
@@ -186,6 +199,7 @@ def run(self):
186
199
'forgedreplay' ,
187
200
client_mac = client_mac ,
188
201
replay_file = replay_file )
202
+ time_unchanged_ivs = time .time () # Reset unchanged IVs time (it may have taken a while to forge the packet)
189
203
continue
190
204
else :
191
205
# Failed to forge packet. drop out
@@ -197,7 +211,7 @@ def run(self):
197
211
break # Continue to other attacks
198
212
199
213
# Check if IVs stopped flowing (same for > N seconds)
200
- if airodump_target .ivs > previous_ivs :
214
+ if airodump_target .ivs > last_ivs_count :
201
215
time_unchanged_ivs = time .time ()
202
216
elif Configuration .wep_restart_stale_ivs > 0 and \
203
217
attack_name != 'chopchop' and \
@@ -214,7 +228,7 @@ def run(self):
214
228
client_mac = client_mac , \
215
229
replay_file = replay_file )
216
230
time_unchanged_ivs = time .time ()
217
- previous_ivs = airodump_target .ivs
231
+ last_ivs_count = airodump_target .ivs
218
232
219
233
time .sleep (1 )
220
234
continue
@@ -223,11 +237,19 @@ def run(self):
223
237
except KeyboardInterrupt :
224
238
if fakeauth_proc : fakeauth_proc .stop ()
225
239
if len (attacks_remaining ) == 0 :
240
+ if keep_ivs :
241
+ Airodump .delete_airodump_temp_files ('wep' )
242
+
226
243
self .success = False
227
244
return self .success
245
+
228
246
if self .user_wants_to_stop (attack_name , attacks_remaining , airodump_target ):
247
+ if keep_ivs :
248
+ Airodump .delete_airodump_temp_files ('wep' )
249
+
229
250
self .success = False
230
251
return self .success
252
+
231
253
except Exception as e :
232
254
Color .pl ("\n {!} {R}Error: {O}%s" % str (e ))
233
255
if Configuration .verbose > 0 or Configuration .print_stack_traces :
@@ -243,6 +265,9 @@ def run(self):
243
265
# End of big try-catch
244
266
# End of for-each-attack-type loop
245
267
268
+ if keep_ivs :
269
+ Airodump .delete_airodump_temp_files ('wep' )
270
+
246
271
self .success = False
247
272
return self .success
248
273
0 commit comments