mirror of https://github.com/aliasrobotics/cai.git
Review structure tools with @lidia9
This commit is contained in:
parent
f1559e0bea
commit
131fcc491e
|
|
@ -1,74 +0,0 @@
|
|||
|
||||
|
||||
def pwd_command(path: str, args: str = "") -> str:
|
||||
"""
|
||||
Retrieve the current working directory.
|
||||
|
||||
Returns:
|
||||
str: The absolute path of the current working directory
|
||||
"""
|
||||
global ctf
|
||||
command = f'pwd'
|
||||
return run_ctf(ctf, command)
|
||||
|
||||
def strings_command(args: str, file_path: str) -> str:
|
||||
"""
|
||||
Extract printable strings from a binary file.
|
||||
|
||||
Args:
|
||||
args: Additional arguments to pass to the strings command
|
||||
file_path: Path to the binary file to extract strings from
|
||||
|
||||
Returns:
|
||||
str: The output of running the strings command
|
||||
"""
|
||||
global ctf
|
||||
command = f'strings {file_path} '
|
||||
return run_ctf(ctf, command)
|
||||
|
||||
|
||||
def nmap_command(ip_address: str, args: str = "") -> str:
|
||||
"""
|
||||
Scan a network host for open ports and services.
|
||||
|
||||
Args:
|
||||
ip_address: The IP address or hostname of the target to scan
|
||||
args: Additional arguments to pass to the nmap command
|
||||
|
||||
Returns:
|
||||
str: The output of running the nmap command
|
||||
"""
|
||||
global ctf
|
||||
command = f'nmap {ip_address} {args}'
|
||||
return run_ctf(ctf, command)
|
||||
|
||||
|
||||
def netcat_command(ip_address: str, port: str, args: str = "") -> str:
|
||||
"""
|
||||
Connect to a network host via a specific port.
|
||||
"""
|
||||
global ctf
|
||||
command = f'nc {ip_address} {port} {args}'
|
||||
return run_ctf(ctf, command)
|
||||
|
||||
def decode64(input_data: str, args: str = "") -> str:
|
||||
"""
|
||||
Decode a base64-encoded string.
|
||||
|
||||
Args:
|
||||
input_data: The base64-encoded string to decode
|
||||
args: Additional arguments (not used in this function)
|
||||
|
||||
Returns:
|
||||
str: The decoded string
|
||||
"""
|
||||
import base64
|
||||
try:
|
||||
decoded_bytes = base64.b64decode(input_data)
|
||||
decoded_str = decoded_bytes.decode('utf-8')
|
||||
return decoded_str
|
||||
except Exception as e:
|
||||
print(color(f"Error decoding base64 data: {e}", fg="red"))
|
||||
return f"Error decoding base64 data: {str(e)}"
|
||||
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# URLDecodeTool
|
||||
# HexDumpTool
|
||||
# Base64DecodeTool
|
||||
# ROT13DecodeTool
|
||||
# BinaryAnalysisTool
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# """
|
||||
# Here are crypto tools
|
||||
# """
|
||||
# # import base64
|
||||
# from cai.tools.common import run_command
|
||||
# # URLDecodeTool
|
||||
# # HexDumpTool
|
||||
# # Base64DecodeTool
|
||||
# # ROT13DecodeTool
|
||||
# # BinaryAnalysisTool
|
||||
|
||||
|
||||
# def strings_command(file_path: str, ctf=None) -> str:
|
||||
# """
|
||||
# Extract printable strings from a binary file.
|
||||
|
||||
# Args:
|
||||
# args: Additional arguments to pass to the strings command
|
||||
# file_path: Path to the binary file to extract strings from
|
||||
|
||||
# Returns:
|
||||
# str: The output of running the strings command
|
||||
# """
|
||||
# command = f'strings {file_path} '
|
||||
# return run_command(ctf, command)
|
||||
|
||||
|
||||
# def decode64(input_data: str) -> str:
|
||||
# """
|
||||
# Decode a base64-encoded string.
|
||||
|
||||
# Args:
|
||||
# input_data: The base64-encoded string to decode
|
||||
# args: Additional arguments (not used in this function)
|
||||
|
||||
# Returns:
|
||||
# str: The decoded string
|
||||
# """
|
||||
|
||||
# try:
|
||||
# decoded_bytes = base64.b64decode(input_data)
|
||||
# decoded_str = decoded_bytes.decode('utf-8')
|
||||
# return decoded_str
|
||||
# except UnicodeDecodeError as e:
|
||||
# print(f"Error decoding bytes to string: {e}")
|
||||
# return f"Error decoding bytes to string: {str(e)}"
|
||||
|
|
@ -34,11 +34,22 @@ 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
|
||||
# FileSearchTool
|
||||
# ListDirTool
|
||||
# TextSearchTool
|
||||
# FileAnalysisTool
|
||||
# StringExtractionTool
|
||||
# ReadFileTool
|
||||
# FilePermissionsTool
|
||||
# FileCompressionTool
|
||||
|
||||
|
||||
def pwd_command(ctf=None) -> str:
|
||||
"""
|
||||
Retrieve the current working directory.
|
||||
|
||||
Returns:
|
||||
str: The absolute path of the current working directory
|
||||
"""
|
||||
command = 'pwd'
|
||||
return run_command(command, ctf=ctf)
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
#ProcessListTool
|
||||
#EnvironmentVariablesTool
|
||||
#SystemInformationTool
|
||||
|
|
@ -1 +0,0 @@
|
|||
#GenericLinuxCommandTool
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
from cai.tools.common import run_command
|
||||
"""
|
||||
Here are the netcat tools.
|
||||
Here are the tools for netcat command
|
||||
"""
|
||||
def netcat(args: str, host: str, port: int, data: str = '', ctf=None) -> str:
|
||||
from cai.tools.common import run_command # pylint: disable=import-error
|
||||
|
||||
|
||||
def netcat(host: str, port: int, data: str = '',
|
||||
args: str = '', ctf=None) -> str:
|
||||
"""
|
||||
A simple netcat tool to connect to a specified host and port.
|
||||
Args:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
# ProcessListTool
|
||||
# EnvironmentVariablesTool
|
||||
# SystemInformationTool
|
||||
Loading…
Reference in New Issue