求:通过机器码获得注册码的完整方案(700分,不够可加)(100分)

  • 主题发起人 oceanwave
  • 开始时间
O

oceanwave

Unregistered / Unconfirmed
GUEST, unregistred user!
想加密自己的软件,看过一些软件的作法,思路如下:
1、用户安装后,得出本机的机器码(硬盘的序列号,不想用网卡,因为很多机器没有网
卡)。生成机器码代码,150分
2、用户将该机器码EMAIL给我,我用该机器码生成一个注册码,发送给用户。注册码生成
代码,150分
3、用户在程序中输入该注册码,程序逆算该注册码,与机器码核对,查看是否相符。注册
码逆算、核对代码,150分。
4、如果用户安装后没有得到注册码,在N天后部分功能不可用。不要太容易被改(虽然说
安装后也只有少部份功能能用)。时限功能代码,150分。
其余100分,参与者有分。
先出100,其余分另开贴给。谢谢!
 
function GetHDNumber(Drv : String): DWORD; //得到硬盘序列号
var
VolumeSerialNumber : DWORD;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
begin
if Drv[Length(Drv)] =':' then Drv := Drv + '/';
GetVolumeInformation(pChar(Drv),
nil,
0,
@VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
Result:= (VolumeSerialNumber);

end;

function Serial(Num:DWORD):string; //这个号码是用户给你生成注册码的,它通过对硬盘序列号编码而来。
var sNum:string; inChar:array[1..4]of char;
begin

Num:=Num xor 8009211011;
sNum:=inttostr(Num);
inChar[1]:=char(((integer(sNum[1])+integer(sNum[2]))mod 5)+integer('a'));
inChar[2]:=char(((integer(sNum[3])+integer(sNum[4]))mod 5)+integer('a'));
inChar[3]:=char(((integer(sNum[5])+integer(sNum[6]))mod 5)+integer('a'));
inChar[4]:=char(((integer(sNum[7])+integer(sNum[8])+integer(sNum[9]))mod 5)+integer('a'));
insert(inChar[1],sNum,1);
insert(inChar[4],sNum,3);
insert(inChar[2],sNum,5);
insert(inChar[3],sNum,9);
Result:=sNum;

end;

function encode(License:string):string;
var str,sNum:string; number:dword; byte,byte1:array[1..4]of dword;
inChar:array[1..3]of char;
begin
str:=license;
delete(str,1,1);
delete(str,2,1);
delete(str,3,1);
delete(str,6,1);
number:=strtoint64(str);
number:=not number;
number:=number xor $1973122980;
byte[1]:=(number and $0ff000000) shr 24;
byte[2]:=(number and $0ff0000) shr 16;
byte[3]:=(number and $0ff00) shr 8;
byte[4]:=(number and $0ff);

byte1[1]:=((byte[1]and $0c0)+(byte[2]and $0c0)shr 2)+((byte[3]and $0c0)shr 4)+((byte[4]and $0c0)shr 6);
byte1[2]:=((byte[1]and $30)shl 2)+(byte[2]and $30)+((byte[3]and $30)shr 2)+((byte[4]and $30)shr 4);
byte1[3]:=((byte[1]and $0c)shl 4)+((byte[2]and $0c)shl 2)+(byte[3]and $0c)+((byte[4]and $0c)shr 2);
byte1[4]:=((byte[1]and $03)shl 6)+((byte[2]and $03)shl 4)+((byte[3]and $03)shl 2)+(byte[4]and $03);
number:=((byte1[1])shl 24)+((byte1[2])shl 16)
+((byte1[3])shl 8)+(byte1[4]);

byte[1]:=((number and $0ff000000)shr 24);//右移24位
byte[2]:=((number and $0ff0000)shr 16);
byte[3]:=((number and $0ff00)shr 8);
byte[4]:=(number and $0ff);

byte[1]:=(((byte[1] and $f0))shr 4)+(((byte[1] and $0f))shl 4);
byte[2]:=(((byte[2] and $f0))shr 4)+(((byte[2] and $0f))shl 4);
byte[3]:=(((byte[3] and $f0))shr 4)+(((byte[3] and $0f))shl 4);
byte[4]:=(((byte[4] and $f0))shr 4)+(((byte[4] and $0f))shl 4);

number:=((byte[2])shl 24)+((byte[1])shl 16)
+((byte[4])shl 8)+(byte[3]);

sNum:=inttostr(Number);
inChar[1]:=char(((integer(sNum[1])+integer(sNum[2]))mod 5)+integer('a'));
inChar[2]:=char(((integer(sNum[3])+integer(sNum[4]))mod 5)+integer('a'));
inChar[3]:=char(((integer(sNum[5])+integer(sNum[6]))mod 5)+integer('a'));
insert(inChar[1],sNum,1);
insert(inChar[2],sNum,5);
insert(inChar[3],sNum,9);
result:=sNum;


end;

function decode(code:string):dword;
var str:string; number:dword; byte,byte1:array[1..4]of dword;
begin

str:=code;
delete(str,1,1);
delete(str,4,1);
delete(str,7,1);
number:= strtoint64(str);
byte[1]:=(number and $0ff000000) shr 24;
byte[2]:=(number and $0ff0000) shr 16;
byte[3]:=(number and $0ff00) shr 8;
byte[4]:=(number and $0ff);

////0123 --> 1032
byte[1]:=(((byte[1] and $f0))shr 4)+(((byte[1] and $0f))shl 4);
byte[2]:=(((byte[2] and $f0))shr 4)+(((byte[2] and $0f))shl 4);
byte[3]:=(((byte[3] and $f0))shr 4)+(((byte[3] and $0f))shl 4);
byte[4]:=(((byte[4] and $f0))shr 4)+(((byte[4] and $0f))shl 4);

number:=((byte[2])shl 24)+((byte[1])shl 16)
+((byte[4])shl 8)+(byte[3]);

byte[1]:=((number and $0ff000000)shr 24);//右移24位
byte[2]:=((number and $0ff0000)shr 16);
byte[3]:=((number and $0ff00)shr 8);
byte[4]:=(number and $0ff);

byte1[1]:=(byte[1]and $0c0)+((byte[2]and $0c0)shr 2)+((byte[3]and $0c0)shr 4)+((byte[4]and $0c0)shr 6);
byte1[2]:=((byte[1]and $30)shl 2)+(byte[2]and $30)+((byte[3]and $30)shr 2)+((byte[4]and $30)shr 4);
byte1[3]:=((byte[1]and $0c)shl 4)+((byte[2]and $0c)shl 2)+(byte[3]and $0c)+((byte[4]and $0c)shr 2);
byte1[4]:=((byte[1]and $03)shl 6)+((byte[2]and $03)shl 4)+((byte[3]and $03)shl 2)+(byte[4]and $03);

number:=((byte1[1])shl 24)+((byte1[2])shl 16)
+((byte1[3])shl 8)+(byte1[4]);

number:=number xor $1973122980;
number:= not number;
result:= number;

end;

加解密部分自己要改一下,因为我已经贴出来了,改几个常量即可。
 
谢先!试试看,可以后马上开贴给分。
 
to zw84611:
 试了你的代码后,有几个问题请教:
1、用GetHDNumber取得硬盘序列号后,用Serial生成注册码。那encode和decode如何用呢?
2、如何将serial逆算成为硬盘序列号与原序列号相核对?
3、Serial函数中第一行的8009211011应该就是一个加密转换的常量吧?还有inChar的Index
值?
再请教大家关于加密软件的一些经验,同样给出150分酬谢。(当是散分了)
 
最好做一个不可逆的算法
 
看了一篇这方面的文章,是VC++的,不过思路一样
http://www.powerba.com/develop/vc/article/20011113001.htm
zw84611的回答很好。现在的问题是
不可逆算法的实现,多层的加密位,注册信息的保存,还有先前第四个问题。
谢谢
 
1、利用RSA算法
2、在功能函数中进行校验
3、多处进行校验
4、利用线程、消息、延时
5、监测软件关键点,防止强行跳过
、、、
 
这个应该是硬盘的序列号,而不是硬盘的机器码,格式化后序列号失效。
 
硬盘序列号可以复制的,硬盘的机器码到是不错,但是SCSI硬盘没有,读出来全0
 
即使用硬盘的机器码也有问题,有些硬盘没有序列号。
我采用硬盘的机器码加密已经有三年了,这种事情遇到过!
最好采用Bios的内容加密。不过Bios一旦升级则密码失效!
我所采用的方法是内存大小+硬盘大小+硬盘序列号+CPU型号和速度+Bios中的某固定数据段
前提是他的计算机不允许升级或者升级后允许到你那里重新注册(激活)。
以上的硬件信息的获取方法本论坛十分丰富(自己找找看吧)。
 
其实用GetVolumeInformation这个API获得的是分区的序列号,我说的机器码是对用户而言
的。因为是分区的序列号,所以每次格式化或对硬盘的FAT表进行改动后,序列号都会改变
。这个问题都不大。
to youth[dfw]:请问能给出具体的代码吗?额外给100分。谢谢!
 
·······
 
我也想知道,UP!
 
JIFEE的做法够可靠,但如果再加上网卡序列号会更好。
因为如果组成一个多台计算机的环境,所购计算机会使用相同配置的同一批机器。
GHOST就可以解决问题。
 
有道理,不过关键是有否网卡的情况下机器码分别是如何生成。谢谢!
怎么都没人回答了?分不够可以再加嘛。
 
顶部