cSploit / android

cSploit - The most complete and advanced IT security professional toolkit on Android.
http://www.csploit.org/
GNU General Public License v3.0
3.32k stars 1.1k forks source link

preloadVendors() and preloadServices() takes too much time on old devices #332

Closed gustavo-iniguez-goya closed 9 years ago

gustavo-iniguez-goya commented 9 years ago

Edited: the problem is with these 2 methods, which take to load on a htc desire 4s and 11s respectively.

preloadVendors() causes on old devices to display a blank screen on the app start up. preloadServices() causes several problems when using the Port Scanner.

On certain situations, the Port event arrives a few seconds later than the onEnd() event. The result is that we display an info message saying "No open ports detected on current target...", and a few seconds later the opened ports are added to the list. I will add debug messages with timestamps and post the result here if needed.

sorano commented 9 years ago

I have also seen this issue, nothing major, but a bug nonetheless.

gustavo-iniguez-goya commented 9 years ago

Due to this problem, if you perform a port scanner, and exits from the app, when the event arrives this exception is fired:

2131-2930/org.csploit.android E/ACRA﹕ org.csploit.android fatal error : length=0; index=2 java.lang.ArrayIndexOutOfBoundsException: length=0; index=2 at java.util.Vector.arrayIndexOutOfBoundsException(Vector.java:907) at java.util.Vector.elementAt(Vector.java:328) at java.util.Vector.get(Vector.java:442) at org.csploit.android.core.System.getTarget(System.java:1032) at org.csploit.android.core.System.getCurrentTarget(System.java:1044) at org.csploit.android.core.System.addOpenPort(System.java:1144) at org.csploit.android.core.System.addOpenPort(System.java:1134)

gustavo-iniguez-goya commented 9 years ago

When we perform a port scan by the first time, we tried to get the port protocol by calling System.getProtocolByPort(port); from onPortfound().

getProtocolByPort() calls preloadServices() to load known services from files/tools/nmap/nmap-services, which takes 21s. That seems to be the culprit of this behaviour.

gustavo-iniguez-goya commented 9 years ago

Workaround for PortScanner (preloadServces()): by deleting comments (#.*$) and services of "unknown" type from the file nmap-services, the file reduces from ~600KB (~20k lines) to ~80KB (~4k lines), and then it takes to load just 2-3secs.

Does it have any sense to have such a big file to only use 4k lines? @cSploit/android-devs , @users

gustavo-iniguez-goya commented 9 years ago

nmap-services.stripped.txt