@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); UIThread = this; if (System.getMsfRpc() == null) { new FinishDialog(getString(R.string.error), "MSF RPC not connected", Sessions.this).show(); return; } mResults = System.getCurrentTarget().getSessions(); mListView = (ListView) findViewById(android.R.id.list); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mResults); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(clickListener); mListView.setOnItemLongClickListener(longClickListener); new Thread( new Runnable() { @Override public void run() { System.getMsfRpc().updateSessions(); runOnUiThread( new Runnable() { @Override public void run() { if (mResults.isEmpty()) { new FinishDialog( getString(R.string.warning), getString(R.string.no_opened_sessions), Sessions.this) .show(); } else { mAdapter.notifyDataSetChanged(); } } }); } }) .start(); }
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 > DNS spoofing"); setContentView(R.layout.plugin_mitm_dns_spoofing); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mTextDnsList = (TextView) findViewById(R.id.textViewDNSList); mCmdSave = (Button) findViewById(R.id.cmd_save); mSniffToggleButton = (ToggleButton) findViewById(R.id.sniffToggleButton); mSniffProgress = (ProgressBar) findViewById(R.id.sniffActivity); mTextDnsList.setHorizontallyScrolling(true); mSpoofSession = new SpoofSession(false, false, null, null); readDNSlist(); mSniffToggleButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mRunning) { setStoppedState(); } else { setStartedState(); } } }); mCmdSave.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { saveDNSlist(); } }); }
@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final Session s = mAdapter.getItem(position); final ArrayList<Integer> availableChoices = new ArrayList<Integer>(); availableChoices.add(R.string.show_full_description); if (s.haveShell()) availableChoices.add(R.string.open_shell); if (s.isMeterpreter()) { if (System.getCurrentTarget().getDeviceOS().toLowerCase().contains("windows")) availableChoices.add(R.string.clear_event_log); } availableChoices.add(R.string.delete); new ListChoiceDialog( R.string.choose_an_option, availableChoices.toArray(new Integer[availableChoices.size()]), Sessions.this, new ChoiceDialog.ChoiceDialogListener() { @Override public void onChoice(int choice) { switch (availableChoices.get(choice)) { case R.string.open_shell: System.setCurrentSession(s); startActivity(new Intent(Sessions.this, Console.class)); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); break; case R.string.show_full_description: String message = s.getDescription(); if (s.getInfo().length() > 0) message += "\n\nInfo:\n" + s.getInfo(); new ErrorDialog(s.getName(), message, Sessions.this).show(); break; case R.string.clear_event_log: ((ShellSession) s) .addCommand( "clearev", new ShellSession.RpcShellReceiver() { @Override public void onNewLine(String line) {} @Override public void onEnd(int exitValue) { Toast.makeText( Sessions.this, "command returned " + exitValue, Toast.LENGTH_LONG) .show(); } @Override public void onRpcClosed() { Toast.makeText( Sessions.this, "RPC channel has been closed", Toast.LENGTH_LONG) .show(); } @Override public void onTimedOut() { Toast.makeText( Sessions.this, "command timed out", Toast.LENGTH_LONG) .show(); } }); break; case R.string.delete: s.stopSession(); System.getCurrentTarget().getSessions().remove(s); mAdapter.notifyDataSetChanged(); break; } } }) .show(); return true; }