Thursday, December 22, 2011

OWASPジャパンについて僕の意見です。(My Opinion on OWASP Japan)

OWASPジャパンについて僕の意見です。

始めに、念のため言いますが、ローカルチャプター、リーダー会議、カンファレンス等をリードするつもりは全くなくて、だたOWASPの興味を持っている人にOWASPジャパンを始める方法を僕なりに説明したいだけです。

1. ローカルチャプターやリーダー会議やカンファレンスを行いたい人は電話会議か実際に会って会議をする。これは必要と思う。しないと何も動かないかな。

2. 興味を持っている人に役割を与える。もし、複数の人が同じことをやりたかったら選挙を行ったりする。ポジションの名前はわかんないけど、以下のような例がある。

I. OWASP全国リーダー

II. OWASPイベント主催者

III. OWASP担当マネージャー(これはいろいろな国際OWASPメンバーと関わるので英会話がかなり必要)

IV. OWASPチャプターリーダー(市)

V. OWASPチャプター主催者(チャプターリーダーと同じ人でも大丈夫)

VI. OWASPテクニカルリーダー(職務はプレゼン、書類を作るかレビューする)

VII. 他 もっとあるはず。。。

3. リソース(会議室)やOWASPに時間や資金を寄付する余裕がある組織を見つける。

4. もし、問題があったら選挙システムを作る。

個人的に、日本人がトップポジションすべてをこなした方が良いと思います。また、女性がこれらのポジションの一部を保持し、OWASP日本に貢献することが重要だと思います。


My Opinion on OWASP Japan

First, let me be clear that I do not want to run any local chapters, leader meetings or conferences. The point of me writing this is explain what I think needs to be done to get OWASP Japan started.

1. Get everyone interested in running chapter meetings, leader meetings or conferences together, either face to face or via teleconference. This is a must, otherwise you won't move forward.

2. Determine and assign duties and positions to those interested. If multiple people want the same position, a vote should be held. I don’t know if there are proper names for these positions but examples are:

i. OWASP Country Leader(s)

ii. OWASP Event Organizer(s)

iii. OWASP Relations Managers (Someone who can deal with international OWASP leaders and members; English is a requirement.)

iv. OWASP Chapter Leaders (per city/area)

v. OWASP Chapter Organizers (Could be same person as Chapter Leader)

vi. OWASP Technical supporters (People who give talks/presentations help review and create security guides)

vii. Probably more

3. Find organizations which are willing to donate resources (conference rooms) or time to OWASP.

4. Create a voting system to handle issues when occur.

Personally, I’d prefer to see Japanese people lead all of the top level positions. I also think it is important to have women hold some of these positions and contribute to OWASP Japan.

Thursday, June 16, 2011

Windows IE Test Images in Virtual Box | VirtualBoxでWindowsIEのテストVMイメージ

This quick guide will show you how to get Microsoft's free IE testing images working in Virtual Box.

このガイドはVirtualBoxでマイクロソフトのIEテストVMイメージを動きことを説明する。


Step 1. Download MS Images | MSイメージをダウンロード
MS Images


Step 2. Download Intel 1000 Desktop Drivers | Intel 1000 デスクトップドライバーをダウンロード
Intel Driver


Step 3. Create new WinXP VM | 新しいWinXPVMを作成

Be sure when creating the image to chose the .vhd file that you extracted from the MS "installer".

マイクロソフトのイメージインストラーからの「.vhd」ファイルを選択する。






Step 4. Change Network Card | ネットワークカードを変更
Under 'Settings' -> Network -> "Adapter 1" tab chose your network type (bridged/NAT whatever). Then under Advanced chose "Intel PRO/1000 MT Desktop (82540EM)" for the driver.

設定 → ネットワーク → アダプタ1のタブのネットワーク割り当てから好きな設定を選択する。高度設定のアダプタタイプから「Intel PRO/1000 MT Desktop (82540EM)」を選び。






Step 5. Create ISO from Intel Driver | インテルドライバーのISOを作る
You should have the PROWin32.exe driver downloaded. Start up cygwin for windows (or your terminal in *nix. Go to the directory that has the driver installer and run the following command:

genisoimage -o inteldriver.iso PROWin32.exe

もう既にPROWin32.exeドライバをダウンロードした。WindowsでのcygwinかUnixでのシェールを起動し、PROWin32.exeの入っているディレクトリから以下のようなコマンドを実行する:
genisoimage -o inteldriver.iso PROWin32.exe



Step 6. Start VM | VMを起動

Step 7. Mount the Intel Driver ISO | インテルドライバのISOをマウント



Step 8. Install Driver | ゲストでドライバをインストールする

Step 9. Profit! | 利益!
Don't forget to activate!

Activateを忘れないで!

Sunday, June 12, 2011

WBTS Version 1.0 | WBTSバージョン1.0

It's been a long time but I'm back to updating WBTS. This version will contain the following changes:
1. Removal of extjs (I didn't like the gplv3 license) moved to MIT license.
2. Total re-write of service code. Removal of web resources in favour of xmlrpc. Ability to drop in new XML-RPC services is now much easier
3. Auto-configuration creation script now available to build wbts configuration.
4. Built in pydictdb for those who don't want to run MongoDB. Also a new abstracted storage API if you want to build your own storage sub-system.
5. Possible creation of windows installer / virtual environment. Still not sure yet.

Release is planned for late June, So stay tuned!

いや、久しぶりですが、またWBTSの開発を続けている。このバージョンは複数の新しい項目を含んでいる。
1.extjsを削除した。(gplv3好きじゃないから)MITライセンスに変更した。
2.全部のサービスコードを書き換えた。Webコードを切って、XML-RPCで管理できるようになった。新しいXMLRPCサービスを追加したい方が簡単にできるようになった。
3.新し自動にWBTSの構成ファイルを作るスクリプトを作った。
4.MongoDBの代わりにWBTS内に設置されているPythonDictでデータを保存できる。新しいストレージAPIで自分の好きなデーターベースに作られる。
5.まだ決めてないけど、Windowsインストーラを作成するかもしれない。

6月下旬にリリースする予定だ。

Here's some images of the new mgmt interface.
新しい管理コンソールの画像だ!

Results table:(結果表)





Here's viewing a result (テスト結果)





Here's the new DNS tab (DNS設定タブ)





Here's the new XML-RPC testing interface (新しいXML-RPCインタフェース)

Wednesday, October 20, 2010

Some Bug Reports | いくつかの脆弱性報告

Recently some bugs I found in browsers and a flash player have had their advisories released. The first is a bug in Camtasia that allows for XSS because they allow remote inclusion of configuration files. Inside of the configuration files you can specify a javascript:... URL inside of an XML Element. This javascript URL is executed after the movie has finished playing.

The other bug was one I found while working on WBTS. It's a bug in version 10.62 of Opera's browser. This allowed for CSS and potentially other data to be accessed cross origin. This bug was due to a problem with redirects and reading in the remote files cssRules. I said it in my WBTS talk and I'll say it again, redirects are a common source of browser bugs!

最近、ベンダーさんは僕が見つけた脆弱性情報を発表した。ひとつのバッグはCamtasiaというフラッシュ映画の作れるソフトにXSS攻撃が可能だった。 そのソフトはフラッシュ映画にリモート(他のサーバー)からXML設定ファイルを挿入できる。設定ファイルの中にXML要素で「javascript:」のURLを指定し、映画が終わったらフラッシュによってブラウザはこのURLをアクセスする。

他のはWBTSを作ったときに見つけた脆弱性だ。Operaバージョン10.62でのブラウザの問題だ。この脆弱性で他サイトのCSSか他の情報漏洩の問題だ。詳しくはCSSファイルをリダイレクトでアクセスすると、他のドメインのcssRulesを読める。WBTSプレゼンテーションでも再度言ったんだが、「ブラウザのセキュリティーにおいて、リダイレクトの問題は日常的だ!」。

Friday, October 8, 2010

Slides Available | スライドを発表した

Quick note I just uploaded my slides from the SyScan talk to the WBTS Project Page.

SyScanのWBTSプロジェクトのスライドをWBTS プロジェクトページにアップロードした。

Tuesday, October 5, 2010

SyScan Done WBTS Released | SyScan終わったWBTS発表した

I finally finished all the work necessary for my SyScan talk at Ho Chi Minh. It went well and I had a pretty awesome time in Vietnam. I was going to post an update when I got back but I've been too tired to do anything. After 8-9 months of work, I would like to report I have finally released WBTS. There are a few missing test cases from the initial release as I have open bugs with Opera and BlackBerry. Once they fix those bugs I'll release the WBTS cases. Anyways you can download WBTS here and WBTS Runner here.
Enjoy!

やっとSyScanでのプレゼンテーションが終わった。本当によかった、ベトナムは楽しかった。戻った後にすぐブログを書こうと思ったけど、結構疲れたから今までやらなかった。9ヶ月間の努力の末にやっとWBTSを発表した。まだ、ブラウザベンダー「BlackBerry、Opera」が脆弱性を直してないから、最初のリリースはその直してない脆弱性のテストケースを含まない。直した後に発表する。以下のようなリンクでWBTSをダウンロードできる。WBTS。。。 WBTS Runner.
楽しんで!

Wednesday, August 18, 2010

Overlong UTF-8 Generator | 不正なUTF-8シーケンスジェネレーター

Real quick post about some code I made to generate invalid UTF-8 sequences. I couldn't find this online so I made my own ;D.
Here it is:

Web検索で見つかれなかったので、自力で不正なUTF-8シーケンスジェネレーターツールを使った。


Example:


overlongyourmom.py written by wirepair
Enter an ASCII char to make overlong, or hex (ex: h27) or 'quit': '
char ['] dec [39] hex [27] url: %27
overlong 2-byte sequence: c0 a7
overlong 3-byte sequence: e0 a7
overlong 4-byte sequence: f0 80 80 a7
overlong 5-byte sequence: f8 80 80 80 a7
overlong 6-byte sequence: fc 80 80 80 80 a7
Enter an ASCII char to make overlong, or hex (ex: h27) or 'quit': /
char [/] dec [47] hex [2f] url: %2f
overlong 2-byte sequence: c0 af
overlong 3-byte sequence: e0 af
overlong 4-byte sequence: f0 80 80 af
overlong 5-byte sequence: f8 80 80 80 af
overlong 6-byte sequence: fc 80 80 80 80 af
Enter an ASCII char to make overlong, or hex (ex: h27) or 'quit': ]
char []] dec [93] hex [5d] url: %5d
overlong 2-byte sequence: c1 9d
overlong 3-byte sequence: e1 9d
overlong 4-byte sequence: f1 80 80 9d
overlong 5-byte sequence: f9 80 80 80 9d
overlong 6-byte sequence: fd 80 80 80 80 9d
Enter an ASCII char to make overlong, or hex (ex: h27) or 'quit': \
char [\] dec [92] hex [5c] url: %5c
overlong 2-byte sequence: c1 9c
overlong 3-byte sequence: e1 9c
overlong 4-byte sequence: f1 80 80 9c
overlong 5-byte sequence: f9 80 80 80 9c
overlong 6-byte sequence: fd 80 80 80 80 9c
Enter an ASCII char to make overlong, or hex (ex: h27) or 'quit': h0a
char [
] dec [10] hex [0a] url: %0a
overlong 2-byte sequence: c0 8a
overlong 3-byte sequence: e0 8a
overlong 4-byte sequence: f0 80 80 8a
overlong 5-byte sequence: f8 80 80 80 8a
overlong 6-byte sequence: fc 80 80 80 80 8a

Tuesday, August 17, 2010

Designing a testcase system for browsers | ブラウザによるテストケースシステムの設計

The testcase system is an important piece to the WBTS project. It went through a few design changes while I was working on it. It is made up of two parts, the client side and the server side.

Client Side
The client side code is just a single javascript object called TestCase. It allows you in your testcase to store the following information:
1. input: A quick summary of the input to your testcase like document.cookie = 0x00-0xff.
2. output: The output of the test, if there is any. You can supply your own html formatting as well.
3. description: A quick description of the test like: "Inject headers into xhr object"
4. target host: The host name you expect the request to becoming from (usually only used for SOP tests).
5. expected result: What you expect the result to be like: "null" or "exception"
6. result: The actual result of the test.
7. test passed: Did the test pass or fail? (Usually true or false).

There are two methods of running a test. For simple tests, you can fill out the object, run a test then just call the testcase objects saveTest method. For more complex, or dangerous testcases you can use the savePreTest method. This allows you to set up all the test information and store it in a temporary document. You then run the test. If the test causes the browser to stop, the blade automation system will call a failTest method, indicating that it was unable to complete. This also causes the temporary data to be copied into the real results database.

Here is an example testcase:

Lines 6-12 are used to ensure our testcase function "f" fires when the window finishes loading.
Lines 15-25 create a string of bytes to be used as input.
Line 26 URL decodes the data into their "raw" form.
Line 27 creates a cookie value.
Line 29 sets the testcase input (this will be directly visible in the results database).
Line 30 sets the description.
Line 31 is the actual test, creating a cookie for the document, then making a request to a special resource. After showRequest is called via XHR, the "save_test" call back function will have access to the response data and our testcase object.
Line 36 takes the response data and sets that as our output.
Line 37-38 tries to remove the cookie data.
Line 39 finally saves the test to our results database.
It should be noted, each testcase is called with a query parameter called client_id. This value is generated by the blade automation system and used for tracking purposes. A request to a testcase would look like: http://www.attacker.com/testcases/headertests/sometest.html?client_id=<some unique id>

Server Side
Our test case system is mapped to /tc/ on all virtual hosts. It offers three resources: saveTest, savePreTest, and failTest. They are not very complicated, they just take in the data as POST parameters. A few fields are base64 encoded for storage as it may contain invalid UTF-8 bytes which may cause MongoDB to throw an error. savePreTest will store data in a temporary database. The pretest data contains the testcase information configured for a failure result. This way, when failTest is called, it can just copy the information into our results database.

WBTSプロジェクトのためにテストケースシステムが大事。作りながら何回もデザインが変更した。テストケースシステムは二つの部分(クライアント側とサーバー側)がある。

クライアント側
クライアントサイドコードはTestCaseというのJavaScriptオブジェクトだけである。このオブジェクトが以下のような情報を保存する:
1. input(入力): テストケースの簡単な概要。例:document.cookie ^ 0x00 - 0xff。
2. output (出力): テストの出力。HTML様式もできる。
3. description: テストケースの説明。例: 「XHRオブジェクトにヘッダーをインジェクトする。」
4. target host: テストケースの実行されるホスト名。普段は、SOP専用
5. expected result(予想通りの結果): 例: 「null」または「exception」
6. result (結果): 実際のテスト結果。
7. test passed (テストの成否): テストは失敗か正解だったか。普段は 「true」か「false」。

(上記のコードーを見て。)
Line 6-12 Windowがロードーするのを完成したら「f」という関数を実行する。
Lines 15-25 テストの入力による、文字列を作成する。
Line 26 データーをURLデコードする。
Line 27 クッキー値を作成する。
Line 29 テストケースの入力を設定する。(この情報は結果DBで見られるようにする)
Line 30 説明を設定する。
Line 31 これが実際のテスト。ドキュメントのクッキーを作成、特別なWebリソースに呼び出す。XHRでshowRequestを呼び出した後は「save_test」のコールバック関数を呼び出す。この関数がレスポンス情報とTestCaseのオブジェクトにアクセスできる。
Line 36 レスポンス情報を出力に設定する。
Line 37-38 クッキーを削除する。
Line 39 テストの結果をDBに送信する。
実は、「client_id」と言うパラメーターは格テストケースに送信する。トラッキングのため、この「client_id」値はbladeシステムによって作られたものだ。例えば、下記のようなURLはテストケースのリクエスト。
http://www.attacker.com/testcases/headertests/sometest.html?client_id=<some unique id>

サーバー側
テストケースシステムは全部のVirtualHostsで「/tc/」にマップした。このシステムは三つのリソース「saveTest」、「savePreTest」、「failTest」を実装する。そんなに複雑ではない。POSTでのパラメーターだけ受信する。テスト結果が不正なUTF-8バイトを持っているかもうしれないので、多少のDBフィールドはbase64エンコードする必要がある。エンコードしないと、MongoDBがエラーを発生する。「savePreTest」リソースはテストデータをDBに一時的に保存する。テストが失敗する場合、bladeシステムは「failTest」に呼び出すと一時的なDBから結果DBにコピーされる。

Friday, June 25, 2010

Linux GUI Automation | Linux GUI オートメーション

Recently, I've been researching UI automation in linux for driving web browsers. So naturally, I wanted to find a python library for doing this. I found two libraries, dogtail and ldtp for automation in python. Both use the AT-SPI Accessibility functionality for finding controls (like textboxes/buttons). I chose LDTP because dogtail has not been updated in 4 years. Also, a lot of dogtail's code seems to be unimplemented or not working. Since I am automating browsers, I'd like to show you how to automate the following:
1. Start Firefox
2. Type in a URL
3. Look for a pop up and close it if it exists.
4. If a pop up exists, go to a new url.

I will also use twisted python and setup a LoopingCall to monitor for the popups.
See the code below.



So let's review the code.
Line 27: Use ldtp to launch firefox.
Line 28: Create a LoopingCall task using our check_dlgs function.
Line 29: Set that function to be called every 3 seconds. (False says don't call now)
Line 30: Tell the twisted reactor to call 'typestuff' function in 1 second.
Line 24: typestuff is called. ldtp can use regex's for finding window names. Spaces and special characters are removed from the name. The name of the URL bar control is 'txtSearchBookmarksandHistory' and url is the text we want to enter.
Line 25: Type enter (we have focus on this window)
Line 15: 3 seconds pass and we should be at the popup.html URL. It is a dialog and the title is 'The page at 192.168.0.196:8080 says...' but we can just use the regex.
Line 17: Hit enter (activates the OK button)
Line 18. Go to a new URL
Lines 9-11: Do the same process to go to a new url.
Line 21: Stop reactor and quit.

Pretty neat huh?
最近、Webブラウザを動かせるのために、LinuxでのUIオートメーションを勉強している。もちろん、Pythonでのライブラリを欲しかったのでそれを探した。二つのライブラリを見つかった、「dogtail」と「ldtp」というのオートメーションライブラリがある。UIのコントロール(テクストボックスとかボタンなど)の探すよるに両方のライブラリがAT-SPIの機能を利用する。多くのdogtailコードが不実装か壊れたからLDTPを選んだ。それと、dogtailの最後のアップデートが4年前だった。今ブラウザのオートメーションを勉強するから以下のようなコードで自動的にブラウザでURLに動かせる。
1.Firefoxを起動
2.URLを入力する
3.ダイアログボックス存在する場合、自動的に閉じる。
4.ボックスを閉じ、新しいURLを入力する。

Twisted PythonのLoopingCallでFirefoxのダイアログボックスを存在すれば、自動的に閉じる。

上記のコードをレビューしましょうか?
Line 27: LDTPでFirefoxを起動
Line 28: check_dlgs関数でLoopingCallを造る。
Line 29: その関数が毎3秒後呼び出す。(Falseの値の意味は「今呼び出さない」ということです)
Line 30: twisted reactorは1秒後、typestuff関数を呼び出す。
Line 24: typestuffを呼び出した。LDTPは正規表現を使う上でWindow名を探せる。スペース字と記号文字が抜いている。URLのテクストボックスの名前は「txtSearchBookmarksandHistory」というです。「url」はWebアドレスです。
Line 25: リターンを押す。(FirefoxのWindowはフォーカスがある)
Line 15: 3秒後は「popup.html」のページに着きました。ダイアログボックスの名前は「The page at 192.168.0.196:8080 says...」ですが、正規表現を使える。
Line 17: リターンを押す。(OKボタンを押す)
Line 18: 新しいURLに動く。
Lines 9-11: また、同じプロセスで新しいURLに動く。
Line 21: reactorを停止して、プロセスも停止。

カッコイイじゃないの?

Monday, June 21, 2010

Introducing... WBTS | WBTSの紹介

For those that know me, probably know I've been working a lot on a personal project called WBTS. WBTS is a Web Browser Testing System for finding bugs. I built it using the twisted python framework. But what exactly is WBTS?
1. A cross-platform web application server supporting SSL, Virtual Hosts, processors for various web languages and the ability to include your own. All built on python's stupid fast Twisted framework.
2. A built in DNS server to allow records to be created on the fly, as well as built-in DNS
rebinding functionality accessible via web requests.
3. A cross-browser JavaScript test case framework that allows you to quickly create new test cases for various browser bugs using different automation methods. The framework hooks into MongoDB to store the results in an easily search-able data store.
4. Lots of test cases both from public sources such as WebKit's LayoutTests, old known
browser vulnerabilities taken from Mozilla Firefox's and Google Chrome's bug tracker
systems as well as ones created by myself.
5. A slick management Web UI to review test results and configure WBTS.
6. Future plans to implement a fully featured fuzzing framework.

See the screen shots below!

たぶん知ってるけど、最近僕はWBTSというプログラムを作っている。WBTSというのは脆弱性を見つけるためのウェブブラウザテスティングシステムです。このアプリケーションはTwisted Pythonのフレームワークで作ったものだ。でも、WBTSとは何でしょか?

1. SSL,VirtualHosts,自分の好きな言語をサポートされているクロスプラットホームのWebアプリケーションサーバーです。
2. 組み込みDNSサーバーが一瞬的に記録を作られ、WebのURIアクセスすると、DNSリバインディング攻撃ができる。
3. 複数のオートメーション方法で簡単にテストケースを作られるクロスブラウザテストケースシステム。このシステムがテストの結果をMongoDBに保存します。
4. WebKitのLayoutTests、古いのMozillaとChromeの脆弱性と自分の作ったのたくさんのテストケースが入っている。
5. カッコイイWebUIで結果をレビューし、WBTSの設定も簡単にできる。
6. Fuzzingシステムを作る予定もある。

以下のようなWBTSの画像を見てください!
1. Cross Platform UI! (Windows) | クロスプラットホームUI! (windows版)


2. DNS Server Settings | DNSサーバーの設定


3. Test case results | テストケースの結果


4. Various WBTS Settings | いろいろなWBTSの設定

Thursday, April 22, 2010

eXternal Xml Entities - 外部XMLエンティティ

You probably know all about XXE attacks. They've been around for years. There's even an OWASP page dedicated for testing Xml Injection bugs. In the past 2 months I have found this vulnerability in 3 separate applications. It appears that most xml processors are vulnerable by default if you are validating the XML. The most common fix is to replace the EntityResolver with an empty one. This is outlined for Java here and here for .NET. In some cases you can see the results. So I supply:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///c:/boot.ini" >]>
<foo>&xxe;</foo>

And the server responds with:
Error parsing xml... blah blah:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

is not valid blah blah...

So what are the risks when I can't see the results? I'm glad you asked!
Here is what *I* think the risks are:
1. SMB Reflection attacks file:\\ip.ip.ip.ip/C$ (Windows only?)
2. Bypass of 'host based' protections... http://localhost/admin?newuser=...
2.a. Potential Access to unprotected internal systems http://someserver/user?command=new&user=...
3. Exploit vulnerabilities in client protocols (ftp, smb, http, https... etc) as they connect. Think fuzzing request/responses.
4. Exploit vulnerabilities in protocol handlers. telnet://ip.ip.ip.ip & cmd.exe ... Only http/file/ftp appear to be possible.
5. Discovery of allowed outbound ports via egress port scan http://ip.ip.ip.ip:1, http://ip.ip.ip.ip:2, http://ip.ip.ip.ip:3...

What do *you* think?


XXE攻撃を知ってるでしょうか。XXEは長年に公開の情報です。OWASPサイトではXMLインジェクション攻撃のページがあるから結構、よく知られているんじゃないでしょうか。二ヶ月間の間に三つのWebアプリでこの脆弱性を見つかった。XML構成をチェック(Validating)するなら、アプリケーションは脆弱みたいだ。
対策方法としては風通に新しい(外部のEntityを探さないように)Resolverに変更する。この対策方法はJavaの場合ここ、.NETの場合ここで説明する。攻撃する時に時々結果を見ないようにするケースある。例えば:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///c:/boot.ini" >]>
<foo>&xxe;</foo>

サーバの返事が下のように:
エラーが発生しました。。。:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

構成が正しくありません。。。

でも、結果を見ない時もあるから、リスクは何でしょうか?質問ありがとう!
俺の場合は下のようにリスクがあると思う:
1. SMB Reflection(反映攻撃と言うかな?)file:\\ip.ip.ip.ip/C$ (Windows だけ?)
2. ホストでのアクセス予防の回避... http://localhost/admin?newuser=...
2.a. 守ってないの内部システムの攻撃... http://someserver/user?command=new&user=...
3. クライアント側(ftp, smb, http, https...等)での接続するときに脆弱性を攻撃する。リクエスト・レスポンスのFuzzingを考えたら。。。
4. プロトコールのハンドラの攻撃... telnet://ip.ip.ip.ip & cmd.exe... http/ftp/fileだけ使うみたい
5. 外部のアクセスできるポートスキャン: http://ip.ip.ip.ip:1, http://ip.ip.ip.ip:2, http://ip.ip.ip.ip:3...

どう思う?

Tuesday, April 13, 2010

.NET Controls

Investigating an issue today and learned something new. Microsoft chose to encode various ASP.NET controls differently. While some make sense, the entire list is pretty bizarre. Oh versions of ASP.NET also matter 1.1 is different than 2.0. Check out: http://msmvps.com/blogs/calinoiu/archive/2006/06/13/what-s-wrong-with-asp-net-html-encoding.aspx for a nice writeup. Still no updated list for 3.5 Framework though.

今日は新しいことを習うんだ。マイクロソフトはASP.NETのエンコーディングのやり方がコントロールと.NETバージョンによるみたいだ。ま、コントロールが違うからわかるけど、全部を見たら変じゃないかなっと思った。次のサイトはASP.NETの異常説明した: http://msmvps.com/blogs/calinoiu/archive/2006/06/13/what-s-wrong-with-asp-net-html-encoding.aspx.。でも、ASP.NET3.5のエンコーディングリストを見つかれなかった。

Thursday, April 8, 2010

Long time.. - 久しぶり。。。

It has been a while since I have updated this. I probably should seeing that I now that I quit Symantec and work for an American company www.veracode.com. I still live in japan but, i don't really use my Japanese much these days. Expect some new interesting technical stuff here soon!

久しぶりですね、ぜんぜん書いてないこれ。シマンテックを辞めて、Veracodeに勤めている。まだ日本に住んでいるが日本語をあまり使わない。なので、日本語の練習のために書いたほうがいいよね。そろそろ、新しい技術的なことを書くからもうちょっと待ってください!

Thursday, July 31, 2008

.WAR Games - .WAR ゲームズ

So lets talk about .WARs, if you see my previous post you will know they are simply web application archive files. They are zip files that contain all the necessary components (jsp/images/html/java classes) that are required for the web application to work. Lets go over the structure, ascii-style. And by ascii, I mean a bitmap of ascii art.


Yeah that looks Terrible. Anyways, so thats the structure of the .WAR file. How do you extract it? I mentioned earlier it is simply a zip file, you can exact it via an unzip program, or with java provided you installed the latest JDK. If the java directory is in your path, you can just do "jar -xf .war" without the quotes. Let's do a trial run here and download Some Random Java Application. Just download the ginp.war file. Once that is completed, unzip the file, and you should see a directory structure similiar to the one I described above. Always go directly to the WEB-INF/ directory and open the web.xml first. Let's pull out a servlet's details...
<servlet-name
>ginp Controller Servlet</servlet-name>
...
<servlet-class>net.sf.ginp.GinpServlet</servlet-class>
...
<servlet-mapping>
<servlet-name>ginp Controller Servlet</servlet-name>
<url-pattern>/styles/backinblack/ginpservlet</url-pattern>
</servlet-mapping>

So the ginp Controller Servlet is mapped to a url /styles/backinblack/ginpservlet. This means we can access it via: http://thehost/appname/styles/backinblack/ginpservlet. Easy as that.
It may take some parameters, but we don't know, so lets look at the class.
Under servlet-class we see net.sf.ginp.GinpServlet, so if we go into the WEB-INF directory, then classes/net/sf/ginp/ directory we can see none other than... GinpServlet.class!
Lets decompile the class with Jad. From the /ginp/ directory run the command (provided jad is in your path):
C:\Documents and Settings\eff.bee.eye\Desktop\kougeki\ginp\WEB-INF\classes\net\s
f\ginp>jad -8 -s .java GinpServlet.class

Parsing GinpServlet.class... Generating GinpServlet.java
Couldn't resolve all exception handlers in method doHttpMethod
Couldn't fully decompile method _mthclass$
Couldn't resolve all exception handlers in method _mthclass$

Most servlets process GET requests and forward them to a POST (doPost) method. This one just forwards it to another method doHttpMethod. We're starting to see a number of classes being referenced outs
ide our initial servlet. When this happens, it's usually a good idea to just decompile the entire package:
C:\Documents and Settings\eff.bee.eye\Desktop\kougeki\ginp\WEB-INF\classes>jad -8 -s .java -r */**/*.class
Parsing net/sf\ginp/CommandParameter.class... Generating net\sf\ginp\CommandParameter.java

....
From here we would begin to do a code-review to identify areas of potential vulnerability but, I think we will leave code-reviewing for the next installment! Until then!

.WARの話しましょう。前の記事を見たらWARファイルはWebアプリケーションアーカイブを知っています。アプリケーションの実行するためにWARは 必要なファイル(JSP/画像/HTML/Javaクラス)を含んでいるZipファイルです。 ASCIIスタイルでWARのディレクトリ構成をレビュー します。実はASCIIスタイルというのはbitmap画像です。


↑見た目が本当に悪いですよね。上記の画像はWARファイルの構成の説明です。どの方法でアーカイブから解凍しますか。前の時、zipファイルだと言ったので、Unzipプログラムで解凍するか、JavaのJDKをインストールしたらJarアプリでも解凍できます。 Javaパースを環境値に含んでいる場合、”jar -xf [appname].war"のコマンドを実行すると、自動的に解凍します。試しに適当なJavaアプリケーションを探して、サイトからginp.warファイルをダウンロードします。そのあと、解凍すると、上記構成のように見えます。いつも、初めにWEB-INFディレクトリのweb.xml設定ファイルを開きます。最初のJavaサーブレットを見ましょう。
<servlet-name>ginp Controller Servlet</servlet-name>
...
<servlet-class>net.sf.ginp.GinpServlet</servlet-class>
...
<servlet-mapping>
<servlet-name>ginp Controller Servlet</servlet-name>
<url-pattern>/styles/backinblack/ginpservlet</url-pattern>
</servlet-mapping>

ginp Controller Servletは/styles/backinblack/ginpservletに参照します。そのurl-patternの値が存在するので、直接ブラウザーでhttp://thehost/appname/styles/backinblack/ginpservletへアクセスできます。
それは簡単です。そのサーブレットはパラメータが必要かもしれないので、Javaクラスを見ましょう。 servlet-classの値でnet.sf.ginp.GinpServletがあるので、WEB-INF/classes/net/sf/ginpのディレクトリに入って、GinpServlet.classファイルを見ます。このクラスファイルをJadでディコンパイルしましょう。「/ginp」ディレクトリで(Jadプログラムを環境値にパース入っている場合)以下のコマンドを実行します。

C:\Documents and Settings\eff.bee.eye\Desktop\kougeki\ginp\WEB-INF\classes\net\s
f\ginp>jad -8 -s .java GinpServlet.class
Parsing GinpServlet.class... Generating GinpServlet.java
Couldn't resolve all exception handlers in method doHttpMethod
Couldn't fully decompile method _mthclass$
Couldn't resolve all exception handlers in method _mthclass$

殆どのサーブレットはHTTPのGETメソッドを受付すると、POSTメソッド(JavaのdoPostメソッド)に転送します。このアプリは両方のメソッドを他のJavaメソッドdoHttpMethodに転送します。GinpServletは複数のクラスに
このGinpServletクラスを理解するには、クラスファイル内の複数の参照を見る必要があるので、全てのアプリケーション名前空間ファイルをディコンパイルしたら良いです。
C:\Documents and Settings\eff.bee.eye\Desktop\kougeki\ginp\WEB-INF\classes>
jad -8 -s .java -r */**/*.class
Parsing net/sf\ginp/CommandParameter.class... Generating net\sf\ginp\CommandParameter.java
ここから可能な脆弱性を発見するために、コードレビューをしますが、今度の記事でコードレビュー方法を説明します。それまで!

Tuesday, July 15, 2008

TASPO came! - TASPO着きました!

So, I'm a smoker (until I have kids, then I quit) . In Japan, cigarette vending machines now require a RFID card called TASPO before they allow you to buy cigarettes. Because they are free to get, I figured they would use a cheap system. I was right, they use MIFARE. How do I know? I put the card on my SCM Smart Card reader and it gave me the following information:
僕はタバコを吸う人です(子供を出来たら止めます)。今、日本ではタバコを買う前にタバコ自動販売機がTAPSOと言うRFIDカードが必要です。カードは無料なので、RFIDシステムはお金が掛からないシステムを使っていると思いました。僕は正解です。TASPOシステムはMIFAREを使います。(MIFAREは安い)何で僕はシステムがMIFAREを使っているのかわかるか?TASPOカードをSCMのスマートカードリーダの上に置くと以下の情報を読み込めました:
Unfortunately, I do not know the key so I can not authenticate to the card. If I could authenticate, I could add up to 200$ on the card and buy cigarettes for free. This is not a good thing, because well, MIFARE has been cracked already. For a non-technical explanation please read this url. For a technical explanation see this one. So how do you authenticate to a MIFARE card? Well you need a smart card reader, and either RFIdiot or tools that come with the reader (I just use the ones from my SCM reader.) Here's a simple table of commands:
残念ですが、TASPOカードの認証鍵わからないので、ログインできませんでした。もし、出来たら、カードの金額を追加し、無料でタバコを買えます。でも、誰かが既にMIFAREの暗号アルゴリズムをクラックしたので、鍵情報は必要ありません。これは本当にだめです。簡単な説明を見たい場合このURLを読んでください。もっと難しい説明を読みたい場合、このURLを読んでください。ところで、もし、鍵値を知っている場合、MIFAREカードのログインプロセスは何でしょうか。スマートカードリーダーとRFIDiot(ツール)かリーダーのツール(僕のSCMリーダーのツールを使う)を使います。RFIDのコマンドの表は以下のようになります。

To authenticate、 we would send 0xFC 0x20 0x60 0x00 0x06 [key] where [key] is a 6 byte value such as FFFFFFFFFF,000000000000, etc. I tried simple ones, but I imagine the keys are based off of some custom algorithm. Anyways, that was just a quick post on TASPO, if I do additional research I'll post it later.
ログインプロセスは「0xFC 0x20 0x60 0x00 0x06 <鍵>」のバイトを送信します。鍵は6のバイトので、FFFFFFFFFF,000000000000の形です。僕は簡単な鍵値を推測試みたが、出来ませんでした。たぶん、鍵値がカスタムアルゴリズムで基づくかもしれないんです。もし、さらにリサーチした場合、後で追記します。

Sunday, July 13, 2008

Attack Surface 攻撃サーフィス

Before we get into the specifics of attacking a J2EE server lets quickly touch on the topic of attack surfaces. What is an attack surface? It's basically all of the points or areas that an attacker can access a system or application. It is very important for both attackers and defenders to know their applications attack surface. You can not protect what you don't know exists. As a defender, you want to have the smallest possible attack surface. As an attacker, you want to identify areas the defender may have missed, or did not consider as being a potential attack vector. Lets use a generic J2EE application server as our example.
Breaking down the possible attack surfaces:
1. HTTP Server Instances - Most application servers have multiple HTTP/HTTPS instances running.
  • - Admin Instance, most come with a web management interface.
  • - Example Content Instances, sometimes developers leave the example content http instances accessible.
  • - User Created Instance(s), for hosting individual applications that the developers created.
2. ORB-IIOP listener - Most enterprise j2EE application servers have some sort of IIOP listener. These are accessible via remote clients through RMI-IIOP.
3. JMX-RMI management ports - These are accessible remotely by clients (usually they come with the application server installation) over the Java Remote Method Protocol (JRMP).
4. JMS Service - Java Message Service, These are also accessible remotely by clients, the server software usually comes with a client that you can use to connect.
5. JDBC service - Some application servers come with their own database service, you'll commonly see Apache's Derby DB. (http://db.apache.org/derby/)

Depending on the application server, you may see more or less than this. These are just the ones I commonly see in large (enterprise level) J2EE application servers. So we just went from thinking our J2EE server only had HTTP services to attack, to identifying four additional places that may contain vulnerabilities.

J2EEのハッキング方法の話前に攻撃サーフィスを話します。攻撃サーフィスと言うのは何でしょうか。基本的に攻撃者がアプリケーションやシステムのアクセス(攻撃)できる所です。
攻撃者やディフェンダーとしても、攻撃サーフィスの知識は本当に大事です。攻撃サーフィスがわからないと守れません。ディフェンダーとしては攻撃サーフィスが小さいほどより良いです。
攻撃者としてはアプリケーション内のディフェンダーの気づかない所を見つけれなければなりません。以下の例は普通のJ2EEアプリケーションサーバーです。
1. HTTPサーバーインスタンス - 殆どのアプリケーションサーバーは複数のHTTP・HTTPSのインスタンスを実行されます。
  • 管理インスタンス - 殆どのサーバーは管理者コンソールがあります。
  • サンプルコンテンツのインスタンス - 時々、開発者はサンプルコンテンツのサーバーを実行のままにする。
  • 開発のインスタンス - アプリケーションの配備インスタンス。

2. ORB-IIOP リスナー - 殆どの企業アプリケーションサーバーはIIOPリスナー実行されます。RMI-IIOPでリモートクライアントをアクセスできます。
3. JMX-RMI 管理ポート - JRMPでリモートクライアントをアクセスできます。通常のサーバーはクライアントと一緒にインストールをします。
4. JMSサービス - Javaメッセージサービス、また、リモートクライアントでアクセスできます。
5. JDBCサービス - いくつかのサーバーはDBと一緒にインストールするので、サーバーをアクセスできるクライアントもインストールをします。殆どのサーバーがApacheのDerbyをインストールします。(http://db.apache.org/derby/、http://ja.wikipedia.org/wiki/Apache_Derby)

アプリケーションサーバーによって多かれ少なかれこのサービスにアクセスできます。僕の経験では企業のJ2EEサーバーで以上のリストを結構見ます。J2EEサーバーの攻撃サーフィスはHTTP・HTTPSだけではなく、複数あります。

Saturday, July 12, 2008

J2EE Hacking Server First Steps - J2EEサーバーのハッキング紹介

So, you just downloaded and installed some j2ee server and you want to hack it. What are the first steps you should take? You should be aware of the application servers architecture, usually you can read the manuals to get a high level understanding of how it works. You'll probably see a bunch of ridiculous java terms being thrown around, so lets do a quick run down of what they are;
  • JSP - Java Server Pages, a form of scripting that allows the developer to inter-mix HTML and Java code in the same file. Much the same as ASP, PHP and other Web Programming Languages.
  • Web Services - Basically an API that is accessible over the HTTP protocol using standard HTTP methods. Client sends a request, the server processes it, runs some code and returns the results back to the client. Messages are commonly transfered in XML messages that follow the SOAP standard.
  • SOAP - [Simple Object Access Protocol] is a protocol for exchanging XML messages to a Web Service.
  • WSDL - Web Services Definition Language, yet another xml format for determining how a client should call a web service.
  • JAR - Java ARchive, basically a zip file with all html, images, java classes, jsp pages required for an application.
  • WAR - Web ARchive, Web Application Archive, same format as a JAR but specifically for web applications. Contains the web.xml configuration file along with classes, other jars and anything else required by the web application.
  • EAR - Enterprise ARchive, basically an application that contains a bunch of web 'modules' that work together to form an enterprise application. Think of it as a container for multiple web application(s) and their components.
  • EJB- Enterprise Java Bean, used for housing the 'business' or 'application' logic. It's a rather advanced architecture that is run inside of a J2EE server. It has its own specifications and API, please see sun's website: http://java.sun.com/products/ejb/.
  • RMI - Remote Method Invocation, allows programmers to write objects in a distributed environment. These objects can be called remotely.
  • ORB-IIOP - Object Request Broker Internet Inter-Orb Protocol, a communication protocol for two systems to access objects. This is a language neutral communication protocol. These are accessible via remote clients through RMI-IIOP. For more information on RMI-IIOP see: http://en.wikipedia.org/wiki/RMI-IIOP.
  • JRMP - Java Remote Method Protocol, like ORB-IIOP but for one java application to access the objects of a different java applications.
  • JMS - Java Message Service, an API for sending messages between two or more clients.
  • JMX-RMI - Java Management eXtensions Remote Method Invocation is used for managing and monitoring the servers applications.
  • JNI - Java Native Interface, Allows java code to integrated with code in other langauges such as C/C++. (Good for legacy systems).
  • JAX-WS - Java API for XML Web Services, basically an API that utilizes XML messages for communication between the web service and the client.
  • JSF - Java Server Faces, a framework for building MVC (Model View Controller) web applications. Competes with Apache Struts.
  • JBI - Java Business Integration, a specification for implementing a SOA (Service Oriented Archeticture). JBI is built upon the web services model.
  • And many more...
This is one reason I hate java so much, too many acronyms and specifications, most of which are quite useless.

Tools.
I'm not much of a 'tools' person, I prefer simple methods and if required, I write my own scripts. But there are a few I simply can not live without and as they relate to hacking J2EE apps and servers here's what I usually use.
  • Burpsuite - A HTTP Intercepter Proxy tool. I've been using it for almost 6 years now and I still love it.
  • Jad - Java Decompiler. A *must* for decompiling java bytecode.
  • cygwin - I'm a windows guy, but I also know when Unix tools are better served ;>.
  • SysInternals Procexp and Tcpview. Good to see which files and ports are in use by a process.
  • More to come later.
Thats it for my quick introduction, later I'll be posting what to actually /do/ to figure out what vulnerabilities may exist in J2EE servers.

新しいJ2EEサーバーをダウンロード、インストールするとハッキングをしたくなりますよね。最初はどうするか。はじめに、サーバーのアーキテクチャの説明書を読んで、一般的な知識を得ればいいと思います。
確かに、おかしいJava言葉をばっかり見るのでちょっとレビューしますよ。

* JSP - (Java Server Pages) 開発者のためにHTMLとJavaスクリプトコード同じファイルに入れるWebスクリプティング言語です。これはASPやPHPやほかのWebプログラミング言語と同じです。
* Web Services - 基本的に、HTTPプロトコールでプログラミングAPI。クライアントはリクエストを送信し、サーバー側でコードを実行し、レスポンスを送ります。一般的に送信データの構成がSOAP標準構成で実装します。
* SOAP - (Simple Object Access Protocol)シンプルオブジェクトアクセスプロトコールはXMLメッセージをクライアントからサーバーに切り替えるプロトコールです。
* WSDL - (Web Services Definition Language) WebサービスデフィニションランゲージはXMLドキュメントでWebServiceの定義ファイルです。このファイルを理解すれば、クライアントはサーバーのWebサービスを使えます。
* JAR - (Java ARchive) アプリケーションのために、HTML、画像、Javaクラス、JSPファイルなど、必要なファイルをジップファイルに含むアーカイブです。
* WAR - (Web ARchive) WebアプリケーションアーカイブはJARと同じ構成ですが、Webアプリケーションのだけです。このアーカイブはweb.xmlコンフィグレーションファイル、Javaクラスファイル、JARファイルなどの必要ファイルを含むアーカイブです。
* EAR - (Enterprise ARchive)企業アプリケーションの関連Webモジュールを含むアプリケーションアーカイブです。複数のWebアプリケーションためのコンテナーとして用いられる。
* EJB- (Enterprise Java Bean)EJBは事務ロジックかアプリケーションロジックのための実装です。 結構上級なJ2EEサーバーでJavaBean実装です。 EJBのAPI説明書を見てください:http://java.sun.com/products/ejb/.
* RMI - (Remote Method Invocation)分散型環境のためJavaオブジェクトを作れます。 このオブジェクトはリモートから呼び出します。
* ORB-IIOP - (オブジェクトリクエストブローカーインターネットインターオアブプロトコール)このプロトコールは二つのシステムの間でオブジェクトを交換する。ORB-IIOPがプログラミング言語に依存していません。 IIOPの説明書を見てください:http://ja.wikipedia.org/wiki/IIOP.
* JRMP - (Java リモートメソッドプロトコール)ORB-IIOPのようですが、JRMPは他のJavaアプリケーションオブジェクトへアクセスするJavaアプリケーションのために使用される。
* JMS - (Java メッセージサービス) 二つ(もしくはそれ以上)のクライアントの間でメッセージを送信する。
* JMX-RMI - (Java Management eXtensions Remote Method Invocation)JMX-RMIはサーバーのアプリケーションを管理や監視のために使用される。
* JNI - (Java Native Interface) Javaコードは他の言語(C/C++)でインテグレートできるインタフェースです。 (古いシステムに良いです)。
* JAX-WS - (Java API for XML Web Services) クライアントとサーバーの送信に使用するためのXMLメッセージAPI.
* JSF - (Java Server Faces)Sun MicrosystemsのMVC(モデル、ビュー、コントローラー)のWebアプリケーションフレームワーク。JSFはApacheStrutsに対抗する。
* JBI - (Java Business Integration)SOA(サービス向けアーキテクチャ)の実装です。JBIはWebサービスモデルで作成された。
* その他

略語と仕様がたくさんあるので僕はJavaが嫌いです。殆どの仕様は役に立ちません。

ツール。
僕はツールばかり使う人ではありません。僕の意見は簡単な方法でハッキングすることが一番良いと思います。もし、必要ならば、自分でツールやスクリプトを作ります。でも、J2EEアプリケーションとサーバーをハッキングするため、必要なツールをもちろん使います。
以下参照:
  • Burpsuite - HTTPのインターセプタープロクシツール。 6年間使用中、かなり気にいってます。
  • Jad - Javaデコンパイラ。Javaバイトコードをデコンパイルするために使う必要があります。
  • cygwin - 僕はWindowsの方が好きですが、Unixツールを使う時も多いです。
  • SysInternals - ProcexpとTcpview。このツールの目的はどのファイルやどのポートをプロセスに使うか検索します。
  • 随時追加。
以上ですが、次回はJ2EEのハッキングやり方と脆弱性の見つけ方を説明します。

Introduction - 紹介

I decided to start a hacking blog, the only twist is, I'm going to write each entry in Japanese as well. Since I write very slowly -- and will make many mistakes -- it probably is best to read the English part only ;>. To start, I plan on writing a lot about j2ee and attacking java servlet containers, stay tuned!

ハッキングブログを初めることにしました。普通のブログの違いは英語、日本語ともに書きます。僕の日本語あまりよくないので時間かかったり、間違えたりするので、英語のほうを読んだらいいと思います。はじめに、j2eeとjavaサーブレットコンテナの攻撃方法を書いていこうと思います。Stay tuned!