Privilege Escalate
PrivilegeEscalate
carries out an exploit on a specific host that Red has a user shell on, to gain a shell with root privileges.
Here, we will be privilege escalating the first host that Red knows.
Identify Host with User Shell
In order to run privilege escalation, we must find the target host's name. We do this by looking at Red's initial observation.
Code Output
{'contractor_network_subnet_user_host_4': {'Interface': [{'Subnet': IPv4Network('10.0.96.0/24'),
'interface_name': 'eth0',
'ip_address': IPv4Address('10.0.96.73')}],
'Processes': [{'PID': 5753,
'username': 'ubuntu'}],
'Sessions': [{'PID': 5753,
'Type': <SessionType.RED_ABSTRACT_SESSION: 10>,
'agent': 'red_agent_0',
'session_id': 0,
'timeout': 0,
'username': 'ubuntu'}],
'System info': {'Architecture': <Architecture.x64: 2>,
'Hostname': 'contractor_network_subnet_user_host_4',
'OSDistribution': <OperatingSystemDistribution.KALI: 9>,
'OSType': <OperatingSystemType.LINUX: 3>,
'OSVersion': <OperatingSystemVersion.K2019_4: 11>,
'position': array([0., 0.])},
'User Info': [{'Groups': [{'GID': 0}],
'username': 'root'},
{'Groups': [{'GID': 1}],
'username': 'user'}]},
'success': <TernaryEnum.UNKNOWN: 2>}
The only host Red is currently aware of has a hostname visible in the key contractor_network_subnet_user_host_4
.
We already have a user shell on contractor_network_subnet_user_host_4
- this is shown in Red's initial observations above:
'Sessions': [{'PID': 5753,
'Type': <SessionType.RED_ABSTRACT_SESSION: 10>,
'agent': 'red_agent_0',
'session_id': 0,
'timeout': 0,
'username': 'ubuntu'}],
PrivilegeEscalate
on contractor_network_subnet_user_host_4
.
If we did not have a user shell on the host that we want to perform a privilege escalate on, we would need to do that first.
Privilege Escalate
red_privilege_escalate.py | |
---|---|
Code Output
{'action': PrivilegeEscalate contractor_network_subnet_user_host_4,
'contractor_network_subnet_user_host_4': {'Interface': [{'Subnet': IPv4Network('10.0.96.0/24'),
'ip_address': IPv4Address('10.0.96.73')}],
'Sessions': [{'Type': <SessionType.RED_ABSTRACT_SESSION: 10>,
'agent': 'red_agent_0',
'session_id': 0,
'username': 'root'}],
'System info': {'Hostname': 'contractor_network_subnet_user_host_4'}},
'success': <TernaryEnum.TRUE: 1>}
Comparing the resulting observation to Red's initial observation, the username
in Red's session on contractor_network_subnet_user_host_4
has changed to root
, demonstrating the success of the privilege escalation: