首页
社区
课程
招聘
[原创]crakeme1解题思路
2015-1-23 03:18 2151

[原创]crakeme1解题思路

2015-1-23 03:18
2151
1.用jeb反编译程序
package com.example.simpleencryption;

import android.app.Activity;
import android.app.AlertDialog$Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface$OnClickListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View$OnClickListener;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class MainActivity extends Activity {
    public MainActivity() {
        super();
    }

    static String access$0(String arg1, byte[] arg2) {
        return MainActivity.bytesToAliSmsCode(arg1, arg2);
    }

    static void access$1(MainActivity arg0) {
        arg0.showDialog();
    }

    private static byte[] aliCodeToBytes(String codeTable, String strCmd) {
        byte[] v1 = new byte[strCmd.length()];
        int v2;
        for(v2 = 0; v2 < strCmd.length(); ++v2) {
            v1[v2] = ((byte)codeTable.indexOf(strCmd.charAt(v2)));
        }

        return v1;
    }

    private static String bytesToAliSmsCode(String table, byte[] data) {
        StringBuilder v1 = new StringBuilder();
        int v0;
        for(v0 = 0; v0 < data.length; ++v0) {
            v1.append(table.charAt(data[v0] & 255));
        }

        return v1.toString();
    }

    protected String getPwdFromPic() {
        String v6;
        InputStream v3;
        String v5 = "";
        try {
            v3 = this.getResources().getAssets().open("logo.png");
            int v4 = v3.available();
            byte[] v0 = new byte[v4];
            v3.read(v0, 0, v4);
            byte[] v1 = new byte[18];
            System.arraycopy(v0, 91265, v1, 0, 18);
            v6 = new String(v1, "utf-8");
            if(v3 == null) {
                return v6;
            }
        }
        catch(Throwable v7) {
        label_30:
            if(v3 != null) {
                try {
                    v3.close();
                }
                catch(IOException v8) {
                }
            }

            throw v7;
        }
        catch(Exception v2) {
            try {
                v2.printStackTrace();
                if(v3 == null) {
                    return v5;
                }
            }
            catch(Throwable v7) {
                goto label_30;
            }

            try {
                v3.close();
            }
            catch(IOException v7_1) {
            }

            return v5;
        }

        try {
            v3.close();
            v5 = v6;
        }
        catch(IOException v7_1) {
            v5 = v6;
        }

        return v5;
    }

    protected String getTableFromPic() {
        String v6;
        InputStream v3;
        String v5 = "";
        try {
            v3 = this.getResources().getAssets().open("logo.png");
            int v4 = v3.available();
            byte[] v0 = new byte[v4];
            v3.read(v0, 0, v4);
            byte[] v1 = new byte[768];
            System.arraycopy(v0, 89473, v1, 0, 768);
            v6 = new String(v1, "utf-8");
            if(v3 == null) {
                return v6;
            }
        }
        catch(Throwable v7) {
        label_30:
            if(v3 != null) {
                try {
                    v3.close();
                }
                catch(IOException v8) {
                }
            }

            throw v7;
        }
        catch(Exception v2) {
            try {
                v2.printStackTrace();
                if(v3 == null) {
                    return v5;
                }
            }
            catch(Throwable v7) {
                goto label_30;
            }

            try {
                v3.close();
            }
            catch(IOException v7_1) {
            }

            return v5;
        }

        try {
            v3.close();
            v5 = v6;
        }
        catch(IOException v7_1) {
            v5 = v6;
        }

        return v5;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(1);
        this.setContentView(2130903064);
        this.findViewById(2131034174).setOnClickListener(new View$OnClickListener() {
            public void onClick(View v) {
                String v3 = this.val$edit.getText().toString();
                String v5 = MainActivity.this.getTableFromPic();
                String v4 = MainActivity.this.getPwdFromPic();
                Log.i("lil", "table:" + v5);
                Log.i("lil", "pw:" + v4);
                try {
                    String v2 = MainActivity.bytesToAliSmsCode(v5, v3.getBytes("utf-8"));
                    Log.i("lil", "enPassword:" + v2);
                }
                catch(UnsupportedEncodingException v1) {
                    v1.printStackTrace();
                }

                if(v4 == null || (v4.equals("")) || !v4.equals(v2)) {
                    AlertDialog$Builder v0 = new AlertDialog$Builder(MainActivity.this);
                    v0.setMessage(2131361809);
                    v0.setTitle(2131361808);
                    v0.setPositiveButton(2131361811, new DialogInterface$OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    v0.show();
                }
                else {
                    MainActivity.this.showDialog();
                }
            }
        });
    }

    private void showDialog() {
        AlertDialog$Builder v0 = new AlertDialog$Builder(((Context)this));
        v0.setMessage(2131361810);
        v0.setTitle(2131361808);
        v0.setPositiveButton(2131361811, new DialogInterface$OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        v0.show();
    }
}
很容易看到原码。
然后阅读源代码知道程序要求出一串下标。
自己写程序读出两张表。
        //获取字符串
        String strTable="";
        InputStream v3;
        InputStream v5;
            try
            {
                v3 = this.getResources().getAssets().open("logo.png");
                int v4 = v3.available();
                byte[] v0 = new byte[v4];
                v3.read(v0, 0, v4);
                byte[] v1 = new byte[768];
                System.arraycopy(v0, 89473, v1, 0, 768);
                strTable = new String(v1, "utf-8");
            } catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Log.i("lil", "table:" + strTable);
            
            String strPass="";
            try
            {
                v5 = getResources().getAssets().open("logo.png");
                int v4 = v5.available();
                byte[] v0 = new byte[v4];
                v5.read(v0, 0, v4);
                byte[] v1 = new byte[18];
                System.arraycopy(v0, 91265, v1, 0, 18);
                strPass = new String(v1, "utf-8");
            } catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Log.i("lil", "pw:" + strPass);

都出来是这样的。:
table:
一乙二十丁厂七卜人入八九几儿了力乃刀又三
于干亏士工土才寸下大丈与万上小口巾山千乞
川亿个勺久凡及夕丸么广亡门义之尸弓己已子
卫也女飞刃习叉马乡丰王井开夫天无元专云扎
艺木五支厅不太犬区历尤友匹车巨牙屯比互切
瓦止少日中冈贝内水见午牛手毛气升长仁什片
仆化仇币仍仅斤爪反介父从今凶分乏公仓月氏
勿欠风丹匀乌凤勾文六方火为斗忆订计户认心
尺引丑巴孔队办以允予劝双书幻玉刊示末未击
打巧正扑扒功扔去甘世古节本术可丙左厉右石
布龙平灭轧东卡北占业旧帅归且旦目叶甲申叮
电号田由史只央兄叼叫另叨叹四生失禾丘付仗
代仙们仪白仔他斥瓜乎丛令用甩印乐

pw:义弓么丸广之
在table中查找pw的位置。
得到下标:053 056 049 048 050 054
上边下标是utf_8编码 转成数字是581026 就是答案。

[培训]内核驱动高级班,冲击BAT一流互联网大厂工 作,每周日13:00-18:00直播授课

收藏
点赞0
打赏
分享
最新回复 (1)
雪    币: 3003
活跃值: (464)
能力值: ( LV15,RANK:1395 )
在线值:
发帖
回帖
粉丝
lacoucou 12 2015-1-25 15:44
2
0
好吧,经过三天的比赛总算 入门了。
在虚拟机里运行程序,在DDMS 中就可以看到结果:

下边就是求下标了。
求出下标:053 056 049 048 050 054
这是UTF_8的编码,对应的数值是:5 8 1 0 2 6
上传的附件:
游客
登录 | 注册 方可回帖
返回