Skip to content

Commit 2e2dcaf

Browse files
committed
remove redundant code
1 parent 80bb7ca commit 2e2dcaf

File tree

5 files changed

+12
-187
lines changed

5 files changed

+12
-187
lines changed

core/common/output.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"os"
8+
79
"hack-browser-data/log"
810
"hack-browser-data/utils"
9-
"os"
1011

1112
"github.com/jszwec/csvutil"
1213
)

core/common/parse.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import (
44
"bytes"
55
"database/sql"
66
"encoding/base64"
7-
"hack-browser-data/core/decrypt"
8-
"hack-browser-data/log"
9-
"hack-browser-data/utils"
107
"io/ioutil"
118
"os"
129
"sort"
1310
"time"
1411

12+
"hack-browser-data/core/decrypt"
13+
"hack-browser-data/log"
14+
"hack-browser-data/utils"
15+
1516
_ "github.com/mattn/go-sqlite3"
1617
"github.com/tidwall/gjson"
1718
)
@@ -244,9 +245,9 @@ func (h *History) ChromeParse(key []byte) error {
244245
func (c *Cookies) ChromeParse(secretKey []byte) error {
245246
cookie := cookies{}
246247
c.cookies = make(map[string][]cookies)
247-
cookieDB, err := sql.Open("sqlite3", utils.Cookies)
248+
cookieDB, err := sql.Open("sqlite3", ChromeCookies)
248249
defer func() {
249-
if err := os.Remove(utils.Cookies); err != nil {
250+
if err := os.Remove(ChromeCookies); err != nil {
250251
log.Error(err)
251252
}
252253
}()
@@ -534,11 +535,11 @@ func getDecryptKey() (item1, item2, a11, a102 []byte, err error) {
534535
nssRows *sql.Rows
535536
)
536537
defer func() {
537-
if err := os.Remove(utils.FirefoxKey4DB); err != nil {
538+
if err := os.Remove(FirefoxKey4DB); err != nil {
538539
log.Error(err)
539540
}
540541
}()
541-
keyDB, err = sql.Open("sqlite3", utils.FirefoxKey4DB)
542+
keyDB, err = sql.Open("sqlite3", FirefoxKey4DB)
542543
defer func() {
543544
if err := keyDB.Close(); err != nil {
544545
log.Error(err)

core/decrypt/decrypt_linux.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ import (
1111
"golang.org/x/crypto/pbkdf2"
1212
)
1313

14-
const (
15-
fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default-release/"
16-
fireFoxCommand = ""
17-
)
18-
1914
var (
20-
chromeIV = []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
21-
chromeSalt = []byte("saltysalt")
15+
chromeIV = []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
2216
)
2317

2418
func ChromePass(key, encryptPass []byte) ([]byte, error) {

core/decrypt/decrypt_windows.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,6 @@ import (
1414
"golang.org/x/crypto/pbkdf2"
1515
)
1616

17-
const (
18-
chromeProfilePath = "/AppData/Local/Google/Chrome/User Data/*/"
19-
chromeKeyPath = "/AppData/Local/Google/Chrome/User Data/Local State"
20-
edgeProfilePath = "/AppData/Local/Microsoft/Edge/User Data/*/"
21-
edgeKeyPath = "/AppData/Local/Microsoft/Edge/User Data/Local State"
22-
speed360ProfilePath = "/AppData/Local/360chrome/Chrome/User Data/*/"
23-
speed360KeyPath = ""
24-
qqBrowserProfilePath = "/AppData/Local/Tencent/QQBrowser/User Data/*/"
25-
qqBrowserKeyPath = ""
26-
firefoxProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-release/"
27-
firefoxKeyPath = ""
28-
)
29-
30-
var (
31-
browserList = map[string]struct {
32-
ProfilePath string
33-
KeyPath string
34-
}{
35-
"chrome": {
36-
chromeProfilePath,
37-
chromeKeyPath,
38-
},
39-
"edge": {
40-
edgeProfilePath,
41-
edgeKeyPath,
42-
},
43-
"360speed": {
44-
speed360ProfilePath,
45-
speed360KeyPath,
46-
},
47-
"qq": {
48-
qqBrowserProfilePath,
49-
qqBrowserKeyPath,
50-
},
51-
"firefox": {
52-
firefoxProfilePath,
53-
"",
54-
},
55-
}
56-
)
57-
5817
func ChromePass(encryptPass, key []byte) ([]byte, error) {
5918
if len(encryptPass) > 15 {
6019
// remove prefix 'v10'

utils/utils.go

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,17 @@
11
package utils
22

33
import (
4-
"crypto/aes"
5-
"crypto/cipher"
6-
"crypto/des"
7-
"encoding/asn1"
84
"fmt"
9-
"hack-browser-data/log"
105
"io/ioutil"
116
"os"
127
"path"
138
"path/filepath"
149
"strings"
1510
"time"
16-
)
17-
18-
type DecryptError struct {
19-
err error
20-
msg string
21-
}
22-
23-
func (e *DecryptError) Error() string {
24-
return fmt.Sprintf("%s: %s", e.msg, e.err)
25-
}
2611

27-
func (e *DecryptError) Unwrap() error {
28-
return e.err
29-
}
30-
31-
type Browser struct {
32-
Name string
33-
DataDir string
34-
}
35-
36-
const (
37-
LoginData = "Login Data"
38-
History = "History"
39-
Cookies = "Cookies"
40-
Bookmarks = "Bookmarks"
41-
FirefoxCookie = "cookies.sqlite"
42-
FirefoxKey4DB = "key4.db"
43-
FirefoxLoginData = "logins.json"
44-
FirefoxData = "places.sqlite"
45-
FirefoxKey3DB = "key3.db"
12+
"hack-browser-data/log"
4613
)
4714

48-
49-
func GetDBPath(dir string, dbName ...string) (dbFile []string) {
50-
for _, v := range dbName {
51-
s, err := filepath.Glob(dir + v)
52-
if err != nil && len(s) == 0 {
53-
continue
54-
}
55-
if len(s) > 0 {
56-
log.Debugf("Find %s File Success", v)
57-
log.Debugf("%s file location is %s", v, s[0])
58-
dbFile = append(dbFile, s[0])
59-
}
60-
}
61-
return dbFile
62-
}
63-
6415
func CopyDB(src, dst string) error {
6516
locals, _ := filepath.Glob("*")
6617
for _, v := range locals {
@@ -117,16 +68,6 @@ func TimeEpochFormat(epoch int64) time.Time {
11768
return t
11869
}
11970

120-
// check time our range[1.9999]
121-
func checkTimeRange(check time.Time) time.Time {
122-
end, _ := time.Parse(time.RFC3339, "9000-01-02T15:04:05Z07:00")
123-
if check.Before(end) {
124-
return check
125-
} else {
126-
return end
127-
}
128-
}
129-
13071
func ReadFile(filename string) (string, error) {
13172
s, err := ioutil.ReadFile(filename)
13273
return string(s), err
@@ -152,74 +93,3 @@ func MakeDir(dirName string) {
15293
err = os.Mkdir(dirName, 0700)
15394
}
15495
}
155-
156-
func PaddingZero(s []byte, l int) []byte {
157-
h := l - len(s)
158-
if h <= 0 {
159-
return s
160-
} else {
161-
for i := len(s); i < l; i++ {
162-
s = append(s, 0)
163-
}
164-
return s
165-
}
166-
}
167-
168-
func PKCS5UnPadding(src []byte) []byte {
169-
length := len(src)
170-
unpadding := int(src[length-1])
171-
return src[:(length - unpadding)]
172-
}
173-
174-
func Des3Decrypt(key, iv []byte, src []byte) ([]byte, error) {
175-
block, err := des.NewTripleDESCipher(key)
176-
if err != nil {
177-
log.Error(err)
178-
return nil, err
179-
}
180-
blockMode := cipher.NewCBCDecrypter(block, iv)
181-
sq := make([]byte, len(src))
182-
blockMode.CryptBlocks(sq, src)
183-
return sq, nil
184-
}
185-
186-
/*
187-
SEQUENCE (3 elem)
188-
OCTET STRING (16 byte)
189-
SEQUENCE (2 elem)
190-
OBJECT IDENTIFIER 1.2.840.113549.3.7 des-EDE3-CBC (RSADSI encryptionAlgorithm)
191-
OCTET STRING (8 byte)
192-
OCTET STRING (16 byte)
193-
*/
194-
type LoginPBE struct {
195-
CipherText []byte
196-
SequenceLogin
197-
Encrypted []byte
198-
}
199-
200-
type SequenceLogin struct {
201-
asn1.ObjectIdentifier
202-
Iv []byte
203-
}
204-
205-
func DecodeLogin(decodeItem []byte) (pbe LoginPBE, err error) {
206-
_, err = asn1.Unmarshal(decodeItem, &pbe)
207-
if err != nil {
208-
log.Error(err)
209-
return
210-
}
211-
return pbe, nil
212-
}
213-
214-
func aes128CBCDecrypt(key, iv, encryptPass []byte) ([]byte, error) {
215-
216-
block, err := aes.NewCipher(key)
217-
if err != nil {
218-
return []byte{}, err
219-
}
220-
dst := make([]byte, len(encryptPass))
221-
mode := cipher.NewCBCDecrypter(block, iv)
222-
mode.CryptBlocks(dst, encryptPass)
223-
dst = PKCS5UnPadding(dst)
224-
return dst, nil
225-
}

0 commit comments

Comments
 (0)