fix: missing key and value in localstorage

pull/224/head
moonD4rk 2 years ago
parent c070323e86
commit b824f74fae
  1. 22
      browingdata/localstorage/localstorage.go
  2. 10
      utils/byteutil/byteutil.go

@ -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)
s.fillValue(value) // don't all value upper than 1kB
// don't save meta data if len(value) < maxLocalStorageLength {
s.fillValue(value)
} 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

@ -0,0 +1,10 @@
package byteutil
var (
OnSplitUTF8Func = func(r rune) rune {
if r == 0x00 || r == 0x01 {
return -1
}
return r
}
)
Loading…
Cancel
Save