首页
社区
课程
招聘
[原创]第五题 交响曲
2018-12-9 21:21 2212

[原创]第五题 交响曲

2018-12-9 21:21
2212
将classes.dex用jadx打开:
package cn.kwaiching.crackme;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class CrackMe extends AppCompatActivity {
    int[] a = new int[]{16, 6, 7, 10, 9, 16, 10, 8, 8, 9, 6, 6};
    int[] b = new int[]{5, 10, 8, 15, 16, 15, 8, 16, 8, 16, 9, 17, 8, 17, 10, 8, 9, 18, 5, 15, 10, 9, 8, 9, 15, 18, 7, 8, 16, 6};
    int[] c = new int[]{6, 7, 18, 9, 5, 16, 9, 15, 18, 8, 9, 5};
    int[] d = new int[]{7, 7, 9, 12, 8, 7, 13, 5, 14, 5, 9, 17, 5, 7, 12, 8, 8, 6, 19, 6, 8, 16, 10, 6, 12, 9, 6, 7, 12, 5, 9, 8, 7, 8, 15, 9, 16, 8, 8, 19, 12, 6, 8, 7, 5, 15, 6, 16, 15, 7, 9, 12, 10, 7, 15, 6, 5, 14, 14, 9};
    int e;
    int f;
    int g;
    int h;
    int i;
    int j;
    int k;
    String[] l = new String[73];
    String[] m = new String[]{"23to01", "01to03", "03to05", "05to07", "07to09", "09to11", "11to13", "13to15", "15to17", "17to19", "19to21", "21to23"};
    TextView n;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.activity_fate_me);
        b();
        this.n = (TextView) findViewById(R.id.fate);
        ((Button) findViewById(R.id.ok)).setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                try {
                    CrackMe.this.a();
                } catch (Exception unused) {
                    CrackMe.this.n.setText(CrackMe.this.getString(R.string.notMe));
                }
            }
        });
    }

    private void a() {
        try {
            c();
            if (this.j == 0 || this.i == 0 || this.h == 0) {
                this.n.setText(getString(R.string.notMe));
                return;
            }
            d();
            a(((e() + f()) + g()) + h());
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
        }
    }

    private void b() {
        for (int i = 0; i <= 72; i++) {
            if (i != 34) {
                this.l[i] = getResources().getString(R.string.success00);
            } else {
                this.l[i] = getResources().getString(R.string.success34);
            }
        }
    }

    private void c() {
        try {
            String obj = ((EditText) findViewById(R.id.code)).getText().toString();
            this.j = 0;
            this.i = 0;
            this.h = 0;
            this.j = Integer.parseInt(obj.length() > 4 ? obj.substring(0, 4) : obj);
            if (this.j > 0 && this.j < 189) {
                this.j = 0;
            }
            if (this.j <= 1983 || this.j >= 2007) {
                this.j = 0;
            }
            this.i = Integer.parseInt(obj.length() > 6 ? obj.substring(4, 6) : obj);
            if (this.i < 1 || this.i > 12) {
                this.i = 0;
            }
            if (obj.length() > 8) {
                obj = obj.substring(6, 8);
            }
            this.h = Integer.parseInt(obj);
            if (this.h < 1 || this.h > 31) {
                this.h = 0;
            }
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
        }
    }

    private void d() {
        try {
            if (this.j == 1989 || this.j == 2004) {
                this.h = 31;
            }
            if (this.i == 1 || this.i == 4 || this.i == 5 || this.i == 7 || this.i == 10 || this.i == 11 || this.i == 12) {
                this.j = 1999;
            }
            if (this.j <= 1994 && (this.i == 2 || this.i == 6 || this.i == 8)) {
                this.i = 3;
            }
            if (this.j >= 1996 && (this.i == 2 || this.i == 6 || this.i == 8)) {
                this.i = 9;
            }
            if (this.j == 1995 && (this.h > this.i + 2 || this.i == this.h)) {
                this.i = 6;
            }
            this.g = this.j;
            this.f = this.i;
            this.e = this.h;
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
        }
    }

    private void a(int i) {
        if (i > 34 || i < 34) {
            this.n.setText(getString(R.string.notMe));
            return;
        }
        try {
            this.n.setText(String.format("%s%s", new Object[]{getString(R.string.me), this.l[i]}));
            ((Button) findViewById(R.id.ok)).setEnabled(false);
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
        }
    }

    private int e() {
        try {
            return this.d[(this.g - 1900) % 60];
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
            return 0;
        }
    }

    private int f() {
        try {
            return this.c[this.f - 1];
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
            return 0;
        }
    }

    private int g() {
        try {
            return this.b[this.e - 1];
        } catch (Exception unused) {
            this.n.setText(getString(R.string.notMe));
            return 0;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0050 A:{Catch:{ Exception -> 0x005c }} */
    private int h() {
        /*
        r6 = this;
        r0 = 2131165227; // 0x7f07002b float:1.7944665E38 double:1.0529355243E-314;
        r1 = 2131427370; // 0x7f0b002a float:1.8476354E38 double:1.05306504E-314;
        r2 = 0;
        r0 = r6.findViewById(r0);	 Catch:{ Exception -> 0x005c }
        r0 = (android.widget.EditText) r0;	 Catch:{ Exception -> 0x005c }
        r0 = r0.getText();	 Catch:{ Exception -> 0x005c }
        r0 = r0.toString();	 Catch:{ Exception -> 0x005c }
        r3 = 8;
        r4 = r0.length();	 Catch:{ Exception -> 0x005c }
        r0 = r0.substring(r3, r4);	 Catch:{ Exception -> 0x005c }
        r3 = r6.f;	 Catch:{ Exception -> 0x005c }
        r4 = 0;
    L_0x0022:
        r5 = r6.m;	 Catch:{ Exception -> 0x005c }
        r5 = r5.length;	 Catch:{ Exception -> 0x005c }
        if (r4 >= r5) goto L_0x004d;
    L_0x0027:
        r5 = r6.m;	 Catch:{ Exception -> 0x005c }
        r5 = r5[r4];	 Catch:{ Exception -> 0x005c }
        r5 = r0.equals(r5);	 Catch:{ Exception -> 0x005c }
        if (r5 == 0) goto L_0x004a;
    L_0x0031:
        r5 = 2;
        if (r3 != r5) goto L_0x0042;
    L_0x0034:
        r3 = r6.m;	 Catch:{ Exception -> 0x005c }
        r5 = 6;
        r3 = r3[r5];	 Catch:{ Exception -> 0x005c }
        r0 = r0.equals(r3);	 Catch:{ Exception -> 0x005c }
        if (r0 == 0) goto L_0x0042;
    L_0x003f:
        r0 = 63;
        return r0;
    L_0x0042:
        r0 = r6.a;	 Catch:{ Exception -> 0x005c }
        r0 = r0[r4];	 Catch:{ Exception -> 0x005c }
        r6.k = r0;	 Catch:{ Exception -> 0x005c }
        r0 = 1;
        goto L_0x004e;
    L_0x004a:
        r4 = r4 + 1;
        goto L_0x0022;
    L_0x004d:
        r0 = 0;
    L_0x004e:
        if (r0 != 0) goto L_0x0059;
    L_0x0050:
        r0 = r6.n;	 Catch:{ Exception -> 0x005c }
        r3 = r6.getString(r1);	 Catch:{ Exception -> 0x005c }
        r0.setText(r3);	 Catch:{ Exception -> 0x005c }
    L_0x0059:
        r0 = r6.k;	 Catch:{ Exception -> 0x005c }
        return r0;
    L_0x005c:
        r0 = r6.n;
        r1 = r6.getString(r1);
        r0.setText(r1);
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: cn.kwaiching.crackme.CrackMe.h():int");
    }
}

基本上相当于直接得到源码了(只有h()函数没完全解析,不过不影响理解)
通过c()函数不难看出注册码前八位是一个1984到2006年的日期,然后使用d()函数用一些规则对这个日期进行一些处理,因此实际能取到的日期很有限
再看h()函数可知注册码后半部分为m数组中的一个字符串,最终注册码为:year+month+day+string  四部分组成
判断注册码正确的条件为:将year%60、month-1、day-1、string在m中的位置分别作为索引从数组d、c、b、a取四个值相加为34
因此简单遍历下所有日期即可得到注册码:
public class solve {
	
    static int[] a = new int[]{16, 6, 7, 10, 9, 16, 10, 8, 8, 9, 6, 6};
    static int[] b = new int[]{5, 10, 8, 15, 16, 15, 8, 16, 8, 16, 9, 17, 8, 17, 10, 8, 9, 18, 5, 15, 10, 9, 8, 9, 15, 18, 7, 8, 16, 6};
    static int[] c = new int[]{6, 7, 18, 9, 5, 16, 9, 15, 18, 8, 9, 5};
    static int[] d = new int[]{7, 7, 9, 12, 8, 7, 13, 5, 14, 5, 9, 17, 5, 7, 12, 8, 8, 6, 19, 6, 8, 16, 10, 6, 12, 9, 6, 7, 12, 5, 9, 8, 7, 8, 15, 9, 16, 8, 8, 19, 12, 6, 8, 7, 5, 15, 6, 16, 15, 7, 9, 12, 10, 7, 15, 6, 5, 14, 14, 9};
    static String[] m = new String[]{"23to01", "01to03", "03to05", "05to07", "07to09", "09to11", "11to13", "13to15", "15to17", "17to19", "19to21", "21to23"};

    static int day;
    static int month;
    static int year;
    static int str;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("start");
		for(int i1 = 1984;i1 <= 2006;i1++)
		{
			if(i1 == 1989 || i1 == 2004)
				continue;
			for(int i2 = 1;i2 <= 12;i2++)
			{
				for(int i3 = 1;i3 <= 30;i3++)
				{
					for(int i4 = 1;i4 <= 12;i4++)
					{
						year = i1;month = i2; day = i3;str = i4;
						check();
						if((d[(year-1900)%60] + c[month-1] + b[day-1] + a[str-1]) == 34)
						{
							System.out.println("sn:"+i1+i2+i3+m[i4-1]);
						}
					}

				}
				
			}
		}
		System.out.println("end");	
		
	}
	
	
	private static void check()
	{
        if (month == 1 || month == 4 || month == 5 || month == 7 || month == 10 || month == 11 || month == 12) {
        	year = 1999;
        }
        if (year <= 1994 && (month == 2 || month == 6 || month == 8)) {
        	month = 3;
        }
        if (year >= 1996 && (month == 2 || month == 6 || month == 8)) {
        	month = 9;
        }
        if (year == 1995 && (day > month + 2 || month == day)) {
        	month = 6;
        }

	}

}
输出结果:
start
sn:19952305to07
sn:19952311to13
end
有两个结果,分别试一下,第一个是正确的(其实仔细看一下h()函数可以发现字符串为11to13的情况被排除了)
最终注册码为:1995020305to07(月日都是个位数,因此前面要加个0)

算法复杂的题一个都不会,想放弃了QAQ

[培训]《安卓高级研修班(网课)》月薪三万计划

收藏
点赞1
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回