{$R *.dfm}
//字符串加密
function XorStrings(Str,Key:String): String; //?????,??1:???,??2:??
var
X, Y : Integer;
A : Byte;
begin
Y := 1;
for X := 1 to Length(Str) do
begin
A := (Ord(Str[X]) and $0f) xor (Ord(Key[Y]) and $0f);
Str[X] := Char((ord(Str[X]) and $f0) + A);
Inc(Y);
If Y > Length(Key) then Y := 1;
end;
Result := Str;
end;
//取窗口文字
function GetWinTitle(hWnd: HWnd): string;
var
WindowTitle: array[0..MAX_PATH] of Char;
begin
WindowTitle[SendMessage(hWnd, WM_GETTEXT, MAX_PATH, Integer(@WindowTitle))] := #0;
Result := WindowTitle;
end;
//线程
function SLthreadfunction(info:pointer):integer;stdcall;
var
s:string;
i:integer;
b:integer;
tx:string;
begin
for i:=0 to 20 do //无用循环
begin
sleep(1);
s:='.';
b:=b xor i;
end;
s:=GetWinTitle(editHwnd); //取密码
if length(s)<>6 then exit; //长度检测
for i:=1 to 6 do //比较
begin
tx:=copy(s,length(s),length(s)); //取最后一位
setlength(s,length(s)-1); //删除最后一位
case i of
1,2:if XorStrings(tx,'666')<>ss4 then exit;
3,6:if XorStrings(tx,'666')<>ss1 then exit;
4:if XorStrings(tx,'666')<>ss3 then exit;
5 :if XorStrings(tx,'666')<>ss2 then exit;
end;
end;
SendMessage(formHwnd, WM_SYSCOMMAND, SC_CLOSE, 0); //用SendMessage关闭程序主要是不想用弹出窗口的方式,那样容易下断
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
editHwnd:=edit1.Handle; //EDIT窗口句柄
formHwnd:=form1.Handle; //主窗口句柄
threadhandle:=createthread(nil,0,@SLthreadfunction,nil,0,threadid); //创建线程进行比较
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close; //放弃
end;
var
Form1: TForm1;
threadhandle:thandle;
threadid:dword;
editHwnd:thandle;
formHwnd:thandle;
implementation
{$R *.dfm}
function GetWinTitle(hWnd: HWnd): string;
var
WindowTitle: array[0..MAX_PATH] of Char;
begin
WindowTitle[SendMessage(hWnd, WM_GETTEXT, MAX_PATH, Integer(@WindowTitle))] := #0;
Result := WindowTitle;
end;
function SLthreadfunction(info:pointer):integer;stdcall;
var
s:string;
i:integer;
b:integer;
tx:string;
b3133:dword;
time:dword;
begin
s:=GetWinTitle(editHwnd);
s:=trim(s);
if IsNumString(s)=false then exit; //有非数字则退出
b3133:=strtoint(s); //转换为数值 313319943
if (b3133>400000000) or (b3133<300000000) then exit; //如果数值过大或过小就退出 增加难度
time:=GetMessageTime() div 1000; //取系统启动时间,以秒为单位.
//如果在下面比较字符串用的时间多过2秒则退出,
//也就是说如果用OD单步执行,那就显得不可能了.只有2秒的时间给你玩.
//有创意吧 ^_^
for i:=1 to 24 do //用的还是上个版本的每个字符进行明码比较 要知道这明码是怎么来的,也不是容易的事 ^_^
begin
if ((GetMessageTime() div 1000)-1) >time then exit; //代码运行时间比较 只有2秒的时间给你分析这个循环
tx:=copy(s,length(s),length(s));
log(pchar(tx+' '+inttostr(i)));
setlength(s,length(s)-1);
case i of //pQBqDp8qWzO0hepUEy+NEg== 用313319943 加密后的结果
1:if tx<>'=' then exit;
2:if tx<>'=' then exit;
3:if tx<>'g' then exit;
4:if tx<>'E' then exit;
5:if tx<>'N' then exit;
6:if tx<>'+' then exit;
7:if tx<>'y' then exit;
8:if tx<>'E' then exit;
9:if tx<>'U' then exit;
10:if tx<>'p' then exit;
11:if tx<>'e' then exit;
12:if tx<>'h' then exit;
13:if tx<>'0' then exit;
14:if tx<>'O' then exit;
15:if tx<>'z' then exit;
16:if tx<>'W' then exit;
17:if tx<>'q' then exit;
18:if tx<>'8' then exit;
19:if tx<>'p' then exit;
20:if tx<>'D' then exit;
21:if tx<>'q' then exit;
22:if tx<>'B' then exit;
23:if tx<>'Q' then exit;
24:if tx<>'p' then exit;
end;
end;
SendMessage(formHwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
editHwnd:=edit1.Handle;
formHwnd:=form1.Handle;
threadhandle:=createthread(nil,0,@SLthreadfunction,nil,0,threadid);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;