<jupyter_start><jupyter_text>VT Graphs in Jupyter NotebookIn this notebook we will explore how to obtain attributes and relationship for different entities using VirusTotal API v3. Finally we can render all the relationships we have obtained using VTGraph.  Import libraries<jupyter_code>from msticpy.sectools.vtlookupv3 import VTLookupV3

import networkx as nx
import matplotlib.pyplot as plt
import os
import pandas as pd

import nest_asyncio
nest_asyncio.apply()<jupyter_output><empty_output><jupyter_text>Create Lookup instance<jupyter_code># Obtain key from env varaible
vt_key = os.environ["VT_API_KEY"]
# Instanciate vt_lookup object
vt_lookup = VTLookupV3(vt_key)<jupyter_output><empty_output><jupyter_text>Types of DataFramesOur functions will return and accept two different types of DataFrames.- **Attributes DataFrame**: Contains the properties of a entity. It has the columns:    - id    - type    - ..properties- **Relationships DataFrames**: Contains the relationship between two entities, and the type of relationship. It contains the columns:    - source    - target    - source_type    - target_type    - relationship_type<jupyter_code>FILE = 'ed01ebfbc9eb5bbea545af4d01bf5f1071661840480439c6e5babe8e080e41aa'
example_attribute_df = vt_lookup.lookup_ioc(observable=FILE, vt_type='file')
example_attribute_df
example_relationship_df = vt_lookup.lookup_ioc_relationships(
    observable=FILE, 
    vt_type='file', 
    relationship='execution_parents')
example_relationship_df<jupyter_output><empty_output><jupyter_text>Obtaining result for multiple entitiesThe function `lookup_iocs` is able to obtain attributes for all the rows in a DataFrame. If no `observable_column` and `observable_type` parameters are specified, the function will obtain the attributes of all the entities that are in the column `target`, and will obtain their types from the `target_type` column.This function is especially usefull when a user has obtained a set of relationships, and would like to obtain their attributes.<jupyter_code>example_multiple_attribute_df = vt_lookup.lookup_iocs(example_relationship_df)
example_multiple_attribute_df<jupyter_output><empty_output><jupyter_text>Also, if we would like to obtain the relationships for a set of entities, we have the function `lookup_iocs_relationships`. Here also, if no `observable_column` and `observable_type` parameters are specified, the function will obtain the relationships of all the entities that are in the column `target`, and will obtain their types from the `target_type` column.<jupyter_code>example_multiple_relationship_df = vt_lookup.lookup_iocs_relationships(example_relationship_df, 'contacted_domains')
example_multiple_relationship_df<jupyter_output><empty_output><jupyter_text>Integration with VTGraphOnce we have some DataFrames with the relationships, we are able to generate and visualize a VT Graph in our notebook. The function `create_vt_graph` accepts as input a **list of Relationship DataFrames**.<jupyter_code>graph_id = vt_lookup.create_vt_graph(
    relationship_dfs=[example_relationship_df, example_multiple_relationship_df],
    name="My first Jupyter Notebook Graph"
)
graph_id
vt_lookup.render_vt_graph(
    graph_id = graph_id,
    width = 800,
    height = 500
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0593607305936073, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 6.695550351288056, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '530208', 'license': 'MIT', 'n_tokens_mistral': 994, 'n_tokens_neox': 943, 'n_words': 310, 'path': 'docs/notebooks/VTLookupV3.ipynb', 'repo_name': 'deeso/msticpy', 'size': '3285'}