From bb26db3f7f9d68ffffdbd397e7495550af478014 Mon Sep 17 00:00:00 2001 From: Mery-Sanz Date: Fri, 10 Jan 2025 15:53:17 +0000 Subject: [PATCH 1/5] Try to remove blank files --- .../command_and_control/command_and_control.py | 0 .../data_exfiltration/data_exfiltration.py | 0 cai/tools/reconnaissance/curl.py | 18 +++++++++++++++++- .../2_picoctf_reversing_python.py | 8 +++++--- 4 files changed, 22 insertions(+), 4 deletions(-) delete mode 100644 cai/tools/command_and_control/command_and_control.py delete mode 100644 cai/tools/data_exfiltration/data_exfiltration.py diff --git a/cai/tools/command_and_control/command_and_control.py b/cai/tools/command_and_control/command_and_control.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cai/tools/data_exfiltration/data_exfiltration.py b/cai/tools/data_exfiltration/data_exfiltration.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cai/tools/reconnaissance/curl.py b/cai/tools/reconnaissance/curl.py index 0191627f..6ec543af 100644 --- a/cai/tools/reconnaissance/curl.py +++ b/cai/tools/reconnaissance/curl.py @@ -1 +1,17 @@ -#curl \ No newline at end of file +from cai.tools.common import run_command +""" +Here are the curl tools. +""" +def curl(args: str, target: str, ctf=None) -> str: + """ + A simple curl tool to make HTTP requests to a specified target. + + Args: + args: Additional arguments to pass to the curl command + target: The target URL to request + + Returns: + str: The output of running the curl command + """ + command = f'curl {args} {target}' + return run_command(command, ctf=ctf) \ No newline at end of file diff --git a/examples/cybersecurity/2_picoctf_reversing_python.py b/examples/cybersecurity/2_picoctf_reversing_python.py index d6ea4f59..6dbb968e 100644 --- a/examples/cybersecurity/2_picoctf_reversing_python.py +++ b/examples/cybersecurity/2_picoctf_reversing_python.py @@ -13,16 +13,16 @@ import os # 2. Init the CTF environment ctf = ptt.ctf( "picoctf_reversing_python", - subnet="192.168.9.0/24", + subnet="192.168.2.0/24", container_name="ancient", - ip_address="192.168.9.52" + ip_address="192.168.2.52" ) ctf.start_ctf() challenges = list(ctf.get_challenges().keys()) challenge = challenges[0] # 3. Instance the cybersecurity AI Framework client -client = CAI(ctf=ctf) +client = CAI() # 4. Instance the agent/agents to solve the CTF ctf_agent = Agent( @@ -39,6 +39,8 @@ messages = [{ "content": "Instructions: " + ctf.get_instructions() + "\nChallenge: " + ctf.get_challenges()[challenge] + "\nTechniques: " + ctf.get_techniques() + + "\nTarget IP: " + ctf.get_ip() + + "\nTarget Port: 5555" "\nExtract and return only the flag" "\nYOU MUST RETURN THE FLAG IN PLAIN TEXT" }] From 45dcabeb1345ec357d6369c4277b0d55338beaaf Mon Sep 17 00:00:00 2001 From: Mery-Sanz Date: Fri, 10 Jan 2025 16:01:54 +0000 Subject: [PATCH 2/5] Organize tools and blank files @lidia9 --- .../ftp_upload.py => command_and_control/.gitkeep} | 0 .../script_execution.py => data_exfiltration/.gitkeep} | 0 cai/tools/exploitation/{metasploit.py => .gitkeep} | 0 cai/tools/lateral_movement/{ssh.py => .gitkeep} | 0 cai/tools/lateral_movement/reverse_shell.py | 6 ------ cai/tools/others/{others.py => .gitkeep} | 0 cai/tools/privilege_scalation/{file.py => gitkeep} | 0 cai/tools/reconnaissance/dirb_scan.py | 1 - cai/tools/reconnaissance/gobuster_scan.py | 0 cai/tools/reconnaissance/hashcat_cracker.py | 0 cai/tools/reconnaissance/system_info.py | 3 --- 11 files changed, 10 deletions(-) rename cai/tools/{exploitation/ftp_upload.py => command_and_control/.gitkeep} (100%) rename cai/tools/{exploitation/script_execution.py => data_exfiltration/.gitkeep} (100%) rename cai/tools/exploitation/{metasploit.py => .gitkeep} (100%) rename cai/tools/lateral_movement/{ssh.py => .gitkeep} (100%) delete mode 100644 cai/tools/lateral_movement/reverse_shell.py rename cai/tools/others/{others.py => .gitkeep} (100%) rename cai/tools/privilege_scalation/{file.py => gitkeep} (100%) delete mode 100644 cai/tools/reconnaissance/dirb_scan.py delete mode 100644 cai/tools/reconnaissance/gobuster_scan.py delete mode 100644 cai/tools/reconnaissance/hashcat_cracker.py delete mode 100644 cai/tools/reconnaissance/system_info.py diff --git a/cai/tools/exploitation/ftp_upload.py b/cai/tools/command_and_control/.gitkeep similarity index 100% rename from cai/tools/exploitation/ftp_upload.py rename to cai/tools/command_and_control/.gitkeep diff --git a/cai/tools/exploitation/script_execution.py b/cai/tools/data_exfiltration/.gitkeep similarity index 100% rename from cai/tools/exploitation/script_execution.py rename to cai/tools/data_exfiltration/.gitkeep diff --git a/cai/tools/exploitation/metasploit.py b/cai/tools/exploitation/.gitkeep similarity index 100% rename from cai/tools/exploitation/metasploit.py rename to cai/tools/exploitation/.gitkeep diff --git a/cai/tools/lateral_movement/ssh.py b/cai/tools/lateral_movement/.gitkeep similarity index 100% rename from cai/tools/lateral_movement/ssh.py rename to cai/tools/lateral_movement/.gitkeep diff --git a/cai/tools/lateral_movement/reverse_shell.py b/cai/tools/lateral_movement/reverse_shell.py deleted file mode 100644 index 24c3474e..00000000 --- a/cai/tools/lateral_movement/reverse_shell.py +++ /dev/null @@ -1,6 +0,0 @@ -# ReverseShellTool -# ReverseShellSession -# ReverseShellManager -# ShellCommandExecutor -# SessionManager -# UploadReverseShellTool diff --git a/cai/tools/others/others.py b/cai/tools/others/.gitkeep similarity index 100% rename from cai/tools/others/others.py rename to cai/tools/others/.gitkeep diff --git a/cai/tools/privilege_scalation/file.py b/cai/tools/privilege_scalation/gitkeep similarity index 100% rename from cai/tools/privilege_scalation/file.py rename to cai/tools/privilege_scalation/gitkeep diff --git a/cai/tools/reconnaissance/dirb_scan.py b/cai/tools/reconnaissance/dirb_scan.py deleted file mode 100644 index 5292a4cd..00000000 --- a/cai/tools/reconnaissance/dirb_scan.py +++ /dev/null @@ -1 +0,0 @@ -# DirbScanTool diff --git a/cai/tools/reconnaissance/gobuster_scan.py b/cai/tools/reconnaissance/gobuster_scan.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cai/tools/reconnaissance/hashcat_cracker.py b/cai/tools/reconnaissance/hashcat_cracker.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cai/tools/reconnaissance/system_info.py b/cai/tools/reconnaissance/system_info.py deleted file mode 100644 index be418115..00000000 --- a/cai/tools/reconnaissance/system_info.py +++ /dev/null @@ -1,3 +0,0 @@ -# ProcessListTool -# EnvironmentVariablesTool -# SystemInformationTool From d92d8519efad09aab0cb15d56ebf749834d5a805 Mon Sep 17 00:00:00 2001 From: Mery-Sanz Date: Fri, 10 Jan 2025 16:08:41 +0000 Subject: [PATCH 3/5] add generic linux command tool --- .../reconnaissance/generic_linux_command.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cai/tools/reconnaissance/generic_linux_command.py b/cai/tools/reconnaissance/generic_linux_command.py index e69de29b..27de5856 100644 --- a/cai/tools/reconnaissance/generic_linux_command.py +++ b/cai/tools/reconnaissance/generic_linux_command.py @@ -0,0 +1,19 @@ +""" +This is used to create a generic linux command. +""" +from cai.tools.common import run_command # pylint: disable=import-error + + +def generic_linux_command(command: str = "", args: str = "", ctf=None) -> str: + """ + A simple tool to do a linux command. + + Args: + command: The name of the command + args: Additional arguments to pass to the command + + Returns: + str: The output of running the linux command + """ + command = f'{command} {args}' + return run_command(command, ctf=ctf) From 2ba488d1e40f032eb50333d3c75f7443753c9bf8 Mon Sep 17 00:00:00 2001 From: Mery-Sanz Date: Fri, 10 Jan 2025 16:10:40 +0000 Subject: [PATCH 4/5] add curl tool --- cai/tools/reconnaissance/curl.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cai/tools/reconnaissance/curl.py b/cai/tools/reconnaissance/curl.py index 6ec543af..08928e66 100644 --- a/cai/tools/reconnaissance/curl.py +++ b/cai/tools/reconnaissance/curl.py @@ -1,11 +1,13 @@ -from cai.tools.common import run_command """ Here are the curl tools. """ -def curl(args: str, target: str, ctf=None) -> str: +from cai.tools.common import run_command # pylint: disable=import-error + + +def curl(args: str = "", target: str = "", ctf=None) -> str: """ A simple curl tool to make HTTP requests to a specified target. - + Args: args: Additional arguments to pass to the curl command target: The target URL to request @@ -14,4 +16,4 @@ def curl(args: str, target: str, ctf=None) -> str: str: The output of running the curl command """ command = f'curl {args} {target}' - return run_command(command, ctf=ctf) \ No newline at end of file + return run_command(command, ctf=ctf) From 8eb4d90a5009f5d245de971e2f1fbb2d3e65e21d Mon Sep 17 00:00:00 2001 From: lidia9 Date: Fri, 10 Jan 2025 16:13:09 +0000 Subject: [PATCH 5/5] new tools netstat wget -- typo in curl --- cai/tools/reconnaissance/netstat.py | 18 +++++++++++++++++- cai/tools/reconnaissance/wget.py | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/cai/tools/reconnaissance/netstat.py b/cai/tools/reconnaissance/netstat.py index 86fd2910..44d7ae09 100644 --- a/cai/tools/reconnaissance/netstat.py +++ b/cai/tools/reconnaissance/netstat.py @@ -1 +1,17 @@ -#NetworkConnectionstool in exploitFlow \ No newline at end of file +# NetworkConnectionstool in exploitFlow +""" +Netstat tool +""" +from cai.tools.common import run_command # pylint: disable=import-error + + +def netstat(args: str = '', ctf=None) -> str: + """ + netstat tool to list all listening ports and their associated programs. + Args: + args: Additional arguments to pass to the netstat command + Returns: + str: The output of running the netstat command + """ + command = f'netstat -tuln {args}' + return run_command(command, ctf=ctf) diff --git a/cai/tools/reconnaissance/wget.py b/cai/tools/reconnaissance/wget.py index 11529ece..b47ada0a 100644 --- a/cai/tools/reconnaissance/wget.py +++ b/cai/tools/reconnaissance/wget.py @@ -1 +1,19 @@ -#FileDownloadTool in exploitFlow \ No newline at end of file +#FileDownloadTool in exploitFlow + +""" +Wget tool +""" +from cai.tools.common import run_command # pylint: disable=import-error + +def wget(url: str, args: str = '', ctf=None) -> str: + """ + Wget tool to download files from the web. + Args: + url: The URL of the file to download + args: Additional arguments to pass to the wget command + + Returns: + str: The output of running the wget command + """ + command = f'wget {args} {url}' + return run_command(command, ctf=ctf) \ No newline at end of file