☆Obaby's H4cking W0rld☆

Hack-Crack==Backdoors - RATs - Trojans // Binders-Packers - Rootkits

破解-黑客-零日漏洞-灰鸽子/上兴/PCShare-木马免杀-网站入侵-信息安全

2009年3月2日星期一

RC4 Code

function RC4(Expression, Password: string): string;
var
RB : array[0..255] of Integer;
X, Y, Z: longint;
Key : array of byte;
ByteArray : array of byte;
Temp: byte;
Counter: integer;
begin
If (Length(Expression) = 0) then Exit;
If (Length(Password) = 0) then Exit;
If (Length(Password) > 256) then begin
Password := Copy(Password, 1, 256);
end;
SetLength(Key, Length(Password));
for Counter := 0 to Length(Password) - 1 do
begin
Key[Counter] := ord(Password[Counter + 1]);
end;
for X := 0 to 255 do
begin
RB[X] := X;
end;
X := 0;
Y := 0;
Z := 0;
for X := 0 to 255 do
begin
Y := (Y + RB[X] + Key[X mod Length(Password)]) mod 256;
Temp := RB[X];
RB[X] := RB[Y];
RB[Y] := Temp;
end;
X := 0;
Y := 0;
Z := 0;
SetLength(ByteArray, Length(Expression));
for Counter := 0 to Length(Expression) - 1 do
begin
ByteArray[Counter] := ord(Expression[Counter + 1]);
end;
for X := 0 to Length(Expression) do
begin
Y := (Y + 1) mod 256;
Z := (Z + RB[Y]) mod 256;
Temp := RB[Y];
RB[Y] := RB[Z];
RB[Z] := Temp;
ByteArray[X] := ByteArray[X] xor (RB[(RB[Y] + RB[Z]) mod 256]);
end;
for Counter := 0 to Length(Expression) - 1 do
begin
Result := Result + chr(ord(ByteArray[Counter]));
end;
end;

//Code by unkn0wn.ws

0 评论:

发表评论