Skip to content
This repository was archived by the owner on Apr 8, 2022. It is now read-only.

Commit dc28351

Browse files
committed
Update version, use new Notification Builder with channel ID, fix minor code issues (C-style array declarations, use StringBuilder instead of string concatenation)
1 parent 6bfe77a commit dc28351

9 files changed

Lines changed: 56 additions & 45 deletions

File tree

.idea/caches/gradle_models.ser

1 Byte
Binary file not shown.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
/.ccx

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55
applicationId "com.hijacker"
66
minSdkVersion 21
77
targetSdkVersion 28
8-
versionCode 33
9-
versionName "v1.5-beta.9"
8+
versionCode 34
9+
versionName "v1.5-beta.10"
1010
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1111
externalNativeBuild {
1212
cmake {

app/src/main/java/com/hijacker/MainActivity.java

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.app.Activity;
2323
import android.app.FragmentManager;
2424
import android.app.FragmentTransaction;
25+
import android.app.NotificationChannel;
2526
import android.app.NotificationManager;
2627
import android.app.PendingIntent;
2728
import android.content.ClipData;
@@ -113,7 +114,7 @@ public class MainActivity extends AppCompatActivity{
113114
static int aireplay_running = 0, currentFragment = FRAGMENT_AIRODUMP; //Set currentFragment in onResume of each Fragment
114115
//Filters
115116
static boolean show_ap = true, show_st = true, show_na_st = true, wpa = true, wep = true, opn = true;
116-
static boolean show_ch[] = {true, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
117+
static boolean[] show_ch = {true, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
117118
static int pwr_filter = 120;
118119
static String manuf_filter = "";
119120
//Airodump list sort
@@ -128,8 +129,8 @@ public class MainActivity extends AppCompatActivity{
128129
static DrawerLayout mDrawerLayout;
129130
static NavigationView navigationView;
130131
static SparseArray<String> navTitlesMap = new SparseArray<>(); //SparseArray to map fragment IDs to their respective navigation titles
131-
static Drawable overflow[] = {null, null, null, null, null, null, null, null}; //Drawables to use for overflow button icon
132-
static ImageView status[] = {null, null, null, null, null}; //Icons in TestDialog, set in TestDialog class
132+
static Drawable[] overflow = {null, null, null, null, null, null, null, null}; //Drawables to use for overflow button icon
133+
static ImageView[] status = {null, null, null, null, null}; //Icons in TestDialog, set in TestDialog class
133134
static int progress_int;
134135
static long last_action; //Timestamp for the last action. Used in watchdog to avoid false positives
135136
static Thread wpa_thread;
@@ -175,16 +176,16 @@ protected void onCreate(Bundle savedInstanceState){
175176
@Override
176177
public void uncaughtException(Thread thread, Throwable throwable){
177178
throwable.printStackTrace();
178-
String stackTrace = "";
179-
stackTrace += throwable.getMessage() + '\n';
179+
StringBuilder stackTrace = new StringBuilder();
180+
stackTrace.append(throwable.getMessage()).append('\n');
180181
for(int i=0;i<throwable.getStackTrace().length;i++){
181-
stackTrace += throwable.getStackTrace()[i].toString() + '\n';
182+
stackTrace.append(throwable.getStackTrace()[i].toString()).append('\n');
182183
}
183184

184185
Intent intent = new Intent();
185186
intent.setAction("com.hijacker.SendLogActivity");
186187
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
187-
intent.putExtra("exception", stackTrace);
188+
intent.putExtra("exception", stackTrace.toString());
188189
startActivity(intent);
189190

190191
finish();
@@ -381,7 +382,7 @@ protected Boolean doInBackground(Void... params){
381382
//cap directory was never changed so there may be files in /sdcard/cap/
382383
File old_dir = new File("/sdcard/cap");
383384
if(old_dir.exists() && old_dir.isDirectory()){
384-
File files[] = old_dir.listFiles();
385+
File[] files = old_dir.listFiles();
385386
if(files!=null){
386387
Toast.makeText(MainActivity.this, "Moving cap files from " + old_dir.getAbsolutePath() + " to " + cap_path, Toast.LENGTH_LONG).show();
387388
for(File f : old_dir.listFiles()){
@@ -395,15 +396,23 @@ protected Boolean doInBackground(Void... params){
395396

396397
//Initialize notifications
397398
publishProgress(getString(R.string.init_notifications));
398-
//Create intents
399+
//Create intents
399400
Intent cancel_intent = new Intent(MainActivity.this, DismissReceiver.class);
400401
Intent stop_intent = new Intent(MainActivity.this, StopReceiver.class);
401402
Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class);
402403
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
403404
PendingIntent click_intent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);
404405

405-
//Create 'running' notification
406-
notif = new NotificationCompat.Builder(MainActivity.this);
406+
// Get a channel ID
407+
String channelID;
408+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
409+
channelID = NotificationChannel.DEFAULT_CHANNEL_ID;
410+
}else{
411+
channelID = getString(R.string.DEFAULT_CHANNEL_ID);
412+
}
413+
414+
//Create 'running' notification
415+
notif = new NotificationCompat.Builder(MainActivity.this, channelID);
407416
notif.setContentTitle(getString(R.string.notification_title));
408417
notif.setContentText(" ");
409418
notif.setSmallIcon(R.drawable.ic_notification);
@@ -414,17 +423,17 @@ protected Boolean doInBackground(Void... params){
414423
notif.addAction(R.drawable.stop_drawable, getString(R.string.stop_attacks), PendingIntent.getBroadcast(MainActivity.this.getApplicationContext(), 0, stop_intent, 0));
415424
notif.setContentIntent(click_intent);
416425

417-
//Create 'error' notification (used by watchdog)
418-
error_notif = new NotificationCompat.Builder(MainActivity.this);
426+
//Create 'error' notification (used by watchdog)
427+
error_notif = new NotificationCompat.Builder(MainActivity.this, channelID);
419428
error_notif.setSmallIcon(R.drawable.ic_notification);
420429
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
421430
error_notif.setColor(getColor(android.R.color.holo_red_dark));
422431
}
423432
error_notif.setContentIntent(click_intent);
424433
error_notif.setVibrate(new long[]{500, 500});
425434

426-
//Create 'handshake captured' notification (used by wpa_thread)
427-
handshake_notif = new NotificationCompat.Builder(MainActivity.this);
435+
//Create 'handshake captured' notification (used by wpa_thread)
436+
handshake_notif = new NotificationCompat.Builder(MainActivity.this, channelID);
428437
handshake_notif.setContentTitle(getString(R.string.handshake_captured));
429438
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
430439
handshake_notif.setColor(getColor(android.R.color.holo_green_dark));
@@ -1229,7 +1238,6 @@ public boolean onOptionsItemSelected(MenuItem item){
12291238
return super.onOptionsItemSelected(item);
12301239
}
12311240
}
1232-
// See https://g.co/AppIndexing/AndroidStudio for more information.
12331241
@Override
12341242
protected void onResume(){
12351243
super.onResume();
@@ -1299,7 +1307,7 @@ public boolean onCreateOptionsMenu(Menu menu){
12991307
return true;
13001308
}
13011309
@Override
1302-
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
1310+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
13031311
if(requestCode==0){
13041312
//The one and only request this app sends
13051313
if (grantResults.length > 0 && grantResults[2]==PackageManager.PERMISSION_GRANTED) {
@@ -1595,9 +1603,9 @@ static String getFixed(String text, int size){
15951603
if(text.length() > size){
15961604
text = text.substring(0, size);
15971605
}
1598-
String str = "";
1606+
StringBuilder str = new StringBuilder();
15991607
for(int i=0;i < size-text.length();i++){
1600-
str += " ";
1608+
str.append(" ");
16011609
}
16021610
return str + text;
16031611
}
@@ -1608,7 +1616,7 @@ static int checkChroot(){
16081616
shell.run("echo $PATH; echo ENDOFPATH");
16091617
String path = getLastLine(shell.getShell_out(), "ENDOFPATH");
16101618
shell.done();
1611-
String paths[] = path.split(":");
1619+
String[] paths = path.split(":");
16121620
for(String temp : paths){
16131621
if(new RootFile(temp + "/bootkali_init").exists()){
16141622
bin = true;

app/src/main/java/com/hijacker/ReaverFragment.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,13 @@ static String get_chroot_env(final Activity activity){
329329
"SHLVL=1",
330330
"YOU_KNOW_WHAT=THIS_IS_KALI_LINUX_NETHUNER_FROM_JAVA_BINKY"
331331
};
332-
String ENV_OUT = "";
332+
StringBuilder ENV_OUT = new StringBuilder();
333333
for (String aENV : ENV) {
334-
ENV_OUT = ENV_OUT + "export " + aENV + " && ";
334+
ENV_OUT.append("export ").append(aENV).append(" && ");
335335
}
336336
if(monstart){
337-
ENV_OUT += "source monstart-nh";
338-
ENV_OUT += cont_on_fail ? "; " : " && ";
337+
ENV_OUT.append("source monstart-nh");
338+
ENV_OUT.append(cont_on_fail ? "; " : " && ");
339339
}
340340
if(!custom_chroot_cmd.equals("")){
341341
if(custom_chroot_cmd.contains("'") && activity!=null){
@@ -346,11 +346,11 @@ public void run(){
346346
}
347347
});
348348
}else{
349-
ENV_OUT += custom_chroot_cmd;
350-
ENV_OUT += cont_on_fail ? "; " : " && ";
349+
ENV_OUT.append(custom_chroot_cmd);
350+
ENV_OUT.append(cont_on_fail ? "; " : " && ");
351351
}
352352
}
353-
return ENV_OUT;
353+
return ENV_OUT.toString();
354354
}
355355
class ReaverTask extends AsyncTask<Void, String, Boolean>{
356356
String pinDelay, lockedDelay;

app/src/main/java/com/hijacker/RootFile.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class RootFile{
8282

8383
exists = true;
8484

85-
String temp[] = buffer.split(" ");
85+
String[] temp = buffer.split(" ");
8686
//0: type & permissions, 4: size, 5,6,7: last edited date, rest is name
8787
if(temp[0].length()!=10){
8888
throw new IllegalFormatFlagsException(temp[0] + " is not how it should be\nbuffer: " + buffer + "\nbuffer before: " + before);
@@ -189,17 +189,17 @@ List<RootFile> listFiles(){
189189
buffer = buffer.replace(" ", " ");
190190
}
191191
//Separate by ' ' to get the name
192-
String temp[] = buffer.split(" ");
192+
String[] temp = buffer.split(" ");
193193
if(temp.length>8){
194194
//Reconstruct the full_name (it may contain spaces, so it's many arguments)
195-
String full_name = "";
195+
StringBuilder full_name = new StringBuilder();
196196
for(int i = 8; i<temp.length; i++){
197-
full_name += temp[i] + ' ';
197+
full_name.append(temp[i]).append(' ');
198198
}
199199
if(full_name.charAt(full_name.length() - 1)==' '){
200-
full_name = full_name.substring(0, full_name.length() - 1);
200+
full_name = new StringBuilder(full_name.substring(0, full_name.length() - 1));
201201
}
202-
if(!full_name.contains(" -> ")){
202+
if(!full_name.toString().contains(" -> ")){
203203
result.add(new RootFile(absolutePath + (absolutePath.length()==1 ? "" : '/') + full_name));
204204
}
205205
}

app/src/main/java/com/hijacker/SendLogActivity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState){
9595
new SetupTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
9696
}
9797
@Override
98-
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults){
98+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){
9999
boolean writeGranted = grantResults.length>0 && grantResults[0]==PackageManager.PERMISSION_GRANTED;
100100
if(shell==null){
101101
progressBar.setVisibility(View.GONE);
@@ -133,7 +133,7 @@ protected Boolean doInBackground(Void... params){
133133
}
134134
}
135135
private class ReportTask extends AsyncTask<Void, String, Boolean>{
136-
String bugReport = "";
136+
StringBuilder bugReport = new StringBuilder();
137137
@Override
138138
protected Boolean doInBackground(Void... params){
139139
report = new File(Environment.getExternalStorageDirectory() + "/report.txt");
@@ -143,7 +143,8 @@ protected Boolean doInBackground(Void... params){
143143
BufferedReader br = new BufferedReader(new FileReader(report));
144144
String buffer;
145145
while((buffer = br.readLine())!=null){
146-
bugReport += buffer + '\n';
146+
bugReport.append(buffer);
147+
bugReport.append('\n');
147148
}
148149
}catch(IOException ignored){
149150
return false;
@@ -183,19 +184,19 @@ public void onRestart(View v){
183184
}
184185
public void stopAll(){
185186
ArrayList<Integer> pids = new ArrayList<>();
186-
String processes[] = {
187+
String[] processes = {
187188
"airodump-ng",
188189
"aireplay-ng",
189190
"aircrack-ng",
190191
"mdk3",
191192
"reaver",
192193
"reaver-wash"
193194
};
194-
String cmd = busybox + " pidof";
195+
StringBuilder cmd = new StringBuilder(busybox + " pidof");
195196
for(String process_name : processes){
196-
cmd += ' ' + process_name;
197+
cmd.append(' ').append(process_name);
197198
}
198-
cmd += "; echo ENDOFPIDOF\n";
199+
cmd.append("; echo ENDOFPIDOF\n");
199200
shell_in.print(cmd);
200201
shell_in.flush();
201202
String buffer = null;

app/src/main/java/com/hijacker/Tile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int findIndex(List<Tile> list, Tile tile, Comparator<Tile> comp){
130130
when we gave up on searching.
131131
*/
132132
if(list.size()==0) return 0;
133-
Tile array[] = list.toArray(new Tile[list.size()]);
133+
Tile[] array = list.toArray(new Tile[0]);
134134
int L = 0, R = list.size()-1, M = 0;
135135
while(L<=R){
136136
M = (L + R)/2;

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources>
22
<string name="app_name" translatable="false">Hijacker</string>
3+
<string name="DEFAULT_CHANNEL_ID" translatable="false">Hijacker_Notification_Channel</string>
34

45
<!-- Toolbar -->
56
<string name="stop_aireplay">Stop Aireplay</string>
@@ -297,8 +298,8 @@
297298
<string name="done">Done</string>
298299

299300
<!-- UpdateConfirmDialog -->
300-
<string name="update_title">New update available</string>
301-
<string name="update_text">There is a new update available.</string>
301+
<string name="update_title">Update available</string>
302+
<string name="update_text">There is an update available.</string>
302303
<string name="latest_version">Latest Version</string>
303304
<string name="current_version">Current Version</string>
304305

0 commit comments

Comments
 (0)