1212import android .webkit .WebViewClient ;
1313import android .widget .ProgressBar ;
1414import android .widget .Toast ;
15+ import java .io .File ;
1516
1617public 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 \n Please 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