Example #1
0
  private void setStoppedState() {
    mSpoofSession.stop();

    try {
      if (mBufferedWriter != null) mBufferedWriter.close();
    } catch (IOException e) {
      System.errorLogging(e);
    }

    mSniffProgress.setVisibility(View.INVISIBLE);
    mRunning = false;
    mSniffToggleButton.setChecked(false);
  }
Example #2
0
  private void setStartedState() {

    try {
      mSpoofSession.start(
          new Ettercap.OnDNSSpoofedReceiver() {
            @Override
            public void onSpoofed(String line) {
              Logger.info("DNSSpoofing.onevent() line: " + line);

              if (line.contains("spoofed to"))
                Toast.makeText(DNSSpoofing.this, line, Toast.LENGTH_LONG).show();
            }

            @Override
            public void onStderr(String line) {
              if (line.contains("spoofed to"))
                Toast.makeText(DNSSpoofing.this, line, Toast.LENGTH_LONG).show();
            }

            @Override
            public void onReady() {}

            @Override
            public void onEnd(final int exitValue) {
              DNSSpoofing.this.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (exitValue != 0) {
                        Toast.makeText(
                                DNSSpoofing.this,
                                "ettercap returned #" + exitValue,
                                Toast.LENGTH_LONG)
                            .show();
                      }
                      setStoppedState();
                    }
                  });
            }

            @Override
            public void onError(final String error) {
              DNSSpoofing.this.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (!DNSSpoofing.this.isFinishing()) {
                        new ErrorDialog(getString(R.string.error), error, DNSSpoofing.this).show();
                        setStoppedState();
                      }
                    }
                  });
            }

            @Override
            public void onDeath(final int signal) {
              DNSSpoofing.this.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      Toast.makeText(
                              DNSSpoofing.this,
                              "ettercap killed by signal #" + signal,
                              Toast.LENGTH_LONG)
                          .show();
                      setStoppedState();
                    }
                  });
            }
          });

      mSniffProgress.setVisibility(View.VISIBLE);
      mRunning = true;

    } catch (ChildManager.ChildNotStartedException e) {
      System.errorLogging(e);
      mSniffToggleButton.setChecked(false);
      Toast.makeText(DNSSpoofing.this, getString(R.string.child_not_started), Toast.LENGTH_LONG)
          .show();
    }
  }