-
-
[原创] 看雪 ctf 攻防战 2018 - 交响曲
-
2018-12-11 09:16 2300
-
android 题目
下了个最新版的 dex2jar 转成 java 在 jd-gui 上看
分析
逻辑还是挺清晰的, 输入一个字符串然后判断正确与否的形式,有回显
总体流程如下
private void a() { try { c(); if ((this.j != 0) && (this.i != 0) && (this.h != 0)) { d(); a(e() + f() + g() + h()); return; } this.n.setText(getString(2131427370)); } catch (Exception localException) { this.n.setText(getString(2131427370)); } }
- c() : 获取输入
- d() : 对输入进行变换
- e(),f(),g(),h() : 各个字段的变换
- a(num) : 校验函数
下面一个一个看
c()
private void c() { try { String str1 = ((EditText)findViewById(2131165227)).getText().toString(); this.j = 0; this.i = 0; this.h = 0; // input[0:4] if (str1.length() > 4) { str2 = str1.substring(0, 4); } else { str2 = str1; } this.j = Integer.parseInt(str2); if ((this.j > 0) && (this.j < 189)) { this.j = 0; } if ((this.j <= 1983) || (this.j >= 2007)) { this.j = 0; } //input[4:6] if (str1.length() > 6) { str2 = str1.substring(4, 6); } else { str2 = str1; } this.i = Integer.parseInt(str2); if ((this.i < 1) || (this.i > 12)) { this.i = 0; } String str2 = str1; //input[6:8] if (str1.length() > 8) { str2 = str1.substring(6, 8); } this.h = Integer.parseInt(str2); if ((this.h < 1) || (this.h > 31)) { this.h = 0; } } catch (Exception localException) { this.n.setText(getString(2131427370)); } }
c() 函数主要就是获取输入的字符串,并分段进行检验,结合后面的函数可以知道输入大概是
jjjjiihhmmmmmm
具体的校验如下
- jjjj : 四个字符长度,转换成 int 范围[1983,2007]
- ii : 两个字符, 转换成 int [1,12]
hh : 两个字符, 转换成 int [1,31]
mmmmmm 需要看后面的函数
上面的 e(), f(),g(),h() 函数分别是对这四个字段的变换
e() ==> jjjj
f() ==> ii
g() ==> hh
h() ==> mmmmmmm
大概都是差不多的形式,定义了一个 表,然会将输入的字段作为index 查表做返回值,比如 e()private int e() { try { int i1 = this.g; i1 = this.d[((i1 - 1900) % 60)]; return i1; } catch (Exception localException) { this.n.setText(getString(2131427370)); } return 0; }
(jjjj-1900)%60 作为 index , d[index] 作为返回值
mmmmmm 根据h() 函数可以确定是一个字符串,是一个表里面的值String[] m = { "23to01", "01to03", "03to05", "05to07", "07to09", "09to11", "11to13", "13to15", "15to17", "17to19", "19to21", "21to23" };
最后的 checker 检查的是 e()+f()+g()+h() 返回值是否 等于 34
private void a(int paramInt) { if ((paramInt <= 34) && (paramInt >= 34)) {} try { this.n.setText(String.format("%s%s", new Object[] { getString(2131427369), this.l[paramInt] })); ((Button)findViewById(2131165273)).setEnabled(false); } catch (Exception localException) { this.n.setText(getString(2131427370)); } this.n.setText(getString(2131427370)); }
到了这里其实已经可以解了,因为输入的字段的搜索空间都不会很大
2007-1983=24,len(m)=12
24*12*31*12 完全可以写个脚本爆破一下
也可以人力的算一下,之前写的脚本丢了,上班摸鱼就先写到这里吧,后面的大家都懂了:)
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
看原图