一、前言
有的软件加入了注册机需要注册码才可以使用,修改的话有的软件有加固针对强度高的又让部分人无法重打包,HOOK有检测,没root等问题。那么如果针对本地注册机我们可以分析他的算法来编写一个注册机进行注册使用。
二、工具
1.某app
2.jadx
3.idea
三、流程
首先我们打开软件随便输入一个就能看到他提示注册失败
 ![]./a1.png)
![]./a1.png)
软件有加固,我这边就不多说了直接扔到脱壳网站上传脱壳就行,脱壳完的的dex全部拖到jadx,然后直接搜索注册失败


在这个代码中可以看到判断前就是他的注册码计算流程,第一个判断
| 1
 | BigInteger(MD5.md5String(String.valueOf(Util.this.machine) + intValue), 16).toString().substring(0, 5);
 | 
是验证了注册码是否过期,说明这个是带时间限制的判断,第二个
| 1
 | BigInteger(MD5.md5String(String.valueOf(Util.this.machine) + Util.this.ps), 16).toString().substring(0, 8);
 | 
则是注册成并没有到期限制,说明这个是无限制,我这边直接拿他的无限制注册算法就行。
根据他的代码得出注册是machine(机器码)和ps 拼接后,进行MD5生成取 MD5 中间 16 位,将这 16 位十六进制字符串转换为 BigInteger 对象。从 BigInteger 对象的十进制字符串表示中截取前 8 位就是他的注册码了。
搜索一下 String ps

然后搜索得到ps值是xcheck225。我这边搞了一个代码
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 
 | import java.math.BigInteger;import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
 public class Main {
 
 public static void main(String[] args) {
 
 String machineCode = "38dec90d";
 String registrationCode = generateRegistrationCode(machineCode);
 System.out.println("注册码: " + registrationCode);
 }
 
 public static String generateRegistrationCode(String machineCode) {
 
 String input = machineCode + "xcheck225";
 
 String md5Hash = getMD5(input);
 
 
 String middlePart = md5Hash.substring(8, 24);
 
 
 BigInteger middlePartBI = new BigInteger(middlePart, 16);
 
 
 String registrationCode = middlePartBI.toString().substring(0, 8);
 
 return registrationCode;
 }
 
 private static String getMD5(String input) {
 try {
 MessageDigest md = MessageDigest.getInstance("MD5");
 byte[] messageDigest = md.digest(input.getBytes());
 BigInteger no = new BigInteger(1, messageDigest);
 String hashtext = String.format("%032x", no);
 return hashtext;
 } catch (NoSuchAlgorithmException e) {
 throw new RuntimeException("not found", e);
 }
 }
 }
 
 | 

我这边idea运行一下生成注册码。结果是注册码: 14005263。结果也是注册成功的

然后也是简单写了一个注册机app。

四、小结
本文比较简单小白向,为初学者提供一个逆向分析注册码生成的流程,有助于理解软件破解的基本原理和方法。
声明这个软件也是别人求助的,然后我这边也把注册机提取出来了可供参考学习,原调用被加固抽调了,根据samli代码分析,写一个调用也能完成这个注册机调用
| 12
 3
 4
 5
 6
 7
 
 | new-instance v0, Lxh/L/Util;
 
 invoke-direct {v0, p0}, Lxh/L/Util;-><init>(Landroid/app/Activity;)V
 
 invoke-virtual {v0}, Lxh/L/Util;->check()V
 
 
 | 
即可调用
下面附上原注册机dex和app源码