0

Hi
Anyone know why this program not work?I wonder if I use right usage?

import os
import optparse
import mechanize
import urllib
import re
import urlparse
from _winreg import *
def val2addr(val):
    addr = ''
    for ch in val:
        addr += '%02x ' % ord(ch)
    addr = addr.strip(' ').replace(' ', ':')[0:17]
    return addr


def wiglePrint(username, password, netid):
    browser = mechanize.Browser()
    browser.open('http://wigle.net')
    reqData = urllib.urlencode({'credential_0': username,
                               'credential_1': password})
    browser.open('https://wigle.net/gps/gps/main/login', reqData)
    params = {}
    params['netid'] = netid
    reqParams = urllib.urlencode(params)
    respURL = 'http://wigle.net/gps/gps/main/confirmquery/'
    resp = browser.open(respURL, reqParams).read()
    mapLat = 'N/A'
    mapLon = 'N/A'
    rLat = re.findall(r'maplat=.*\&', resp)
    if rLat:
        mapLat = rLat[0].split('&')[0].split('=')[1]
    rLon = re.findall(r'maplon=.*\&', resp)
    if rLon:
        mapLon = rLon[0].split
    print '[-] Lat: ' + mapLat + ', Lon: ' + mapLon


def printNets(username, password):
    net = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"+\
          "\NetworkList\Signatures\Unmanaged"
    key = OpenKey(HKEY_LOCAL_MACHINE, net)
    print '\n[*] Networks You have Joined.'
    for i in range(100):
        try:
            guid = EnumKey(key, i)
            netKey = OpenKey(key, str(guid))
            (n, addr, t) = EnumValue(netKey, 5)
            (n, name, t) = EnumValue(netKey, 4)
            macAddr = val2addr(addr)
            netName = str(name)
            print '[+] ' + netName + '  ' + macAddr
            wiglePrint(username, password, macAddr)
            CloseKey(netKey)
        except:
            break


def main():
    parser = optparse.OptionParser('usage %prog '+\
      '-u <wigle username> -p <wigle password>')
    parser.add_option('-u', dest='username', type='string',
                      help='specify wigle password')
    parser.add_option('-p', dest='password', type='string',
                      help='specify wigle username')
    (options, args) = parser.parse_args()
    username = options.username
    password = options.password
    if username == None or password == None:
        print parser.usage
        exit(0)
    else:
        printNets(username, password)


if __name__ == '__main__':
    main()

Output

================================ RESTART ================================

usage %prog -u <wigle username> -p <wigle password>

Traceback (most recent call last):
  File "C:\Users\linux\Desktop\1-discoverNetworks.py", line 78, in <module>
    main()
  File "C:\Users\linux\Desktop\1-discoverNetworks.py", line 72, in main
    exit(0)
  File "C:\Python27\lib\site.py", line 372, in __call__
    raise SystemExit(code)
SystemExit: 0
>>> 

Edited by tony75: Moved to Python forum

3
Contributors
3
Replies
35
Views
4 Years
Discussion Span
Last Post by kwheeles
0

It appears that user name or password are None as the program prints the message and then exits, but it should be sys.exit(0) instead of exit(0).

Edited by woooee

0

Thanks woooee
I changed to the sys.exit(0) but still get error again?
Do you know how can I fix error?

C:\Users\matrix\Desktop>python discoverNetworks.py -u xxxx -p xxxx
Traceback (most recent call last):
  File "discoverNetworks.py", line 77, in <module>
    main()
  File "discoverNetworks.py", line 73, in main
    printNets(username, password)
  File "discoverNetworks.py", line 42, in printNets
    key = OpenKey(HKEY_LOCAL_MACHINE, net)
WindowsError: [Error 5] Access is denied

Edited by tony75

0

You need to run the command line in administrator mode. Start->All Programs->Accessories
Right click on Command line. Run as administrator.

But I still can't get the wigle access to work properly. Still fooling with it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.