コード例 #1
0
ファイル: PortScanner.java プロジェクト: Rub3nCT/dsploit
  private void setStartedState() {
    mPortList.clear();

    System.getNMap().synScan(System.getCurrentTarget(), mScanReceiver, mCustomPorts).start();

    mRunning = true;
  }
コード例 #2
0
ファイル: PortScanner.java プロジェクト: Rub3nCT/dsploit
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mScanToggleButton = (ToggleButton) findViewById(R.id.scanToggleButton);
    mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);

    mScanToggleButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mRunning) {
              setStoppedState();
            } else {
              setStartedState();
            }
          }
        });

    ListView mScanList = (ListView) findViewById(R.id.scanListView);

    for (Port port : System.getCurrentTarget().getOpenPorts()) {
      mPortList.add(port.number + " ( " + port.protocol.toString().toLowerCase() + " )");
    }

    mListAdapter = new ArrayAdapter<String>(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 = System.getCurrentTarget().getOpenPorts().get(position).number;
            String url = "";

            if (portNumber == 80)
              url = "http://" + System.getCurrentTarget().getCommandLineRepresentation() + "/";
            else if (portNumber == 443)
              url = "https://" + System.getCurrentTarget().getCommandLineRepresentation() + "/";
            else if (portNumber == 21)
              url = "ftp://" + System.getCurrentTarget().getCommandLineRepresentation();
            else if (portNumber == 22)
              url = "ssh://" + System.getCurrentTarget().getCommandLineRepresentation();
            else
              url =
                  "telnet://"
                      + System.getCurrentTarget().getCommandLineRepresentation()
                      + ":"
                      + portNumber;

            final String furl = url;

            new ConfirmDialog(
                    "Open",
                    "Open " + url + " ?",
                    PortScanner.this,
                    new ConfirmDialogListener() {
                      @Override
                      public void onConfirm() {
                        try {
                          Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(furl));

                          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;
          }
        });
  }