You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.0 KiB
139 lines
3.0 KiB
3 years ago
|
package creditcard
|
||
3 years ago
|
|
||
|
import (
|
||
|
"database/sql"
|
||
3 years ago
|
"os"
|
||
3 years ago
|
|
||
2 years ago
|
// import sqlite3 driver
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
2 years ago
|
|
||
|
"github.com/moond4rk/HackBrowserData/crypto"
|
||
|
"github.com/moond4rk/HackBrowserData/item"
|
||
|
"github.com/moond4rk/HackBrowserData/log"
|
||
3 years ago
|
)
|
||
|
|
||
|
type ChromiumCreditCard []card
|
||
|
|
||
3 years ago
|
type card struct {
|
||
|
GUID string
|
||
|
Name string
|
||
|
ExpirationYear string
|
||
|
ExpirationMonth string
|
||
|
CardNumber string
|
||
|
Address string
|
||
|
NickName string
|
||
|
}
|
||
|
|
||
|
const (
|
||
|
queryChromiumCredit = `SELECT guid, name_on_card, expiration_month, expiration_year, card_number_encrypted, billing_address_id, nickname FROM credit_cards`
|
||
|
)
|
||
|
|
||
3 years ago
|
func (c *ChromiumCreditCard) Parse(masterKey []byte) error {
|
||
3 years ago
|
creditDB, err := sql.Open("sqlite3", item.TempChromiumCreditCard)
|
||
3 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
3 years ago
|
defer os.Remove(item.TempChromiumCreditCard)
|
||
3 years ago
|
defer creditDB.Close()
|
||
|
rows, err := creditDB.Query(queryChromiumCredit)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
for rows.Next() {
|
||
|
var (
|
||
3 years ago
|
name, month, year, guid, address, nickname string
|
||
|
value, encryptValue []byte
|
||
3 years ago
|
)
|
||
3 years ago
|
if err := rows.Scan(&guid, &name, &month, &year, &encryptValue, &address, &nickname); err != nil {
|
||
3 years ago
|
log.Warn(err)
|
||
3 years ago
|
}
|
||
3 years ago
|
ccInfo := card{
|
||
3 years ago
|
GUID: guid,
|
||
|
Name: name,
|
||
|
ExpirationMonth: month,
|
||
|
ExpirationYear: year,
|
||
3 years ago
|
Address: address,
|
||
|
NickName: nickname,
|
||
3 years ago
|
}
|
||
|
if masterKey == nil {
|
||
2 years ago
|
value, err = crypto.DPAPI(encryptValue)
|
||
3 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
} else {
|
||
2 years ago
|
value, err = crypto.Chromium(masterKey, encryptValue)
|
||
3 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
3 years ago
|
ccInfo.CardNumber = string(value)
|
||
|
*c = append(*c, ccInfo)
|
||
3 years ago
|
}
|
||
|
return nil
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func (c *ChromiumCreditCard) Name() string {
|
||
|
return "creditcard"
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func (c *ChromiumCreditCard) Length() int {
|
||
|
return len(*c)
|
||
|
}
|
||
|
|
||
3 years ago
|
type YandexCreditCard []card
|
||
|
|
||
|
func (c *YandexCreditCard) Parse(masterKey []byte) error {
|
||
|
creditDB, err := sql.Open("sqlite3", item.TempYandexCreditCard)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer os.Remove(item.TempYandexCreditCard)
|
||
|
defer creditDB.Close()
|
||
3 years ago
|
defer creditDB.Close()
|
||
3 years ago
|
rows, err := creditDB.Query(queryChromiumCredit)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
for rows.Next() {
|
||
|
var (
|
||
3 years ago
|
name, month, year, guid, address, nickname string
|
||
|
value, encryptValue []byte
|
||
3 years ago
|
)
|
||
3 years ago
|
if err := rows.Scan(&guid, &name, &month, &year, &encryptValue, &address, &nickname); err != nil {
|
||
3 years ago
|
log.Warn(err)
|
||
|
}
|
||
3 years ago
|
ccInfo := card{
|
||
3 years ago
|
GUID: guid,
|
||
|
Name: name,
|
||
|
ExpirationMonth: month,
|
||
|
ExpirationYear: year,
|
||
3 years ago
|
Address: address,
|
||
|
NickName: nickname,
|
||
3 years ago
|
}
|
||
|
if masterKey == nil {
|
||
2 years ago
|
value, err = crypto.DPAPI(encryptValue)
|
||
3 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
} else {
|
||
2 years ago
|
value, err = crypto.Chromium(masterKey, encryptValue)
|
||
3 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
3 years ago
|
ccInfo.CardNumber = string(value)
|
||
|
*c = append(*c, ccInfo)
|
||
3 years ago
|
}
|
||
|
return nil
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func (c *YandexCreditCard) Name() string {
|
||
|
return "creditcard"
|
||
|
}
|
||
3 years ago
|
|
||
|
func (c *YandexCreditCard) Length() int {
|
||
|
return len(*c)
|
||
|
}
|