64
64
def get_and_print_card_info():
65
## The function's name is self explanatory, but aniway this is thanks to mintwifi.py
65
##The function's name is self explanatory, but aniway this is thanks to mintwifi.py
66
66
os.system('lspci | grep \"Network controller\" > /tmp/detected_wireless_devices')
67
67
devices_file = open('/tmp/detected_wireless_devices')
68
68
for device_item in devices_file.readlines():
69
deviceArray = device_item.split()
70
device = ' '.join(deviceArray[3:])
71
pci_id_line = commands.getoutput('lspci -n | grep ' + deviceArray[0])
69
devicearray = device_item.split()
70
device = ' '.join(devicearray[3:])
71
pci_id_line = commands.getoutput('lspci -n | grep ' + devicearray[0])
72
72
pci_id_array = pci_id_line.split()
73
73
pci_id = ' '.join(pci_id_array[2:])
74
74
print ' -- ' + device
75
75
print ' ==> PCI ID = ' + pci_id
78
def check_for_internet(url, card):
78
def check_for_internet(url, card_id):
79
79
##Checks if the user has an internet connection available
80
80
print '[*] Looking if an Internet connection is available, this may take a few seconds.'
81
81
test = commands.getoutput('ping -c 1 google.com')
155
154
def create_auto_ndis_folder():
156
155
##Creates a folder to place the drivers
158
os.makedirs('%s/%s' % (opts.tmp_dir, card, ))
157
os.makedirs('%s/%s' % (opts.tmp_dir, card_id, ))
159
158
print 'Tmpdir created'
160
159
os.chmod(opts.tmp_dir,0777)
161
os.chdir('%s/%s' % (opts.tmp_dir, card, ))
160
os.chdir('%s/%s' % (opts.tmp_dir, card_id, ))
163
if os.path.exists('%s/%s' % (opts.tmp_dir, card, )):
162
if os.path.exists('%s/%s' % (opts.tmp_dir, card_id, )):
164
163
print 'Tmpdir exists and ok, continuing'
165
os.chdir('%s/%s' % (opts.tmp_dir, card, ))
164
os.chdir('%s/%s' % (opts.tmp_dir, card_id, ))
167
166
print '[ERROR] cant create tmpdir'
168
167
print ' Either specify an alternative or ensure that /tmp is writable and not full'
173
172
decompression = 'manual'
175
174
if '.exe' in driver_url or '.zip' in driver_url:
176
decompression = 'unzip '
175
decompression = 'unzip'
178
177
elif '.tar' in driver_url:
179
decompression = 'tar -vvf '
178
decompression = 'tar -vvf'
181
180
elif '.tar.gz' in driver_url:
182
decompression = 'tar -xvvzf '
181
decompression = 'tar -xvvzf'
184
183
elif '.tar.bz2' in driver_url:
185
decompression = 'tar -xvvjf '
184
decompression = 'tar -xvvjf'
187
186
elif '.cab' in driver_url:
188
decompression = 'cabextract '
187
decompression = 'cabextract'
190
189
elif '.rar' in driver_url:
191
decompression = 'unrar '
190
decompression = 'unrar'
193
192
if decompression != 'manual':
194
193
#Checks if the system has the necessary decompression program
200
199
return decompression
202
def fetchnextract(url, card):
203
## determine decompression method
204
decompression = 'manual'
205
decompression = find_decompression(url)
207
if ( decompression != 'manual'):
209
print '[*] Downloading driver now from "%s"' % (url, )
211
os.system('wget %s -qO %s/%s/driver' % (url, opts.tmp_dir, card))
201
def fetch(url, card_id):
202
##Determine decompression method
203
print '[*] Downloading driver now from "%s"' % (url, )
205
retcode = subprocess.call(['wget', url, '-qO', opts.tmp_dir/card_id/driver])
207
print '[ERROR] Download unsuccessfull, please check your Internet conecction'
213
os.system('wget %s -O %s/%s/driver' % (url, opts.tmp_dir, card))
210
retcode = subprocess.call(['wget', url, '-O', opts.tmp_dir/card_id/driver])
212
print '[ERROR] Download unsuccessfull, please check your Internet conecction'
214
214
print ' Download successfull'
215
print '[*] Extracting driver'
217
print '[DEBUG] Decompression method: %s' % (decompression, )
219
os.system('%s %s/%s/driver' % (decompression, opts.tmp_dir, card))
216
def extract(decompression):
217
print '[*] Extracting driver'
220
print '[DEBUG] Decompression method: %s' % (decompression, )
222
retcode = subprocess.call([decompression, opts.tmp_dir/card_id/driver])
225
print '[ERROR] Decompression failed'
226
choice = raw_input('(C)ontinue, (R)etry, (S)pecify different decompression method or (E)xit: ')
228
if choice == 'C' or choice == 'c':
231
elif choice == 'R' or choice == 'r':
232
return extract(decompression)
234
elif choice == 'S' or choice == 's':
235
divided_url = url.split('.')
236
file_type = divided_url[len(divided_url)-1]
237
decompression = raw_input('Enter command to decompress %s files: ' % (file_type, ))
238
return extract(decompression)
240
elif choice == 'E' or choice == 'e':
244
return extract(decompression)
222
manualmode(url, card)
246
manualmode(url, card_id)
224
def manualmode(url, card):
248
def manualmode(url, card_id):
225
249
##Comes into play if the user doesn't have an internet connection or if the driver need to be fetched manually
226
yourcard = data[card]
227
driver = yourcard['driver']
250
yourcard_dic = data[card_id]
251
driver = yourcard_dic['driver']
228
252
print 'The driver needs to be fetched manually from: %s' % (url, )
229
253
print 'Please place the "%s" file, along with the .sys files into:' % (driver, )
230
print '"%s/%s/"' % (opts.tmp_dir, card, )
231
while not any(driver in line for line in os.listdir('%s/%s/' % (opts.tmp_dir, card, ))):
232
#while ((commands.getoutput("ls %s/%s/|grep %s" % (opts.tmp_dir, card, driver, ))) == ""):
254
print '"%s/%s/"' % (opts.tmp_dir, card_id, )
255
while not any(driver in line for line in os.listdir('%s/%s/' % (opts.tmp_dir, card_id, ))):
256
#while ((commands.getoutput("ls %s/%s/|grep %s" % (opts.tmp_dir, card_id, driver, ))) == ""):
234
258
dummy = raw_input('When you have succesfully dowloaded the driver and extracted it press <Enter>: ')
237
## executed when CTRL + C is pressed
261
##Executed when CTRL + C is pressed
238
262
print '\n\nCanceled!\n'
240
264
print ' Driver file found! Continuing installation.'
242
def installdriver(card):
266
def installdriver(card_id):
243
267
##Installs the driver with NDISwrapper
244
driver = yourcard['driver']
245
Inf = commands.getoutput('find %s/%s/ -name %s' % (opts.tmp_dir, card, driver, ))
268
driver = yourcard_dic['driver']
269
Inf = commands.getoutput('find %s/%s/ -name %s' % (opts.tmp_dir, card_id, driver, ))
246
270
if ( opts.debug ):
247
271
print '[DEBUG] Driver found at %s' % (Inf, )
248
272
os.system('%s -i %s' % (opts.ndiswrapper_bin, Inf, ))
249
273
os.system('%s -l' % (opts.ndiswrapper_bin, ))
250
274
os.system('%s -ma' % (opts.ndiswrapper_bin, ))
251
os.system('modprobe -r ndiswrapper')
252
275
os.system('modprobe ndiswrapper')
253
276
os.system('echo ndiswrapper >> /etc/modules')
322
344
get_and_print_card_info()
347
card_id = get_card_id()
348
yourcard_dic = data[card_id]
349
url = yourcard_dic['url']
350
driver = yourcard_dic['driver']
351
decompression = find_decompression(url)
326
353
print '[*] Card Supported'
327
yourcard = data[card]
328
print '[*] Will attempt to fetch and install driver for this card'
329
get_and_print_card_info()
330
url = yourcard['url']
354
print '[*] Will attempt to fetch and install driver for the card with id: %s' % (card_id, )
331
355
print '[*] Will attempt to fetch driver from: %s' % (url, )
332
driver = yourcard['driver']
333
print '[*] Will attempt to install driver: %s\n' % (driver, )
356
print '[*] Will attempt to install driver: %s' % (driver, )
336
359
print ' Do you want to continue?'