Giter VIP home page Giter VIP logo

twindbg's Introduction

Caution

This project is no longer maintained due to several reasons:

  • The official pykd is no longer updated.
  • Windbg has become an excellent tool. It has a nice UI, and if you need telescope there's also a script that'll do the work. IMO there's no need to use this tool anymore.

I would like to thank anyone that has supported this project. I had a lot of fun writing this tool :)


Python 3 Code Climate Issue Count MIT License

TWindbg

PEDA-like debugger UI for WinDbg

context img

Introduction

This is a windbg extension ( using pykd ) to let user having a PEDA-like debugger UI in WinDbg.
It will display the following context in each step/trace:

  • Registers
  • Disassembled code near PC
  • Contents of the stack pointer ( with basic smart dereference )

It also supports some peda-like commands ( see the support commands section )

For now it supports both x86 & x64 WinDbg.

Dependencies

  • Python 3

I decided to drop the support of Python2.7 since it has reached the EOL. I believe the project is Python2/3 compatible, however there might exist some issues in pykd and can cause different behavior in Python2/3. Since now the project will only be tested on Python3, I strongly suggest using TWindbg on Python3 instead of Python 2.7. If you still want to use it on Python 2.7, feel free to fork the project and do the development.

Installation

  • Install Python3
  • Install pykd
    • Download Pykd-Ext, unpack pykd.dll to the [WinDbg Directory]\x86(or x64)\winext\ directory.
      • This will allow you to run python in Windbg.
    • In the Windbg command line, enter command .load pykd to load the pykd module.
    • Enter !pip install pykd to install the pykd python package.
      • Upgrade the pykd module with command !pip install --upgrade pykd.
      • If something went wrong during the installation with pip install, try installing the wheel package instead of the one on PyPI. You can download the wheel package here.
  • Download the repository
  • Install the matrix theme by double-clicking the matrix_theme.reg
    • The matrix theme is required for letting the color theme work in TWindbg
    • You can preview the theme by importing the matrix_theme.WEW workspace into WinDbg.
  • Copy the TWindbg folder into [WinDbg Directory]\x64\winext\ & [WinDbg Directory]\x86\winext\

Usage

Launch TWindbg manually

  • Open an executable or attach to a process with WinDbg
  • Use .load pykd to load the pykd extension
  • Use !py -g winext\TWindbg\TWindbg.py to launch TWindbg

Launch TWindbg with command

[PATH_TO_WINDBG] -a pykd -c "!py -g winext\TWindbg\TWindbg.py"

Or you can write a simple batch file for the sake of convenience.

After that you can just use t or p to see if the extension is working.

Support Commands

  • TWindbg: List all the command in TWindbg
  • ctx: Print out the current context
  • tel / telescope: Display memory content at an address with smart dereferences tel img

Note

Maybe ( just maybe ) I'll add more command to make WinDbg behave more like PEDA ( or other debugger like pwndbg, GEF... ) in the future.

twindbg's People

Contributors

bruce30262 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twindbg's Issues

Python3 support

The day has come. RIP Python2 :(

The code hasn't been tested on Python3 yet. Although I thought the code is Python2/3 compatible ( like 80 % sure ), I'm gonna take some time to make sure that it fully support both Python2 and Python3.

NameError: global name 'MemoryException' is not defined

Hi, I got exception as follows:

Traceback (most recent call last):

  File "c:\pykdscript\TWindbg.py", line 86, in onExecutionStatusChange
    self.print_context()

  File "c:\pykdscript\TWindbg.py", line 95, in print_context
    self.print_stack()

  File "c:\pykdscript\TWindbg.py", line 166, in print_stack
    ptr_values = self.smart_dereference(cur_sp)

  File "c:\pykdscript\TWindbg.py", line 180, in smart_dereference
    except MemoryException: # no more dereference

NameError: global name 'MemoryException' is not defined

adding module name fixed it

diff --git a/TWindbg/TWindbg.py b/TWindbg/TWindbg.py
index daf8966..18be21f 100644
--- a/TWindbg/TWindbg.py
+++ b/TWindbg/TWindbg.py
@@ -177,7 +177,7 @@ class ContextHandler(pykd.eventHandler):
                 val = pykd.loadPtrs(addr, 1)[0]
                 ret.append(val)
                 addr = val
-            except MemoryException: # no more dereference
+            except pykd.MemoryException: # no more dereference
                 break
 
         return ret

[TODO] 2017/08/05

  • enhance smart dereference
    • detect type ( code / string / raw data )
    • support telescope command
  • context : print out the current context
  • help command ( list the TWindbg command )

The length of dereference is a bit too long

Right now the default length of dereferencing the pointers is 20 ( set by the MAX_DEREF variable ) , which is a bit too long for normal usage. Some solutions:

  • Take other project ( pwndbg / peda/ GEF ) as reference and set the same length as those projects did.
  • Set a configuration point and let user can customize the length themselves. However this will require more work, also I'm not sure if it's suitable to add a configuration file for TWindbg ( .TWindbginit ? Looks weird :/ )

error when loading

0:000> .load pykd
0:000> !py -g winext\TWindbg\TWindbg\TWindbg.py

Traceback (most recent call last):

File "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\winext\TWindbg\TWindbg\TWindbg.py", line 10, in
context.init_arch()

File "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\winext\TWindbg\TWindbg\context.py", line 17, in init_arch
cpu_mode = pykd.getCPUMode()

AttributeError: 'module' object has no attribute 'getCPUMode'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.