mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-23 19:14:01 +02:00
Support credit cards for chrome (#52)
This commit is contained in:
+9
-4
@@ -41,10 +41,11 @@ type Browser interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cookie = "cookie"
|
cookie = "cookie"
|
||||||
history = "history"
|
history = "history"
|
||||||
bookmark = "bookmark"
|
bookmark = "bookmark"
|
||||||
password = "password"
|
password = "password"
|
||||||
|
creditcard = "creditcard"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -75,6 +76,10 @@ var (
|
|||||||
mainFile: data.ChromePasswordFile,
|
mainFile: data.ChromePasswordFile,
|
||||||
newItem: data.NewCPasswords,
|
newItem: data.NewCPasswords,
|
||||||
},
|
},
|
||||||
|
creditcard: {
|
||||||
|
mainFile: data.ChromeCreditFile,
|
||||||
|
newItem: data.NewCCards,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
firefoxItems = map[string]struct {
|
firefoxItems = map[string]struct {
|
||||||
mainFile string
|
mainFile string
|
||||||
|
|||||||
@@ -62,6 +62,16 @@ func (c *cookies) outPutJson(browser, dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) outPutJson(browser, dir string) error {
|
||||||
|
filename := utils.FormatFileName(dir, browser, "credit", "json")
|
||||||
|
err := writeToJson(filename, credit.cards)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func writeToJson(filename string, data interface{}) error {
|
func writeToJson(filename string, data interface{}) error {
|
||||||
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -123,6 +133,19 @@ func (c *cookies) outPutCsv(browser, dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) outPutCsv(browser, dir string) error {
|
||||||
|
filename := utils.FormatFileName(dir, browser, "credit", "csv")
|
||||||
|
var tempSlice []card
|
||||||
|
for _, v := range credit.cards {
|
||||||
|
tempSlice = append(tempSlice, v...)
|
||||||
|
}
|
||||||
|
if err := writeToCsv(filename, tempSlice); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func writeToCsv(filename string, data interface{}) error {
|
func writeToCsv(filename string, data interface{}) error {
|
||||||
var d []byte
|
var d []byte
|
||||||
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||||
@@ -168,3 +191,9 @@ func (p *passwords) outPutConsole() {
|
|||||||
fmt.Printf("%+v\n", v)
|
fmt.Printf("%+v\n", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) outPutConsole() {
|
||||||
|
for _, v := range credit.cards {
|
||||||
|
fmt.Printf("%+v\n", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ type Item interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
ChromeCreditFile = "Web Data"
|
||||||
ChromePasswordFile = "Login Data"
|
ChromePasswordFile = "Login Data"
|
||||||
ChromeHistoryFile = "History"
|
ChromeHistoryFile = "History"
|
||||||
ChromeCookieFile = "Cookies"
|
ChromeCookieFile = "Cookies"
|
||||||
@@ -47,6 +48,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
queryChromiumCredit = `SELECT guid,name_on_card,expiration_month,expiration_year,card_number_encrypted FROM credit_cards`
|
||||||
queryChromiumLogin = `SELECT origin_url, username_value, password_value, date_created FROM logins`
|
queryChromiumLogin = `SELECT origin_url, username_value, password_value, date_created FROM logins`
|
||||||
queryChromiumHistory = `SELECT url, title, visit_count, last_visit_time FROM urls`
|
queryChromiumHistory = `SELECT url, title, visit_count, last_visit_time FROM urls`
|
||||||
queryChromiumCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies`
|
queryChromiumCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies`
|
||||||
@@ -609,6 +611,90 @@ func (p *passwords) OutPut(format, browser, dir string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type creditcards struct {
|
||||||
|
mainPath string
|
||||||
|
cards map[string][]card
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCCards(main string, sub string) Item {
|
||||||
|
return &creditcards{mainPath: main}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) FirefoxParse() error {
|
||||||
|
return nil // FireFox does not have a credit card saving feature
|
||||||
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) ChromeParse(secretKey []byte) error {
|
||||||
|
credit.cards = make(map[string][]card)
|
||||||
|
creditDB, err := sql.Open("sqlite3", ChromeCreditFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := creditDB.Close(); err != nil {
|
||||||
|
log.Debug(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
rows, err := creditDB.Query(queryChromiumCredit)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
log.Debug(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
for rows.Next() {
|
||||||
|
var (
|
||||||
|
name, expirationm, expirationy, guid string
|
||||||
|
value, encryptValue []byte
|
||||||
|
)
|
||||||
|
err := rows.Scan(&guid, &name, &expirationm, &expirationy, &encryptValue)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
creditCardInfo := card{
|
||||||
|
GUID: guid,
|
||||||
|
Name: name,
|
||||||
|
ExpirationMonth: expirationm,
|
||||||
|
ExpirationYear: expirationy,
|
||||||
|
}
|
||||||
|
if secretKey == nil {
|
||||||
|
value, err = decrypt.DPApi(encryptValue)
|
||||||
|
} else {
|
||||||
|
value, err = decrypt.ChromePass(secretKey, encryptValue)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
|
}
|
||||||
|
creditCardInfo.Cardnumber = string(value)
|
||||||
|
credit.cards[guid] = append(credit.cards[guid], creditCardInfo)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) CopyDB() error {
|
||||||
|
return copyToLocalPath(credit.mainPath, filepath.Base(credit.mainPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) Release() error {
|
||||||
|
return os.Remove(filepath.Base(credit.mainPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (credit *creditcards) OutPut(format, browser, dir string) error {
|
||||||
|
switch format {
|
||||||
|
case "csv":
|
||||||
|
err := credit.outPutCsv(browser, dir)
|
||||||
|
return err
|
||||||
|
case "console":
|
||||||
|
credit.outPutConsole()
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
err := credit.outPutJson(browser, dir)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// getFirefoxDecryptKey get value from key4.db
|
// getFirefoxDecryptKey get value from key4.db
|
||||||
func getFirefoxDecryptKey() (item1, item2, a11, a102 []byte, err error) {
|
func getFirefoxDecryptKey() (item1, item2, a11, a102 []byte, err error) {
|
||||||
var (
|
var (
|
||||||
@@ -720,6 +806,13 @@ type (
|
|||||||
VisitCount int
|
VisitCount int
|
||||||
LastVisitTime time.Time
|
LastVisitTime time.Time
|
||||||
}
|
}
|
||||||
|
card struct {
|
||||||
|
GUID string
|
||||||
|
Name string
|
||||||
|
ExpirationMonth string
|
||||||
|
ExpirationYear string
|
||||||
|
Cardnumber string
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p passwords) Len() int {
|
func (p passwords) Len() int {
|
||||||
|
|||||||
Reference in New Issue
Block a user