nitesh@gupta
Proving Grounds Linux

Law

Full walkthrough — enumeration, foothold and privilege escalation.

Nmap output

Nmap scan report for 192.168.123.190
Host is up (0.056s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 c9:c3:da:15:28:3b:f1:f8:9a:36:df:4d:36:6b:a7:44 (RSA)
|   256 26:03:2b:f6:da:90:1d:1b:ec:8d:8f:8d:1e:7e:3d:6b (ECDSA)
|_  256 fb:43:b2:b0:19:2f:d3:f6:bc:aa:60:67:ab:c1:af:37 (ED25519)
80/tcp open  http    Apache httpd 2.4.56 ((Debian))
|_http-server-header: Apache/2.4.56 (Debian)
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: htmLawed (1.2.5) test
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

We have HTMLAWED 1.2.5 running on port 80

Law walkthrough, Got root, screenshot 1
Law, step 1

Found RCE for this version on exploit-db

https://github.com/cosad3s/CVE-2022-35914-poc.git

Law walkthrough, Got root, screenshot 2
Law, step 2

Tried the exploit but it didn’t worked

Law walkthrough, Got root, screenshot 3
Law, step 3

While directory bruteforcing we found index.php

Law walkthrough, Got root, screenshot 4
Law, step 4

Changed the path in exploit to index.php

Law walkthrough, Got root, screenshot 5
Law, step 5

Ran the exploit and we got code execution

Law walkthrough, Got root, screenshot 6
Law, step 6

Ran the exploit for reverse shell

Law walkthrough, Got root, screenshot 7
Law, step 7

Got reverse shell

Law walkthrough, Got root, screenshot 8
Law, step 8

Ran pspy and we see that root user is running cleanup.sh file

Law walkthrough, Got root, screenshot 9
Law, step 9

We found local.txt in /var/www/ directory

Law walkthrough, Got root, screenshot 10
Law, step 10

Got local.txt (9c3f8bcca5e0dcefeab60c3f12f6e572)

Law walkthrough, Got root, screenshot 11
Law, step 11

www-data user has write permission on this file

Law walkthrough, Got root, screenshot 12
Law, step 12

added “echo 'www-data ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers” in cleanup.sh

Law walkthrough, Got root, screenshot 13
Law, step 13

Got all access

Law walkthrough, Got root, screenshot 14
Law, step 14

Got root

Law walkthrough, Got root, screenshot 15
Law, step 15

Got proof.txt (8ebe057024dc59764e2ec34325808377)

Law walkthrough, Got root, screenshot 16
Law, step 16

More walkthroughs