WithSecureLabs / needle

The iOS Security Testing Framework
https://mobiletools.mwrinfosecurity.com/
Other
1.33k stars 283 forks source link

Needle failed to connect to iOS Device via USB #100

Closed illnino closed 7 years ago

illnino commented 7 years ago

Failed to install required tools on iOS device

Expected behaviour

With SETUP_DEVICE=True, needle should install required tools on the iOS device.

Actual behaviour

Error returned, stating Exception: Could not open a connection to 127.0.0.1. AttributeError - 'EntryPoint' object has no attribute 'resolve'

Steps to reproduce

  1. Install required tools on MacOS
  2. Connect Jailbroken iPhone to MacOS
  3. Run python needle.py -r config.txt with SETUP_DEVICE=True & DEBUG=True
  4. Error found - Exception: Could not open a connection to 127.0.0.1. AttributeError - 'EntryPoint' object has no attribute 'resolve'

needle error logs

Ensure verbose and debug mode are enabled:

[needle] > set VERBOSE True
VERBOSE => True
[needle] > set DEBUG True
DEBUG => True
➜  needle git:(master) python needle.py
Traceback (most recent call last):
  File "needle.py", line 9, in <module>
    from core.framework import cli
  File "/Users/its/Project/tools/needle/needle/core/framework/cli.py", line 9, in <module>
    from framework import Framework, FrameworkException
  File "/Users/its/Project/tools/needle/needle/core/framework/framework.py", line 9, in <module>
    from ..device.device import Device
  File "/Users/its/Project/tools/needle/needle/core/device/device.py", line 2, in <module>
    import paramiko
ImportError: No module named paramiko

Try to reinstall paramiko

➜  needle git:(master) sudo -H pip install paramiko --ignore-installed
Collecting paramiko
  Using cached paramiko-2.1.1-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from paramiko)
  Downloading pyasn1-0.1.9-py2.py3-none-any.whl
Collecting cryptography>=1.1 (from paramiko)
  Using cached cryptography-1.7.1-cp27-cp27m-macosx_10_10_intel.whl
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko)
  Using cached cffi-1.9.1-cp27-cp27m-macosx_10_10_intel.whl
Collecting setuptools>=11.3 (from cryptography>=1.1->paramiko)
  Using cached setuptools-32.3.0-py2.py3-none-any.whl
Collecting six>=1.4.1 (from cryptography>=1.1->paramiko)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting idna>=2.0 (from cryptography>=1.1->paramiko)
  Using cached idna-2.2-py2.py3-none-any.whl
Collecting ipaddress (from cryptography>=1.1->paramiko)
  Using cached ipaddress-1.0.17-py2-none-any.whl
Collecting enum34 (from cryptography>=1.1->paramiko)
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.1->paramiko)
Installing collected packages: pyasn1, pycparser, cffi, setuptools, six, idna, ipaddress, enum34, cryptography, paramiko
Successfully installed cffi-1.9.1 cryptography-1.7.1 enum34-1.1.6 idna-2.2 ipaddress-1.0.17 paramiko-2.1.1 pyasn1-0.1.9 pycparser-2.17 setuptools-32.3.0 six-1.10.0

Check if paramiko works fine

➜  needle git:(master) ✗ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from paramiko.dsskey import DSSKey
>>>
➜  needle git:(master) ✗ python needle.py -r config.txt

             __   _ _______ _______ ______         _______
             | \  | |______ |______ |     \ |      |______
             |  \_| |______ |______ |_____/ |_____ |______

                   Needle v0.1.1 [mwr.to/needle]
  [MWR InfoSecurity (@MWRLabs) - Marco Lancini (@LanciniMarco)]

[*] Loading commands from resource file
[needle] > set DEBUG True
DEBUG => True
[needle] > set SETUP_DEVICE True
SETUP_DEVICE => True
[needle] > EOF
[+] Resource file successfully loaded
[needle] >
[needle] > use binary/meta
[needle][metadata] > run
[D] Setup local output folder: /Users/its/.needle/output
[*] Checking connection with device...
[V] Connection not present, creating a new instance
[V] Setting up USB port forwarding on port 2222
[D] [LOCAL CMD] Local Subprocess Command: /Users/its/Project/tools/needle/needle/libs/usbmuxd/tcprelay.py -t 22:2222
[V] Setting up SSH connection...
No handlers could be found for logger "paramiko.transport"
[!] Problem establishing connection: Exception - Could not open a connection to 127.0.0.1. AttributeError - 'EntryPoint' object has no attribute 'resolve' .
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/its/Project/tools/needle/needle/core/framework/framework.py", line 642, in _connection_new
    self.device.connect()
  File "/Users/its/Project/tools/needle/needle/core/device/device.py", line 221, in connect
    self._connect_ssh()
  File "/Users/its/Project/tools/needle/needle/core/device/device.py", line 101, in _connect_ssh
    raise Exception('Could not open a connection to %s. %s - %s' % (self._ip, type(e).__name__, e.message))
Exception: Could not open a connection to 127.0.0.1. AttributeError - 'EntryPoint' object has no attribute 'resolve'
------------------------------------------------------------
[!] Exception: Could not open a connection to 127.0.0.1. AttributeError - 'EntryPoint' object has no attribute 'resolve'.
[V] Stopping USB port forwarding
[D] [LOCAL CMD] Stopping Local Subprocess Command [pid: 20123]

Environment

Workstation Operating System

MacOs 10.11.6

Python Version

Python 2.7.10 (default, Oct 23 2015, 19:19:21)

Python Packages (pip freeze)

➜  needle git:(master) ✗ pip freeze
alembic==0.8.8
altgraph==0.10.2
ana==0.2
androguard==3.0
angr==5.6.10.12
angr-only-z3-custom==9002
appnope==0.1.0
archinfo==5.6.10.5
attrs==16.2.0
awsebcli==3.8.4
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.5.0.1
bdist-mpkg==0.5.0
bintrees==2.0.4
blessed==1.9.5
blessings==1.6
bonjour-py==0.3
botocore==1.4.78
cachetools==2.0.0
capstone==3.0.4
cement==2.8.2
certifi==2016.8.31
cffi==1.8.2
chardet==2.3.0
claripy==5.6.10.12
cle==5.6.10.5
click==6.6
cmd2==0.6.9
colorama==0.3.7
configparser==3.5.0
cooldict==1.2
cryptography==1.5
dataset==0.7.0
decorator==4.0.10
Django==1.10b1
docker-py==1.7.2
dockerpty==0.4.1
docopt==0.6.2
docutils==0.12
dominate==2.2.1
dpkt-fix==1.7
enum34==1.1.6
Flask==0.11.1
Flask-Bootstrap==3.3.7.0
Flask-Script==2.0.5
frida==8.2.2
future==0.15.2
futures==3.0.5
haxor-news==0.4.1
html5lib==1.0b8
idalink==0.11
idna==2.1
ipaddress==1.0.16
ipython==5.1.0
ipython-genutils==0.1.0
itsdangerous==0.24
Jinja2==2.8
jmespath==0.9.0
lxml==3.6.4
macholib==1.5.1
Mako==1.0.6
MarkupSafe==0.23
matplotlib==1.3.1
modulegraph==0.10.4
mulpyplexer==0.7
networkx==1.11
normality==0.3.6
numpy==1.8.0rc1
paramiko==2.1.1
pathlib2==2.1.0
pathspec==0.3.4
pbr==1.10.0
pefile==2016.3.28
pexpect==4.2.1
pickleshare==0.7.4
Pillow==3.3.1
plumbum==1.6.2
progressbar==2.3
prompt-toolkit==1.0.7
psutil==4.2.0
ptyprocess==0.5.1
py2app==0.7.3
pyasn1==0.1.9
pyasn1-modules==0.0.8
pycparser==2.14
pyelftools==0.24
Pygments==2.1.3
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyOpenSSL==0.13.1
pyparsing==2.0.1
PyPDF2==1.26.0
python-dateutil==1.5
python-editor==1.0.1
pytz==2013.7
pyvex==5.6.10.5
PyYAML==3.12
reportlab==3.3.0
requests==2.12.1
rpyc==3.3.0
rsa==3.4.2
scipy==0.13.0b1
semantic-version==2.5.0
service-identity==16.0.0
simplegeneric==0.8.1
simuvex==5.6.10.12
six==1.4.1
SQLAlchemy==1.1.4
sshtunnel==0.1.2
stevedore==1.18.0
termcolor==1.1.0
texttable==0.8.7
tornado==4.1
traitlets==4.3.1
Twisted==16.4.1
txdbus==1.0.13
vboxapi==1.0
virtualenv==15.1.0
virtualenv-clone==0.2.6
virtualenvwrapper==4.7.2
visitor==0.1.3
wcwidth==0.1.7
websocket-client==0.37.0
Werkzeug==0.11.11
wpa-supplicant==0.2
xattr==0.6.4
xhtml2pdf==0.0.6
z3-solver==4.4.2.1.post1
zope.interface==4.1.1

Device iOS Version

iOS 9.1

illnino commented 7 years ago

Downgrade cryptography should fix the problem.

pip install cryptography==1.2.1
floyd-fuh commented 7 years ago

That's fine and all, but why not change the Installation howto that says cryptography==1.2.1 is necessary and let all users run into this bug themselves?