Add notice about missing decryption rules

This commit is contained in:
emanuele-f 2023-08-21 07:48:19 +02:00
parent c08ac59f46
commit a6e908be89
3 changed files with 31 additions and 0 deletions

View File

@ -62,6 +62,7 @@ import com.emanuelef.remote_capture.CaptureHelper;
import com.emanuelef.remote_capture.ConnectionsRegister;
import com.emanuelef.remote_capture.Log;
import com.emanuelef.remote_capture.MitmReceiver;
import com.emanuelef.remote_capture.PCAPdroid;
import com.emanuelef.remote_capture.activities.prefs.SettingsActivity;
import com.emanuelef.remote_capture.fragments.ConnectionsFragment;
import com.emanuelef.remote_capture.fragments.StatusFragment;
@ -102,6 +103,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
// helps detecting duplicate state reporting of STOPPED in MutableLiveData
private boolean mWasStarted = false;
private boolean mStartPressed = false;
private boolean mDecEmptyRulesNoticeShown = false;
private static final String TAG = "Main";
@ -194,6 +197,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
appStateReady();
mWasStarted = false;
mStartPressed = false;
} else /* STOPPED -> STOPPED */
appStateReady();
});
@ -554,6 +558,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
checkVpnLockdownNotice();
else if(mStartPressed) { // STOPPED -> STARTED
if(CaptureService.isDecryptingTLS() && !CaptureService.isCapturingAsRoot())
checkDecryptionRulesNotice();
}
}
public void appStateStopping() {
@ -561,6 +569,22 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
notifyAppState();
}
private void checkDecryptionRulesNotice() {
if(!mDecEmptyRulesNoticeShown && PCAPdroid.getInstance().getDecryptionList().isEmpty()) {
new AlertDialog.Builder(this)
.setMessage(R.string.tls_decryption_no_rules_notice)
.setPositiveButton(R.string.yes, (d, whichButton) -> {
Intent intent = new Intent(MainActivity.this, EditListActivity.class);
intent.putExtra(EditListActivity.LIST_TYPE_EXTRA, ListInfo.Type.DECRYPTION_LIST);
startActivity(intent);
})
.setNegativeButton(R.string.no, (d, whichButton) -> {
})
.show();
mDecEmptyRulesNoticeShown = true;
}
}
private void checkLoadedPcap() {
if(mPcapLoadDialog != null) {
mPcapLoadDialog.dismiss();
@ -632,6 +656,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
int id = item.getItemId();
if(id == R.id.start_live_capture) {
mStartPressed = true;
startCapture();
return true;
} else if(id == R.id.action_stop) {

View File

@ -300,6 +300,10 @@ public class ConnectionOverview extends Fragment implements ConnectionDetailsAct
mError.setTextColor(ContextCompat.getColor(context, R.color.warning));
mError.setText(context.getString(R.string.netd_block_missed));
mError.setVisibility(View.VISIBLE);
} else if(mConn.getDecryptionStatus() == ConnectionDescriptor.DecryptionStatus.ENCRYPTED) {
mError.setTextColor(ContextCompat.getColor(context, R.color.colorTabText));
mError.setText(R.string.decryption_info_no_rule);
mError.setVisibility(View.VISIBLE);
} else
mError.setVisibility(View.GONE);
}

View File

@ -490,4 +490,6 @@
<string name="host_resolution_failed">"Could not resolve host %1$s</string>
<string name="pcapdroid_trailer_notice">To show the actual apps instead of \"%1$s\", be sure to enable the \"%2$s\" option before exporting the PCAP file</string>
<string name="live_capture">Live capture</string>
<string name="decryption_info_no_rule">This connection will not be decrypted. Create a decryption rule to decrypt it</string>
<string name="tls_decryption_no_rules_notice">TLS decryption is only applied to connections that match the configured rules. Do you want to create decryption rules now?</string>
</resources>