Search in sources :

Example 1 with ConfirmDialog

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

the class MainFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch(item.getItemId()) {
        case R.id.add:
            new InputDialog(getString(R.string.add_custom_target), getString(R.string.enter_url), getActivity(), new InputDialogListener() {

                @Override
                public void onInputEntered(String input) {
                    final Target target = Target.getFromString(input);
                    if (target != null) {
                        ThreadHelper.getSharedExecutor().execute(new Runnable() {

                            @Override
                            public void run() {
                                System.addOrderedTarget(target);
                            }
                        });
                    } else
                        new ErrorDialog(getString(R.string.error), getString(R.string.invalid_target), getActivity()).show();
                }
            }).show();
            return true;
        case R.id.scan:
            startNetworkRadar();
            return true;
        case R.id.wifi_ifaces:
            displayNetworkInterfaces(true);
            return true;
        case R.id.wifi_scan:
            stopNetworkRadar();
            mRadarReceiver.unregister();
            mUpdateReceiver.unregister();
            startActivityForResult(new Intent(getActivity(), WifiScannerActivity.class), WIFI_CONNECTION_REQUEST);
            getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein);
            return true;
        case R.id.new_session:
            new ConfirmDialog(getString(R.string.warning), getString(R.string.warning_new_session), getActivity(), new ConfirmDialogListener() {

                @Override
                public void onConfirm() {
                    try {
                        System.reset();
                        Toast.makeText(getActivity(), getString(R.string.new_session_started), Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        new FatalDialog(getString(R.string.error), e.toString(), getActivity()).show();
                    }
                }

                @Override
                public void onCancel() {
                }
            }).show();
            return true;
        case R.id.save_session:
            new InputDialog(getString(R.string.save_session), getString(R.string.enter_session_name), System.getSessionName(), true, false, getActivity(), new InputDialogListener() {

                @Override
                public void onInputEntered(String input) {
                    String name = input.trim().replace("/", "").replace("..", "");
                    if (!name.isEmpty()) {
                        try {
                            String filename = System.saveSession(name);
                            Toast.makeText(getActivity(), getString(R.string.session_saved_to) + filename + " .", Toast.LENGTH_SHORT).show();
                        } catch (IOException e) {
                            new ErrorDialog(getString(R.string.error), e.toString(), getActivity()).show();
                        }
                    } else
                        new ErrorDialog(getString(R.string.error), getString(R.string.invalid_session), getActivity()).show();
                }
            }).show();
            return true;
        case R.id.restore_session:
            final ArrayList<String> sessions = System.getAvailableSessionFiles();
            if (sessions != null && sessions.size() > 0) {
                new SpinnerDialog(getString(R.string.select_session), getString(R.string.select_session_file), sessions.toArray(new String[sessions.size()]), getActivity(), new SpinnerDialogListener() {

                    @Override
                    public void onItemSelected(int index) {
                        String session = sessions.get(index);
                        try {
                            System.loadSession(session);
                        } catch (Exception e) {
                            e.printStackTrace();
                            new ErrorDialog(getString(R.string.error), e.getMessage(), getActivity()).show();
                        }
                    }
                }).show();
            } else
                new ErrorDialog(getString(R.string.error), getString(R.string.no_session_found), getActivity()).show();
            return true;
        case R.id.settings:
            startActivity(new Intent(getActivity(), SettingsActivity.class));
            getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein);
            return true;
        case R.id.ss_monitor:
            new Thread(new Runnable() {

                @Override
                public void run() {
                    Services.getNetworkRadar().onMenuClick(getActivity(), item);
                }
            }).start();
            return true;
        case R.id.ss_msfrpcd:
            new Thread(new Runnable() {

                @Override
                public void run() {
                    Services.getMsfRpcdService().onMenuClick(getActivity(), item);
                }
            }).start();
            return true;
        case R.id.submit_issue:
            String uri = getString(R.string.github_new_issue_url);
            Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
            startActivity(browser);
            //   String.format(getString(R.string.issue_message), getString(R.string.github_issues_url), getString(R.string.github_new_issue_url));
            return true;
        case R.id.about:
            new AboutDialog(getActivity()).show();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : InputDialog(org.csploit.android.gui.dialogs.InputDialog) AboutDialog(org.csploit.android.gui.dialogs.AboutDialog) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) IOException(java.io.IOException) NoRouteToHostException(java.net.NoRouteToHostException) IOException(java.io.IOException) InputDialogListener(org.csploit.android.gui.dialogs.InputDialog.InputDialogListener) Target(org.csploit.android.net.Target) SpinnerDialog(org.csploit.android.gui.dialogs.SpinnerDialog) SpinnerDialogListener(org.csploit.android.gui.dialogs.SpinnerDialog.SpinnerDialogListener) FatalDialog(org.csploit.android.gui.dialogs.FatalDialog) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 2 with ConfirmDialog

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

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    if (mLastBackPressTime < java.lang.System.currentTimeMillis() - 4000) {
        mToast = Toast.makeText(this, getString(R.string.press_back), Toast.LENGTH_SHORT);
        mToast.show();
        mLastBackPressTime = java.lang.System.currentTimeMillis();
    } else {
        if (mToast != null)
            mToast.cancel();
        new ConfirmDialog(getString(R.string.exit), getString(R.string.close_confirm), this, new ConfirmDialogListener() {

            @Override
            public void onConfirm() {
                MainActivity.this.finish();
            }

            @Override
            public void onCancel() {
            }
        }).show();
        mLastBackPressTime = 0;
    }
}
Also used : ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 3 with ConfirmDialog

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

the class PortScanner method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    mPreferences = System.getSettings();
    mTextDoc = (TextView) findViewById(R.id.scanDoc);
    mTextParameters = (EditText) findViewById(R.id.scanParameters);
    mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
    mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
    mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
    if (mShowCustomParameters)
        displayParametersField();
    else
        hideParametersField();
    mScanFloatingActionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    ListView mScanList = (ListView) findViewById(R.id.scanListView);
    createPortList();
    final Target target = System.getCurrentTarget();
    final String cmdlineRep = target.getCommandLineRepresentation();
    mScanReceiver = new Receiver(target);
    mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
    mScanList.setAdapter(mListAdapter);
    mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            int portNumber = target.getOpenPorts().get(position).getNumber();
            if (!urlFormats.containsKey(portNumber)) {
                portNumber = 0;
            }
            final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
            new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {

                @Override
                public void onConfirm() {
                    try {
                        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        PortScanner.this.startActivity(browser);
                    } catch (ActivityNotFoundException e) {
                        System.errorLogging(e);
                        new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
                    }
                }

                @Override
                public void onCancel() {
                }
            }).show();
            return false;
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Target(org.csploit.android.net.Target) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) OnClickListener(android.view.View.OnClickListener) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 4 with ConfirmDialog

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

the class Sniffer method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    setTitle(System.getCurrentTarget() + " > MITM > Sniffer");
    setContentView(R.layout.plugin_mitm_sniffer);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mSniffToggleButton = (ToggleButton) findViewById(R.id.sniffToggleButton);
    mSniffProgress = (ProgressBar) findViewById(R.id.sniffActivity);
    mSortSpinner = (Spinner) findViewById(R.id.sortSpinner);
    mListView = (ListView) findViewById(R.id.listView);
    mAdapter = new StatListAdapter(R.layout.plugin_mitm_sniffer_list_item);
    mSampleTime = (int) (Double.parseDouble(System.getSettings().getString("PREF_SNIFFER_SAMPLE_TIME", "1.0")) * 1000);
    mSpoofSession = new SpoofSession(false, false, null, null);
    mSortSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, SORT));
    mSortSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
            mSortType = position;
        }

        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(this);
    mSniffToggleButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    new ConfirmDialog(getString(R.string.file_output), getString(R.string.question_save_to_pcap), this, new ConfirmDialog.ConfirmDialogListener() {

        @Override
        public void onConfirm() {
            mDumpToFile = true;
            mPcapFileName = (new File(System.getStoragePath(), "csploit-sniff-" + java.lang.System.currentTimeMillis() + ".pcap")).getAbsolutePath();
        }

        @Override
        public void onCancel() {
            mDumpToFile = false;
            mPcapFileName = null;
        }
    }).show();
}
Also used : SharedPreferences(android.content.SharedPreferences) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) File(java.io.File) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 5 with ConfirmDialog

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

the class Sniffer method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    String address = mAdapter.getByPosition(position).mAddress;
    final Target t = System.getTargetByAddress(address);
    if (t == null)
        return;
    new ConfirmDialog(getString(R.string.mitm_ss_select_target_title), String.format(getString(R.string.mitm_ss_select_target_prompt), address), Sniffer.this, new ConfirmDialog.ConfirmDialogListener() {

        @Override
        public void onConfirm() {
            System.setCurrentTarget(t);
            setStoppedState();
            Toast.makeText(Sniffer.this, getString(R.string.selected_) + System.getCurrentTarget(), Toast.LENGTH_SHORT).show();
            startActivity(new Intent(Sniffer.this, ActionActivity.class));
            overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
        }

        @Override
        public void onCancel() {
        }
    }).show();
}
Also used : Target(org.csploit.android.net.Target) Intent(android.content.Intent) ActionActivity(org.csploit.android.ActionActivity) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Aggregations

ConfirmDialog (org.csploit.android.gui.dialogs.ConfirmDialog)9 ConfirmDialogListener (org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener)7 Intent (android.content.Intent)5 ErrorDialog (org.csploit.android.gui.dialogs.ErrorDialog)4 Target (org.csploit.android.net.Target)4 SharedPreferences (android.content.SharedPreferences)3 View (android.view.View)3 AdapterView (android.widget.AdapterView)3 ListView (android.widget.ListView)3 TextView (android.widget.TextView)3 IOException (java.io.IOException)3 InputDialog (org.csploit.android.gui.dialogs.InputDialog)3 InputDialogListener (org.csploit.android.gui.dialogs.InputDialog.InputDialogListener)3 OnClickListener (android.view.View.OnClickListener)2 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)2 NoRouteToHostException (java.net.NoRouteToHostException)2 AboutDialog (org.csploit.android.gui.dialogs.AboutDialog)2 FatalDialog (org.csploit.android.gui.dialogs.FatalDialog)2 SpinnerDialog (org.csploit.android.gui.dialogs.SpinnerDialog)2 SpinnerDialogListener (org.csploit.android.gui.dialogs.SpinnerDialog.SpinnerDialogListener)2