csle_attacker.emulation.util package
Submodules
csle_attacker.emulation.util.exploit_util module
- class csle_attacker.emulation.util.exploit_util.ExploitUtil[source]
Bases:
object
Class containing utility functions for the exploit-related functionality to the emulation
- static check_if_rce_exploit_succeeded(user: str, pw: str, source_ip: str, port: int, target_ip: str, proxy_conn) bool [source]
Utility function for checking if a RCE exploit succeeded or not, i.e. if we got shell access
- Parameters
user – the user that should have access
pw – the password
source_ip – the ip of the source node of the attack
port – the port on the target
target_ip – the target ip
proxy_conn – optional proxy connection (jumphost)
- Returns
True if the exploit succeeded, otherwise false
- static cve_2010_0426_helper(s: EmulationEnvState, a: EmulationAttackerAction, machine: EmulationAttackerMachineObservationState, result: EmulationAttackerMachineObservationState) Tuple[EmulationAttackerMachineObservationState, float, bool, Credential, str] [source]
Helper for executing the CVE-2010-0426 privelege_escalation action
- Parameters
s – the current state
a – the CVE-2010-0425 privilege escalation action
- Returns
new_machine_obs, cost, successful, root_credential, service_name
- static cve_2015_1427_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Helper for executing the CVE-2015-1427 exploit action
- Parameters
s – the current state
a – the CVE-2015-1427 exploit action
- Returns
s_prime
- static cve_2015_3306_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Helper for executing the CVE-2015-3306 exploit action
- Parameters
s – the current state
a – the CVE-2015-3306 exploit action
- Returns
s_prime
- static cve_2015_5602_helper(s: EmulationEnvState, a: EmulationAttackerAction, machine: EmulationAttackerMachineObservationState, result: EmulationAttackerMachineObservationState) Tuple[EmulationAttackerMachineObservationState, float, bool, Credential, str] [source]
Helper for executing the CVE-2015-5602 privilege escalation action
- Parameters
s – the current state
a – the CVE-2015-5602 privilege escalation action
- Returns
s_prime, cost, e_succ (flag), credentials, servicename
- static cve_2016_10033_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Helper for executing the CVE-2016-10033 exploit action
- Parameters
s – the current state
a – the CVE-2016-10033 exploit action
- Returns
s_prime
- static dvwa_sql_injection_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Helper for executing the DVWA SQL Injection exploit action
- Parameters
s – the current state
a – the DVWA SQL Injection exploit action
- Returns
s_prime
- static read_dvwa_sql_injection_result(conn, dir: str) str [source]
Reads the result of a DVWA SQL Injection Attack :param conn: connection to use for reading :param dir: the dir to check :return: the read result
- static remove_dvwa_sql_injection_result(conn, dir: str) None [source]
Remove the result of a DVWA SQL Injection Attack :param conn: connection to use for the removal :param dir: the directory where the file is :return: None
csle_attacker.emulation.util.nikto_util module
- class csle_attacker.emulation.util.nikto_util.NiktoUtil[source]
Bases:
object
Class containing utility functions for the nikto-related functionality to the emulation
- static merge_nikto_scan_result_with_state(scan_result: NiktoScanResult, s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Merges a Nikto scan result with an existing observation state
- Parameters
scan_result – the scan result
s – the current state
a – the action just executed
- Returns
s’, reward, done
- static nikto_scan_action_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Helper function for executing a NIKTO web scan action on the emulation. Implements caching.
- Parameters
s – the current env state
a – the Nikto action to execute
emulation_env_config – the emulation env config
- Returns
s’, reward, done
csle_attacker.emulation.util.nmap_util module
- class csle_attacker.emulation.util.nmap_util.NmapUtil[source]
Bases:
object
Class containing utility functions for the nmap-related functionality to the emulation
- static merge_nmap_scan_result_with_state(scan_result: NmapScanResult, s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Merges a NMAP scan result with an existing observation state
- Parameters
scan_result – the scan result
s – the current state
a – the action just executed
- Returns
s’
- static merge_nmap_scan_results(scan_result_1: NmapScanResult, scan_result_2: NmapScanResult) NmapScanResult [source]
Merges two nmap scan results
- Parameters
scan_result_1 – the first result to merge
scan_result_2 – the second result to merge
- Returns
the merged result
- static nmap_pivot_scan_action_helper(s: EmulationEnvState, a: EmulationAttackerAction, partial_result: NmapScanResult) EmulationEnvState [source]
Performs an NMAP pivot scan, utilizing many compromised hosts
- Parameters
s – the curretn state
a – the attacker scan action
partial_result – the initial result before pivoting
- Returns
the new state
- static nmap_scan_action_helper(s: EmulationEnvState, a: EmulationAttackerAction, masscan: bool = False) EmulationEnvState [source]
Helper function for executing a NMAP scan action on the emulation. Implements caching.
- Parameters
s – the current env state
a – the NMAP action to execute
masscan – whether it is a masscan or not
- Returns
s’
- static parse_nmap_scan(file_name: str, emulation_env_config: EmulationEnvConfig, conn=None, dir: str = '') Element [source]
Parses an XML file containing the result of an nmap scan
- Parameters
file_name – name of the file to parse
conn – the SSH connection to use for parsing
dir – the directory to parse the XML file
emulation_env_config – environment config
- Returns
the parsed xml file
csle_attacker.emulation.util.shell_util module
- class csle_attacker.emulation.util.shell_util.ShellUtil[source]
Bases:
object
Class containing utility functions for the shell-related functionality to the emulation
- static execute_service_login_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Executes a service login on the emulation using previously found credentials
- Parameters
s – the current state
a – the action to take
- Returns
s_prime, reward, done
- static execute_ssh_backdoor_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Uses compromised machines with root access to setup SSH backdoor
- Parameters
s – the current state
a – the action to take
- Returns
s_prime
- static install_tools_helper(s: EmulationEnvState, a: EmulationAttackerAction) EmulationEnvState [source]
Uses compromised machines with root access to install tools
- Parameters
s – the current state
a – the action to take
- Returns
s_prime
- static parse_tools_installed_file(file_name: str, emulation_env_config: EmulationEnvConfig) bool [source]
Parses a file containing cached results of a install-tools action
- Parameters
file_name – name of the file to parse
emulation_env_config – environment config
- Returns
boolean: if installed or not