Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
id: velociraptor
with:
repository: velocidex/velociraptor
tag: v0.75
fileName: "velociraptor-v0.75.2-linux-amd64-musl"
tag: v0.77.3
fileName: "velociraptor-v0.77.3-linux-amd64-musl.gz"
out-file-path: tests

- name: Build artifacts
Expand All @@ -29,7 +29,8 @@ jobs:

- name: Run Velociraptor
run: |
mv ${{ fromJson(steps.velociraptor.outputs.downloaded_files)[0]}} ./tests/velociraptor.bin
mv ${{ fromJson(steps.velociraptor.outputs.downloaded_files)[0]}} ./tests/velociraptor.bin.gz
gunzip ./tests/velociraptor.bin.gz
chmod +x ./tests/velociraptor.bin
ls -l ./output/
./tests/velociraptor.bin artifacts verify --builtin -v ./output/*.yaml
Expand Down
2 changes: 2 additions & 0 deletions compile/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"text/template"

"github.com/Velocidex/SQLiteHunter/api"
"github.com/Velocidex/SQLiteHunter/definitions"
"github.com/Velocidex/ordereddict"

_ "embed"
Expand Down Expand Up @@ -42,6 +43,7 @@ func (self *Artifact) Yaml() (string, error) {
"Quote": func(in interface{}) interface{} {
return fmt.Sprintf("%q", in)
},
"Sanitize": definitions.SanitizeName,
"DictRange": func(in interface{}) interface{} {
var res []dictValue

Expand Down
2 changes: 1 addition & 1 deletion compile/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sources:
{{ $action = "ApplyFile" }}
{{ end -}}

- name: {{ Quote $v.Key }}
- name: {{ Sanitize $v.Key }}
notebook:
- type: none
output: "{{ $v.Key }} - Recalculate to view results"
Expand Down
2 changes: 2 additions & 0 deletions definitions/Apple_IntelligencePlatform_Wifi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ SQLiteIdentifyValue: 1

Sources:
- name: Wifi
Preamble: |
// linter: symbol_mask_warn:timestamp
SQL: |
SELECT behaviorType, behaviorIdentifier, timestamp
FROM wifiContextEvents ORDER BY timestamp
Expand Down
5 changes: 4 additions & 1 deletion definitions/MacOS_Applications_Cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Globs:
- "/Users/*/Library/Caches/*/Cache.db"

Sources:
- VQL: |
- Preamble: |
// linter: symbol_mask_warn:version

VQL: |
SELECT
time_stamp AS Timestamp,
OSPath.Base AS Application,
Expand Down
23 changes: 20 additions & 3 deletions definitions/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ package definitions

import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/Velocidex/SQLiteHunter/api"
"gopkg.in/yaml.v3"
)

// Artifact names are more strict now so we need to clean them up.
var artifactNameRegex = regexp.MustCompile("[^a-zA-Z0-9_.]")

func SanitizeName(name string) string {
return artifactNameRegex.ReplaceAllLiteralString(name, "_")
}

func LoadDefinitions(root string) ([]api.Definition, error) {
var definitions []api.Definition

Expand All @@ -25,7 +33,7 @@ func LoadDefinitions(root string) ([]api.Definition, error) {
return nil
}

data, err := ioutil.ReadAll(fd)
data, err := io.ReadAll(fd)
if err != nil {
fmt.Printf("Error processing %v: %v\n", path, err)
return nil
Expand All @@ -39,10 +47,19 @@ func LoadDefinitions(root string) ([]api.Definition, error) {
definition.Filename_ = path
definition.RawData_ = string(data)

definitions = append(definitions, definition)
definitions = append(definitions, sanitizeDefinition(definition))
}
return nil
})

return definitions, err
}

func sanitizeDefinition(definition api.Definition) api.Definition {
definition.Name = SanitizeName(definition.Name)
for _, s := range definition.Sources {
s.Name = SanitizeName(s.Name)
}

return definition
}
130 changes: 85 additions & 45 deletions docs/content/docs/rules/index.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions testing/fixtures/TestArtifact.golden
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
{
"All Records": [
"[][",
"[",
" {",
" \"LastVisitDate\": \"2020-06-27T09:29:54.51375Z\",",
" \"URL\": \"https://www.mozilla.org/privacy/firefox/\",",
" \"Description\": null,",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" },",
" {",
" \"LastVisitDate\": \"2020-06-27T09:30:05.721357Z\",",
" \"URL\": \"http://github.com/seanbreckenridge/dotfiles\",",
" \"Description\": null,",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" },",
" {",
" \"LastVisitDate\": \"2020-06-30T05:53:37.171Z\",",
" \"URL\": \"https://www.mozilla.org/en-US/firefox/78.0a2/firstrun/\",",
" \"Description\": \"Firefox Developer Edition is the blazing fast browser that offers cutting edge developer tools and latest features like CSS Grid support and framework debugging\",",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" },",
" {",
" \"LastVisitDate\": \"2021-02-21T08:55:10.488Z\",",
" \"URL\": \"https://www.mozilla.org/en-US/privacy/firefox/\",",
" \"Description\": \"\\n Our Privacy Notices describe the data our products and services receive, share, and use, as well as choices available to you.\\n\",",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" }",
"]"
],
"After 2021-02-20T08:55:10.488Z should be only 2021-02-21T08:55:10.488Z": [
"[][",
"[",
" {",
" \"LastVisitDate\": \"2021-02-21T08:55:10.488Z\",",
" \"URL\": \"https://www.mozilla.org/en-US/privacy/firefox/\",",
" \"Description\": \"\\n Our Privacy Notices describe the data our products and services receive, share, and use, as well as choices available to you.\\n\",",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" }",
"]"
],
"DateBefore=2020-06-27T09:30:00Z should be only 2020-06-27T09:29:54.51375Z": [
"[][",
"[",
" {",
" \"LastVisitDate\": \"2020-06-27T09:29:54.51375Z\",",
" \"URL\": \"https://www.mozilla.org/privacy/firefox/\",",
" \"Description\": null,",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" }",
"]"
],
"FilterRegex=Firefox Developer Edition": [
"[][",
"[",
" {",
" \"LastVisitDate\": \"2020-06-30T05:53:37.171Z\",",
" \"URL\": \"https://www.mozilla.org/en-US/firefox/78.0a2/firstrun/\",",
" \"Description\": \"Firefox Developer Edition is the blazing fast browser that offers cutting edge developer tools and latest features like CSS Grid support and framework debugging\",",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox Places History\"",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Firefox_Places_History\"",
" }",
"]"
]
Expand Down
4 changes: 2 additions & 2 deletions testing/fixtures/TestEdgeWebAssistDatabase.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FilterRegex=Audio": [
"[][",
"[",
" {",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/AllFiles\",",
" },",
Expand All @@ -10,7 +10,7 @@
" \"Title\": \"How to Record Audio on Windows 10\",",
" \"URL\": \"https://www.lifewire.com/how-to-record-audio-on-windows-10-4773840\",",
" \"VisitCount\": 1,",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Edge Browser Navigation History_Navigation History\",",
" \"_Source\": \"Generic.Forensic.SQLiteHunter/Edge_Browser_Navigation_History_Navigation_History\",",
" }",
"]"
]
Expand Down
8 changes: 6 additions & 2 deletions testing/sqlitehunter_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package testing

import (
"compress/gzip"
"fmt"
"io"
"net/http"
Expand All @@ -18,7 +19,7 @@ import (
)

const (
VelociraptorUrl = "https://github.com/Velocidex/velociraptor/releases/download/v0.74/velociraptor-v0.74.5-linux-amd64-musl"
VelociraptorUrl = "https://github.com/Velocidex/velociraptor/releases/download/v0.77.3/velociraptor-v0.77.3-linux-amd64-musl.gz"
VelociraptorBinaryPath = "./velociraptor.bin"
)

Expand Down Expand Up @@ -48,7 +49,10 @@ func (self *SQLiteHunterTestSuite) findAndPrepareBinary() {
defer out.Close()

// Write the body to file
_, err = io.Copy(out, resp.Body)
gz, err := gzip.NewReader(resp.Body)
assert.NoError(t, err)

_, err = io.Copy(out, gz)
assert.NoError(t, err)
}
}
Expand Down
14 changes: 7 additions & 7 deletions testing/testcases/chrome_notifications.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Output: [
"Site": "https://docs.velociraptor.app:443,*",
"LastModified": "2024-01-22T04:19:19Z",
"LastEngagementTime": "2024-01-21T20:10:29Z",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_Site Engagements",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_Site_Engagements",
"OSPath": "Preferences"
},
{
"Site": "https://github.com:443,*",
"LastModified": "2024-01-22T04:19:19Z",
"LastEngagementTime": "2024-01-21T20:17:51Z",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_Site Engagements",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_Site_Engagements",
"OSPath": "Preferences"
},
{
Expand All @@ -30,7 +30,7 @@ Output: [
"CouldShowBannerEvents": "2024-01-21T14:33:10Z",
"LastShown": "2024-01-21T14:32:36Z"
},
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_App Banners",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_App_Banners",
"OSPath": "Preferences"
},
{
Expand All @@ -41,7 +41,7 @@ Output: [
"CouldShowBannerEvents": "2024-01-23T01:36:02Z",
"LastShown": "2024-01-23T01:35:54Z"
},
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_App Banners",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_App_Banners",
"OSPath": "Preferences"
},
{
Expand All @@ -52,7 +52,7 @@ Output: [
"CouldShowBannerEvents": "2024-01-21T14:48:57Z",
"LastShown": "2024-01-21T14:48:23Z"
},
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_App Banners",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_App_Banners",
"OSPath": "Preferences"
},
{
Expand All @@ -63,14 +63,14 @@ Output: [
"CouldShowBannerEvents": "2024-01-21T14:37:03Z",
"LastShown": "2024-01-21T14:36:56Z"
},
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_App Banners",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_App_Banners",
"OSPath": "Preferences"
},
{
"Site": "https://appuals.com:443,*",
"LastModified": "2019-10-14T06:39:30Z",
"Setting": "Block",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium Browser Notifications_Notification Preferences",
"_Source": "Generic.Forensic.SQLiteHunter/Chromium_Browser_Notifications_Notification_Preferences",
"OSPath": "Preferences"
}
]
Expand Down
2 changes: 1 addition & 1 deletion testing/testcases/edge_webassist.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Output: [
"Title": "How to Record Audio on Windows 10",
"URL": "https://www.lifewire.com/how-to-record-audio-on-windows-10-4773840",
"VisitCount": 1,
"_Source": "Generic.Forensic.SQLiteHunter/Edge Browser Navigation History_Navigation History",
"_Source": "Generic.Forensic.SQLiteHunter/Edge_Browser_Navigation_History_Navigation_History",
"OSPath": "WebAssistDatabase"
}
]
Expand Down
Loading