From 92215e06a5a5f76b636c4bc2e81465c81035fa58 Mon Sep 17 00:00:00 2001 From: Mery-Sanz Date: Fri, 10 Jan 2025 10:39:31 +0000 Subject: [PATCH] Add new tools with @lidia9 and @luijait2 --- cai/tools/reconnaissance/filesystem.py | 9 +++++ .../reconnaissance/generic_linux_command.py | 1 + cai/tools/reconnaissance/netcat.py | 35 +++++++++++++++++++ cai/tools/reconnaissance/nmap.py | 18 ++++++++++ 4 files changed, 63 insertions(+) create mode 100644 cai/tools/reconnaissance/generic_linux_command.py create mode 100644 cai/tools/reconnaissance/netcat.py create mode 100644 cai/tools/reconnaissance/nmap.py diff --git a/cai/tools/reconnaissance/filesystem.py b/cai/tools/reconnaissance/filesystem.py index bb45931a..f904f8fe 100644 --- a/cai/tools/reconnaissance/filesystem.py +++ b/cai/tools/reconnaissance/filesystem.py @@ -33,3 +33,12 @@ def cat_file(file_path: str, args: str = "", ctf=None) -> str: """ command = f'cat {args} {file_path} ' return run_command(command, ctf=ctf) + +#FileSearchTool +#ListDirTool +#TextSearchTool +#FileAnalysisTool +#StringExtractionTool +#ReadFileTool +#FilePermissionsTool +#FileCompressionTool diff --git a/cai/tools/reconnaissance/generic_linux_command.py b/cai/tools/reconnaissance/generic_linux_command.py new file mode 100644 index 00000000..d70cf272 --- /dev/null +++ b/cai/tools/reconnaissance/generic_linux_command.py @@ -0,0 +1 @@ +#GenericLinuxCommandTool \ No newline at end of file diff --git a/cai/tools/reconnaissance/netcat.py b/cai/tools/reconnaissance/netcat.py new file mode 100644 index 00000000..68d393ea --- /dev/null +++ b/cai/tools/reconnaissance/netcat.py @@ -0,0 +1,35 @@ +from cai.tools.common import run_command +""" +Here are the netcat tools. +""" +def netcat(args: str, host: str, port: int, data: str = '', ctf=None) -> str: + """ + A simple netcat tool to connect to a specified host and port. + Args: + args: Additional arguments to pass to the netcat command + host: The target host to connect to + port: The target port to connect to + data: Data to send to the host (optional) + + Returns: + str: The output of running the netcat command + """ + if data: + command = f'echo "{data}" | nc -w 3 {host} {port} {args}' + else: + command = f'nc -w 3 {host} {port} {args}' + return run_command(command, ctf=ctf) + +def nmap(args: str, target: str, ctf=None) -> str: + """ + A simple nmap tool to scan a specified target. + + Args: + args: Additional arguments to pass to the nmap command + target: The target host or IP address to scan + + Returns: + str: The output of running the nmap command + """ + command = f'nmap {args} {target}' + return run_command(command, ctf=ctf) \ No newline at end of file diff --git a/cai/tools/reconnaissance/nmap.py b/cai/tools/reconnaissance/nmap.py new file mode 100644 index 00000000..94c4514d --- /dev/null +++ b/cai/tools/reconnaissance/nmap.py @@ -0,0 +1,18 @@ +from cai.tools.common import run_command +""" +Here are the nmap tools. +""" +def nmap(args: str, target: str, ctf=None) -> str: + """ + A simple nmap tool to scan a specified target. + + Args: + args: Additional arguments to pass to the nmap command + target: The target host or IP address to scan + + Returns: + str: The output of running the nmap command + """ + command = f'nmap {args} {target}' + return run_command(command, ctf=ctf) +