Como automaticamente atachar um processo a um debugger.

Posted on Wed, Nov 11, 2020 bof osce binary-exploitation

No processo de criação de um exploit, no estudo de Buffer Overflow por exemplo, temos várias fases: fuzzing, poc, teste de badchars, etc. Isso acaba envolvendo muito trabalho repetitivo de abrir o excutável alvo, abrir o debugger e então anexar o processo.

Uma forma de agilizar um pouco é fazer com que, ao abrir o aplicativo que você deseja testar, ele seja automaticamente "atachado" ao debugger de sua preferência.

Para isso, basta fazer:

  1. Criar uma nova chave com o nome exato do aplicativo, incluindo a extensão, no registro em Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
  2. Dentro dessa nova chave criar uma entrada do tipo string de nome debugger.
  3. O valor da entrada debugger deve ser o caminho completo, incluindo o executável, do debugger de sua preferência.

Abaixo, como fica no regedit, a criação da entrada para um aplicativo de nome trainingserver.exe que deverá ser automaticamente anexado ao Immunity Debugger, ao ser iniciado.

Agora é só iniciar o aplicativo e ele já abrirá no debugger. Só dar play e se divertir. ;D

How to: Launch the Debugger Automatically

Sometimes, you may need to debug the startup code for an application that is launched by another process. Examples include services and custom setup actions. In these scenarios, you can have the debugger launch and automatically attach when your application starts. Start the Registry Editor (regedit). In the Registry Editor, open the HKEY_LOCAL_MACHINE folder.