feat: support credit card export

pull/83/head
moond4rk 4 years ago committed by ᴍᴏᴏɴD4ʀᴋ
parent 905cce75ff
commit c23cb8a4d6
  1. 16
      core/data/output.go
  2. 42
      core/data/parse.go

@ -62,13 +62,13 @@ func (c *cookies) outPutJson(browser, dir string) error {
return nil return nil
} }
func (credit *creditcards) outPutJson(browser, dir string) error { func (c *creditCards) outPutJson(browser, dir string) error {
filename := utils.FormatFileName(dir, browser, "credit", "json") filename := utils.FormatFileName(dir, browser, "credit", "json")
err := writeToJson(filename, credit.cards) err := writeToJson(filename, c.cards)
if err != nil { if err != nil {
return err return err
} }
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename) fmt.Printf("%s Get %d credit cards, filename is %s \n", utils.Prefix, len(c.cards), filename)
return nil return nil
} }
@ -133,16 +133,16 @@ func (c *cookies) outPutCsv(browser, dir string) error {
return nil return nil
} }
func (credit *creditcards) outPutCsv(browser, dir string) error { func (c *creditCards) outPutCsv(browser, dir string) error {
filename := utils.FormatFileName(dir, browser, "credit", "csv") filename := utils.FormatFileName(dir, browser, "credit", "csv")
var tempSlice []card var tempSlice []card
for _, v := range credit.cards { for _, v := range c.cards {
tempSlice = append(tempSlice, v...) tempSlice = append(tempSlice, v...)
} }
if err := writeToCsv(filename, tempSlice); err != nil { if err := writeToCsv(filename, tempSlice); err != nil {
return err return err
} }
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename) fmt.Printf("%s Get %d credit cards, filename is %s \n", utils.Prefix, len(c.cards), filename)
return nil return nil
} }
@ -192,8 +192,8 @@ func (p *passwords) outPutConsole() {
} }
} }
func (credit *creditcards) outPutConsole() { func (c *creditCards) outPutConsole() {
for _, v := range credit.cards { for _, v := range c.cards {
fmt.Printf("%+v\n", v) fmt.Printf("%+v\n", v)
} }
} }

@ -611,21 +611,21 @@ func (p *passwords) OutPut(format, browser, dir string) error {
} }
} }
type creditcards struct { type creditCards struct {
mainPath string mainPath string
cards map[string][]card cards map[string][]card
} }
func NewCCards(main string, sub string) Item { func NewCCards(main string, sub string) Item {
return &creditcards{mainPath: main} return &creditCards{mainPath: main}
} }
func (credit *creditcards) FirefoxParse() error { func (c *creditCards) FirefoxParse() error {
return nil // FireFox does not have a credit card saving feature return nil // FireFox does not have a credit card saving feature
} }
func (credit *creditcards) ChromeParse(secretKey []byte) error { func (c *creditCards) ChromeParse(secretKey []byte) error {
credit.cards = make(map[string][]card) c.cards = make(map[string][]card)
creditDB, err := sql.Open("sqlite3", ChromeCreditFile) creditDB, err := sql.Open("sqlite3", ChromeCreditFile)
if err != nil { if err != nil {
return err return err
@ -646,18 +646,18 @@ func (credit *creditcards) ChromeParse(secretKey []byte) error {
}() }()
for rows.Next() { for rows.Next() {
var ( var (
name, expirationm, expirationy, guid string name, month, year, guid string
value, encryptValue []byte value, encryptValue []byte
) )
err := rows.Scan(&guid, &name, &expirationm, &expirationy, &encryptValue) err := rows.Scan(&guid, &name, &month, &year, &encryptValue)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
creditCardInfo := card{ creditCardInfo := card{
GUID: guid, GUID: guid,
Name: name, Name: name,
ExpirationMonth: expirationm, ExpirationMonth: month,
ExpirationYear: expirationy, ExpirationYear: year,
} }
if secretKey == nil { if secretKey == nil {
value, err = decrypt.DPApi(encryptValue) value, err = decrypt.DPApi(encryptValue)
@ -667,30 +667,30 @@ func (credit *creditcards) ChromeParse(secretKey []byte) error {
if err != nil { if err != nil {
log.Debug(err) log.Debug(err)
} }
creditCardInfo.Cardnumber = string(value) creditCardInfo.CardNumber = string(value)
credit.cards[guid] = append(credit.cards[guid], creditCardInfo) c.cards[guid] = append(c.cards[guid], creditCardInfo)
} }
return nil return nil
} }
func (credit *creditcards) CopyDB() error { func (c *creditCards) CopyDB() error {
return copyToLocalPath(credit.mainPath, filepath.Base(credit.mainPath)) return copyToLocalPath(c.mainPath, filepath.Base(c.mainPath))
} }
func (credit *creditcards) Release() error { func (c *creditCards) Release() error {
return os.Remove(filepath.Base(credit.mainPath)) return os.Remove(filepath.Base(c.mainPath))
} }
func (credit *creditcards) OutPut(format, browser, dir string) error { func (c *creditCards) OutPut(format, browser, dir string) error {
switch format { switch format {
case "csv": case "csv":
err := credit.outPutCsv(browser, dir) err := c.outPutCsv(browser, dir)
return err return err
case "console": case "console":
credit.outPutConsole() c.outPutConsole()
return nil return nil
default: default:
err := credit.outPutJson(browser, dir) err := c.outPutJson(browser, dir)
return err return err
} }
} }
@ -809,9 +809,9 @@ type (
card struct { card struct {
GUID string GUID string
Name string Name string
ExpirationMonth string
ExpirationYear string ExpirationYear string
Cardnumber string ExpirationMonth string
CardNumber string
} }
) )

Loading…
Cancel
Save