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.6.5
PowerShellv2.2.9
Gov0.22.0
TypeScriptv0.6.0
Rustv0.7.1
Rubyv1.4.0

This service collection has code examples posted to the repository.



OperationDescription
GetMalQueryDownloadV1
get_download
Download a file indexed by MalQuery.
GetMalQueryEntitiesSamplesFetchV1
get_samples
Fetch a zip archive with password ‘infected’ containing the samples.
GetMalQueryMetadataV1
get_metadata
Retrieve indexed files metadata by their hash
GetMalQueryQuotasV1
get_quotas
Get information about search and download quotas in your environment
GetMalQueryRequestV1
get_request
Check the status and results of an asynchronous request, such as hunt or exact-search.
PostMalQueryEntitiesSamplesMultidownloadV1
samples_multidownload
Schedule samples for download.
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.
PostMalQueryFuzzySearchV1
fuzzy_search
Search Falcon MalQuery quickly, but with more potential for false positives.
PostMalQueryHuntV1
hunt
Schedule a YARA-based search for execution.

Download a file indexed by MalQuery.

Method GET
Route /malquery/entities/download-files/v1
Scope MalQuery: READ
PEP 8 get_download
ids query · string or list of strings
The file SHA256.
parameters query · dictionary
Full query string parameters payload in JSON format. Not required when using other keywords.
stream body · boolean
Enable 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)
{
"errors": [
{
"code": 0,
"id": "string",
"message": "string"
}
],
"meta": {
"pagination": {
"limit": 0,
"offset": 0,
"total": 0
},
"powered_by": "string",
"query_time": 0.0,
"trace_id": "string",
"writes": {
"resources_affected": 0
}
}
}


Fetch a zip archive with password ‘infected’ containing the samples.

Method GET
Route /malquery/entities/samples-fetch/v1
Scope MalQuery: READ
PEP 8 get_samples
ids query · string
Multidownload job id
parameters query · dictionary
Full query string parameters payload in JSON format. Not required when using other keywords.
stream body · boolean
Enable 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)
{
"errors": [
{
"code": 0,
"id": "string",
"message": "string"
}
],
"meta": {
"pagination": {
"limit": 0,
"offset": 0,
"total": 0
},
"powered_by": "string",
"query_time": 0.0,
"trace_id": "string",
"writes": {
"resources_affected": 0
}
}
}


Retrieve indexed files metadata by their hash

Method GET
Route /malquery/entities/metadata/v1
Scope MalQuery: READ
PEP 8 get_metadata
ids query · string or list of strings
The file SHA256.
parameters query · dictionary
Full query string parameters payload in JSON format. Not required when using other keywords.
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)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"label": "string",
"md5": "string",
"sha1": "string",
"sha256": "string"
}
]


Get information about search and download quotas in your environment

Method GET
Route /malquery/aggregates/quotas/v1
Scope MalQuery: READ
PEP 8 get_quotas
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.get_quotas()
print(response)
{
"errors": [
{
"code": 0,
"id": "string",
"message": "string"
}
],
"meta": {
"days_left": 0,
"download_count": 0,
"download_counts": [],
"download_limit": 0,
"hunt_count": 0,
"hunt_counts": [],
"hunt_limit": 0,
"monitor_count": 0,
"monitor_limit": 0,
"refresh_time": "string"
}
}


Check the status and results of an asynchronous request, such as hunt or exact-search.

Method GET
Route /malquery/entities/requests/v1
Scope MalQuery: READ
PEP 8 get_request
ids query · string or list of strings
Identifier of a MalQuery request
parameters query · dictionary
Full query string parameters payload in JSON format. Not required when using other keywords.
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)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"ignore_reason": "string",
"label": "string",
"label_confidence": "string",
"md5": "string",
"pattern": "string",
"pattern_type": "string",
"samples": [],
"sha1": "string",
"sha256": "string",
"tags": [],
"yara_rule": "string",
"yara_rules": []
}
]


PostMalQueryEntitiesSamplesMultidownloadV1

Section titled “PostMalQueryEntitiesSamplesMultidownloadV1”

Schedule samples for download.

Method POST
Route /malquery/entities/samples-multidownload/v1
Scope MalQuery: WRITE
PEP 8 samples_multidownload
body body · dictionary
Full body payload as JSON formatted dictionary.
samples body · array
List of sample sha256 ids
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)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"ignore_reason": "string",
"label": "string",
"label_confidence": "string",
"md5": "string",
"pattern": "string",
"pattern_type": "string",
"samples": [],
"sha1": "string",
"sha256": "string",
"tags": [],
"yara_rule": "string",
"yara_rules": []
}
]


Search Falcon MalQuery for a combination of hex patterns and strings in order to identify samples based upon file content at byte level granularity.

Method POST
Route /malquery/queries/exact-search/v1
Scope MalQuery: WRITE
PEP 8 exact_search
body body · dictionary
Full body payload as JSON formatted dictionary.
options body · object
Additional search options
patterns body · array
Patterns to search for
filter_filetypes body · list of strings
File types to filter on.
filter_meta body · list of strings
File metadata to filter on.
limit body · string
Integer representing maximum number of matches to return.
max_date body · string
Maximum date to match. UTC formatted.
min_date body · string
Minimum date to match. UTC formatted.
max_size body · string
Maximum size in bytes to match.
min_size body · string
Minumum size in bytes to match.
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="string",
max_date="string",
min_date="string",
max_size="string",
min_size="string",
patterns=patterns)
print(response)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"ignore_reason": "string",
"label": "string",
"label_confidence": "string",
"md5": "string",
"pattern": "string",
"pattern_type": "string",
"samples": [],
"sha1": "string",
"sha256": "string",
"tags": [],
"yara_rule": "string",
"yara_rules": []
}
]


Search Falcon MalQuery quickly, but with more potential for false positives.

Method POST
Route /malquery/combined/fuzzy-search/v1
Scope MalQuery: WRITE
PEP 8 fuzzy_search
body body · dictionary
Full body payload as JSON formatted dictionary.
options body · object
patterns body · array
List of dictionaries containing patterns to match.
filter_meta body · list of strings
limit body · string
Integer representing maximum number of matches to return.
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="string",
patterns=patterns)
print(response)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"label": "string",
"md5": "string",
"sha1": "string",
"sha256": "string"
}
]


Schedule a YARA-based search for execution.

Method POST
Route /malquery/queries/hunt/v1
Scope MalQuery: WRITE
PEP 8 hunt
body body · dictionary
Full body payload as JSON formatted dictionary.
options body · object
Optional advanced searching parameters
yara_rule body · string
A YARA rule that defines your search
filter_filetypes body · list of strings
File types to filter on.
filter_meta body · list of strings
File metadata to filter on.
limit body · string
Integer representing maximum number of matches to return.
max_date body · string
Maximum date to match. UTC formatted.
min_date body · string
Minimum date to match. UTC formatted.
max_size body · string
Maximum size in bytes to match.
min_size body · string
Minumum size in bytes to match.
from falconpy import MalQuery
falcon = MalQuery(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.hunt(filter_filetypes=["string"],
filter_meta=["string"],
limit="string",
max_date="string",
min_date="string",
max_size="string",
min_size="string",
yara_rule="string")
print(response)
[
{
"family": "string",
"filesize": 0,
"filetype": "string",
"first_seen": "string",
"ignore_reason": "string",
"label": "string",
"label_confidence": "string",
"md5": "string",
"pattern": "string",
"pattern_type": "string",
"samples": [],
"sha1": "string",
"sha256": "string",
"tags": [],
"yara_rule": "string",
"yara_rules": []
}
]