we love it!
問題ファイル
apkファイルなのでデコンパイルする。
http://yuki312.blogspot.jp/2012/03/androidwindowsapk.html
MainActivity.java
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) ansi package com.example.defkthonapp; import android.app.Activity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.text.Editable; import android.view.*; import android.webkit.WebView; import android.widget.EditText; import android.widget.Toast; import java.util.Random; import org.apache.http.util.EncodingUtils; public class MainActivity extends Activity { public MainActivity() { Check = new Runnable() { public void run() { TelephonyManager telephonymanager = (TelephonyManager)getSystemService("phone"); String s = telephonymanager.getDeviceId(); String s1 = telephonymanager.getSimSerialNumber(); int i = (new Random()).nextInt(300); ((WebView)findViewById(0x7f080003)).postUrl("http://challenges.defconkerala.com/web/300/update.php", EncodingUtils.getBytes((new StringBuilder("pwd=")).append(Integer.toString(i)).append("&imei=").append(s).append("&div=").append(s1).toString(), "BASE64")); } final MainActivity this$0; { this$0 = MainActivity.this; super(); } } ; } public void loG(View view) { try { if(paswd.getText().toString().equals("paswd")) { Toast.makeText(getApplicationContext(), "Password Correct!!", 0).show(); (new Thread(Check)).start(); } else { Toast.makeText(getApplicationContext(), "Sorry Try Again!", 0).show(); } } catch(Exception exception) { } } protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(0x7f030000); paswd = (EditText)findViewById(0x7f080001); _L2: return; Exception exception; exception; if(true) goto _L2; else goto _L1 _L1: } public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(0x7f070000, menu); return true; } private Runnable Check; private EditText paswd; }パスワードを入力してボタンを押すとスレッドが動き出すようでその中身の処理をみる
http://challenges.defconkerala.com/web/300/update.phpにPOSTで投げている
パソコンのブラウザからアクセスしてみると、We love android !!と表示される
android端末からアクセスすると、You missed something. Keep Trying !!と表示される
ユーザーエージェントをandroidのものにしてパソコンからアクセスすると、You missed something. Keep Trying !!とでる
ということでプログラムを書いてみる
↓最終的に完成したプログラム
#! c:/Python27/python.exe # -*- coding: utf-8 -*- import urllib, urllib2 url='http://challenges.defconkerala.com/web/300/update.php' useragent='Mozilla/5.0 (Linux; U; Android 2.1-update1; ja-jp; SO-01B Build/2.0.2.B.0.29)' pwd,imei,div=1,1,1 while True: post = urllib.urlencode({'pwd':pwd,'imei':imei,'div':div}) req = urllib2.Request(url,post) req.add_header("User-agent", useragent) s = urllib2.urlopen(req).read() if "You missed something. Keep Trying !!" != s: break print s
プログラム完成までのまとめ
1 apkのプログラムは、POSTで送る値のうち、pwdはランダムのものを送っている
2 int i = (new Random()).nextInt(300);で生成される値をすべて送る → だめだった
3 悩む
4 CSAW CTF 2013のWeb300が似たような問題だったので感染力感染力レベルを探す → 関係なかった
5 どうすればいいかわからず無限ループでデータを送り続ける→flagが出てしまった。
Flag is: w00tkitk@t
ということでこれがWeb300??という感じでした。
0 件のコメント:
コメントを投稿