snare / voltron

A hacky debugger UI for hackers
MIT License
6.18k stars 414 forks source link

AttributeError: 'NoneType' object has no attribute 'adaptor_class' #158

Closed trietptm closed 8 years ago

trietptm commented 8 years ago

I build the latest Voltron from GitHub and install in Windows following the instructions at https://github.com/snare/voltron/wiki/Installation#windbg and receive the following error in my WinDbg Command log:

0:000> .load pykd 0:000> !py --global C:\Python27\Lib\site-packages\voltron-0.1.5-py2.7.egg\voltron\entry.py C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT) An error occurred while loading Voltron:

Traceback (most recent call last): File "C:\Python27\Lib\site-packages\voltron-0.1.5-py2.7.egg\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

snare commented 8 years ago

Sounds like it hasn't installed the plugins properly. Can you try installing the Voltron package in develop mode?

$ cd voltron
$ pip uninstall .
$ pip install -e .

This will remove the Voltron egg from the Python packages directory, and create an egg-link to the source directory. Not a great solution, but might work for now. I'll investigate and see if I can reproduce the issue.

trietptm commented 8 years ago

The same adaptor_class problem still occurs:

0:000> !py --global D:\GitHub\voltron\voltron\entry.py An error occurred while loading Voltron:

Traceback (most recent call last): File "D:\GitHub\voltron\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

Please ensure Voltron is installed correctly per the documentation: https://github.com/snare/voltron/wiki/Installation

trietptm commented 8 years ago

Now, I found a new script called voltron-script.py, is that the one I should execute?

0:000> .load pykd 0:000> !py --global c:\python27\scripts\voltron-script.py C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT) usage: voltron-script.py [-h] [--debug] [-o O] {view,v} ... voltron-script.py: error: too few arguments 0:000> !py --global c:\python27\scripts\voltron-script.py -h usage: voltron-script.py [-h] [--debug] [-o O] {view,v} ...

optional arguments: -h, --help show this help message and exit --debug, -d print debug logging -o O override config variable

subcommands: valid subcommands

{view,v} view (v) display a view

lazyhack commented 8 years ago

Same problem with running the voltron on Windbg

0:010> !py --global c:\tmp\voltron-master\voltron\entry.py C:\Python27\lib\site-packages\blessed-1.14.1-py2.7.egg\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width An error occurred while loading Voltron:

Traceback (most recent call last): File "c:\tmp\voltron-master\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

Please ensure Voltron is installed correctly per the documentation: https://github.com/snare/voltron/wiki/Installation

snare commented 8 years ago

No, you should be loading entry.py. I am not able to reproduce this on Windows 7. Will try on a fresh system.

snare commented 8 years ago

Can you tell me which version of Windows, WinDbg and PyKD you're using?

lazyhack commented 8 years ago

My tested is version is..

OS : Windows 7 Ultimate K (Build 7601, SP1) WinDBG 6.12.0002.633 X85 PyKD 1.0.1.14 (downloaded the latest version yesterday) Python version 2.7.3 (32bit)

and.. I did below for the installation

  1. I didn't execute install.sh because of My OS is Windows
  2. Install the Pykd-0.3.0.38-py2-none-win_win32.whl
  3. Install the Curses-2.2-cp27-none-win32.whl
  4. python \setup.py install
  5. then, On WinDBG, !py --global voltron\entry.py

C:\Python27\lib\site-packages\blessed-1.14.1-py2.7.egg\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width An error occurred while loading Voltron:

Traceback (most recent call last): File "c:\tmp\voltron-master\voltron\entry.py", line 57, in import voltron ImportError: No module named voltron

So, I copied Voltron folder to \Lib\Site-packages\volton

and The result is below..

0:013> !py --global c:\tmp\voltron-master\voltron\entry.py An error occurred while loading Voltron:

Traceback (most recent call last): File "c:\tmp\voltron-master\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

Please ensure Voltron is installed correctly per the documentation: https://github.com/snare/voltron/wiki/Installation

What did I wrong?

Thanks

snare commented 8 years ago

I've tried to reproduce it and it seems that the install is failing on some of the dependencies. It would have thrown an error when you ran python setup.py install about the requests module not being available. If you then run the install again it will succeed on that dependency and fail on another one. If you run it 3 or 4 times it should get all the way through and successfully install. This has worked fine for me, and I can now load Voltron on a fresh machine. I'll investigate why the install is failing and fix it.

The AttributeError you're seeing indicates that the plugins aren't loaded properly, which says to me that your manual install method of copying the Voltron folder into site-packages hasn't worked as intended.

lazyhack commented 8 years ago

Yes! I did execute "python setup.py install" 3 times due to fail of installing some module. Then Should not I copy the Voltron folder into the site-packages folder manually? If I don't copy the Voltron folder into the site-packages folder, the ImporError of voltron occur. You mean I did wrong installation?

snare commented 8 years ago

You should not need to copy it manually, that's what the install does. What happens if you do this:

    > python -c "import voltron;print voltron" 
lazyhack commented 8 years ago

In the "manual copied" status => "< module 'voltron' from c:\python27\lib\site-packages\voltroninitpyc' >"

In the NOT "manual copied" status after python setup.py install => ImportError: No module named voltron

snare commented 8 years ago

So, when you ran python setup.py install 3 times it succeeded on the 3rd time? Can you run it again and verify it runs successfully? I cannot reproduce the install failing to install the module given running it enough times for the install to appear to have succeeded.

snare commented 8 years ago

And now run the command again:

> python -c "import voltron;print voltron" 
lazyhack commented 8 years ago

After "python setup.py install 3 times" I got the log volt_log.txt

lazyhack commented 8 years ago

On WinDBG

:013> .load pykd 0:013> !py --global c:\tmp\voltron-master\voltron\entry.py C:\Python27\lib\site-packages\blessed-1.14.1-py2.7.egg\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width An error occurred while loading Voltron:

Traceback (most recent call last): File "c:\tmp\voltron-master\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

Please ensure Voltron is installed correctly per the documentation: https://github.com/snare/voltron/wiki/Installation

0:013> !py --global entry.py An error occurred while loading Voltron:

Traceback (most recent call last): File "c:\tmp\voltron-master\voltron\entry.py", line 98, in voltron.debugger = plugin.adaptor_class(*args) AttributeError: 'NoneType' object has no attribute 'adaptor_class'

0:013> !py Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) ; > > > import voltron ; > > > print voltron ; < module 'voltron' from 'C:\Python27\lib\site-packages\voltron-0.1.5-py2.7.egg\voltroninit.pyc' >

snare commented 8 years ago

Have you removed all trace of your manually installed version of Voltron first?

snare commented 8 years ago

I cannot reproduce the AttributeError and strongly suspect it's still related to your broken manual "install"

lazyhack commented 8 years ago

I will try again on clean system. Thanks.

lazyhack commented 8 years ago

Still the problem exists.

I did again on the clean system "WITHOUT MANUAL COPY"

executed "python setup.py install" 3 times

"python.exe -c "import voltron;print voltron" => < module 'voltron ' from voltroninit.py' >

Same problem on windbg here.

snare commented 8 years ago

Ok, in the logs you posted above you are importing the Voltron entry point from the source directory. Can you please try importing the one that is now installed in site-packages?

snare commented 8 years ago

I'm just setting up a new environment to try to reproduce this

snare commented 8 years ago

I still can't reproduce the error.

image

lazyhack commented 8 years ago

Another problem.

I installed the voltron on other system. [Windows 7 x64, Windbg 6.12.0002.633 x86]

It seems to work normally,

but, Runtime Library error occured.

Attached file is the screeenshot

volt

snare commented 8 years ago

I have no idea. Does other stuff work in PyKD now?

lazyhack commented 8 years ago

Yes, It seems to work fine. I will try next time. Thank you~! (I have to work back)

binjo commented 8 years ago

My error output

0:000> !py -g c:\Python27\Lib\site-packages\voltron\entry.py
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more o
f the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win
32'. The following methods of Terminal are dummy/no-op unless a deriving class o
verrides them: setraw, cbreak, kbhit, height, width
  warnings.warn(_MSG_NOSUPPORT)
An error occurred while loading Voltron:

Traceback (most recent call last):
  File "c:\Python27\Lib\site-packages\voltron\entry.py", line 98, in <module>
    voltron.debugger = plugin.adaptor_class(*args)
AttributeError: 'NoneType' object has no attribute 'adaptor_class'

Please ensure Voltron is installed correctly per the documentation: https://gith
ub.com/snare/voltron/wiki/Installation

stty

The stty is missing in Windows, so the view.window_size will throw error.

    def window_size(self):
        height, width = subprocess.check_output(['stty', 'size']).split()
        height = int(height) - int(self.config.pad.pad_bottom)
        width = int(width) - int(self.config.pad.pad_right)
        return (height, width)

error output

voltron view d
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width
  warnings.warn(_MSG_NOSUPPORT)

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
    self.run()
  File "C:\Python27\lib\threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "C:\Python27\lib\site-packages\voltron\view.py", line 404, in stopwatch
    self.update()
  File "C:\Python27\lib\site-packages\voltron\view.py", line 448, in update
    reqs = self.build_requests()
  File "C:\Python27\lib\site-packages\voltron\plugins\view\disasm.py", line 25, in build_requests
    req.count = self.body_height()
  File "C:\Python27\lib\site-packages\voltron\view.py", line 319, in body_height
    height, width = self.window_size()
  File "C:\Python27\lib\site-packages\voltron\view.py", line 313, in window_size
    height, width = subprocess.check_output(['stty', 'size']).split()
  File "C:\Python27\lib\subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['stty', 'size']' returned non-zero exit status -1073741515

dbg_windbg.py

The dbg_windbg.py plugin currently has a logic to check if in_windbg or not by importing vtrace.

try:
    in_windbg = False
    import pykd
    try:
        import vtrace
    except:
        in_windbg = True
except ImportError:
    pass

However, vtrace module may exist in the system, e.x: vivisect will install vtrace, such that dbg_windbg.py will never be loaded.

Change it to as follows, the windbg plugin will load success, but voltron view still failed, due to stty issue. I haven't found a replacement of stty yet, what's your solution here? @snare

try:
    in_windbg = False
    import pykd
    if 'Microsoft (R) Windows Debugger Version' in pykd.dbgCommand('version'):
        in_windbg = True
except Exception:
    pass
snare commented 8 years ago

Re: stty, I've only ever used Voltron with Git Bash or ConEmu, and the GNU userland installed by Git which I suppose includes stty. I'll investigate a workaround, but in the mean time I'd suggest installing Git for Windows and using Git Bash or ConEmu.

Re: importing vtrace, vivisect is never installed as far as I know. It is used in-situ within the downloaded directory. There's no setup.py, etc, so as far as I can see, vtrace will never be in your Python path. Under what circumstances are you encountering this issue? IIRC the reason it works the way it does is because pykd will be importable from within the VDB adapter if the pykd package is installed in Python site-packages, but vtrace should never be importable from a script running in pykd. Your solution looks like it would incorrectly identify that it is running in WinDbg if it is in fact running in VDB if the pykd package is installed on the system.,

Re: your error output from loading Voltron, can you please try installing the Voltron package again per the previous discussion with @lazyhack and post your install log here? It seems that the install fails on dependencies a couple of times and needs to be run 3 times in order to install successfully. I haven't looked at this issue yet.

binjo commented 8 years ago

It turns I installed the vivisect from https://github.com/williballenthin/vivisect/, which includes a vtrace. :(

FTR, using full installation of Windows GIT, which includes stty, under bash, pip install voltron will succeed w/o error. voltron is usable, despite the error message from blessed\terminal. However the dependency of blessed module imports fcntl, which is not available in Windows, I couldn't find a resolution for this.

try:
    import termios
    import fcntl
    import tty
    HAS_TTY = True
except ImportError:
    _TTY_METHODS = ('setraw', 'cbreak', 'kbhit', 'height', 'width')
    _MSG_NOSUPPORT = (
        "One or more of the modules: 'termios', 'fcntl', and 'tty' "
        "are not found on your platform '{0}'. The following methods "
        "of Terminal are dummy/no-op unless a deriving class overrides "
        "them: {1}".format(sys.platform.lower(), ', '.join(_TTY_METHODS)))
    warnings.warn(_MSG_NOSUPPORT)
    HAS_TTY = False

In all, I'm giving up to use voltron under Windows, troublesome and I don't want to install a bunch of git tools in my analysis vm ;)

snare commented 8 years ago

Ahhh ok, I'll try to find a better method of detecting WinDbg and vtrace including support for Willi's fork of vivisect.

Windows/WinDbg support in general is quite new and needs some work. I've not yet investigated the blessed warning, but it doesn't actually effect the operation of Voltron so I've ignored it thus far. I may put some effort into supporting Windows without the Linux userland tools at some point, but my care factor for it is pretty low. However, I'll certainly be making sure it works properly under the new Windows 10 Linux userland without additional tools.