mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
version 0.1.0
This commit is contained in:
+24
-14
@@ -12,11 +12,6 @@ import (
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
const (
|
||||
Chrome = "Chrome"
|
||||
Safari = "Safari"
|
||||
)
|
||||
|
||||
const (
|
||||
bookmarkID = "id"
|
||||
bookmarkAdded = "date_added"
|
||||
@@ -27,7 +22,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
FullData = new(BrowserData)
|
||||
FullDataSlice []*BrowserData
|
||||
FullData = new(BrowserData)
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -77,16 +73,16 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func ChromeDB(dbname string) {
|
||||
func ParseResult(dbname string) {
|
||||
switch dbname {
|
||||
case utils.LoginData:
|
||||
parseLogin()
|
||||
case utils.Bookmarks:
|
||||
parseBookmarks()
|
||||
case utils.Cookies:
|
||||
parseCookie()
|
||||
case utils.History:
|
||||
parseHistory()
|
||||
case utils.Cookies:
|
||||
parseCookie()
|
||||
case utils.LoginData:
|
||||
parseLogin()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +141,18 @@ func parseLogin() {
|
||||
UserName: username,
|
||||
encryptPass: pwd,
|
||||
LoginUrl: url,
|
||||
CreateDate: utils.TimeEpochFormat(create),
|
||||
}
|
||||
password, err = utils.DecryptChromePass(pwd)
|
||||
if utils.VersionUnder80 {
|
||||
password, err = utils.DecryptStringWithDPAPI(pwd)
|
||||
} else {
|
||||
password, err = utils.DecryptChromePass(pwd)
|
||||
}
|
||||
if create > time.Now().Unix() {
|
||||
login.CreateDate = utils.TimeEpochFormat(create)
|
||||
} else {
|
||||
login.CreateDate = utils.TimeStampFormat(create)
|
||||
}
|
||||
|
||||
login.Password = password
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -201,7 +206,12 @@ func parseCookie() {
|
||||
ExpireDate: utils.TimeEpochFormat(expireDate),
|
||||
}
|
||||
// remove prefix 'v10'
|
||||
value, err = utils.DecryptChromePass(encryptValue)
|
||||
if utils.VersionUnder80 {
|
||||
value, err = utils.DecryptStringWithDPAPI(encryptValue)
|
||||
} else {
|
||||
value, err = utils.DecryptChromePass(encryptValue)
|
||||
}
|
||||
|
||||
cookie.Value = value
|
||||
if _, ok := cookieMap[host]; ok {
|
||||
cookieMap[host] = append(cookieMap[host], cookie)
|
||||
|
||||
+26
-10
@@ -2,30 +2,39 @@ package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hack-browser-data/log"
|
||||
"hack-browser-data/utils"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/gocarina/gocsv"
|
||||
)
|
||||
|
||||
func (b BrowserData) OutPutCsv(dir, format string) error {
|
||||
func (b BrowserData) OutPutCsv(dir, browser, format string) error {
|
||||
switch {
|
||||
case len(b.BookmarkSlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.Bookmarks, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.Errorf("create file %s fail", filename)
|
||||
}
|
||||
gocsv.SetCSVWriter(func(out io.Writer) *gocsv.SafeCSVWriter {
|
||||
writer := csv.NewWriter(out)
|
||||
writer.Comma = ' '
|
||||
return gocsv.NewSafeCSVWriter(writer)
|
||||
})
|
||||
err = gocsv.MarshalFile(b.BookmarkSlice, file)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
fmt.Printf("%s Get %d bookmarks, filename is %s \n", log.Prefix, len(b.BookmarkSlice), filename)
|
||||
fallthrough
|
||||
case len(b.LoginDataSlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.LoginData, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.LoginData, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -35,9 +44,10 @@ func (b BrowserData) OutPutCsv(dir, format string) error {
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.LoginDataSlice), filename)
|
||||
fallthrough
|
||||
case len(b.CookieMap) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.Cookies, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.Cookies, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -51,9 +61,10 @@ func (b BrowserData) OutPutCsv(dir, format string) error {
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
fmt.Printf("%s Get %d cookies, filename is %s \n", log.Prefix, len(b.CookieMap), filename)
|
||||
fallthrough
|
||||
case len(b.HistorySlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.History, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.History, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -63,14 +74,15 @@ func (b BrowserData) OutPutCsv(dir, format string) error {
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.HistorySlice), filename)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b BrowserData) OutPutJson(dir, format string) error {
|
||||
func (b BrowserData) OutPutJson(dir, browser, format string) error {
|
||||
switch {
|
||||
case len(b.BookmarkSlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.Bookmarks, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -82,9 +94,10 @@ func (b BrowserData) OutPutJson(dir, format string) error {
|
||||
enc.SetIndent("", "\t")
|
||||
enc.Encode(b.BookmarkSlice)
|
||||
file.Write(w.Bytes())
|
||||
fmt.Printf("%s Get %d bookmarks, filename is %s \n", log.Prefix, len(b.BookmarkSlice), filename)
|
||||
fallthrough
|
||||
case len(b.CookieMap) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.Cookies, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.Cookies, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -99,9 +112,10 @@ func (b BrowserData) OutPutJson(dir, format string) error {
|
||||
log.Println(err)
|
||||
}
|
||||
file.Write(w.Bytes())
|
||||
fmt.Printf("%s Get %d cookies, filename is %s \n", log.Prefix, len(b.CookieMap), filename)
|
||||
fallthrough
|
||||
case len(b.HistorySlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.History, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.History, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -116,9 +130,10 @@ func (b BrowserData) OutPutJson(dir, format string) error {
|
||||
log.Println(err)
|
||||
}
|
||||
file.Write(w.Bytes())
|
||||
fmt.Printf("%s Get %d history, filename is %s \n", log.Prefix, len(b.HistorySlice), filename)
|
||||
fallthrough
|
||||
case len(b.LoginDataSlice) != 0:
|
||||
filename := utils.FormatFileName(dir, utils.LoginData, format)
|
||||
filename := utils.FormatFileName(dir, browser, utils.LoginData, format)
|
||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -133,6 +148,7 @@ func (b BrowserData) OutPutJson(dir, format string) error {
|
||||
log.Println(err)
|
||||
}
|
||||
file.Write(w.Bytes())
|
||||
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.LoginDataSlice), filename)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user