@@ -90,17 +90,25 @@ def stop(self):
90
90
91
91
def get_output (self ):
92
92
''' Returns stdout from aireplay process '''
93
- return self .pid . stdout ()
93
+ return self .stdout
94
94
95
95
def run (self ):
96
+ self .stdout = ''
97
+ self .xor_percent = '0%'
96
98
while self .pid .poll () is None :
97
99
time .sleep (0.1 )
98
100
if not os .path .exists (self .output_file ): continue
99
101
# Read output file & clear output file
100
102
with open (self .output_file , "r+" ) as fid :
101
103
lines = fid .read ()
104
+ self .stdout += lines
102
105
fid .seek (0 )
103
106
fid .truncate ()
107
+
108
+ if Configuration .verbose > 1 and lines .strip () != '' :
109
+ from ..util .color import Color
110
+ Color .pl ('\n {P} [?] aireplay output:\n %s{W}' % lines .strip ().replace ('\n ' , '\n ' ))
111
+
104
112
for line in lines .split ("\n " ):
105
113
line = line .replace ("\r " , "" ).strip ()
106
114
if line == "" : continue
@@ -124,33 +132,85 @@ def run(self):
124
132
self .status = True
125
133
elif self .attack_type == WEPAttackType .chopchop :
126
134
# Look for chopchop status. Potential output lines:
135
+
127
136
# (START) Read 178 packets...
128
137
read_re = re .compile (r"Read (\d+) packets" )
129
138
matches = read_re .match (line )
130
139
if matches :
131
140
self .status = "Waiting for packet (read %s)..." % matches .group (1 )
141
+
142
+ # Sent 1912 packets, current guess: 70...
143
+ sent_re = re .compile (r"Sent (\d+) packets, current guess: (\w+)..." )
144
+ matches = sent_re .match (line )
145
+ if matches :
146
+ self .status = "Generating .xor (%s)... current guess: %s" % (self .xor_percent , matches .group (2 ))
147
+
132
148
# (DURING) Offset 52 (54% done) | xor = DE | pt = E0 | 152 frames written in 2782ms
133
149
offset_re = re .compile (r"Offset.*\(\s*(\d+%) done\)" )
134
150
matches = offset_re .match (line )
135
151
if matches :
136
- self .status = "Generating Xor (%s)" % matches .group (1 )
152
+ self .xor_percent = matches .group (1 )
153
+ self .status = "Generating .xor (%s)..." % matches .group (1 )
154
+
137
155
# (DONE) Saving keystream in replay_dec-0516-202246.xor
138
156
saving_re = re .compile (r"Saving keystream in (.*\.xor)" )
139
157
matches = saving_re .match (line )
140
158
if matches :
141
159
self .status = matches .group (1 )
142
- pass
160
+
161
+ # (ERROR) fakeauth required
162
+ if 'try running aireplay-ng in authenticated mode' in line :
163
+ self .status = 'fakeauth is required and you are not authenticated'
164
+
143
165
elif self .attack_type == WEPAttackType .fragment :
144
- # TODO: Parse fragment output, update self.status
166
+ # Parse fragment output, update self.status
167
+
168
+ # (START) Read 178 packets...
169
+ read_re = re .compile (r"Read (\d+) packets" )
170
+ matches = read_re .match (line )
171
+ if matches :
172
+ self .status = "Waiting for packet (read %s)..." % matches .group (1 )
173
+
145
174
# 01:08:15 Waiting for a data packet...
175
+ if 'Waiting for a data packet' in line :
176
+ self .status = 'waiting for packet'
177
+
178
+ # Read 207 packets...
179
+ trying_re = re .compile (r"Trying to get (\d+) bytes of a keystream" )
180
+ matches = trying_re .match (line )
181
+ if matches :
182
+ self .status = 'trying to get %sb of a keystream' % matches .group (1 )
183
+
146
184
# 01:08:17 Sending fragmented packet
185
+ if 'Sending fragmented packet' in line :
186
+ self .status = 'sending packet'
187
+
147
188
# 01:08:37 Still nothing, trying another packet...
189
+ if 'Still nothing, trying another packet' in line :
190
+ self .status = 'sending another packet'
191
+
148
192
# XX:XX:XX Trying to get 1500 bytes of a keystream
193
+ trying_re = re .compile (r"Trying to get (\d+) bytes of a keystream" )
194
+ matches = trying_re .match (line )
195
+ if matches :
196
+ self .status = 'trying to get %sb of a keystream' % matches .group (1 )
197
+
149
198
# XX:XX:XX Got RELAYED packet!!
199
+ if 'Got RELAYED packet' in line :
200
+ self .status = 'got relayed packet'
201
+
150
202
# XX:XX:XX Thats our ARP packet!
203
+ if 'Thats our ARP packet' in line :
204
+ self .status = 'relayed packet was our'
205
+
151
206
# XX:XX:XX Saving keystream in fragment-0124-161129.xor
207
+ saving_re = re .compile (r"Saving keystream in (.*\.xor)" )
208
+ matches = saving_re .match (line )
209
+ if matches :
210
+ self .status = 'saving keystream to %s' % saving_re .group (1 )
211
+
152
212
# XX:XX:XX Now you can build a packet with packetforge-ng out of that 1500 bytes keystream
153
- pass
213
+
154
214
else : # Replay, forged replay, etc.
155
215
# Parse Packets Sent & PacketsPerSecond. Possible output lines:
156
216
# Read 55 packets (got 0 ARP requests and 0 ACKs), sent 0 packets...(0 pps)
@@ -188,7 +248,7 @@ def get_aireplay_command(target, attack_type,
188
248
cmd = ["aireplay-ng" ]
189
249
cmd .append ("--ignore-negative-one" )
190
250
191
- if not client_mac and len (target .clients ) > 0 :
251
+ if client_mac is None and len (target .clients ) > 0 :
192
252
# Client MAC wasn't specified, but there's an associated client. Use that.
193
253
client_mac = target .clients [0 ].station
194
254
0 commit comments