Skip to content

Commit

Permalink
added Chromium support. see #1
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonSmasher committed Nov 11, 2019
1 parent e9e66f0 commit a8a1853
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ git-add:
git commit -m "Add generated browserbeat files"


BEAT_VERSION=0.0.2
BEAT_VERSION=0.0.3
VERSION_QUALIFIER=alpha1

VERSION=${BEAT_VERSION}-${VERSION_QUALIFIER}
Expand Down
2 changes: 1 addition & 1 deletion beater/browserbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (bt *Browserbeat) Run(b *beat.Beat) error {

//********************************* Begin main loop ***********************************************************/
// Loop for each supported browser
for _, browser := range []string{"chrome", "firefox", "safari"} {
for _, browser := range []string{"chrome", "firefox", "safari", "chromium"} {
// Read the current target browser's data base for each user on the machine
events := readBrowserData(browsers, browser, hn, ipAddresses)
// Loop through all of the browser history events
Expand Down
59 changes: 51 additions & 8 deletions beater/libbrowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,34 @@ func getChromePaths(users []string) []userBrowserHistoryPath {
return paths
}

// Returns Chromium history DB paths for each user on the machine
func getChromiumPaths(users []string) []userBrowserHistoryPath {
var paths []userBrowserHistoryPath
for _, user := range users {
var userPath string
if isWindows() {
userPath = filepath.Join("C:\\", "Users", user, "AppData", "Local", "Chromium", "User Data", "Default", "History")
} else if isMacos() {
userPath = filepath.Join("/Users", user, "Library", "Application Support", "Chromium", "Default", "History")
} else if isLinux() {
userPath = filepath.Join("/home", user, ".config", "chromium", "Default", "History")
}
if stat, err := os.Stat(userPath); err == nil {
if !stat.IsDir() {
srcDestMap := new(srcAndDestPaths)
srcDestMap.src = userPath
srcDestMap.dest = filepath.Join(getScratchPath(user), "chromium.sqlite")

ubhp := new(userBrowserHistoryPath)
ubhp.user = user
ubhp.paths = []srcAndDestPaths{*srcDestMap}
paths = append(paths, *ubhp)
}
}
}
return paths
}

// Returns Firefox history DB paths for each user on the machine
func getFirefoxPaths(users []string) []userBrowserHistoryPath {
var paths []userBrowserHistoryPath
Expand Down Expand Up @@ -292,6 +320,7 @@ func getBrowserHistoryPaths() systemBrowserHistoryPaths {
histories.chrome = getChromePaths(users)
histories.firefox = getFirefoxPaths(users)
histories.safari = getSafariPaths(users)
histories.chromium = getChromiumPaths(users)
return *histories
}

Expand Down Expand Up @@ -382,6 +411,23 @@ func getHistoryDataFromSqlite(file string, query string) []historyEntry {
return entries
}

// Returns the browser data paths for this machine and target browser combo
func chooseBrowserDataPath(browser string, browsers systemBrowserHistoryPaths) []userBrowserHistoryPath {
var none []userBrowserHistoryPath
switch browser {
case "chrome":
return browsers.chrome
case "firefox":
return browsers.firefox
case "safari":
return browsers.safari
case "chromium":
return browsers.chromium
default:
return none
}
}

// Stores the timestamp of the last history entry from the current run for the target user => browser pair
func storeUserBrowserState(browser string, user string, stamp string) {
mkDirP(path.Join("data", "states"))
Expand All @@ -402,15 +448,11 @@ func readBrowserData(browsers systemBrowserHistoryPaths, browser string, hn host
var browserData []userBrowserHistoryPath
var browserBeatDatas []browserBeatData
dateFormat := "2006-01-02 15:04:05"
// Chrome based browsers
chromes := []string{"chrome", "chromium"}

// Chose the browser database paths based on the current browser
if browser == "chrome" {
browserData = browsers.chrome
} else if browser == "firefox" {
browserData = browsers.firefox
} else if browser == "safari" {
browserData = browsers.safari
}
browserData = chooseBrowserDataPath(browser, browsers)

if len(browserData) > 0 { // Are there any database => user pairs to go through?
// Loop through each dataset in the collection
Expand All @@ -429,8 +471,9 @@ func readBrowserData(browsers systemBrowserHistoryPaths, browser string, hn host
// Change the SQL query strings to get history entries since the datetime stamp
qMap = getQueryMapSince(stamp)
}

// Based on our browser and the timestamp chose our SQL query
if browser == "chrome" {
if stringInSlice(browser, chromes) {
query = qMap.chrome
} else if browser == "firefox" {
query = qMap.firefox
Expand Down
1 change: 1 addition & 0 deletions beater/libbrowsertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type systemBrowserHistoryPaths struct {
chrome []userBrowserHistoryPath
firefox []userBrowserHistoryPath
safari []userBrowserHistoryPath
chromium []userBrowserHistoryPath
}

type queryMap struct {
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

const AppVersion = "0.0.2-alpha1"
const AppVersion = "0.0.3-alpha1"

0 comments on commit a8a1853

Please sign in to comment.