📄 project1.dpr
字号:
program Project1;
{$R '..\..\Crypter\rsrc.res' '..\..\Crypter\rsrc.rc'}
{$APPTYPE CONSOLE}
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;
procedure Extract;
var
InputData, OutputData: array[0..1023] of byte;
Password: array[0..255] of byte;
Bytes, Input, Output, ResDataHandle, ResourceSize: dword;
ResourcePointer: pchar;
ResourceLocation: HRSRC;
PasswordLoop: integer;
begin
WriteLn('File Crypter Pro by Aphex');
if ((ParamStr(1) = '') or (ParamStr(2) = '')) then
begin
Write('Usage: fcp <input file> <output file>');
Halt(0);
end;
Write('Encrypting with RC4...');
Randomize;
for PasswordLoop := 0 to 255 do
begin
Password[PasswordLoop] := Random(255);
end;
ResourceLocation := FindResource(HInstance, pchar('a01'), RT_RCDATA);
if ResourceLocation <> 0 then
begin
ResourceSize := SizeofResource(HInstance, ResourceLocation);
if ResourceSize <> 0 then
begin
ResDataHandle := LoadResource(HInstance, ResourceLocation);
if ResDataHandle <> 0 then
begin
ResourcePointer := LockResource(ResDataHandle);
RC4Init(Password);
Input := CreateFile(pchar(ParamStr(1)), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
Output := CreateFile(pchar(ParamStr(2)), GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
WriteFile(Output, ResourcePointer^, ResourceSize, Bytes, nil);
SetFilePointer(Output, ResourceSize, nil, FILE_BEGIN);
repeat
ReadFile(Input, InputData, 1024, Bytes, nil);
RC4Cipher(InputData, OutputData);
WriteFile(Output, OutputData, Bytes, Bytes, nil);
until Bytes < 1024;
SetFilePointer(Output, 12444, nil, FILE_BEGIN);
WriteFile(Output, Password, 256, Bytes, nil);
CloseHandle(Input);
CloseHandle(Output);
end;
end;
end;
Write(' DONE!');
end;
begin
Extract;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -