• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Delphi Unit FixEOF by steve10120

Status
Not open for further replies.

Expermicid

Leech
User
Joined
Oct 23, 2011
Messages
285
Reputation
0
Reaction score
255
Points
63
Credits
0
‎13 Years of Service‎
95%
Esta unit es muy importante en el ámbito de la indetección ya que en multitud de ocasiones es capaz de indetectar ante Avira, lo que hace así explicado malamente es fixear la cabecera, indicando la existencia del EOF (la zona encriptada), cuando ello no es indicado en cabecera es muy probable que avira detecte nuestros encriptados ya que normalmente este dato no se tiene en cuenta.

Esto no quiere decir que nos vaya a sacar Avira del tirón, que aunque lo consiga en multitud de ocasiones, es posible que necesitemos aparte trabajar el binario con otras herramientas que ya conocemos.

[lenguaje=delphi]{ FixEOF

by steve10120

This link is hidden for visitors. Please Log in or register now.


}

unit FixEOF;

interface

uses

Windows;

type

TByteArray = array of Byte;

function ReadAndFix(sFile:string; sDestFile:string):Boolean;

implementation

function FixFile(bFile: TByteArray):Boolean;

var

IDH: TImageDosHeader;

INH: TImageNtHeaders;

ISH: TImageSectionHeader;

i: DWORD;

begin

try

CopyMemory(@IDH, @bFile[0], SizeOf(IDH));

if IDH.e_magic <> IMAGE_DOS_SIGNATURE then Exit;

CopyMemory(@INH, @bFile[iDH._lfanew], SizeOf(INH));

CopyMemory(@ISH, @bFile[iDH._lfanew + SizeOf(INH) + (INH.FileHeader.NumberOfSections - 1) * SizeOf(ISH)], SizeOf(ISH));

i := (ISH.PointerToRawData + ISH.SizeOfRawData);

ISH.SizeOfRawData := ISH.SizeOfRawData + (Length(bFile) - i);

CopyMemory(@bFile[iDH._lfanew + SizeOf(INH) + (INH.FileHeader.NumberOfSections - 1) * SizeOf(ISH)], @ISH, SizeOf(ISH));

Result := TRUE;

except

Result := FALSE;

end;

end;

function ReadAndFix(sFile:string; sDestFile:string):Boolean;

var

hFile: THandle;

bFile: TByteArray;

dSize: DWORD;

dRead: DWORD;

dWritten: DWORD;

begin

Result := FALSE;

hFile := CreateFile(PChar(sFile), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);

if hFile <> INVALID_HANDLE_VALUE then

begin

dSize := GetFileSize(hFile, nil);

SetLength(bFile, dSize);

SetFilePointer(hFile, 0, nil, FILE_BEGIN);

ReadFile(hFile, bFile[0], dSize, dRead, nil);

CloseHandle(hFile);

if FixFile(bFile) then

begin

if sDestFile = '' then sDestFile := sFile;

hFile := CreateFile(PChar(sDestFile), GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, 0, 0);

if hFile <> INVALID_HANDLE_VALUE then

begin

SetFilePointer(hFile, 0, nil, FILE_BEGIN);

WriteFile(hFile, bFile[0], dSize, dWritten, nil);

CloseHandle(hFile);

Result := TRUE;

end;

end;

end;

end;

end.[/lenguaje]

Saludos

 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top