Giter VIP home page Giter VIP logo

Comments (25)

tmr232 avatar tmr232 commented on June 6, 2024

Which OS are you using?
Are you sure the pip you used is using the same Python installation as IDA?

from sark.

phros avatar phros commented on June 6, 2024

I am running latest Ubuntu 32bit. No, I am not sure. I guess this is the problem. How do I specify which Python installation is used by my pip?

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

You need to run pip using the Python bundled with IDA. I don't have IDA on Linux, so I can't verify my solution, but here is my idea:

  1. Download the pip installer https://bootstrap.pypa.io/get-pip.py

  2. Execute it inside IDA (File -> Script File)

  3. Execute the following lines in IDAPython:

    import pip
    pip.install(args=['install', '-r', 'full/path/to/requirements.txt'])

This should trigger pip from within IDAPython and make sure it installs in the correct location. Do tell me if it solves it for you.

from sark.

phros avatar phros commented on June 6, 2024

Thanks for Help. I'm getting the following output. It does not find module "_sysconfigdata_nd":

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
No module named _sysconfigdata_nd
Traceback (most recent call last):
  File "/home/*/ida-6.8/python/idaapi.py", line 601, in IDAPython_ExecScript
    execfile(script, g)
  File "/home/*/Downloads/get-pip.py", line 17759, in <module>
    main()
  File "/home/*/Downloads/get-pip.py", line 162, in main
    bootstrap(tmpdir=tmpdir)
  File "/home/*/Downloads/get-pip.py", line 82, in bootstrap
    import pip
  File "/tmp/tmp11SLGK/pip.zip/pip/__init__.py", line 13, in <module>
  File "/tmp/tmp11SLGK/pip.zip/pip/utils/__init__.py", line 19, in <module>
  File "/tmp/tmp11SLGK/pip.zip/pip/locations.py", line 7, in <module>
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 528, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 412, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

{'userbase'}
Traceback (most recent call last):
  File "/home/*/Downloads/ida-6.8/python/idaapi.py", line 601, in IDAPython_ExecScript
    execfile(script, g)
  File "/home/*/Downloads/get-pip.py", line 17759, in <module>
    main()
  File "/home/*/Downloads/get-pip.py", line 162, in main
    bootstrap(tmpdir=tmpdir)
  File "/home/*/Downloads/get-pip.py", line 82, in bootstrap
    import pip
  File "/tmp/tmpQZGJxS/pip.zip/pip/__init__.py", line 13, in <module>
  File "/tmp/tmpQZGJxS/pip.zip/pip/utils/__init__.py", line 19, in <module>
  File "/tmp/tmpQZGJxS/pip.zip/pip/locations.py", line 7, in <module>
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 261, in getusersitepackages
    USER_SITE = get_path('purelib', '%s_user' % os.name)
  File "/usr/lib/python2.7/sysconfig.py", line 497, in get_path
    return get_paths(scheme, vars, expand)[name]
  File "/usr/lib/python2.7/sysconfig.py", line 488, in get_paths
    return _expand_vars(scheme, vars)
  File "/usr/lib/python2.7/sysconfig.py", line 181, in _expand_vars
    res[key] = os.path.normpath(_subst_vars(value, vars))
  File "/usr/lib/python2.7/sysconfig.py", line 163, in _subst_vars
    raise AttributeError('{%s}' % var)
AttributeError: {'userbase'}


Python>import pip
pip.install(args=['install', '-r', '/home/*****/Sark/requirements.txt'])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: zipimport: can not open file /tmp/tmpsJpesV/pip.zip

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Try this - http://stackoverflow.com/questions/15608236/eclipse-and-google-app-engine-importerror-no-module-named-sysconfigdata-nd-u

from sark.

phros avatar phros commented on June 6, 2024

Ok, this was easy.

Now module distutils is missing. Googled this and they say install ez_setup.py. Running this inside IDA brings me to the error that "md5" cannot be imported.

Also installed python-distutils system wide, but it did not help..

Seems to me that the whole thing is not made for installing other packages :(

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Here a similar problem seems to be resolved using https://github.com/Kerrigan29a/idapython_virtualenv. Maybe this will work?

from sark.

phros avatar phros commented on June 6, 2024

I managed to set up the virtual env and installed sark in this environment and the module is found in IDA.
Now I got the following error.

Python>import sark
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/*/.local/lib/python2.7/site-packages/sark/__init__.py", line 28, in <module>
    from . import (core,
  File "/home/*/.local/lib/python2.7/site-packages/sark/codeblocks.py", line 2, in <module>
    import networkx
  File "/home/*/.local/lib/python2.7/site-packages/networkx/__init__.py", line 87, in <module>
    import networkx.readwrite
  File "/home/*/.local/lib/python2.7/site-packages/networkx/readwrite/__init__.py", line 14, in <module>
    from networkx.readwrite.gml import *
  File "/home/*/.local/lib/python2.7/site-packages/networkx/readwrite/gml.py", line 46, in <module>
    from lib2to3.refactor import RefactoringTool
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/refactor.py", line 27, in <module>
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/fixer_util.py", line 9, in <module>
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/pygram.py", line 32, in <module>
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/pgen2/driver.py", line 121, in load_grammar
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/pgen2/pgen.py", line 385, in generate_grammar
  File "/home/*/ida-6.8/python/lib/python27.zip/lib2to3/pgen2/pgen.py", line 15, in __init__
IOError: [Errno 20] Not a directory: '/home/*/ida-6.8/python/lib/python27.zip/lib2to3/Grammar.txt'

from sark.

tmr232 avatar tmr232 commented on June 6, 2024
  1. Is lib2to3 actually there?
  2. Is your default python version the same as IDA's bundled one? (I have another idea)

from sark.

phros avatar phros commented on June 6, 2024
  1. The files for lib2to3 are available, I mean it states the lines in which the error occurs, so it seems to be present. In the documentation from lib2to3 I found the following statement, maybe this is related to the problem:

The lib2to3 API should be considered unstable and may change drastically in the future.

  1. Default python version is 2.7.10. Python version from IDA is 2.7.9.

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

I doubt this is what causes the issue. It is an internal error, and therefore probably not due to API changes. I can't really help much, though.

I have a suggestion of another solution that might work.

  1. Using your default Python (or installing 2.7.9 if that doesn't work) install Sark and all the required packages (you can also install them to a virtualenv, but that is not necessary).
  2. Add the default Python's site-packages directory to IDA's Python path (either using the PYTHONPATH environment variable or a .pth file).
  3. That should (hopefully) do the trick. Even if it is a bit messy.

from sark.

phros avatar phros commented on June 6, 2024

How do I know if IDA is using my default (and correct) Python stuff? I exported the PYTHONPATH to the value /usr/local/lib/python2.7/dist-packages/. The error stays exactly the same. Importing sark in my default Python is no problem.

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

You might want to remove the libraries you already installed in IDA's Python.
Again - I can only help so much, not having a machine to test on.

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

@phros any luck?

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

@phros Any progress?

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Just saw this - https://github.com/Intezer/IDA-Dockerized/blob/master/Dockerfile - maybe it helps?

from sark.

phros avatar phros commented on June 6, 2024

Sorry for not answering.. I tried everything (except the docker stuff) and nothing worked for me. Fixed my problems without using Sark. In case I need it the next time I try the Dockerfile

from sark.

perks avatar perks commented on June 6, 2024

@phros what was the solution! looking for a fix

from sark.

ronyrus avatar ronyrus commented on June 6, 2024

I don't know if it will help, but it something that worked for me on mac os.
No harm in trying I guess, so I'll describe what I did.

  • git clone the sark repository into an arbitrary location
    in my case "~/tools/IDA/Sark"
  • pip install all the dependencies (I did it manually)
  • add the path into the idapythonrc.py located in the "~/.idapro" directory.
    sys.path.append(r"/usr/local/lib/python2.7/site-packages") sys.path.append(r"/Users/<your user>/tools/IDA/Sark")

The reason for including the "site-package" was not related to sark, but it might play a role anyway.

I hope it will work for you.

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Is this issue still relevant?

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Closing, as I get no replies. Let me know if this is still an issue.

from sark.

bdemick avatar bdemick commented on June 6, 2024

I'm running into the same issue (which apparently fixed itself when I was trying on OS X) on Linux. I've pip install --user'd all the dependencies, which put them under $HOME/.local/lib/python2.7/site-packages.
I appended this to IDA's sys.path, and verified that they're all there, and if I launch the system python from that directory and import networkx, I have no problems seeing that module. I'm at a loss with this one! I'm getting the same errors as the original OS X issue I was having. (here's the error in a gist)

Subsequent attempts to import sark (in the same IDA session) result in networkx cannot import name release

from sark.

yannayl avatar yannayl commented on June 6, 2024

This gist should help you build python 32bit interpreter on Ubuntu 16.04 (64bit but should probably work
on 32bit as well) and make IDA use it.
It also shows how to install pip and other packages needed to install Sark.

from sark.

tmr232 avatar tmr232 commented on June 6, 2024

Closing due to inactivity.

from sark.

nav60 avatar nav60 commented on June 6, 2024

Hi,
this issue helped me to resolve networkx issue on the IDAPRO. Thanks
#97
this is helpful. Thanks

from sark.

Related Issues (20)

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.