はまやんはまやんはまやん

hamayanhamayan's blog

Hack The Box Sherlocks - Litter Writeup

https://app.hackthebox.com/sherlocks/Litter
Hack The Box Sherlocksとは

Sherlock Scenario

Khalid has just logged onto a host that he and his team use as a testing host for many different purposes, it’s off their corporate network but has access to lots of resources in network. The host is used as a dumping ground for a lot of people at the company but it’s very useful, so no one has raised any issues. Little does Khalid know; the machine has been compromised and company information that should not have been on there has now been stolen – it’s up to you to figure out what has happened and what data has been taken.
Khalid は、彼と彼のチームがさまざまな目的でテスト ホストとして使用しているホストにログオンしました。このホストは企業ネットワークから離れていますが、ネットワーク内の多くのリソースにアクセスできます。ホストは会社の多くの人たちのゴミ捨て場として使用されていますが、非常に便利なので、誰も問題を提起していません。ハリドはほとんど知りません。マシンが侵害され、そこにあるはずのない企業情報が盗まれています。何が起こったのか、どのデータが盗まれたのかを解明するのはあなた次第です。

パケットキャプチャ suspicious_traffic.pcap が与えられるので、解析して設問に答える。

Tasks

Task 1

At a glance, what protocol seems to be suspect in this attack?
一見すると、この攻撃ではどのプロトコルが疑わしいと思われますか?

pcapのプロトコル階層統計を見てみるとDNSが異常に多いことが見て取れる。

Task 2

There seems to be a lot of traffic between our host and another, what is the IP address of the suspect host?
私たちのホストと別のホストの間に大量のトラフィックがあるようですが、疑わしいホストの IP アドレスは何ですか?

pcapの終端(endpoints)を見て、パケットの量が多いものから順にみていく。最も多いIPアドレスはパケットキャプチャ端末(私たちのホスト)なので2番目に多いものが答え。

Task 3

What is the first command the attacker sends to the client?
攻撃者がクライアントに送信する最初のコマンドは何ですか?

Task 1,2よりdns && ip.addr == 192.168.157.145grepすると、hex stringが多数送られている。全部抜いてきてデコードすると所々読むことができる。上からコマンドっぽいものを見つけてくると答えが出る。

Task 4

What is the version of the DNS tunneling tool the attacker is using?
攻撃者が使用している DNS トンネリング ツールのバージョンは何ですか?

dirコマンドの結果を見るとdnscat2-v0.07-clientというのがある。
これがトンネリングツールだろう。

Task 5

The attackers attempts to rename the tool they accidentally left on the clients host. What do they name it to?
攻撃者は、誤ってクライアント ホスト上に残したツールの名前を変更しようとします。彼らはそれに何という名前を付けていますか?

コマンドを眺めるとren dnscat2-v0.07-client-win32.exe win_installer.exeというのがあった。変名してますね。

Task 6

The attacker attempts to enumerate the users cloud storage. How many files do they locate in their cloud storage directory?
攻撃者は、ユーザーのクラウド ストレージを列挙しようとします。クラウド ストレージ ディレクトリにはファイルがいくつありますか?

OneDriveの中身を見ているが、ファイルはなかった。

 Directory of C:\Us¿ Íuä]LÒÍ]Luäers\test\OneDrive

04/06/2021  08:52    <DIR>          .
04/06/2021  08:52    <DIR>         ÒÍ]Luäers\test\OneDrive

04/06/2021  08:52    <DIR>          .
04/06/2021  08:52    <DIR>         ÉÍuä]«­Í]«uä ..
               0 File(s)              0 bytes
               2 Dir(s)  24,470,171,648 byt­Í]«uä ..
               0 File(s)              0 bytes
               2 Dir(s)  24,470,171,648 bytÍuä^

Task 7

What is the full location of the PII file that was stolen?
盗まれた PII ファイルの完全な場所はどこですか?

適当に目grepすると見つかる。

Task 8

Exactly how many customer PII records were stolen?
正確に何件の顧客 PII 記録が盗まれましたか?

ちゃんと解析する必要がある。

from scapy.all import rdpcap, DNSQR, DNSRR
import struct

# tshark -r suspicious_traffic.pcap -Y 'dns && ip.addr == 192.168.157.145 && frame.len > 96 && ip.dst == 192.168.157.145' -w dns2.pcap
for p in rdpcap('dns2.pcap'):
    if p.haslayer(DNSQR) and not p.haslayer(DNSRR):
        if 'microsofto365' in p[DNSQR].qname.decode():
            qry = p[DNSQR].qname.decode().replace(".microsofto365.com.","").strip()[9*2:].split(".")
            for x in qry:
                y = bytes.fromhex(x)
                print(y)

こんな感じに出すととてもいい感じにパースされてくるので、SSNのフォーマット\d{3}-\d{2}-\d{4}grepすると721件ヒットするのでそれが答え。