WithSecureLabs / needle

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

Problem establishing connection #243

Closed pragyan1994 closed 6 years ago

pragyan1994 commented 6 years ago

Issue - Problem establishing connection

Expected behaviour

The device should be connected and it should be working

Actual behaviour

Name Current Value Required Description


AGENT_PORT 4444 yes Port on which the Needle Agent is listening APP no Bundle ID of the target application (e.g., com.example.app). Leave empty to launch wizard DEBUG True yes Enable debugging output HIDE_SYSTEM_APPS False yes If set to True, only 3rd party apps will be shown IP 192.168.43.191 yes IP address of the testing device (set to localhost to use USB) OUTPUT_FOLDER /Users/pragyan.a.paramita/.needle/output yes Full path of the output folder, where to store the output of the modules PASSWORD **** yes SSH Password of the testing device PORT 2222 yes Port of the SSH agent on the testing device (needs to be != 22 to use USB) PUB_KEY_AUTH True yes Use public key auth to authenticate to the device. Key must be present in the ssh-agent if a passphrase is used SAVE_HISTORY True yes Persists command history across sessions SKIP_OUTPUT_FOLDER_CHECK False no Skip the check that ensures the output folder does not already contain other files. It will automatically overwrite any file USERNAME root yes SSH Username of the testing device VERBOSE True yes Enable verbose output

[needle] > use device/list_apps [needle][list_apps] > run [*] Checking connection with device... [V] Connection not present, creating a new instance [V] [AGENT] Connecting to agent (192.168.43.191:4444)... [!] Problem establishing connection: error -

Traceback (most recent call last): File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/framework/framework.py", line 641, in _connection_new self.device.connect() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 218, in connect self._connect_agent() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 158, in _connect_agent self.agent.connect() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/agent.py", line 53, in connect self.client = AsyncClient(self._ip, self._port) File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/agent.py", line 18, in init raise se error: [Errno 60] Operation timed out

[!] error: [Errno 60] Operation timed out [V] [SSH] Disconnecting..

Steps to reproduce

  1. run agent on port 4444, and the device IP
  2. Set the same over options in needle over machine
  3. run a selected module.

needle error logs

Name Current Value Required Description


AGENT_PORT 4444 yes Port on which the Needle Agent is listening APP no Bundle ID of the target application (e.g., com.example.app). Leave empty to launch wizard DEBUG True yes Enable debugging output HIDE_SYSTEM_APPS False yes If set to True, only 3rd party apps will be shown IP 192.168.43.191 yes IP address of the testing device (set to localhost to use USB) OUTPUT_FOLDER /Users/pragyan.a.paramita/.needle/output yes Full path of the output folder, where to store the output of the modules PASSWORD **** yes SSH Password of the testing device PORT 2222 yes Port of the SSH agent on the testing device (needs to be != 22 to use USB) PUB_KEY_AUTH True yes Use public key auth to authenticate to the device. Key must be present in the ssh-agent if a passphrase is used SAVE_HISTORY True yes Persists command history across sessions SKIP_OUTPUT_FOLDER_CHECK False no Skip the check that ensures the output folder does not already contain other files. It will automatically overwrite any file USERNAME root yes SSH Username of the testing device VERBOSE True yes Enable verbose output

[needle] > use device/list_apps [needle][list_apps] > run [*] Checking connection with device... [V] Connection not present, creating a new instance [V] [AGENT] Connecting to agent (192.168.43.191:4444)... [!] Problem establishing connection: error -

Traceback (most recent call last): File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/framework/framework.py", line 641, in _connection_new self.device.connect() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 218, in connect self._connect_agent() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 158, in _connect_agent self.agent.connect() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/agent.py", line 53, in connect self.client = AsyncClient(self._ip, self._port) File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/agent.py", line 18, in init raise se error: [Errno 60] Operation timed out

[!] error: [Errno 60] Operation timed out [V] [SSH] Disconnecting..

Environment - mac OS, high sierra

Needle Version -

Workstation Operating System - Mac OS, high sierra, 10.13.3

Python Version

2.7.10

Python Packages (pip freeze)

apkid==1.0.0 appnope==0.1.0 asn1crypto==0.23.0 backports-abc==0.5 backports.ssl-match-hostname==3.4.0.2 bcrypt==3.1.3 beautifulsoup4==4.4.1 bleach==1.4.2 bugzilla==1.0.0 cement==2.10.2 certifi==2018.1.18 cffi==1.11.5 chardet==3.0.4 cheroot==5.8.3 CherryPy==11.0.0 click==6.7 colorama==0.3.9 configparser==3.5.0 coverage==4.0.3 cryptography==2.1.4 decorator==4.0.9 Django==1.11.7 -e git+https://github.com/mwrlabs/drozer/@91132ddae52275d308fa5f4baec2ebc3ee6b29fa#egg=drozer EditorConfig==0.12.1 enum34==1.0.4 Flask==0.10.1 Flask-Restless==0.17.0 Flask-SQLAlchemy==2.2 frida==10.5.15 graphviz==0.8 html5lib==0.9999999 idna==2.6 ipaddress==1.0.14 itsdangerous==0.24 Jinja2==2.9.6 jsbeautifier==1.7.0 lxml==4.1.1 MarkupSafe==1.0 mimerender==0.6.0 paramiko==2.2.1 Paste==2.0.3 pbr==3.1.1 pdfkit==0.6.1 portend==2.1.2 poster==0.8.1 prettytable==0.7.2 prompt-toolkit==1.0.15 protobuf==3.4.0 psycopg2==2.7.4 pyasn1==0.1.8 pycparser==2.14 pydot==1.2.3 pyfiglet==0.7.5 Pygments==2.2.0 PyNaCl==1.1.2 pyOpenSSL==17.5.0 pyparsing==2.2.0 python-dateutil==2.6.1 python-mimeparse==1.6.0 pytz==2017.2 PyYAML==3.12 requests==2.18.4 rsa==3.4.2 simplejson==3.11.1 singledispatch==3.4.0.3 six==1.9.0 smalisca==0.2 SQLAlchemy==1.2.0b2 sshtunnel==0.1.2 stevedore==1.23.0 tempora==1.9 tornado==4.5.3 Unirest==1.1.7 urllib3==1.22 virtualenv==15.1.0 virtualenv-clone==0.2.6 virtualenvwrapper==4.7.2 wcwidth==0.1.7 web.py==0.40.dev0 Werkzeug==0.12.2 yara-python==3.5.0.999 ~$:

Device iOS Version - iphone, 4, 9.3.2

HenryHoggard commented 6 years ago

Can't reproduce this. What jailbreak are you using

pragyan1994 commented 6 years ago

Hi Henry, i am using phoneix jailbreak. It is semi - jailbreak though. should that be an issue anyway ?

pragyan1994 commented 6 years ago

Hi Henry,

Right now, i am getting this issue.

[needle][list_apps] > use device/list_apps [+] Resource file successfully loaded [needle][list_apps] > use device/list_apps [needle][list_apps] > run [*] Checking connection with device... [V] Connection not present, creating a new instance [V] [AGENT] Connecting to agent (192.168.43.149:4444)... [+] [AGENT] Successfully connected to agent (192.168.43.149:4444)... [D] [AGENT] Executing command: os_version [V] [SSH] Connecting (192.168.43.149:2222)... [!] Problem establishing connection: Exception - Could not open a connection to 192.168.43.149. NoValidConnectionsError -

Traceback (most recent call last): File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/framework/framework.py", line 641, in _connection_new self.device.connect() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 219, in connect self.ssh = self._connect_ssh() File "/Users/pragyan.a.paramita/Desktop/needle/needle/core/device/device.py", line 95, 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 192.168.43.149. NoValidConnectionsError -

[!] Exception: Could not open a connection to 192.168.43.149. NoValidConnectionsError - [V] [SSH] Disconnecting... [V] [AGENT] Disconnecting from agent... [needle][list_apps] >

The agent gets connected and later gets disconneted with this error above.

HenryHoggard commented 6 years ago

Try manually ssh to the device and show me what happens.

pragyan1994 commented 6 years ago

It is giving me a bind error 1!

HenryHoggard commented 6 years ago

This isn't a needle issue, this is an issue with your device or jailbreak then.