|
|
@ -11,6 +11,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
"github.com/moond4rk/HackBrowserData/item" |
|
|
|
"github.com/moond4rk/HackBrowserData/item" |
|
|
|
"github.com/moond4rk/HackBrowserData/log" |
|
|
|
"github.com/moond4rk/HackBrowserData/log" |
|
|
|
|
|
|
|
"github.com/moond4rk/HackBrowserData/utils/byteutil" |
|
|
|
"github.com/moond4rk/HackBrowserData/utils/typeutil" |
|
|
|
"github.com/moond4rk/HackBrowserData/utils/typeutil" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +24,8 @@ type storage struct { |
|
|
|
Value string |
|
|
|
Value string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const maxLocalStorageLength = 1024 * 2 |
|
|
|
|
|
|
|
|
|
|
|
func (c *ChromiumLocalStorage) Parse(masterKey []byte) error { |
|
|
|
func (c *ChromiumLocalStorage) Parse(masterKey []byte) error { |
|
|
|
db, err := leveldb.OpenFile(item.TempChromiumLocalStorage, nil) |
|
|
|
db, err := leveldb.OpenFile(item.TempChromiumLocalStorage, nil) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -35,16 +38,16 @@ func (c *ChromiumLocalStorage) Parse(masterKey []byte) error { |
|
|
|
for iter.Next() { |
|
|
|
for iter.Next() { |
|
|
|
key := iter.Key() |
|
|
|
key := iter.Key() |
|
|
|
value := iter.Value() |
|
|
|
value := iter.Value() |
|
|
|
// don't parse value upper than 5kB
|
|
|
|
|
|
|
|
if len(value) > 1024*5 { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
s := new(storage) |
|
|
|
s := new(storage) |
|
|
|
s.fillKey(key) |
|
|
|
s.fillKey(key) |
|
|
|
|
|
|
|
// don't all value upper than 1kB
|
|
|
|
|
|
|
|
if len(value) < maxLocalStorageLength { |
|
|
|
s.fillValue(value) |
|
|
|
s.fillValue(value) |
|
|
|
// don't save meta data
|
|
|
|
} else { |
|
|
|
|
|
|
|
s.Value = fmt.Sprintf("value is too long, length is %d", len(value)) |
|
|
|
|
|
|
|
} |
|
|
|
if s.IsMeta { |
|
|
|
if s.IsMeta { |
|
|
|
continue |
|
|
|
s.Value = fmt.Sprintf("meta data, value bytes is %v", value) |
|
|
|
} |
|
|
|
} |
|
|
|
*c = append(*c, *s) |
|
|
|
*c = append(*c, *s) |
|
|
|
} |
|
|
|
} |
|
|
@ -84,9 +87,8 @@ func (s *storage) fillHeader(url, key []byte) { |
|
|
|
// fillValue fills value of the storage
|
|
|
|
// fillValue fills value of the storage
|
|
|
|
// TODO: support unicode charter
|
|
|
|
// TODO: support unicode charter
|
|
|
|
func (s *storage) fillValue(b []byte) { |
|
|
|
func (s *storage) fillValue(b []byte) { |
|
|
|
t := fmt.Sprintf("%c", b) |
|
|
|
value := bytes.Map(byteutil.OnSplitUTF8Func, b) |
|
|
|
m := strings.NewReplacer(" ", "", "\x00", "", "\x01", "").Replace(t) |
|
|
|
s.Value = string(value) |
|
|
|
s.Value = m |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type FirefoxLocalStorage []storage |
|
|
|
type FirefoxLocalStorage []storage |
|
|
|