Skip to main content

Python SDK for using ReversingLabs services - Python 2 version.

Project description

ReversingLabs

ReversingLabsSDK

A Python SDK for ReversingLabs REST services (TitaniumCloud and appliances) - Python 2 version.

The idea behind this SDK is to enable easier out-of-the-box development of software integrations and automation services that need to interact with ReversingLabs.

The SDK consists of several modules, where each module represents one ReversingLabs service or ReversingLabs TitaniumCloud.

Module: a1000

A Python module representing the ReversingLabs A1000 malware analysis platform.

Class:

class A1000(object)
def __init__(self, host, username=None, password=None, token=None, fields=__FIELDS, wait_time_seconds=2, retries=10, verify=True, proxies=None, user_agent=DEFAULT_USER_AGENT):

Parameters:

host - A1000 address
username - A1000 username
password - A1000 password
token - A1000 user token for the REST API
fields - optional fields that will be returned in the analysis report
wait_time_seconds - wait time between each report fetching retry
retries - number of report fetching retries
verify - verify SSL certificate
proxies - optional proxies in use
user_agent - optional user agent string

NOTE!
The default means of authorization on the ReversingLabs A1000 REST API is the token.
If username and password are used instead, a token fetching request will be done so the token can be used in further actions without the user explicitly providing the token.

Class methods:

  • configuration_dump
    • Returns the configuration of the instantiated A1000 object
  • upload_sample_from_path
    • Accepts a file path string and returns a response containing the analysis task ID
  • upload_sample_from_file
    • Accepts a file open in 'rb' mode and returns a response containing the analysis task ID
  • get_results
    • Accepts a list of hashes and returns a summary JSON report for each of them
    • This method utilizes the set number of retries and wait time in seconds to time out if the analysis results are not ready
  • upload_sample_and_get_results
    • Accepts a file path string or an opened file in 'rb' mode for file upload and returns an analysis report response
    • This method combines uploading a sample and obtaining the analysis results
    • The result fetching action of this method utilizes the set number of retries and wait time in seconds to time out if the analysis results are not ready
  • get_classification
    • Accepts one or more sample hashes and returns their classification
  • get_extracted_files
    • Accepts a sample hash and returns a list of all files TitaniumCore engine extracted from the requested sample during static analysis
  • advanced_search
    • Accepts a search query string and performs advanced search for local samples on A1000
    • Returns only one defined page of results using one request
  • advanced_search_aggregated
    • Accepts a search query string and performs advanced search for local samples on A1000
    • Returns a list of results aggregated through multiple paginated requests

Module: ticloud

A Python module representing the ReversingLabs TitaniumCloud API-s.

Each class in this module represents one TitaniumCloud API and can be instantiated using the same set of parameters:

def __init__(self, host, username, password, verify=True, proxies=None, user_agent=DEFAULT_USER_AGENT, allow_none_return=False)

Parameters:

host - TitaniumCloud address
username - TitaniumCloud username
password - TitaniumCloud password
verify - verify SSL certificate
proxies - optional proxies in use
user_agent - optional user agent string
allow_none_return - if set to True, 404 response codes will return None instead of NotFoundError

Class:

class FileReputation(TiCloudAPI)

Methods:

  • get_file_reputation
    • Accepts a hash string or a list of hash strings and returns file reputation
    • Hash strings in a passed list must all be of the same hashing algorithm

Class:

class AVScanners(TiCloudAPI)

Methods:

  • get_scan_results
    • Accepts a hash string or a list of hash strings and returns AV scanner results
    • Hash strings in a passed list must all be of the same hashing algorithm

Class:

class FileAnalysis(TiCloudAPI)

Methods:

  • get_analysis_results
    • Accepts a hash string or a list of hash strings and returns extended file analysis
  • extract_uri_list_from_report
    • Accepts a list of entries from the FileAnalysis report and returns a list of URI-s from those entries.
  • get_file_type
    • Accepts a sample hash and returns the file type string

Class:

class RHA1FunctionalSimilarity(TiCloudAPI)

Methods:

  • get_similar_hashes
    • Accepts a hash string and returns a list of functionally similar hashes
    • Returns only one defined page of results using one request
  • get_similar_hashes_aggregated
    • Accepts a hash string and returns a list of functionally similar hashes
    • Returns a list of results aggregated through multiple paginated requests

Class:

class RHA1Analytics(TiCloudAPI)

Methods:

  • get_rha1_analytics
    • Accepts one or more hash strings and returns a count of functionally similar hashes grouped by classification

Class:

class URIStatistics(TiCloudAPI)

Methods:

  • get_uri_statistics
    • Accepts a URI string and returns a count of files associated with that URI grouped by classification

Class:

class URIIndex(TiCloudAPI)

Methods:

  • get_uri_index
    • Accepts a URI string and returns a list of files associated with this URI
    • Returns only one defined page of results using one request
  • get_uri_index_aggregated
    • Accepts a URI string and returns a list of files associated with this URI
    • Returns a list of results aggregated through multiple paginated requests

Class:

class AdvancedSearch(TiCloudAPI)

Methods:

  • search
    • Accepts a search query string and performs advanced search on the API
    • Returns only one defined page of results using one request
  • search_aggregated
    • Accepts a search query string and performs advanced search on the API
    • Returns a list of results aggregated through multiple paginated requests

Class:

class ExpressionSearch(TiCloudAPI)

Methods:

  • search
    • Accepts a list containing the search query and performs expression search on the API
    • Returns only one defined page of results using one request
  • search_aggregated
    • Accepts a list containing the search query and performs expression search on the API
    • Returns a list of results aggregated through multiple paginated requests

Class:

class FileDownload(TiCloudAPI)

Methods:

  • get_download_status
    • Accepts a hash string and returns the sample's availability for download
  • download_sample
    • Accepts a hash string and downloads the related sample from TitaniumCloud

Class:

class URLThreatIntelligence(TiCloudAPI)

Methods:

  • get_url_report
    • Accepts a URL string and returns detailed URL analysis info
  • get_downloaded_files
    • Accepts a URL string and returns a list of files downloaded from that URL
  • get_latest_url_analysis_feed
    • Returns the latest URL analysis reports
    • Returns only one defined page of results using one request
  • get_latest_url_analysis_feed_aggregated
    • Returns the latest URL analysis reports
    • Returns a list of results aggregated through multiple paginated requests
  • get_url_analysis_feed_from_date
    • Accepts time format and a start time and returns URL analysis reports from that defined time onward
    • Returns only one defined page of results using one request
  • get_url_analysis_feed_from_date_aggregated
    • Accepts time format and a start time and returns URL analysis reports from that defined time onward
    • Returns a list of results aggregated through multiple paginated requests

Class:

class AnalyzeURL(TiCloudAPI)

Methods:

  • submit_url
    • Sends a URL string for analysis and returns an analysis task ID

Module: tiscale

A Python module representing the ReversingLabs TitaniumScale malware analysis appliance.

Class:

class TitaniumScale(object)
def __init__(self, host, token, wait_time_seconds=2, retries=10, verify=True, proxies=None, user_agent=DEFAULT_USER_AGENT)

Parameters:

host - TitaniumScale address
token - A1000 user token for the REST API
wait_time_seconds - wait time between each report fetching retry
retries - number of report fetching retries
verify - verify SSL certificate
proxies - optional proxies in use
user_agent - optional user agent string

Methods:

  • upload_sample_from_path
    • Accepts a file path string for file upload and returns a response containing the analysis task URL
  • upload_sample_from_file
    • Accepts a file opened in 'rb' mode for file upload and returns a response containing the analysis task URL
  • get_results
    • Accepts an analysis task URL and returns a file analysis summary or a full analysis report
    • This method utilizes the set number of retries and wait time in seconds to time out if the analysis results are not ready
  • upload_sample_and_get_results
    • Accepts a file path string or an opened file in 'rb' mode for file upload and returns a file analysis summary or a full analysis report
    • This method combines uploading a sample and obtaining the analysis results
    • The result obtaining action of this method utilizes the set number of retries and wait time in seconds to time out if the analysis results are not ready

Examples

A1000

from ReversingLabs.SDK.a1000 import A1000

# Using username and password for authorization
a1000 = A1000(
    host="https://a1000.address",
    username="username",
    password="password",
    verify=True,
    wait_time_seconds=3,
    retries=10
)

response = a1000.upload_sample_and_get_results(
    file_path="/path/to/file.exe",
    retry=True,
    custom_filename="CustomName",
    tags="custom,tags,go,here",
)

json_report = response.json()
from ReversingLabs.SDK.a1000 import A1000

# Using token for authorization
a1000 = A1000(
    host="http://a1000.address",
    token="1js76asmklaslk288japj29s89z",
    verify=False,
    wait_time_seconds=2,
    retries=15
)

response = a1000.get_extracted_files(
    sample_hash="cf23df2207d99a74fbe169e3eba035e633b65d94",
    page_size=30
)

json_report = response.json()

TitaniumCloud

from ReversingLabs.SDK.ticloud import FileReputation, URIStatistics, FileDownload


host = "https://data.reversinglabs.com"
username = "username"
password = "password"
user_agent = "MyCustom App v0.0.1"



file_reputation = FileReputation(
    host=host,
    username=username,
    password=password,
    user_agent=user_agent
)

reputation = file_reputation.get_file_reputation(
    hash_input="cf23df2207d99a74fbe169e3eba035e633b65d94",
    extended_results=True,
    show_hashes_in_results=False
)



uri_statistics = URIStatistics(
    host=host,
    username=username,
    password=password,
    user_agent=user_agent
)

statistics = uri_statistics.get_uri_statistics(
    uri_input="youtube.com"
)



file_download = FileDownload(
    host=host,
    username=username,
    password=password,
    user_agent=user_agent
)

download = file_download.download_sample(
    hash_input="cf23df2207d99a74fbe169e3eba035e633b65d94"
)

with open("/path/to/file", "wb") as file_handle:
    file_handle.write(download.content)

TitaniumScale

from ReversingLabs.SDK.tiscale import TitaniumScale


titanium_scale = TitaniumScale(
    host="https://tiscale.address",
    token="js765akj329786afhg",
    verify=True,
    wait_time_seconds=5,
    retries=6
)

results = titanium_scale.upload_sample_and_get_results(
    file_source=open("/path/to/file.exe", "rb"),
    full_report=True
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reversinglabs-sdk-py2-1.0.1.tar.gz (66.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reversinglabs_sdk_py2-1.0.1-py2-none-any.whl (23.8 kB view details)

Uploaded Python 2

File details

Details for the file reversinglabs-sdk-py2-1.0.1.tar.gz.

File metadata

  • Download URL: reversinglabs-sdk-py2-1.0.1.tar.gz
  • Upload date:
  • Size: 66.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.18

File hashes

Hashes for reversinglabs-sdk-py2-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b7c2a599e4418c2eed4c09fe45a5634bdda1add3a64dd38b38d9711cba266ef6
MD5 a2a07c8b6d72aafe51bf5b496f5cd6cd
BLAKE2b-256 951f1541c5de8efc4af5f084315510bdab8407eeb70f3859edce6ec61804dd19

See more details on using hashes here.

File details

Details for the file reversinglabs_sdk_py2-1.0.1-py2-none-any.whl.

File metadata

  • Download URL: reversinglabs_sdk_py2-1.0.1-py2-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.18

File hashes

Hashes for reversinglabs_sdk_py2-1.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 f99d499f211f71f1f8a74409ba599f55b5d683d1896e53140ca21c081dae05aa
MD5 37e77794720c45522f57075b10961a5f
BLAKE2b-256 45ee23a45ebdf9f411eba6a6f2cd775d5d9bd959e94e1b31ebe8be979727e10c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page