Search in sources :

Example 1 with OnAccountListener

use of org.csploit.android.tools.Ettercap.OnAccountListener in project android by cSploit.

the class PasswordSniffer method setStartedState.

private void setStartedState() {
    try {
        // open file in appending mode
        mFileWriter = new FileWriter(mFileOutput, true);
        mBufferedWriter = new BufferedWriter(mFileWriter);
    } catch (IOException e) {
        new FatalDialog("Error", e.toString(), PasswordSniffer.this).show();
    }
    try {
        mSpoofSession.start(new OnAccountListener() {

            @Override
            public void onAccount(final String protocol, final String address, final String username, final String password) {
                final String line = username + ": " + password;
                PasswordSniffer.this.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        if (mAdapter.hasChild(protocol, line) == false) {
                            try {
                                mBufferedWriter.write(line + "\n");
                            } catch (IOException e) {
                                System.errorLogging(e);
                            }
                            mAdapter.addChild(protocol, line);
                        }
                    }
                });
            }

            @Override
            public void onReady() {
            }

            @Override
            public void onEnd(final int exitValue) {
                PasswordSniffer.this.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        if (exitValue != 0) {
                            Toast.makeText(PasswordSniffer.this, "ettercap returned #" + exitValue, Toast.LENGTH_LONG).show();
                        }
                        setStoppedState();
                    }
                });
            }

            @Override
            public void onDeath(final int signal) {
                PasswordSniffer.this.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        Toast.makeText(PasswordSniffer.this, "ettercap killed by signal #" + signal, Toast.LENGTH_LONG).show();
                        setStoppedState();
                    }
                });
            }
        });
        Toast.makeText(PasswordSniffer.this, "Logging to " + mFileOutput, Toast.LENGTH_LONG).show();
        mSniffProgress.setVisibility(View.VISIBLE);
        mRunning = true;
    } catch (ChildManager.ChildNotStartedException e) {
        System.errorLogging(e);
        mSniffToggleButton.setChecked(false);
        Toast.makeText(PasswordSniffer.this, getString(R.string.child_not_started), Toast.LENGTH_LONG).show();
    }
}
Also used : OnAccountListener(org.csploit.android.tools.Ettercap.OnAccountListener) FileWriter(java.io.FileWriter) IOException(java.io.IOException) FatalDialog(org.csploit.android.gui.dialogs.FatalDialog) ChildManager(org.csploit.android.core.ChildManager) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 ChildManager (org.csploit.android.core.ChildManager)1 FatalDialog (org.csploit.android.gui.dialogs.FatalDialog)1 OnAccountListener (org.csploit.android.tools.Ettercap.OnAccountListener)1