《re:从零开始的java逆向基础》#4静态变量存取
本帖最后由 Lightcolour 于 2019-9-21 14:38 编辑static 静态变量可以随便赋值 而final 不能 LCG算法实现例子(来源于网络) public class LCG{public static int rand_state;public void my_srand (int init){rand_state=init;}public static int RNG_a=1664525;public static int RNG_c=1013904223;public int my_rand (){rand_state=rand_state*RNG_a;rand_state=rand_state+RNG_c;return rand_state & 0x7fff;}} 编译 LCG.java 反编译 static {}; descriptor: ()V flags: ACC_STATIC Code: stack=1, locals=0, args_size=0 0: ldc #5 // int 1664525 2: putstatic #3 // Field RNG_a:I 5: ldc #6 // int 1013904223 7: putstatic #4 // Field RNG_c:I 10: return LineNumberTable: line 8: 0 line 9: 5} ldc #5 取常量1664525压栈putstatic #3 从栈中取值存入变量RNG_a:I中ldc #6 取常量1013904223压栈putstatic#4从栈中取值存入变量RNG_C:I中初始化看看my_srand public voidmy_srand(int); descriptor:(I)V flags:ACC_PUBLIC Code: stack=1,locals=2, args_size=2 0: iload_1 1:putstatic #2 // Field rand_state:I 4: return iload_1将参数值压入栈 为什么不是iload_0?看看上面的LCG()已经被使用过了 public LCG(); descriptor: ()V flags:ACC_PUBLIC Code: stack=1,locals=1, args_size=1 0: aload_0 1:invokespecial #1 // Methodjava/lang/Object."<init>":()V 4: return putstatic 从栈中取值存入rand_state:I中 看看my_rand Code: stack=2,locals=1, args_size=1 0:getstatic #2 // Field rand_state:I 3:getstatic #3 // Field RNG_a:I 6: imul 7:putstatic #2 // Field rand_state:I 10:getstatic #2 // Field rand_state:I 13:getstatic #4 // Field RNG_c:I 16: iadd 17:putstatic #2 // Field rand_state:I 20:getstatic #2 // Field rand_state:I 23:sipush 32767 26: iand 27: ireturn getstatic 取值imui 乘iadd加ireturn 返回值本集资源
**** Hidden Message ***** 你将受到所有人的崇拜! 感谢分享呀 [快捷回复]-学破解防逆向,知进攻懂防守! 感谢大佬分享 学习大佬操作 感谢楼主
[快捷回复]-软件反汇编逆向分析,软件安全必不可少! 大佬无敌 谢谢分享