forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lazy objects to pe parser. (Velocidex#857)
The parse_pe() function can spend a lot of time in export/import tables and if the caller does not care about it then it makes no sense to do it. Implementing lazy semantics allows functions and plugins to avoid unnecessary work and increases performance significantly.
- Loading branch information
Showing
37 changed files
with
11,234 additions
and
7,307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ bin/rsrc.syso | |
|
||
artifacts/assets/ab0x.go | ||
gui/assets/ab0x.go | ||
config/ab0x.go | ||
config/ab0x.go | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
Queries: | ||
- SELECT basename(path=FullPath) AS Name, parse_pe(file=FullPath) as PEInfo FROM glob( | ||
globs=srcDir + "/artifacts/**10/*.exe") | ||
# parse_pe() is a lazy function providing a lot of functionality by | ||
# setting callables in the result set. These tests make sure that | ||
# the lazy functions are materialized when needed in a transparent | ||
# way. | ||
|
||
# PEInfo is a lazy object - PEInfo.ImpHash is a callable - this | ||
# tests a callable regex works. | ||
- SELECT basename(path=FullPath) AS Name, parse_pe(file=FullPath) as PEInfo | ||
FROM glob(globs=srcDir + "/artifacts/**10/*.{exe,sys}") | ||
WHERE PEInfo.ImpHash =~ "f34d5f2d4577" | ||
|
||
# Check that Imports (which are lazy) can be passed to function args | ||
- SELECT filter(list=parse_pe(file=FullPath).Imports, regex='MmGetPhysicalMemoryRanges') | ||
FROM glob(globs=srcDir + "/artifacts/**10/*.sys") | ||
|
||
- LET X = SELECT basename(path=FullPath) AS Name, parse_pe(file=FullPath) as PEInfo | ||
FROM glob(globs=srcDir + "/artifacts/**10/*.{exe,sys}") | ||
|
||
# Test Associative protocol. | ||
- SELECT PEInfo.VersionInformation.CompanyName AS CompanyName FROM X | ||
WHERE CompanyName =~ "Microsoft" | ||
|
||
# Test membership protocol | ||
- SELECT Name | ||
FROM glob(globs=srcDir + "/artifacts/**10/*.{sys,exe}") | ||
WHERE "ntoskrnl.exe!MmGetSystemRoutineAddress" IN parse_pe(file=FullPath).Imports | ||
|
||
# Test Iterate protocol on callables - Imports should iterate over | ||
# each string in the array. | ||
- SELECT * FROM foreach( | ||
row=parse_pe(file=srcDir + "/artifacts/testdata/files/winpmem_x64.sys").Imports) | ||
WHERE _value =~ "Physical" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.