昨晚在论坛上看到一个网友说给Listary写了一个注册机,并且给出了源代码。
虽然他是必备的装机软件之一,但是我之前都没去关注它,因为网上都有现成的注册信息。
看到网友写了两份不同的代码我也就来了点兴趣,看到这东西居然是VB.Net写的而且没加壳,所以就自己用dnspy看了一下相关的反编译代码
这东西的注册码算法真是简单的一批啊。难怪那么容易就被玩坏了。
有了注册码算法,直接刚注册机了。
一、下面是我用rust写的注册机
1.1、添加rand库跟clap库
cargo add rand cargo add clap
1.2、拷贝下面的代码到main.rs
use rand::Rng; use clap::{Command, Arg}; fn hash1(a: &str) -> u32 { let mut num: u32 = 0; for c in a.chars() { num = num.wrapping_mul(43) + c as u32; } num } fn hash2(a: &str) -> u32 { let mut num: u32 = 0; for c in a.chars() { num = (num << 4) + c as u32; let num2 = num & 0xF000_0000; if num2 != 0 { num ^= num2 >> 24; num ^= num2; } } num } fn get_license(email: &str) -> String { let alpha_numeric = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; let num = ((hash1(email) as u64) << 32) + hash2(email) as u64; let mut license = String::new(); for i in 0..12 { let index = ((num >> (64 - (i + 1) * 5)) & 31) as usize; license.push(alpha_numeric.chars().nth(index).unwrap()); } let mut rng = rand::thread_rng(); let mut text = String::new(); for i in 0..192 { if i == 172 { text = format!("{}{}", &text[..160], &license); } text.push(alpha_numeric.chars().nth(rng.gen_range(0..alpha_numeric.len())).unwrap()); } text } fn main() { let args = Command::new("listary") .version("1.0") .author("Mr.D <[email protected]>") .about("Listary 6.X 注册机") .arg( Arg::new("email") .short('e') .long("email") ) .get_matches(); let email = args.get_one::<String>("email").expect("required"); println!("{}", listarykeygen::get_license(email)); }
1.3、编译
cargo build
1.4、运行
keygen.exe --email [email protected] 或者 keygen.exe -e [email protected]
二、网友写的C#版注册机
using System; public class Program { private static uint hash1(string a) { uint num = 0U; foreach (char c in a) { num = 43U * num + (uint)c; } return num; } private static uint hash2(string a) { uint num = 0U; foreach (char c in a) { num = (num << 4) + (uint)c; uint num2 = num & 4026531840U; if (num2 != 0U) { num ^= num2 >> 24; num ^= num2; } } return num; } public static string getLicense(string email) { string ALPHA_NUMERIC = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; ulong num = ((ulong)hash1(email) << 32) + (ulong)hash2(email); string license = ""; for (int i = 0; i < 12; i++) { int index = (int)(num >> 64 - (i + 1) * 5) & 31; license += ALPHA_NUMERIC[index]; } Random random = new Random(); string text = ""; for (int i = 0; i < 192; i++) { if (i == 172) { text = text.Substring(0, 160) + license; } text += ALPHA_NUMERIC[random.Next(0, ALPHA_NUMERIC.Length)]; } return text; } public static void Main() { string email = "[email protected]"; string license = getLicense(email); Console.WriteLine(license); } }
三、网友写的Python版注册机
3.1、安装numpy库
pip install numpy
3.2、新建一个listarykeygen.py,写入以下代码
import numpy as np import random def hash1(a: str) -> np.uint32: num = np.uint32(0) for c in a: num = np.uint32(43) * num + np.uint32(ord(c)) return num def hash2(a: str) -> np.uint32: num = np.uint32(0) for c in a: num = (num << np.uint32(4)) + np.uint32(ord(c)) num2 = num & np.uint32(4026531840) if num2 != np.uint32(0): num ^= num2 >> np.uint32(24) num ^= num2 return num def getLicense(email: str) -> str: ALPHA_NUMERIC = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ" num = np.uint64(hash1(email)) << np.uint64(32) | np.uint64(hash2(email)) license = "" for i in range(12): index = int((num >> np.uint64(64 - (i + 1) * 5)) & np.uint64(31)) license += ALPHA_NUMERIC[index] random.seed() text = "" for i in range(192): if i == 172: text = text[:160] + license text += ALPHA_NUMERIC[np.random.randint(0, len(ALPHA_NUMERIC))] return text email = "[email protected]" license = getLicense(email) print(license)
3.3、listarykeygen.py同目录下输入
python listarykeygen.py