From dc2835170358812a02e82980428c0226cc1c38bf Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 10 Nov 2019 15:56:18 +0200 Subject: [PATCH] Update version, use new Notification Builder with channel ID, fix minor code issues (C-style array declarations, use StringBuilder instead of string concatenation) --- .idea/caches/gradle_models.ser | Bin 169110 -> 169111 bytes app/.gitignore | 1 + app/build.gradle | 4 +- .../main/java/com/hijacker/MainActivity.java | 48 ++++++++++-------- .../java/com/hijacker/ReaverFragment.java | 14 ++--- app/src/main/java/com/hijacker/RootFile.java | 12 ++--- .../java/com/hijacker/SendLogActivity.java | 15 +++--- app/src/main/java/com/hijacker/Tile.java | 2 +- app/src/main/res/values/strings.xml | 5 +- 9 files changed, 56 insertions(+), 45 deletions(-) diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index 0f2aebe4bf81ed7e0ebdbbde9b71c583ac0019cc..634a05c103a624b5616753f4211c496a2246b3e5 100644 GIT binary patch delta 877 zcmXAnZ)jFk9LINm99upM=AhL6Jh8ULFgf$wbIv{I+-1ZZK`*j=A#-~po^#K=FmwNy z%hWk7Nrp)nPwc#FOhg-5DGzi-DKX8FFIuRe6VicJFA5syNYk`?_na4pABW%f`}>^l zIb)LrH(5A-xVf+fy>hE6U!I#_u(CYU{Chp}YKv2Dwga9nUw!jP4LWyX>QecG^<(f{ z!`7;&-t$`mY~roD#V3OURU_V-sxxa3mOQq+w5#>?(w?qGeBHJX!BlJ@u>BSY+ysK<=F-^xy|CB*tUJtJ=_4}UW4mpu>6U_3H{~KVRxz% zRxdEPe>-6Wt$%CoTsqtZcPe1{VNW_6!y`b!%U^f6gFB$jHFm>ysG;R-wR=1O%hCtk zu+~GTJFhmmC4JD-6cG|@Vtp+A*kUfE!Nw4c6Q()k#)dS|rBA!sUHuklLz{~0-gfa8 zm_|STb^W)Bg9<~XLPM~O5{0=>1vXrUm?pw1$&$p7*!|Q4AEINQ{c7Diy%~?$bYW3N zEvb!U$P*l^B%80fz)Dzy10lKZbE*_&ZlVu{(TnRIOuLu*;R1U1zi;`Me==dxW&5BVQ1|Ui}t$xl{yVABqb1L#u8O?wR+@P>{WunceMP zbb-QhSYkInxPpDiHG@O!ZWo9wcc~8%^+r&VMFfJ;1-m!L7n%c<9DIe^#(l~{(o}ZQ3I7$(Q)^7zX6vt=IyeWDUfY4 zbpkK0+e%(c_D^#5;e1*Exgaupu6l z@CDGUj(^VSliQ$Dm#u|=QReimqV|n2E&j9?R#*rvrI&PJ1{%t2szN6WT`bZb#mrL_ z3tK2`d!dqqQOQGJzp8;MeYFt^wY?4qT3xp1qE_qR4jT7s&$1kcGU|tlDy+hEgc(x` zi^%sdRU`Z7Dbno%~&HAVHM(R}cZ_{$qjvEj+N^|V`PKa5k9PD#JFqeYZ zJQ9ji*|vMpn8XzQJ_B=5?~@M?b?FAUf!+?io|s@VrIa}lF;8(tqL3z72w!5A4s9j~ zV`1R86*^;(g{bk(t1BjvENabm)#WUtZ4=@-0xRhX%p{4hPzJyqn|UOVlJcl+BnK$a z=bNEG_csAXPk+Cir$?LME-HGo;)fi|_L=mAG-;B+$avJSnDDSC10rq5Pm9R;p6eLQ zMH`N+>CrEm;TkFygUfRq?h(!%=3^RA*CZo-LzDp)o{_Oxm?kdQi(1TQc)4oZWqq{; z2GHk`Lw_XG>q|K?Q?|s?vCS}zoJ4|QLS2UoDwXHNGq=K53(?NHQ*p_5m=9?7P~p#U z{Z9B1P{oYuiSe;kC_ACj)(_{uSOkpB&G navTitlesMap = new SparseArray<>(); //SparseArray to map fragment IDs to their respective navigation titles - static Drawable overflow[] = {null, null, null, null, null, null, null, null}; //Drawables to use for overflow button icon - static ImageView status[] = {null, null, null, null, null}; //Icons in TestDialog, set in TestDialog class + static Drawable[] overflow = {null, null, null, null, null, null, null, null}; //Drawables to use for overflow button icon + static ImageView[] status = {null, null, null, null, null}; //Icons in TestDialog, set in TestDialog class static int progress_int; static long last_action; //Timestamp for the last action. Used in watchdog to avoid false positives static Thread wpa_thread; @@ -175,16 +176,16 @@ protected void onCreate(Bundle savedInstanceState){ @Override public void uncaughtException(Thread thread, Throwable throwable){ throwable.printStackTrace(); - String stackTrace = ""; - stackTrace += throwable.getMessage() + '\n'; + StringBuilder stackTrace = new StringBuilder(); + stackTrace.append(throwable.getMessage()).append('\n'); for(int i=0;i= Build.VERSION_CODES.O){ + channelID = NotificationChannel.DEFAULT_CHANNEL_ID; + }else{ + channelID = getString(R.string.DEFAULT_CHANNEL_ID); + } + + //Create 'running' notification + notif = new NotificationCompat.Builder(MainActivity.this, channelID); notif.setContentTitle(getString(R.string.notification_title)); notif.setContentText(" "); notif.setSmallIcon(R.drawable.ic_notification); @@ -414,8 +423,8 @@ protected Boolean doInBackground(Void... params){ notif.addAction(R.drawable.stop_drawable, getString(R.string.stop_attacks), PendingIntent.getBroadcast(MainActivity.this.getApplicationContext(), 0, stop_intent, 0)); notif.setContentIntent(click_intent); - //Create 'error' notification (used by watchdog) - error_notif = new NotificationCompat.Builder(MainActivity.this); + //Create 'error' notification (used by watchdog) + error_notif = new NotificationCompat.Builder(MainActivity.this, channelID); error_notif.setSmallIcon(R.drawable.ic_notification); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ error_notif.setColor(getColor(android.R.color.holo_red_dark)); @@ -423,8 +432,8 @@ protected Boolean doInBackground(Void... params){ error_notif.setContentIntent(click_intent); error_notif.setVibrate(new long[]{500, 500}); - //Create 'handshake captured' notification (used by wpa_thread) - handshake_notif = new NotificationCompat.Builder(MainActivity.this); + //Create 'handshake captured' notification (used by wpa_thread) + handshake_notif = new NotificationCompat.Builder(MainActivity.this, channelID); handshake_notif.setContentTitle(getString(R.string.handshake_captured)); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ handshake_notif.setColor(getColor(android.R.color.holo_green_dark)); @@ -1229,7 +1238,6 @@ public boolean onOptionsItemSelected(MenuItem item){ return super.onOptionsItemSelected(item); } } - // See https://g.co/AppIndexing/AndroidStudio for more information. @Override protected void onResume(){ super.onResume(); @@ -1299,7 +1307,7 @@ public boolean onCreateOptionsMenu(Menu menu){ return true; } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if(requestCode==0){ //The one and only request this app sends if (grantResults.length > 0 && grantResults[2]==PackageManager.PERMISSION_GRANTED) { @@ -1595,9 +1603,9 @@ static String getFixed(String text, int size){ if(text.length() > size){ text = text.substring(0, size); } - String str = ""; + StringBuilder str = new StringBuilder(); for(int i=0;i < size-text.length();i++){ - str += " "; + str.append(" "); } return str + text; } @@ -1608,7 +1616,7 @@ static int checkChroot(){ shell.run("echo $PATH; echo ENDOFPATH"); String path = getLastLine(shell.getShell_out(), "ENDOFPATH"); shell.done(); - String paths[] = path.split(":"); + String[] paths = path.split(":"); for(String temp : paths){ if(new RootFile(temp + "/bootkali_init").exists()){ bin = true; diff --git a/app/src/main/java/com/hijacker/ReaverFragment.java b/app/src/main/java/com/hijacker/ReaverFragment.java index eb14652..3b7030a 100644 --- a/app/src/main/java/com/hijacker/ReaverFragment.java +++ b/app/src/main/java/com/hijacker/ReaverFragment.java @@ -329,13 +329,13 @@ static String get_chroot_env(final Activity activity){ "SHLVL=1", "YOU_KNOW_WHAT=THIS_IS_KALI_LINUX_NETHUNER_FROM_JAVA_BINKY" }; - String ENV_OUT = ""; + StringBuilder ENV_OUT = new StringBuilder(); for (String aENV : ENV) { - ENV_OUT = ENV_OUT + "export " + aENV + " && "; + ENV_OUT.append("export ").append(aENV).append(" && "); } if(monstart){ - ENV_OUT += "source monstart-nh"; - ENV_OUT += cont_on_fail ? "; " : " && "; + ENV_OUT.append("source monstart-nh"); + ENV_OUT.append(cont_on_fail ? "; " : " && "); } if(!custom_chroot_cmd.equals("")){ if(custom_chroot_cmd.contains("'") && activity!=null){ @@ -346,11 +346,11 @@ public void run(){ } }); }else{ - ENV_OUT += custom_chroot_cmd; - ENV_OUT += cont_on_fail ? "; " : " && "; + ENV_OUT.append(custom_chroot_cmd); + ENV_OUT.append(cont_on_fail ? "; " : " && "); } } - return ENV_OUT; + return ENV_OUT.toString(); } class ReaverTask extends AsyncTask{ String pinDelay, lockedDelay; diff --git a/app/src/main/java/com/hijacker/RootFile.java b/app/src/main/java/com/hijacker/RootFile.java index 3648fd6..4f19692 100644 --- a/app/src/main/java/com/hijacker/RootFile.java +++ b/app/src/main/java/com/hijacker/RootFile.java @@ -82,7 +82,7 @@ class RootFile{ exists = true; - String temp[] = buffer.split(" "); + String[] temp = buffer.split(" "); //0: type & permissions, 4: size, 5,6,7: last edited date, rest is name if(temp[0].length()!=10){ throw new IllegalFormatFlagsException(temp[0] + " is not how it should be\nbuffer: " + buffer + "\nbuffer before: " + before); @@ -189,17 +189,17 @@ List listFiles(){ buffer = buffer.replace(" ", " "); } //Separate by ' ' to get the name - String temp[] = buffer.split(" "); + String[] temp = buffer.split(" "); if(temp.length>8){ //Reconstruct the full_name (it may contain spaces, so it's many arguments) - String full_name = ""; + StringBuilder full_name = new StringBuilder(); for(int i = 8; i ")){ + if(!full_name.toString().contains(" -> ")){ result.add(new RootFile(absolutePath + (absolutePath.length()==1 ? "" : '/') + full_name)); } } diff --git a/app/src/main/java/com/hijacker/SendLogActivity.java b/app/src/main/java/com/hijacker/SendLogActivity.java index 27f629e..40a95d5 100644 --- a/app/src/main/java/com/hijacker/SendLogActivity.java +++ b/app/src/main/java/com/hijacker/SendLogActivity.java @@ -95,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState){ new SetupTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults){ + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){ boolean writeGranted = grantResults.length>0 && grantResults[0]==PackageManager.PERMISSION_GRANTED; if(shell==null){ progressBar.setVisibility(View.GONE); @@ -133,7 +133,7 @@ protected Boolean doInBackground(Void... params){ } } private class ReportTask extends AsyncTask{ - String bugReport = ""; + StringBuilder bugReport = new StringBuilder(); @Override protected Boolean doInBackground(Void... params){ report = new File(Environment.getExternalStorageDirectory() + "/report.txt"); @@ -143,7 +143,8 @@ protected Boolean doInBackground(Void... params){ BufferedReader br = new BufferedReader(new FileReader(report)); String buffer; while((buffer = br.readLine())!=null){ - bugReport += buffer + '\n'; + bugReport.append(buffer); + bugReport.append('\n'); } }catch(IOException ignored){ return false; @@ -183,7 +184,7 @@ public void onRestart(View v){ } public void stopAll(){ ArrayList pids = new ArrayList<>(); - String processes[] = { + String[] processes = { "airodump-ng", "aireplay-ng", "aircrack-ng", @@ -191,11 +192,11 @@ public void stopAll(){ "reaver", "reaver-wash" }; - String cmd = busybox + " pidof"; + StringBuilder cmd = new StringBuilder(busybox + " pidof"); for(String process_name : processes){ - cmd += ' ' + process_name; + cmd.append(' ').append(process_name); } - cmd += "; echo ENDOFPIDOF\n"; + cmd.append("; echo ENDOFPIDOF\n"); shell_in.print(cmd); shell_in.flush(); String buffer = null; diff --git a/app/src/main/java/com/hijacker/Tile.java b/app/src/main/java/com/hijacker/Tile.java index 0dc7445..acd2f92 100644 --- a/app/src/main/java/com/hijacker/Tile.java +++ b/app/src/main/java/com/hijacker/Tile.java @@ -130,7 +130,7 @@ static int findIndex(List list, Tile tile, Comparator comp){ when we gave up on searching. */ if(list.size()==0) return 0; - Tile array[] = list.toArray(new Tile[list.size()]); + Tile[] array = list.toArray(new Tile[0]); int L = 0, R = list.size()-1, M = 0; while(L<=R){ M = (L + R)/2; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd267d3..f91789a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,6 @@  Hijacker + Hijacker_Notification_Channel Stop Aireplay @@ -297,8 +298,8 @@ Done - New update available - There is a new update available. + Update available + There is an update available. Latest Version Current Version