msticpy.context.vtlookupv3.vtlookupv3 module
VirusTotal v3 API.
- class msticpy.context.vtlookupv3.vtlookupv3.ColumnNames(value)
Bases:
Enum
Column name enum for DataFrame output.
- DETECTIONS = 'detections'
- ID = 'id'
- RELATIONSHIP_TYPE = 'relationship_type'
- SCANS = 'scans'
- SOURCE = 'source'
- SOURCE_TYPE = 'source_type'
- TARGET = 'target'
- TARGET_TYPE = 'target_type'
- TYPE = 'type'
- exception msticpy.context.vtlookupv3.vtlookupv3.MsticpyVTGraphSaveGraphError
Bases:
Exception
Could not save VT Graph.
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception msticpy.context.vtlookupv3.vtlookupv3.MsticpyVTNoDataError
Bases:
Exception
No data returned from VT API.
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class msticpy.context.vtlookupv3.vtlookupv3.VTEntityType(value)
Bases:
Enum
VTEntityType: Enum class for VirusTotal entity types.
- DOMAIN = 'domain'
- FILE = 'file'
- IP_ADDRESS = 'ip_address'
- URL = 'url'
- class msticpy.context.vtlookupv3.vtlookupv3.VTLookupV3(vt_key: Optional[str] = None)
Bases:
object
VTLookupV3: VirusTotal lookup of IoC reports.
Create a new instance of VTLookupV3 class.
- Parameters
vt_key (str, optional) – VirusTotal API key, if not supplied, this is read from user configuration.
- create_vt_graph(relationship_dfs: List[DataFrame], name: str, private: bool) str
Create a VirusTotal Graph with a set of Relationship DataFrames.
- Parameters
relationship_dfs – List of Relationship DataFrames
name – New graph name
private – Indicates if the Graph is private or not.
- Return type
Graph ID
- Raises
ValueError when private is not indicated. –
ValueError when there are no relationship DataFrames –
MsticpyVTGraphSaveGraphError when Graph can not be saved –
- get_file_behavior(file_id: Optional[str] = None, file_summary: Optional[Dict[str, Any]] = None, sandbox: Optional[str] = None) VTFileBehavior
Return a VTFileBehavior object with file detonation results.
- Parameters
file_id (Optional[str], optional) – The ID of the file to look up, by default None
file_summary (Optional[Dict[str, Any]], optional) – VT file summary object dictionary, by default None
sandbox (str, optional) – Name of specific sandbox to retrieve, by default None If None, it will retrieve the behavior summary.
- Return type
- get_object(vt_id: str, vt_type: str) DataFrame
Return the full VT object as a DataFrame.
- Parameters
- Returns
Single column DataFrame with attribute names as index and values as data column.
- Return type
pd.DataFrame
- Raises
KeyError – Unrecognized VT Type
MsticpyVTNoDataError – Error requesting data from VT.
Notes
This calls the underlying VT get_object API directly and returns all attributes for the object - hence a very wide DataFrame.
- lookup_ioc(observable: str, vt_type: str, all_props: bool = False) DataFrame
Look up and single IoC observable.
Look single IoC observable related items.
- Parameters
- Returns
Any objects with specified relationship to the entity
- Return type
pd.DataFrame
Notes
This method returns full related objects rather than ID links. It is less efficient than looking up ID links only.
See also
lookup_ioc_relationships
return the related IDs.
- lookup_ioc_relationships(observable: str, vt_type: str, relationship: str, limit: Optional[int] = None, all_props: bool = False) DataFrame
Look up single IoC observable relationship links.
- Parameters
- Return type
Relationship Pandas DataFrame with the relationships of the entity
Notes
This method returns relationship links rather than whole objects. That is, it will return the IDs of related items in the specified relationship, if any.
See also
lookup_ioc_related
return the full related objects.
- lookup_iocs(observables_df: DataFrame, observable_column: str = 'target', observable_type_column: str = 'target_type', all_props: bool = False)
Look up and multiple IoC observables.
- Parameters
observables_df (pd.DataFrame) – A Pandas DataFrame, where each row is an observable
observable_column – ID column of each observable
observable_type_column – Type column of each observable
all_props (bool, optional) – If True, return all properties, by default False
- Return type
Attributes Pandas DataFrame with the properties of the entities
- lookup_iocs_relationships(observables_df: DataFrame, relationship: str, observable_column: str = 'target', observable_type_column: str = 'target_type', limit: Optional[int] = None, all_props: bool = False) DataFrame
Look up and single IoC observable relationships.
- Parameters
observables_df (pd.DataFrame) – A Pandas DataFrame, where each row is an observable
relationship (str) – Desired relationship
observable_column – ID column of each observable
observable_type_column – Type column of each observable.
limit (int) – Relations limit
all_props (bool, optional) – If True, return all properties, by default False
- Return type
Relationship Pandas DataFrame with the relationships of each observable.
- static relationships_to_graph(relationship_dfs: List[DataFrame]) Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]
Generate nodes and edges from relationships.
- Parameters
relationship_dfs (List[pd.DataFrame]) – List of relationship DataFrames
- Returns
List of nodes (node_id, node_type) List of edges (source_node, target_node, connection_type)
- Return type
- Raises
ValueError – If an empty list is supplied.