Search in sources :

Example 6 with InputDialog

use of org.csploit.android.gui.dialogs.InputDialog in project android by cSploit.

the class PortScanner method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.scanner_custom_parameters:
            if (item.isChecked())
                hideParametersField();
            else
                displayParametersField();
            item.setChecked(!item.isChecked());
            return true;
        case R.id.select_ports:
            new InputDialog(getString(R.string.select_ports), getString(R.string.enter_ports_list), this, new InputDialogListener() {

                @Override
                public void onInputEntered(String input) {
                    input = input.trim();
                    if (!input.isEmpty()) {
                        String[] ports = input.split("[^\\d]+");
                        for (String port : ports) {
                            try {
                                if (port.isEmpty())
                                    throw new Exception(getString(R.string.invalid_port_) + port + "'.");
                                else {
                                    int iport = Integer.parseInt(port);
                                    if (iport <= 0 || iport > 65535)
                                        throw new Exception(getString(R.string.port_must_be_greater));
                                }
                            } catch (Exception e) {
                                new ErrorDialog("Error", e.toString(), PortScanner.this).show();
                                return;
                            }
                        }
                        mCustomPorts = "";
                        for (int i = 0, last = ports.length - 1; i < ports.length; i++) {
                            mCustomPorts += ports[i];
                            if (i != last)
                                mCustomPorts += ",";
                        }
                        if (mCustomPorts.isEmpty()) {
                            mCustomPorts = null;
                            new ErrorDialog(getString(R.string.error), getString(R.string.invalid_ports), PortScanner.this).show();
                        }
                        hideParametersField();
                        mMenu.findItem(R.id.scanner_custom_parameters).setChecked(false);
                        Logger.debug("mCustomPorts = " + mCustomPorts);
                    } else
                        new ErrorDialog(getString(R.string.error), getString(R.string.empty_port_list), PortScanner.this).show();
                }
            }).show();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : InputDialogListener(org.csploit.android.gui.dialogs.InputDialog.InputDialogListener) InputDialog(org.csploit.android.gui.dialogs.InputDialog) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 7 with InputDialog

use of org.csploit.android.gui.dialogs.InputDialog in project android by cSploit.

the class WifiScannerFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    final ScanResult result = mAdapter.getItem(position);
    if (result != null) {
        final Keygen keygen = mWifiMatcher.getKeygen(result);
        mPreviousConfig = NetworkManager.getWifiConfiguration(mWifiManager, result);
        if (mPreviousConfig != null) {
            mWifiManager.removeNetwork(mPreviousConfig.networkId);
        }
        if (keygen != null && (result.capabilities.contains("WEP") || result.capabilities.contains("WPA"))) {
            mKeyList.clear();
            new WifiCrackDialog(result.SSID, getResources().getString(R.string.enter_key_or_crack), getActivity(), new WifiCrackDialogListener() {

                @Override
                public void onManualConnect(String key) {
                    mCurrentNetworkId = performConnection(result, key);
                    if (mCurrentNetworkId != -1)
                        mConnectionReceiver.register(getActivity());
                    else
                        mConnectionReceiver.unregister();
                }

                @Override
                public void onCrack() {
                    performCracking(keygen, result);
                }
            }).show();
        } else {
            if (result.capabilities.contains("WEP") || result.capabilities.contains("WPA")) {
                new InputDialog(result.SSID, getString(R.string.enter_wifi_key), null, true, true, getActivity(), new InputDialogListener() {

                    @Override
                    public void onInputEntered(String input) {
                        mCurrentNetworkId = performConnection(result, input);
                        if (mCurrentNetworkId != -1)
                            mConnectionReceiver.register(getActivity());
                        else
                            mConnectionReceiver.unregister();
                    }
                }).show();
            } else
                performConnection(result, null);
        }
    }
}
Also used : InputDialogListener(org.csploit.android.gui.dialogs.InputDialog.InputDialogListener) ScanResult(android.net.wifi.ScanResult) Keygen(org.csploit.android.wifi.Keygen) InputDialog(org.csploit.android.gui.dialogs.InputDialog) WifiCrackDialog(org.csploit.android.gui.dialogs.WifiCrackDialog) WifiCrackDialogListener(org.csploit.android.gui.dialogs.WifiCrackDialog.WifiCrackDialogListener)

Aggregations

InputDialog (org.csploit.android.gui.dialogs.InputDialog)7 InputDialogListener (org.csploit.android.gui.dialogs.InputDialog.InputDialogListener)7 Intent (android.content.Intent)4 ErrorDialog (org.csploit.android.gui.dialogs.ErrorDialog)4 SharedPreferences (android.content.SharedPreferences)3 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 TextView (android.widget.TextView)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ConfirmDialog (org.csploit.android.gui.dialogs.ConfirmDialog)2 ConfirmDialogListener (org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener)2 ScanResult (android.net.wifi.ScanResult)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)1 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)1