com.wjholden.nmap
Class Nmap

java.lang.Object
  extended by Activity
      extended by com.wjholden.nmap.Nmap
All Implemented Interfaces:
Nmap_Constants

public class Nmap
extends Activity
implements Nmap_Constants

Version:
0.4.2 Nmap for Android! The original versions used Nmap binaries I got from Robert McCurdy (http://rmccurdy.com/stuff/G1/BINS/NMAP/). Around v0.3 or Vlatko Kosturjak build newer binaries based on Nmap 5.3 (http://ftp.linux.hr/android/nmap/). TODO: Finish Wifi check, (DONE)build options menu to toggle logcat on, and finish JavaDoc. (DONE) Also, create logic to conditionally execute verifyInstallation() - your users will love you.
Author:
William John Holden (wjholden@gmail.com)

Field Summary
static String bindir
          this is where the nmap/nping/ncat compiled binaries should be stored.
static boolean canGetRoot
          tells us if "su" command is available
static boolean DEBUG
          This variable is set by the user with the context menu.
static Handler h
          handler for inter-thread communication
static boolean hasRunOneScan
          tells us whether one or more scans have been executed
static boolean installationVerified
          if "verifyInstallation()" method has run this should be set to true
private  EditText mArguments
          Input area where command-line arguments (other than target IP)
private  Spinner mCommandSpinner
          Command spinner switches between Nmap, Nping, and Ncat
private  Button mHelp
          Help button, shows result of [command] --help
private  Spinner mOutputSpinner
          Switches between Nmap, XML, and Grepable Nmap output
private  TextView mResults
          Text area where results are shown
private  Button mShare
          Share button, launches Compose Email activity with message body of any data in mResults
private  Button mStart
          Start button initiates scan
private  EditText mTarget
          Input area where user supplies scan target
static NmapError ne
          Instance of my custom error logging utility, designed to store (instead of just stream) debugging output for troubleshooting.
static String outputArgs
          the command to be executed (nmap, nping, ncat) and optional (and mandatory) command line arguments from mArguments
static ProgressDialog pd
          Static so that the other classes can turn it off after it runs.
private  SharedPreferences.Editor preferencesEditor
          Use this to save application and user settings into the SharedPreferences.
static int scanType
          tells the scanning engine what command is to be executed (nmap, nping, ncat)
private  SharedPreferences settings
          Store both user and application settings in here.
static String sh
          location of the 'su' command, if present, otherwise 'sh'.
private   sTask
          scanning engine thread
private   vTask
          verify installation thread
private  WifiInfo wifiInfo
          Provides methods for getting IP address and SSID.
private  WifiManager wifiManager
          Only used get get IP address and SSID.
 
Fields inherited from interface com.wjholden.nmap.Nmap_Constants
BUFFER_SIZE, INSTALL_ERROR, INSTALL_GOOD, INSTALL_NO_ROOT, MENU_GROUP_DEBUG, MENU_GROUP_EXTRA_OPTIONS, MENU_ITEM_DEBUG_EMAIL, MENU_ITEM_DEBUG_ENABLE, MENU_ITEM_EXIT, MENU_ITEM_MORE_HELP, MENU_ITEM_REINSTALL, RUN_COMPLETE, RUN_ERROR, RUN_LINE, SCANTYPE_NCAT, SCANTYPE_NDIFF, SCANTYPE_NMAP, SCANTYPE_NPING, TAG, THREAD_ERROR
 
Constructor Summary
Nmap()
           
 
Method Summary
 void onCreate(Bundle savedInstanceState)
           
protected  void onDestroy()
           
 boolean onMenuItemSelected(int featureId, MenuItem item)
           
protected  void onPause(Bundle outState)
           
 boolean onPrepareOptionsMenu(Menu menu)
           
protected  void onResume(Bundle savedInstanceState)
           
private  void saveUserEntry()
           
static void setBinDir(String b)
           
static void setSh(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bindir

public static String bindir
this is where the nmap/nping/ncat compiled binaries should be stored.


canGetRoot

public static boolean canGetRoot
tells us if "su" command is available


DEBUG

public static boolean DEBUG
This variable is set by the user with the context menu. If on, use the Log utility to send debugging information to logcat, and also present user with a menu option to e-mail debugging output to developer.


h

public static Handler h
handler for inter-thread communication


hasRunOneScan

public static boolean hasRunOneScan
tells us whether one or more scans have been executed


installationVerified

public static boolean installationVerified
if "verifyInstallation()" method has run this should be set to true

Since:
0.4.2 This and most other static variables here are saved in SharedPreferences so verifyInstallation only runs once.

mArguments

private EditText mArguments
Input area where command-line arguments (other than target IP)


mCommandSpinner

private Spinner mCommandSpinner
Command spinner switches between Nmap, Nping, and Ncat


mHelp

private Button mHelp
Help button, shows result of [command] --help


mOutputSpinner

private Spinner mOutputSpinner
Switches between Nmap, XML, and Grepable Nmap output


mResults

private TextView mResults
Text area where results are shown


mShare

private Button mShare
Share button, launches Compose Email activity with message body of any data in mResults


mStart

private Button mStart
Start button initiates scan


mTarget

private EditText mTarget
Input area where user supplies scan target


ne

public static NmapError ne
Instance of my custom error logging utility, designed to store (instead of just stream) debugging output for troubleshooting.


outputArgs

public static String outputArgs
the command to be executed (nmap, nping, ncat) and optional (and mandatory) command line arguments from mArguments


pd

public static ProgressDialog pd
Static so that the other classes can turn it off after it runs. This shall be the only ProgressDialog used. Don't use "new" - instead just change the text and show/hide it.


preferencesEditor

private SharedPreferences.Editor preferencesEditor
Use this to save application and user settings into the SharedPreferences.


scanType

public static int scanType
tells the scanning engine what command is to be executed (nmap, nping, ncat)


settings

private SharedPreferences settings
Store both user and application settings in here.


sh

public static String sh
location of the 'su' command, if present, otherwise 'sh'.


sTask

private  sTask
scanning engine thread


vTask

private  vTask
verify installation thread


wifiInfo

private WifiInfo wifiInfo
Provides methods for getting IP address and SSID.


wifiManager

private WifiManager wifiManager
Only used get get IP address and SSID.

Constructor Detail

Nmap

public Nmap()
Method Detail

onCreate

public void onCreate(Bundle savedInstanceState)

onDestroy

protected void onDestroy()

onMenuItemSelected

public boolean onMenuItemSelected(int featureId,
                                  MenuItem item)

onPause

protected void onPause(Bundle outState)

onPrepareOptionsMenu

public boolean onPrepareOptionsMenu(Menu menu)

onResume

protected void onResume(Bundle savedInstanceState)

saveUserEntry

private void saveUserEntry()

setBinDir

public static void setBinDir(String b)

setSh

public static void setSh(String s)