Spaces:
Runtime error
Runtime error
File size: 4,261 Bytes
3e2bf63 0d4024a 252b40c 3e2bf63 252b40c 9320ddd 0b89350 826aac3 0d4024a 5061d39 f1d068a 8b2adc4 23b379c 0d4024a f1d068a 252b40c 0d4024a 3e2bf63 6de4240 3e2bf63 0d4024a 6de4240 0d4024a f1d068a 0d4024a 9320ddd 8b2adc4 0d4024a 4d96490 0d4024a 3e2bf63 6de4240 3e2bf63 252b40c e30962b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
from pathlib import Path
from typing import NamedTuple
import gradio as gr
import gradio.themes as gr_themes
import markdown
from tdagent.tools.get_domain_information import (
dns_enumeration_tool,
extractor_of_ioc_from_threatfox_tool,
geo_location_tool,
scrap_subdomains_tool,
)
from tdagent.tools.get_url_content import gr_make_http_request
from tdagent.tools.internal_company_user_search import gr_internal_company
from tdagent.tools.lookup_company_cloud_account_information import (
gr_lookup_company_cloud_account_information,
)
from tdagent.tools.query_abuse_ip_db import gr_query_abuseipdb
from tdagent.tools.rdap import gr_query_rdap
from tdagent.tools.retrieve_from_mitre_attack import gr_get_stix_of_attack_id
from tdagent.tools.send_email import gr_send_email
from tdagent.tools.virus_total import gr_virus_total_url_info
# from tdagent.tools.whois import gr_query_whois
## Tools to load into the application interface ##
def _read_markdown_body_as_html(path: str = "README.md") -> str:
with Path(path).open(encoding="utf-8") as f: # Default mode is "r"
lines = f.readlines()
# Skip YAML front matter if present
if lines and lines[0].strip() == "---":
for i in range(1, len(lines)):
if lines[i].strip() == "---":
lines = lines[i + 1:] # skip metadata block
break
markdown_body = "".join(lines).strip()
return markdown.markdown(markdown_body)
class ToolInfo(NamedTuple):
"""Gradio MCP tool info."""
name: str
interface: gr.Interface
TOOLS = (
ToolInfo("Make an HTTP request to a URL with specified method and parameters", gr_make_http_request),
ToolInfo("Query AbuseIPDB", gr_query_abuseipdb),
# Whois does not work from Spaces (port 43 blocked)
# ToolInfo("Query WHOIS", gr_query_whois),
ToolInfo("Query RDAP", gr_query_rdap),
ToolInfo("Virus Total URL info", gr_virus_total_url_info),
ToolInfo("Get IP's Location", geo_location_tool),
ToolInfo("DNS Enumerator", dns_enumeration_tool),
ToolInfo("Subdomain Retriever", scrap_subdomains_tool),
ToolInfo("Extractor of IoCs", extractor_of_ioc_from_threatfox_tool),
ToolInfo("ATT&CK STIX information", gr_get_stix_of_attack_id),
## Fake tools
ToolInfo("Fake company directory", gr_internal_company),
ToolInfo(
"Fake company cloud accounts",
gr_lookup_company_cloud_account_information,
),
ToolInfo("Send email", gr_send_email),
)
## Application Interface ##
custom_css = """
.main-header {
background: linear-gradient(135deg, #00a388 0%, #ffae00 100%);
padding: 30px;
border-radius: 5px;
margin-bottom: 20px;
text-align: center;
}
"""
with (
gr.Blocks(
theme=gr_themes.Origin(
primary_hue="teal",
spacing_size="sm",
font="sans-serif",
),
title="TDAgent",
fill_height=True,
fill_width=True,
css=custom_css,
) as gr_app,
):
gr.HTML(
"""
<div class="main-header">
<h1>π©βπ» TDAgentTools & TDAgent π¨βπ»</h1>
<p style="font-size: 1.2em; margin: 10px 0 0 0;">
Empowering Cybersecurity with Agentic AI
</p>
</div>
""",
)
with gr.Tabs():
with gr.TabItem("About"):
html_content = _read_markdown_body_as_html("README.md")
gr.Markdown(html_content)
with gr.TabItem("TDAgentTools"):
gr.TabbedInterface(
interface_list=[t_info.interface for t_info in TOOLS],
tab_names=[t_info.name for t_info in TOOLS],
title="TDAgentTools",
)
with gr.TabItem("Demo"):
gr.Markdown(
"""
This is a demo of TDAgentTools, a simple MCP server.
Be carefull with using well-known urls for malware distribution
when using the url content extractor tool.
""",
)
gr.HTML(
"""<iframe width="560" height="315" src="https://youtube.com/embed/c7Yg_jOD6J0" frameborder="0" allowfullscreen></iframe>""",
# noqa: E501
)
if __name__ == "__main__":
gr_app.launch(mcp_server=True)
|