refactor: format firefox download code

pull/83/head
moond4rk 4 years ago committed by ᴍᴏᴏɴD4ʀᴋ
parent d1b05814ea
commit d1a8b85a6e
  1. 31
      core/data/parse.go

@ -8,8 +8,8 @@ import (
"os"
"path/filepath"
"sort"
"time"
"strings"
"time"
"hack-browser-data/core/decrypt"
"hack-browser-data/log"
@ -56,7 +56,7 @@ var (
queryChromiumDownload = `SELECT target_path, tab_url, total_bytes, start_time, end_time, mime_type FROM downloads`
queryChromiumCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies`
queryFirefoxHistory = `SELECT id, url, last_visit_date, title, visit_count FROM moz_places`
queryFirefoxDownload = `SELECT place_id, GROUP_CONCAT(content) , url, dateAdded FROM (SELECT * FROM moz_annos INNER JOIN moz_places ON moz_annos.place_id=moz_places.id) t GROUP BY place_id`
queryFirefoxDownload = `SELECT place_id, GROUP_CONCAT(content), url, dateAdded FROM (SELECT * FROM moz_annos INNER JOIN moz_places ON moz_annos.place_id=moz_places.id) t GROUP BY place_id`
queryFirefoxBookMarks = `SELECT id, fk, type, dateAdded, title FROM moz_bookmarks`
queryFirefoxCookie = `SELECT name, value, host, path, creationTime, expiry, isSecure, isHttpOnly FROM moz_cookies`
queryMetaData = `SELECT item1, item2 FROM metaData WHERE id = 'password'`
@ -503,10 +503,10 @@ func (d *downloads) ChromeParse(key []byte) error {
func (d *downloads) FirefoxParse() error {
var (
err error
keyDB *sql.DB
downloadRows *sql.Rows
tempMap map[int64]string
err error
keyDB *sql.DB
downloadRows *sql.Rows
tempMap map[int64]string
)
tempMap = make(map[int64]string)
keyDB, err = sql.Open("sqlite3", FirefoxDataFile)
@ -534,10 +534,10 @@ func (d *downloads) FirefoxParse() error {
}()
for downloadRows.Next() {
var (
content, url string
place_id, dateAdded int64
content, url string
placeID, dateAdded int64
)
err = downloadRows.Scan(&place_id, &content, &url, &dateAdded)
err = downloadRows.Scan(&placeID, &content, &url, &dateAdded)
if err != nil {
log.Warn(err)
}
@ -546,19 +546,20 @@ func (d *downloads) FirefoxParse() error {
path := contentList[0]
json := "{" + contentList[1]
endTime := gjson.Get(json, "endTime")
fileSize:= gjson.Get(json, "fileSize")
fileSize := gjson.Get(json, "fileSize")
d.downloads = append(d.downloads, download{
TargetPath: path,
Url: url,
TargetPath: path,
Url: url,
TotalBytes: fileSize.Int(),
StartTime: utils.TimeStampFormat(dateAdded / 1000000),
EndTime: utils.TimeStampFormat(endTime.Int() / 1000),
StartTime: utils.TimeStampFormat(dateAdded / 1000000),
EndTime: utils.TimeStampFormat(endTime.Int() / 1000),
})
}
tempMap[place_id] = url
tempMap[placeID] = url
}
return nil
}
func (d *downloads) CopyDB() error {
return copyToLocalPath(d.mainPath, filepath.Base(d.mainPath))
}

Loading…
Cancel
Save