refactor: Refactor storage queries and filters.

- Update local storage query constant and function calls
- Remove null and control characters from UTF-8 split function
pull/224/head
moonD4rk 2 years ago
parent 5376184c7e
commit 6c1f653b4f
  1. 6
      browingdata/localstorage/localstorage.go
  2. 16
      browingdata/sessionstorage/sessionstorage.go
  3. 12
      utils/byteutil/byteutil.go

@ -101,8 +101,8 @@ func (s *storage) fillValue(b []byte) {
type FirefoxLocalStorage []storage
const (
queryFirefoxHistory = `SELECT originKey, key, value FROM webappsstore2`
closeJournalMode = `PRAGMA journal_mode=off`
queryLocalStorage = `SELECT originKey, key, value FROM webappsstore2`
closeJournalMode = `PRAGMA journal_mode=off`
)
func (f *FirefoxLocalStorage) Parse(_ []byte) error {
@ -117,7 +117,7 @@ func (f *FirefoxLocalStorage) Parse(_ []byte) error {
if err != nil {
log.Error(err)
}
rows, err := db.Query(queryFirefoxHistory)
rows, err := db.Query(queryLocalStorage)
if err != nil {
return err
}

@ -76,14 +76,12 @@ func (s *session) fillKey(b []byte) {
s.fillHeader(keys[0], keys[1])
}
if len(keys) == 3 {
if string(keys[0]) == "map"{
if string(keys[0]) == "map" {
s.Key = string(keys[2])
} else if string(keys[0]) == "namespace"{
} else if string(keys[0]) == "namespace" {
s.URL = string(keys[2])
s.Key = string(keys[1])
}
}
}
@ -111,23 +109,23 @@ func (s *session) fillValue(b []byte) {
type FirefoxSessionStorage []session
const (
queryFirefoxHistory = `SELECT originKey, key, value FROM webappsstore2`
querySessionStorage = `SELECT originKey, key, value FROM webappsstore2`
closeJournalMode = `PRAGMA journal_mode=off`
)
func (f *FirefoxSessionStorage) Parse(_ []byte) error {
db, err := sql.Open("sqlite3", item.TempFirefoxLocalStorage)
db, err := sql.Open("sqlite3", item.TempFirefoxSessionStorage)
if err != nil {
return err
}
defer os.Remove(item.TempFirefoxLocalStorage)
defer os.Remove(item.TempFirefoxSessionStorage)
defer db.Close()
_, err = db.Exec(closeJournalMode)
if err != nil {
log.Error(err)
}
rows, err := db.Query(queryFirefoxHistory)
rows, err := db.Query(querySessionStorage)
if err != nil {
return err
}
@ -159,7 +157,7 @@ func (s *session) fillFirefox(originKey, key, value string) {
}
func (f *FirefoxSessionStorage) Name() string {
return "localStorage"
return "sessionStorage"
}
func (f *FirefoxSessionStorage) Len() int {

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

Loading…
Cancel
Save