WithSecureLabs / needle

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

Fixing the asyncore problems #179

Closed floyd-fuh closed 7 years ago

floyd-fuh commented 7 years ago

Please check this patch and decide and what should be done when the connection is refused (e.g. app on phone not listening yet).

Added

Changes proposed in this pull request:

Fixed

Bug fixes proposed in this pull request:

floyd-fuh commented 7 years ago

Btw this version is now working fine for me and fixes #161:

$ python needle.py -r config_shell.txt 

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

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

[*] Loading commands from resource file
[needle] > set DEBUG True
DEBUG => True
[needle] > set VERBOSE True
VERBOSE => True
[needle] > 
[needle] > set IP 127.0.0.1
IP => 127.0.0.1
[needle] > set PORT 2222
PORT => 2222
[needle] > set PASSWORD PLACEHOLDER
PASSWORD => ********
[needle] > 
[needle] > shell
[*] Spawning a shell...
[*] Checking connection with device...
[V] Connection not present, creating a new instance
[D] Setting up USB port forwarding on port 2222
[D] [LOCAL CMD] Local Subprocess Command: /opt/needle_floyd/needle/libs/usbmuxd/tcprelay.py -t 22:2222
[D] [AGENT] Setting up port forwarding on port 4444
[V] [AGENT] Connecting to agent (127.0.0.1:4444)...
[+] [AGENT] Successfully connected to agent (127.0.0.1:4444)...
[D] [AGENT] Executing command: os_version
[V] [SSH] Connecting (127.0.0.1:2222)...
[+] [SSH] Connected (127.0.0.1:2222)
[D] [LOCAL CMD] Local Interactive Command: sshpass -p "PLACEHOLDER" ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 2222 root@127.0.0.1
Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
HelloWorld:~ root# pwd
/var/root
HelloWorld:~ root# echo yay
yay
HelloWorld:~ root# exit
logout
Connection to 127.0.0.1 closed.
[needle] > 
[needle] > EOF
[+] Resource file successfully loaded
[needle] > exit
[D] Saving command history to: /Users/user/.needle/needle_history
[V] Cleaning local temp folder: /Users/user/.needle/tmp
[D] Cleaning up remote temp folder: /var/root/needle/
[D] [REMOTE CMD] Remote Command: if [ -d /var/root/needle/ ]; then echo "yes"; else echo "no" ; fi
[V] [SSH] Disconnecting...
[V] [AGENT] Disconnecting from agent...
[D] Stopping USB port forwarding
[D] [LOCAL CMD] Stopping Local Subprocess Command [pid: 12878]
[D] [AGENT] Stopping port forwarding
$
marco-lancini commented 7 years ago

Hi @floyd-fuh, thank you very much for taking the time to fix this. Your fix has just been merged to master: https://github.com/mwrlabs/needle/releases/tag/v1.3.1