-
Notifications
You must be signed in to change notification settings - Fork 676
Debugging Meterpreter(s)
#define DEBUGTRACE 1
Add that at the top of any file you would like to debug, then use dprintf([format string])
For more information, see the code responsible for it in common.h by searching for the DEBUGTRACE macro.
Once that is in place, run debugView as admin on the machine running the payload. Be sure to select "Global_Win32" messages in the "Capture" dropdown box.
Alternatively you can build a debug version of meterpreter within Visual Studio.
When setting up the handler for the connection in msfconsole:
set PythonMeterpreterDebug True
Launch the meterpreter in a location that you will see stdout/stderr like a cmd.exe or a bash window.
The function you will use is debug_print("STRING")
Set JavaMeterpreterDebug=True
when creating the payload. Debugging information (such as exceptions), will now be visible via stderr.
For example, running meterpreter > ls /nosuchfile
on a meterpreter session from a debug payload:
$ ./msfvenom -p java/meterpreter/reverse_tcp JavaMeterpreterDebug=true LHOST=127.0.0.1 LPORT=4444 -o met.jar
Payload size: 5331 bytes
Saved as: met.jar
$ java -jar met.jar
java.io.IOException: File/directory does not exist: /nosuchfile
at com.metasploit.meterpreter.stdapi.stdapi_fs_stat.execute(Unknown Source)
at com.metasploit.meterpreter.CommandManager.executeCommand(Unknown Source)
at com.metasploit.meterpreter.TcpTransport.dispatch(Unknown Source)
at com.metasploit.meterpreter.Meterpreter.startExecuting(Unknown Source)
at com.metasploit.meterpreter.Meterpreter.<init>(Unknown Source)
at com.metasploit.meterpreter.Meterpreter.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at javapayload.stage.Meterpreter.start(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at metasploit.Payload.bootstrap(Unknown Source)
at metasploit.Payload.main(Unknown Source)
Set AndroidMeterpreterDebug=True
when creating the payload. Debugging information (such as exceptions) will be available via ADB