RPISEC Malware Lab#01 をやった その2

RPISEC/Malwareとはマルウェア解析について体系的に学ぶことができる教材のこと。 今回はその中のLab_01-2.malwareを解析した。

Lab_01-2.malware

1. これのMD5ハッシュ値は何?

02658bc9801f98dfdf167accf57f6a36

2. インポートされた関数やそれらのまとまりをいくつか取り上げてマルウェアでどのように使われているか説明せよ

  1. ネットワーク関連(特にHTTP)のAPI - HTTPでファイルか何かをやりとりしている予想される
  2. ファイルを読み書きするAPI - ファイルを読み込んだり書き換えたりしていると予想される
  3. Sleep - 一定時間実行を遅らせることで解析を妨害していると予想される

3. ファイルの文字列で手がかりになりそうなものはどれか

  1. cmd /c - コマンドを実行する
  2. wuauclt.exe - 実行されるファイル名
  3. 69.25.50.10 - 接続先

4. このマルウェアを動かした時に予想される挙動はどのようなものか

ネットワーク越しにファイル(おそらくマルウェア)をダウンロードしサービスとして登録する

5. procmonでフィルタをかける際に使う名前とそれを使う理由

実行時のプロセス名。プロセスの挙動を追うため。

6. ホストベースのシグネチャとなりそうなものは何か(ファイルやレジストリキー、プロセスやらサービス、その他)。もしも存在していたらどのようなものか

wuauclt.exe use error! putf [transpeed] [filepath] 他にも文字列を見ているとコマンドを受け取り実行しそうな感じがする。 stringsで見ただけなのであくまで予想。

7. ネットワークベースのシグネチャとなりそうなものは何か(URL, 通信, その他)。もしも存在していたらどのようなものか

69.25.50.10

8. 解析を妨害する機能は存在するか。存在していた場合、どのようにそれを回避するか

sleep これを回避する方法 * sleep に飛ぶ命令をnopで潰す * 実行時にsleep命令を書き換えるを変更する * 実行時に時間計測系APIへの戻り値を書き換える

9. このマルウェアの目的は何か

ネットワークから他のマルウェアをダウンロードしサービスとして登録する

参考

Practical Malware Analysis

RPISEC Malware Lab#01 をやった

RPISEC Malware Lab#01 をやった

RPISEC/Malwareとはマルウェア解析について体系的に学ぶことができる教材のこと。 今回はその中のLab_01-1.malwareを解析した。

Lab_01-1.malware

1. このファイルはいつコンパイルされたか答えよ

コンパイル時間を確認するときはPEviewを利用する。 f:id:famasoon:20190115234151p:plain 画像のようにPEviewにファイルを読み込ませたあとIMAGE_NT_HEADERS->IMAGE_FILE_HEADER->TimeDataStampを確認する。 ここにはコンパイルされた時間が格納されている。 2009/05/14 Thu 17:12:41 UTCコンパイルされた時間だ。

2. インポートされた関数やそれらのまとまりをいくつか取り上げてマルウェアでどのように使われているか説明せよ

インポートされた関数を確認してみる。 CFF Explorer でLab01_01-1.malware を開く。 次に画面左のImport Directory を選ぶ。 下の画像のようにインポートに使われているdllが一覧表示される。 f:id:famasoon:20190115234244p:plain あとは気になるdllをクリックするだけで、そのdllからインポートされている関数を確認することができる。 回答としては下のようになる。

  1. SHELL32.dllからインポートされている"ShellExecuteExA" - プロセスを起動させる
  2. ソケット関連のAPI - ネットワーク通信をする際に用いられる。
  3. ファイル関連のAPI - ファイルを読みこんだり書き換えたりする。マルウェアをディスクに書き込むときに使われたりする。

3. ファイルの文字列で手がかりになりそうなものはどれか

PowerShell上でstringsコマンドを実行しファイル内の文字列を確認する。 f:id:famasoon:20190115234325p:plain (本当はfileinsightでstringsスクリプトを実行して文字列を抽出しようと思っていたが、なぜか動かなかった。あとで原因を調べる) 結果としては以下の文字列が気になった

  1. http://www.ueopen.com/test.html - 通信先っぽい
  2. 60.248.52.95:443 - 同様に通信先っぽい
  3. cmd.exe - コマンドを実行しそう

他には

*(SY)# cmd
*(SY)#
send = %d
*(SY)#
cmd.exe
exit
Open
 > nul
/c del

といった文字列が気になった。 何かしら受け取ったコマンドを実行しそう。

4. このマルウェアを動かした時に予想される挙動はどのようなものか

問2の回答より、インポートされたAPIから察するにネットワーク通信をしファイルを書き込みマルウェアを実行させる。 通信先は問3の回答で抽出した通信先と予想。

5. procmonでフィルタをかける際に使う名前とそれを使う理由

procmonとはプロセスのイベントを取得しログとして残してくれるツールのこと。 ログを取得する際にフィルタを利用することで特定のイベント/プロセスについて情報を抽出できる。 今回はプロセスの名前を使うと適切だと考えられる。 理由としてはマルウェアの挙動を追うにはプロセス単位で見たほうが効率的だから。

6. ホストベースのシグネチャとなりそうなものは何か(ファイルやレジストリキー、プロセスやらサービス、その他)。もしも存在していたらどのようなものか

抽出した文字列から考えるに cmd.exe /c del でファイル削除をしそう。

7. ネットワークベースのシグネチャとなりそうなものは何か(URL, 通信, その他)。もしも存在していたらどのようなものか

抽出した文字列から下記のURLとIPアドレスがネットワークベースのシグネチャになりそう * http://www.ueopen.com/test.html * 60.248.52.95:443

8. 解析を妨害する機能は存在するか。存在していた場合、どのようにそれを回避するか

このファイルは自身を削除することで解析を妨害してくる。 回避するには2つ手段が存在する。 1. ファイルをコピーして保存しておく 2. ファイルを削除する箇所の命令を無効化しておく

9. このマルウェアの目的は何か

抽出した文字列からネットワーク越しに何かしらのコマンドを実行する。 いわゆるバックドアだと考えられる。

参考

Practical Malware Analysis

minikube で OpenFaas を使う

minikube で OpenFaas を使う

kubernetes 環境で OpenFaas を使いたくなった。 今回はローカルで試すためにも minikube を用いて OpenFaas をインストールする。

必要なもの

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
sudo cp minikube /usr/local/bin && rm minikube

インストールしたら下記コマンドで起動しておく

minikube start
  • faas-cli OpenFaasをCLIから操作するために使うツール。
curl -sSL https://cli.openfaas.com | sudo sh
  • helm k8sのパッケージ管理ツール。
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
kubectl -n kube-system create sa tiller \
 && kubectl create clusterrolebinding tiller \
      --clusterrole cluster-admin \
      --serviceaccount=kube-system:tiller

minikube 上にOpenFaas をインストール

公式のドキュメントを参考に構築する。 まずはk8s名前空間yamlから作成する。

kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml

次にhelmのチャートを追加する。

helm repo add openfaas https://openfaas.github.io/faas-netes/

今回はお試しでローカル環境に作るので認証機能を切って展開する。

helm repo update \
 && helm upgrade openfaas --install openfaas/openfaas \
    --namespace openfaas  \
    --set basic_auth=false \
    --set functionNamespace=openfaas-fn

minikube 上で展開されたか確認。

minikube service list

gateway-external にアクセスすればOpenFaasのダッシュボードを確認することができる。

Golang で whois 情報を取得する

Golangwhois 情報を取得したい時は
github.com
これを使うと便利。
シンプルにwhois情報を呼び出せる上に軽いパーサも付いている。

下記コマンドでインストール。

go get github.com/undiabler/golang-whois

インストール後は下記のようなコードで whois 情報を取得できる。

package main

import (
	"fmt"
	"github.com/undiabler/golang-whois"
)

func main() {
	result, _ := whois.GetWhois("example.com")
	fmt.Println(result)
}

結果

go run main.go
   Domain Name: EXAMPLE.COM
   Registry Domain ID: 2336799_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.iana.org
   Registrar URL: http://res-dom.iana.org
   Updated Date: 2018-08-14T07:14:12Z
   Creation Date: 1995-08-14T04:00:00Z
   Registry Expiry Date: 2019-08-13T04:00:00Z
   Registrar: RESERVED-Internet Assigned Numbers Authority
   Registrar IANA ID: 376
   Registrar Abuse Contact Email:
   Registrar Abuse Contact Phone:
   Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
   Name Server: A.IANA-SERVERS.NET
   Name Server: B.IANA-SERVERS.NET
   DNSSEC: signedDelegation
   DNSSEC DS Data: 31589 8 1 3490A6806D47F17A34C29E2CE80E8A999FFBE4BE
   DNSSEC DS Data: 31589 8 2 CDE0D742D6998AA554A92D890F8184C698CFAC8A26FA59875A990C03E576343C
   DNSSEC DS Data: 43547 8 1 B6225AB2CC613E0DCA7962BDC2342EA4F1B56083
   DNSSEC DS Data: 43547 8 2 615A64233543F66F44D68933625B17497C89A70E858ED76A2145997EDF96A918
   DNSSEC DS Data: 31406 8 1 189968811E6EBA862DD6C209F75623D8D9ED9142
   DNSSEC DS Data: 31406 8 2 F78CF3344F72137235098ECBBD08947C2C9001C7F6A085A17F518B5D8F6B916D
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2018-10-08T12:18:07Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

今回は触れていないけど whois のパースってすごく大変だよね。
早く RDAP の時代来て欲しい。