spacepaste

  1.  
  2. #!/usr/bin/python
  3. # Copyright 2016: dogbert <dogber1@gmail.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #
  20. # This script generates master passwords which can be used to unlock
  21. # the BIOS passwords of most Asus laptops.
  22. # You have to install python for running this script.
  23. import os
  24. def shuffle1(a1, a2):
  25. v3 = 2
  26. for i in range(0, a2):
  27. v4 = v3
  28. v5 = a1
  29. while v5 > 0:
  30. if ( v5 < v4 ):
  31. v5, v4 = v4, v5
  32. v5 %= v4
  33. if (v4 != 1):
  34. v3 += 1;
  35. if ( v3 < a1 ):
  36. continue
  37. return v3
  38. def shuffle2(a1, a2, a3):
  39. if (a1 >= a3):
  40. a1 %= a3
  41. result = a1
  42. if (a2 != 1):
  43. for i in range(0, a2-1):
  44. result = a1 * result % a3;
  45. return result
  46. def initTable(table, i1=11, i2=19, i3=6):
  47. table[0] = chr(i1+ord('0'))
  48. table[1] = chr(i2+ord('0'))
  49. table[2] = chr(i3+ord('0'))
  50. table[3] = "6"
  51. table[4] = "7"
  52. table[5] = "8"
  53. table[6] = "9"
  54. chksum = 0
  55. for i in range(0, 7):
  56. chksum += ord(table[i])
  57. for i in range(7, 32):
  58. chksum = 33676 * chksum + 12345
  59. table[i] = chr(((chksum >> 16) & 0x7FFF) % 43 + ord('0'))
  60. v3 = i1*i2
  61. v4 = shuffle1((i1-1)*(i2-1), i3)
  62. for i in range(0, 32):
  63. table[i] = chr(shuffle2(ord(table[i])-ord('0'), v4, v3))
  64. return table
  65. def calculatePassword(date, table):
  66. date = int(date.replace("-", ""), 16)
  67. chksum = date
  68. password = ""
  69. for i in range(8):
  70. chksum = 33676 * chksum + 12345
  71. index = (chksum >> 16) & 31
  72. pwdC = ord(table[index]) % 36
  73. if pwdC > 9:
  74. password += chr(pwdC + ord('7'))
  75. else:
  76. password += chr(pwdC + ord('0'))
  77. return password
  78. table = initTable(['']*32)
  79. print("Master Password Generator for Asus laptops (system date version)")
  80. print("Copyright (C) 2016 dogbert <dogber1@gmail.com>")
  81. print("")
  82. print("When asked for a password, enter an incorrect password, then press Alt+R. A prompt with the system date will appear, e.g. 2013-12-31")
  83. print("")
  84. print("Please enter the system date: ")
  85. inDate = raw_input().strip().replace('/', '-').replace('.', '-')
  86. password = calculatePassword(inDate, table)
  87. print("")
  88. print("The master password is: " + password)
  89. print("")
  90. print("Please note that the password is encoded for US QWERTY keyboard layouts.")
  91. if (os.name == 'nt'):
  92. print("Press a key to exit...")
  93. raw_input()
  94.