Skip to content

MalQuery

The MalQuery service collection provides operations for searching and downloading malware samples from Falcon’s malware repository. Check quotas, perform fuzzy or exact searches by hex patterns and strings, download files, retrieve metadata, schedule multi-sample downloads, and run YARA-based hunts.

LanguageLast Update
Pythonv1.5.0
PowerShellv2.2.9
Gov0.20.0
TypeScriptv0.6.0
Rustv0.7.0
Rubyv1.2.0

This service collection has code examples posted to the repository.

OperationDescription
GetMalQueryQuotasV1
get_quotas
Get information about search and download quotas in your environment
PostMalQueryFuzzySearchV1
fuzzy_search
Search Falcon MalQuery quickly, but with more potential for false positives. Search for a combination of hex patterns and strings in order to identify samples based upon file content at byte level granularity.
GetMalQueryDownloadV1
get_download
Download a file indexed by MalQuery. Specify the file using its SHA256. Only one file is supported at this time
GetMalQueryMetadataV1
get_metadata
Retrieve indexed files metadata by their hash
GetMalQueryRequestV1
get_request
Check the status and results of an asynchronous request, such as hunt or exact-search. Supports a single request id at this time.
GetMalQueryEntitiesSamplesFetchV1
get_samples
Fetch a zip archive with password ‘infected’ containing the samples. Call this once the /entities/samples-multidownload request has finished processing
PostMalQueryEntitiesSamplesMultidownloadV1
samples_multidownload
Schedule samples for download. Use the result id with the /request endpoint to check if the download is ready after which you can call the /entities/samples-fetch to get the zip
PostMalQueryExactSearchV1
exact_search
Search Falcon MalQuery for a combination of hex patterns and strings in order to identify samples based upon file content at byte level granularity. You can filter results on criteria such as file type, file size and first seen date. Returns a request id which can be used with the /request endpoint
PostMalQueryHuntV1
hunt
Schedule a YARA-based search for execution. Returns a request id which can be used with the /request endpoint

Get information about search and download quotas in your environment

GET /malquery/aggregates/quotas/v1
Scope MalQuery: READ Produces application/json
PEP 8 get_quotas

No keywords are arguments are accepted.

from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.get_quotas()
print(response)

Search Falcon MalQuery quickly, but with more potential for false positives. Search for a combination of hex patterns and strings in order to identify samples based upon file content at byte level granularity.

POST /malquery/combined/fuzzy-search/v1
Scope MalQuery: WRITE Consumes · Produces application/json
PEP 8 fuzzy_search
NameTypeData typeDescription
bodybodydictionaryFull body payload in JSON format.
filter_metabodylist of stringsFQL Syntax.
limitbodyintegerMaximum number of matches to return.
patternsbodylist of dictionariesList of patterns to match in JSON format. Example: {“type”: “string”,“value”: “string”}
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
patterns = [
{
"type": "string",
"value": "string"
}
]
response = falcon.fuzzy_search(filter_meta=["string"],
limit=integer,
patterns=patterns)
print(response)

Download a file indexed by MalQuery. Specify the file using its SHA256. Only one file is supported at this time

GET /malquery/entities/download-files/v1
Scope MalQuery: READ Produces application/octet-stream
PEP 8 get_download
NameTypeData typeDescription
idsquerystring or list of stringsFile(s) SHA256 ID.
parametersquerydictionaryFull query string parameters payload in JSON format.
streamquerybooleanEnable streaming download of the returned file.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
with open("output_file", "wb") as save_file:
response = falcon.get_download(ids=id_list, stream=boolean, stream=boolean)
save_file.write(response)

Retrieve indexed files metadata by their hash

GET /malquery/entities/metadata/v1
Scope MalQuery: READ Produces application/json
PEP 8 get_metadata
NameTypeData typeDescription
idsquerystring or list of stringsFile(s) SHA256 ID.
parametersquerydictionaryFull query string parameters payload in JSON format.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
response = falcon.get_metadata(ids=id_list)
print(response)

Check the status and results of an asynchronous request, such as hunt or exact-search. Supports a single request id at this time.

GET /malquery/entities/requests/v1
Scope MalQuery: READ Produces application/json
PEP 8 get_request
NameTypeData typeDescription
idsquerystringIdentifier of the MalQuery request.
parametersquerydictionaryFull query string parameters payload in JSON format.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
response = falcon.get_request(ids=id_list)
print(response)

Fetch a zip archive with password ‘infected’ containing the samples. Call this once the /entities/samples-multidownload request has finished processing

GET /malquery/entities/samples-fetch/v1
Scope MalQuery: READ Produces application/zip
PEP 8 get_samples
NameTypeData typeDescription
idsquerystring or list of stringsMulti-download job ID(s).
parametersquerydictionaryFull query string parameters payload in JSON format.
streamquerybooleanEnable streaming download of the returned file.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
response = falcon.get_samples(ids=id_list, stream=boolean)
print(response)

PostMalQueryEntitiesSamplesMultidownloadV1

Section titled “PostMalQueryEntitiesSamplesMultidownloadV1”

Schedule samples for download. Use the result id with the /request endpoint to check if the download is ready after which you can call the /entities/samples-fetch to get the zip

POST /malquery/entities/samples-multidownload/v1
Scope MalQuery: WRITE Consumes · Produces application/json
PEP 8 samples_multidownload
NameTypeData typeDescription
bodybodydictionaryFull body payload in JSON format.
samplesbodylist of stringsList of MalQuery sample ID(s) to be downloaded.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
response = falcon.samples_multidownload(samples=id_list)
print(response)

Search Falcon MalQuery for a combination of hex patterns and strings in order to identify samples based upon file content at byte level granularity. You can filter results on criteria such as file type, file size and first seen date. Returns a request id which can be used with the /request endpoint

POST /malquery/queries/exact-search/v1
Scope MalQuery: WRITE Consumes · Produces application/json
PEP 8 exact_search
NameTypeData typeDescription
bodybodydictionaryFull body payload in JSON format.
filter_filetypesbodylist of stringsFile types to filter on.
filter_metabodylist of stringsFile metadata to filter on.
limitbodyintegerMaximum number of matches to return.
min_datebodystringUTC formatted date string representing the earliest date from which to return results.
max_datebodystringUTC formatted date string representing the latest date from which to return results.
min_sizebodystringMinimum file size for returned results.
max_sizebodystringMaximum file size for returned results.
patternsbodylist of dictionariesList of patterns to match in JSON format. Example: {“type”: “string”,“value”: “string”}
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
patterns = [
{
"type": "string",
"value": "string"
}
]
response = falcon.exact_search(filter_filetypes=["string"],
filter_meta=["string"],
limit=integer,
max_date="string",
min_date="string",
max_size="string",
min_size="string",
patterns=patterns)
print(response)

Schedule a YARA-based search for execution. Returns a request id which can be used with the /request endpoint

POST /malquery/queries/hunt/v1
Scope MalQuery: WRITE Consumes · Produces application/json
PEP 8 hunt
NameTypeData typeDescription
bodybodydictionaryFull body payload in JSON format.
filter_filetypesbodylist of stringsFile types to filter on.
filter_metabodylist of stringsFile metadata to filter on.
limitbodyintegerMaximum number of matches to return.
min_datebodystringUTC formatted date string representing the earliest date from which to return results.
max_datebodystringUTC formatted date string representing the latest date from which to return results.
min_sizebodystringMinimum file size for returned results.
max_sizebodystringMaximum file size for returned results.
yara_rulebodystringYara rule to use for matching.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.hunt(filter_filetypes=["string"],
filter_meta=["string"],
limit=integer,
max_date="string",
min_date="string",
max_size="string",
min_size="string",
yara_rule="string")
print(response)