You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HackBrowserData/core/common/common.go

80 lines
1.4 KiB

package common
import (
"database/sql"
"hack-browser-data/log"
"hack-browser-data/utils"
_ "github.com/mattn/go-sqlite3"
)
const (
Chrome = "Chrome"
Safari = "Safari"
)
type (
BrowserData struct {
BrowserName string
LoginData []LoginData
}
LoginData struct {
UserName string
encryptPass []byte
Password string
LoginUrl string
}
History struct {
}
Cookie struct {
}
BookMark struct {
}
)
func ParseDB() (results []*LoginData) {
//datetime(visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch')
loginD := &LoginData{}
logins, err := sql.Open("sqlite3", utils.LoginData)
defer func() {
if err := logins.Close(); err != nil {
log.Println(err)
}
}()
if err != nil {
log.Println(err)
}
err = logins.Ping()
log.Println(err)
rows, err := logins.Query(`SELECT origin_url, username_value, password_value FROM logins`)
defer func() {
if err := rows.Close(); err != nil {
log.Println(err)
}
}()
log.Println(err)
for rows.Next() {
var (
url string
username string
pwd []byte
password string
)
err = rows.Scan(&url, &username, &pwd)
loginD = &LoginData{
UserName: username,
encryptPass: pwd,
LoginUrl: url,
}
if len(pwd) > 3 {
password = utils.Aes128CBCDecrypt(pwd[3:])
}
loginD.Password = password
if err != nil {
log.Println(err)
}
results = append(results, loginD)
}
return
}