|  |  | @ -5,12 +5,10 @@ import ( | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"crypto/aes" |  |  |  | 	"crypto/aes" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"crypto/cipher" |  |  |  | 	"crypto/cipher" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"crypto/sha1" |  |  |  | 	"crypto/sha1" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"fmt" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"hack-browser-data/log" |  |  |  | 	"hack-browser-data/log" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"os/exec" |  |  |  | 	"os/exec" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"path/filepath" |  |  |  | 	"path/filepath" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"github.com/forgoer/openssl" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"golang.org/x/crypto/pbkdf2" |  |  |  | 	"golang.org/x/crypto/pbkdf2" | 
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -26,12 +24,12 @@ var ( | 
			
		
	
		
		
			
				
					
					|  |  |  | 	chromePass []byte |  |  |  | 	chromePass []byte | 
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func GetDBPath(dbName string) string { |  |  |  | func GetDBPath(dbName string) (string, error) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	s, err := filepath.Glob(macChromeDir + dbName) |  |  |  | 	s, err := filepath.Glob(macChromeDir + dbName) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if err != nil && len(s) == 0 { |  |  |  | 	if err != nil && len(s) == 0 { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		panic(err) |  |  |  | 		return "", err | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return s[0] |  |  |  | 	return s[0], nil | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func InitChromeKey() { |  |  |  | func InitChromeKey() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -47,78 +45,33 @@ func InitChromeKey() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.Println(err) |  |  |  | 		log.Println(err) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		panic(err) |  |  |  | 		panic(err) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if stderr.Len() > 0 { |  |  |  | 	if stderr.Len() > 0 { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		panic(stderr.String()) |  |  |  | 		panic(stderr.String()) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	// replace /n
 |  |  |  | 	// replace /n
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	temp := stdout.Bytes() |  |  |  | 	temp := stdout.Bytes() | 
			
		
	
		
		
			
				
					
					|  |  |  | 	chromePass = temp[:len(temp)-1] |  |  |  | 	chromePass = temp[:len(temp)-1] | 
			
		
	
		
		
			
				
					
					|  |  |  | 	chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New) |  |  |  | 	DecryptPass(chromePass) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func DecryptPass(chromePass []byte) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	l := pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return l |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func Aes128CBCDecrypt(encryptPass []byte) string { |  |  |  | func DecryptPass(chromePass []byte) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	src, err := openssl.AesCBCDecrypt(encryptPass, chromeKey, iv, openssl.PKCS5_PADDING) |  |  |  | 	chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.Println(err) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return string(src) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func AesDecrypt(ciphertext []byte, key, iv []byte) ([]byte, error) { |  |  |  | func Aes128CBCDecrypt(encryptPass []byte) (string, error) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	block, err := aes.NewCipher(key) |  |  |  | 	block, err := aes.NewCipher(chromeKey) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	if err != nil { |  |  |  | 	if err != nil { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return nil, err |  |  |  | 		return "", err | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	blockMode := cipher.NewCBCDecrypter(block, iv) |  |  |  | 	dst := make([]byte, len(encryptPass)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	origData := make([]byte, len(ciphertext)) |  |  |  | 	mode := cipher.NewCBCDecrypter(block, iv) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	fmt.Println(blockMode.BlockSize()) |  |  |  | 	mode.CryptBlocks(dst, encryptPass) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//func (x *cbcDecrypter) CryptBlocks(dst, src []byte) {
 |  |  |  | 	dst = PKCS5UnPadding(dst) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//	if len(src)%x.blockSize != 0 {
 |  |  |  | 	return string(dst), nil | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//		panic("crypto/cipher: input not full blocks")
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	blockMode.CryptBlocks(origData, ciphertext) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	origData = PKCS5UnPadding(origData) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return origData, nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func ZeroPadding(ciphertext []byte, blockSize int) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padding := blockSize - len(ciphertext)%blockSize |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padtext := bytes.Repeat([]byte{0}, padding) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return append(ciphertext, padtext...) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func ZeroUnPadding(origData []byte) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	length := len(origData) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	unpadding := int(origData[length-1]) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return origData[:(length - unpadding)] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func PKCS5Padding(ciphertext []byte, blockSize int) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padding := blockSize - len(ciphertext)%blockSize |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padtext := bytes.Repeat([]byte{byte(padding)}, padding) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return append(ciphertext, padtext...) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func PKCS5UnPadding(origData []byte) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	length := len(origData) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	// 去掉最后一个字节 unpadding 次
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	unpadding := int(origData[length-1]) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return origData[:(length - unpadding)] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func PKCS7Padding(ciphertext []byte, blockSize int) []byte { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padding := blockSize - len(ciphertext)%blockSize |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	padtext := bytes.Repeat([]byte{byte(padding)}, padding) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return append(ciphertext, padtext...) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func PKCS7UnPadding(origData []byte) []byte { |  |  |  | func PKCS5UnPadding(src []byte) []byte { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	length := len(origData) |  |  |  | 	length := len(src) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	unpadding := int(origData[length-1]) |  |  |  | 	unpadding := int(src[length-1]) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	return origData[:(length - unpadding)] |  |  |  | 	return src[:(length - unpadding)] | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |