Skip to content

Commit b69e564

Browse files
committed
Add root detection dialog in Android app
1 parent a50460b commit b69e564

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

android-app/app/src/main/java/com/deadnet/app/MainActivity.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.webkit.WebViewClient;
1313
import android.widget.ProgressBar;
1414
import android.widget.Toast;
15+
import java.io.File;
1516

1617
public class MainActivity extends Activity {
1718
private WebView webView;
@@ -29,6 +30,12 @@ protected void onCreate(Bundle savedInstanceState) {
2930
WindowManager.LayoutParams.FLAG_FULLSCREEN
3031
);
3132

33+
// Check root first
34+
if (!isRooted()) {
35+
showRootRequiredDialog();
36+
return;
37+
}
38+
3239
setContentView(R.layout.activity_main);
3340

3441
webView = findViewById(R.id.webView);
@@ -37,6 +44,48 @@ protected void onCreate(Bundle savedInstanceState) {
3744
setupWebView();
3845
loadServer();
3946
}
47+
48+
private boolean isRooted() {
49+
// Check common root paths
50+
String[] paths = {
51+
"/system/app/Superuser.apk",
52+
"/sbin/su",
53+
"/system/bin/su",
54+
"/system/xbin/su",
55+
"/data/local/xbin/su",
56+
"/data/local/bin/su",
57+
"/system/sd/xbin/su",
58+
"/system/bin/failsafe/su",
59+
"/data/local/su",
60+
"/su/bin/su",
61+
"/data/adb/magisk",
62+
"/data/adb/ksu"
63+
};
64+
65+
for (String path : paths) {
66+
if (new File(path).exists()) {
67+
return true;
68+
}
69+
}
70+
71+
// Try executing su
72+
try {
73+
Process process = Runtime.getRuntime().exec(new String[]{"su", "-c", "id"});
74+
process.waitFor();
75+
return process.exitValue() == 0;
76+
} catch (Exception e) {
77+
return false;
78+
}
79+
}
80+
81+
private void showRootRequiredDialog() {
82+
new AlertDialog.Builder(this)
83+
.setTitle("Root Required")
84+
.setMessage("DeadNet requires root access for network attacks.\n\nPlease root your device using Magisk or KernelSU.")
85+
.setPositiveButton("OK", (d, w) -> finish())
86+
.setCancelable(false)
87+
.show();
88+
}
4089

4190
private void setupWebView() {
4291
WebSettings settings = webView.getSettings();

0 commit comments

Comments
 (0)