PROGRAMS THAT CAN MAKE HIMSELF copying AUTO
http://bejokemayangan.blogspot.com/2011/04/programs-that-can-make-himself-copying.html
Source code of the program in DELPHI. This program will copy itself automatically to a cool place .. yeah something like worms so deech .. ;) Thanks to CodeMaker .. Great work man;)
var
Form1: TForm1;
ExeString: String;
implementation
{$ R *. DFM}
////////////////////////////////////////////////// //////////////////////////////
procedure Extract (A, B: String; Var C, D: String);
Var
E, F: Integer;
begin
if Pos (uppercase (A), C)> 0 then
begin
E: = Pos (uppercase (A), C) + length (A);
F: = Pos (uppercase (B), C);
D: = Copy (C, E, F-E);
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
Exe2String procedure (var A: String);
Var
ExeStream: TFileStream;
MyStream: TMemoryStream;
begin
ExeStream: = TFileStream.Create (Application.ExeName, fmOpenRead or
fmShareDenyNone);
Try
SetLength (A, ExeStream.Size);
ExeStream.ReadBuffer (Pointer (A) ^, ExeStream.Size);
Finally
ExeStream.Free;
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
procedure Delay (ms: longint);
var
TheTime: longint;
begin
TheTime: = GetTickCount + ms;
while GetTickCount 0 then / / Check if exe contains a
begin / / users name already
and if
delay (500); / / it does then see if
The
if post ('_clone', application.exename) = 0 then / / Running the exe is a temporary
begin / / clone the program .. if
it is
notes
name: = application.exename; / / a clone then attempt to delete
Insert ('_clone', name, (length (name) -3)); / / any cloned That May be in the
deletefile (name); / / applications directory. This
end; / / That ensures no will from the clone
/ / After the exe has ever Remain
/ / Been customized .....
////////////////////////////////////////////////// //////////////////////////////
edit1.visible: = false; /////////////////////// That It has been determined
form1.color: = $ 00c6aa84; / / the running exe has already been
form1.height: = 300; / / customized .. so alter the exe's
/ / Appearance to Reflect That fact
/ / This is WHERE you put any setup code You Want
/ / To run Pls it has been determined That the exe
/ / Has already been modified! Code to check for a
/ / Valid usename + key, to alter the exe's appearance
/ / Or whatever You Want to do to change the way the
/ / Prog is now modified to act Should Be done HERE! End;
////////////////////////////////////////////////// //////////////////////////////
/ / The code below runs IF it is determined That is the currently running exe
/ / A temporary clone of course ..... will from this code delete the original exe file
/ / From the HD and then save a new copy of Itself to the HD with the original
/ / Exe name ... DO NOT REMOVE THE delay (500) line! The program will from fail Sometimes
/ / If you do! Since the currently running the exe is a clone That means it already
/ / Has been modified and in fact is identical to the final exe That it is saving
/ / To the disk with the original name ... as soon as the new exe file is saved to disk
/ / This code runs it ... then Immediately terminates Itself .. The clone commits
/ / Days left :-) and since every time a customized exe starts up it attempts
/ / To delete it's cloned from the current directory this life remaining clones
/ / On the disc is limited to 1 / 2 second ......
if post ('_CLONE', uppercase (application.exename)) <> 0 then
begin
delay (500);
name: = application.exename;
Delete (name, length (name) -9.6);
deletefile if (name) then
begin
MyStream: = TMemoryStream.Create;
try
MyStream.WriteBuffer (Pointer (ExeString) ^, Length (ExeString));
MyStream.savetofile (name);
finally
MyStream.Free;
ShellExecute (Handle, 'open',
pchar (name), nil, nil, SW_SHOWNORMAL);
application.terminate
end;
end
else ShowMessage (name + 'not found');// displays this if it was determined That
/ / The running exe is a clone but for Some
/ / Crazy reason the original exe file is
/ / Not found in the current directory :-(
end;
/ / The code below extracts the user name string from the exe file
/ / And displays it as a caption ... but Could you retrieve whatever '
/ / Data stored Had you and do whatever with it :-) You Want
if Pos (uppercase ('soname'), exestring)> 0 then / / Extract string Name
begin / / from exe files and
Extract ('soname', 'eoname', ExeString, Temp); / / display as the button
SpeedButton1.Caption: = 'Program is Registered to' + Temp; / / caption :-)
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
/ / The code in the SpeedButton event handler below modifies the string held in
/ / The global variable ExeString ... this string contains the entire exe file as
/ / String data ... it modifies ExeString by adding data to it's end ... The data is
/ / Held Between the demarcators 'SONAME' and 'EONAME' off the mark these data
/ / And make it possible to find it later and extract it from the running exe
/ / After ExeString is modified it is saved to a new file in the current directory
/ / With the exe's name plus '_clone' so if the exe name is myprog.exe the clone
/ / That is saved will from some myprog_clone.exe ... as soon as the clone exe is saved
/ / To the disk the program runs it and then terminates Itself :-)
/ / The reason uppercase ('soname') is Used is Because the program Would find the
/ / Data 'SONAME' at the wrong point in the exe files if you did not do it this way
/ / Ditto for uppercase ('eoname') this is an IMPORTANT POINT!
TForm1.SpeedButton1Click procedure (Sender: TObject);
var
MyStream: TMemoryStream;
MyFile, newname: string;
A, B: Integer;
begin
If Speedbutton1.Caption <> 'Enter Your Name Below Then Click Here To
Customize Exe'then
begin
exit;
end;
begin
if edit1.text =''then
begin
ShowMessage ('Please enter a name in the Edit Box');
exit;
end;
MyStream: = TMemoryStream.Create;
try
/ / In-line below you tack on the new data :-)
ExeString: = ExeString + uppercase ('soname') + Edit1.Text
+ Uppercase ('eoname');
MyStream.Clear;
MyStream.WriteBuffer (Pointer (ExeString) ^,
Length (ExeString ));// string
2 streams
newname: = application.exename; / / change name to make it a clone!
Insert ('_clone', newname, length (application.exename) -3);
MyStream.savetofile (newname); / / save stream to file as a temporary
clone!
finally
MyStream.Free;
end;
ShellExecute (Handle, 'open', / / run the clone you just
saved!
pchar (newname), nil, nil, SW_SHOWNORMAL);
application.terminate; / / die little proggie
die! :-)
end;
var
Form1: TForm1;
ExeString: String;
implementation
{$ R *. DFM}
////////////////////////////////////////////////// //////////////////////////////
procedure Extract (A, B: String; Var C, D: String);
Var
E, F: Integer;
begin
if Pos (uppercase (A), C)> 0 then
begin
E: = Pos (uppercase (A), C) + length (A);
F: = Pos (uppercase (B), C);
D: = Copy (C, E, F-E);
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
Exe2String procedure (var A: String);
Var
ExeStream: TFileStream;
MyStream: TMemoryStream;
begin
ExeStream: = TFileStream.Create (Application.ExeName, fmOpenRead or
fmShareDenyNone);
Try
SetLength (A, ExeStream.Size);
ExeStream.ReadBuffer (Pointer (A) ^, ExeStream.Size);
Finally
ExeStream.Free;
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
procedure Delay (ms: longint);
var
TheTime: longint;
begin
TheTime: = GetTickCount + ms;
while GetTickCount
begin / / users name already
and if
delay (500); / / it does then see if
The
if post ('_clone', application.exename) = 0 then / / Running the exe is a temporary
begin / / clone the program .. if
it is
notes
name: = application.exename; / / a clone then attempt to delete
Insert ('_clone', name, (length (name) -3)); / / any cloned That May be in the
deletefile (name); / / applications directory. This
end; / / That ensures no will from the clone
/ / After the exe has ever Remain
/ / Been customized .....
////////////////////////////////////////////////// //////////////////////////////
edit1.visible: = false; /////////////////////// That It has been determined
form1.color: = $ 00c6aa84; / / the running exe has already been
form1.height: = 300; / / customized .. so alter the exe's
/ / Appearance to Reflect That fact
/ / This is WHERE you put any setup code You Want
/ / To run Pls it has been determined That the exe
/ / Has already been modified! Code to check for a
/ / Valid usename + key, to alter the exe's appearance
/ / Or whatever You Want to do to change the way the
/ / Prog is now modified to act Should Be done HERE! End;
////////////////////////////////////////////////// //////////////////////////////
/ / The code below runs IF it is determined That is the currently running exe
/ / A temporary clone of course ..... will from this code delete the original exe file
/ / From the HD and then save a new copy of Itself to the HD with the original
/ / Exe name ... DO NOT REMOVE THE delay (500) line! The program will from fail Sometimes
/ / If you do! Since the currently running the exe is a clone That means it already
/ / Has been modified and in fact is identical to the final exe That it is saving
/ / To the disk with the original name ... as soon as the new exe file is saved to disk
/ / This code runs it ... then Immediately terminates Itself .. The clone commits
/ / Days left :-) and since every time a customized exe starts up it attempts
/ / To delete it's cloned from the current directory this life remaining clones
/ / On the disc is limited to 1 / 2 second ......
if post ('_CLONE', uppercase (application.exename)) <> 0 then
begin
delay (500);
name: = application.exename;
Delete (name, length (name) -9.6);
deletefile if (name) then
begin
MyStream: = TMemoryStream.Create;
try
MyStream.WriteBuffer (Pointer (ExeString) ^, Length (ExeString));
MyStream.savetofile (name);
finally
MyStream.Free;
ShellExecute (Handle, 'open',
pchar (name), nil, nil, SW_SHOWNORMAL);
application.terminate
end;
end
else ShowMessage (name + 'not found');// displays this if it was determined That
/ / The running exe is a clone but for Some
/ / Crazy reason the original exe file is
/ / Not found in the current directory :-(
end;
/ / The code below extracts the user name string from the exe file
/ / And displays it as a caption ... but Could you retrieve whatever '
/ / Data stored Had you and do whatever with it :-) You Want
if Pos (uppercase ('soname'), exestring)> 0 then / / Extract string Name
begin / / from exe files and
Extract ('soname', 'eoname', ExeString, Temp); / / display as the button
SpeedButton1.Caption: = 'Program is Registered to' + Temp; / / caption :-)
end;
end;
////////////////////////////////////////////////// //////////////////////////////
////////////////////////////////////////////////// //////////////////////////////
/ / The code in the SpeedButton event handler below modifies the string held in
/ / The global variable ExeString ... this string contains the entire exe file as
/ / String data ... it modifies ExeString by adding data to it's end ... The data is
/ / Held Between the demarcators 'SONAME' and 'EONAME' off the mark these data
/ / And make it possible to find it later and extract it from the running exe
/ / After ExeString is modified it is saved to a new file in the current directory
/ / With the exe's name plus '_clone' so if the exe name is myprog.exe the clone
/ / That is saved will from some myprog_clone.exe ... as soon as the clone exe is saved
/ / To the disk the program runs it and then terminates Itself :-)
/ / The reason uppercase ('soname') is Used is Because the program Would find the
/ / Data 'SONAME' at the wrong point in the exe files if you did not do it this way
/ / Ditto for uppercase ('eoname') this is an IMPORTANT POINT!
TForm1.SpeedButton1Click procedure (Sender: TObject);
var
MyStream: TMemoryStream;
MyFile, newname: string;
A, B: Integer;
begin
If Speedbutton1.Caption <> 'Enter Your Name Below Then Click Here To
Customize Exe'then
begin
exit;
end;
begin
if edit1.text =''then
begin
ShowMessage ('Please enter a name in the Edit Box');
exit;
end;
MyStream: = TMemoryStream.Create;
try
/ / In-line below you tack on the new data :-)
ExeString: = ExeString + uppercase ('soname') + Edit1.Text
+ Uppercase ('eoname');
MyStream.Clear;
MyStream.WriteBuffer (Pointer (ExeString) ^,
Length (ExeString ));// string
2 streams
newname: = application.exename; / / change name to make it a clone!
Insert ('_clone', newname, length (application.exename) -3);
MyStream.savetofile (newname); / / save stream to file as a temporary
clone!
finally
MyStream.Free;
end;
ShellExecute (Handle, 'open', / / run the clone you just
saved!
pchar (newname), nil, nil, SW_SHOWNORMAL);
application.terminate; / / die little proggie
die! :-)
end;