add history parse

This commit is contained in:
ᴍᴏᴏɴD4ʀᴋ
2020-06-22 17:23:18 +08:00
parent 0101ffa874
commit 44bccb4dc3
9 changed files with 323 additions and 42 deletions
+33 -7
View File
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"time"
)
const (
@@ -12,28 +13,53 @@ const (
History = "History"
Cookies = "Cookies"
WebData = "Web Data"
Bookmarks = "Bookmarks"
)
func CopyDB(source, dest string) error {
// remove current path db file first
func CopyDB(src, dst string) error {
locals, _ := filepath.Glob("*")
for _, v := range locals {
if v == dest {
err := os.Remove(dest)
if v == dst {
err := os.Remove(dst)
if err != nil {
return err
}
}
}
sourceFile, err := ioutil.ReadFile(source)
sourceFile, err := ioutil.ReadFile(src)
if err != nil {
log.Println(err.Error())
}
err = ioutil.WriteFile(dest, sourceFile, 644)
err = ioutil.WriteFile(dst, sourceFile, 0777)
if err != nil {
log.Println(err.Error())
}
err = os.Chmod(dest, 0777)
return err
}
func ParseBookMarks() {
}
func RemoveFile() {
}
func TimeEpochFormat(epoch int64) time.Time {
t := time.Date(1601, 1, 1, 0, 0, 0, 0, time.UTC)
d := time.Duration(epoch)
for i := 0; i < 1000; i++ {
t = t.Add(d)
}
return t
}
func ReadFile(filename string) (string, error) {
s, err := ioutil.ReadFile(filename)
return string(s), err
}
//func MakeDir(dirName string) error {
//
//}
+21 -11
View File
@@ -5,6 +5,7 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/sha1"
"errors"
"hack-browser-data/log"
"os/exec"
"path/filepath"
@@ -24,15 +25,20 @@ var (
chromePass []byte
)
func GetDBPath(dbName string) (string, error) {
s, err := filepath.Glob(macChromeDir + dbName)
if err != nil && len(s) == 0 {
return "", err
func GetDBPath(dbName ...string) (dbFile []string, err error) {
for _, v := range dbName {
s, err := filepath.Glob(macChromeDir + v)
if err != nil && len(s) == 0 {
continue
}
if len(s) > 0{
dbFile = append(dbFile, s[0])
}
}
return s[0], nil
return dbFile, nil
}
func InitChromeKey() {
func InitChromeKey() error {
var (
cmd *exec.Cmd
stdout, stderr bytes.Buffer
@@ -43,22 +49,26 @@ func InitChromeKey() {
err := cmd.Run()
if err != nil {
log.Println(err)
panic(err)
return err
}
if stderr.Len() > 0 {
panic(stderr.String())
log.Println(stderr.String())
err = errors.New(stderr.String())
}
// replace /n
temp := stdout.Bytes()
chromePass = temp[:len(temp)-1]
DecryptPass(chromePass)
decryptPass(chromePass)
return err
}
func DecryptPass(chromePass []byte) {
func decryptPass(chromePass []byte) {
chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New)
}
func Aes128CBCDecrypt(encryptPass []byte) (string, error) {
if chromeKey == nil {
return "", nil
}
block, err := aes.NewCipher(chromeKey)
if err != nil {
return "", err
+12
View File
@@ -0,0 +1,12 @@
package utils
import (
"fmt"
"testing"
)
func TestTimeEpochFormat(t *testing.T) {
dateAdded := int64(13220074277028707)
s := TimeEpochFormat(dateAdded)
fmt.Println(s)
}