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

Commit

Permalink
Update version, use new Notification Builder with channel ID, fix min…
Browse files Browse the repository at this point in the history
…or code issues (C-style array declarations, use StringBuilder instead of string concatenation)
  • Loading branch information
chrisk44 committed Nov 10, 2019
1 parent 6bfe77a commit dc28351
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 45 deletions.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/.ccx
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {
applicationId "com.hijacker"
minSdkVersion 21
targetSdkVersion 28
versionCode 33
versionName "v1.5-beta.9"
versionCode 34
versionName "v1.5-beta.10"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
Expand Down
48 changes: 28 additions & 20 deletions app/src/main/java/com/hijacker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ClipData;
Expand Down Expand Up @@ -113,7 +114,7 @@ public class MainActivity extends AppCompatActivity{
static int aireplay_running = 0, currentFragment = FRAGMENT_AIRODUMP; //Set currentFragment in onResume of each Fragment
//Filters
static boolean show_ap = true, show_st = true, show_na_st = true, wpa = true, wep = true, opn = true;
static boolean show_ch[] = {true, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
static boolean[] show_ch = {true, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
static int pwr_filter = 120;
static String manuf_filter = "";
//Airodump list sort
Expand All @@ -128,8 +129,8 @@ public class MainActivity extends AppCompatActivity{
static DrawerLayout mDrawerLayout;
static NavigationView navigationView;
static SparseArray<String> 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;
Expand Down Expand Up @@ -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<throwable.getStackTrace().length;i++){
stackTrace += throwable.getStackTrace()[i].toString() + '\n';
stackTrace.append(throwable.getStackTrace()[i].toString()).append('\n');
}

Intent intent = new Intent();
intent.setAction("com.hijacker.SendLogActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("exception", stackTrace);
intent.putExtra("exception", stackTrace.toString());
startActivity(intent);

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

//Initialize notifications
publishProgress(getString(R.string.init_notifications));
//Create intents
//Create intents
Intent cancel_intent = new Intent(MainActivity.this, DismissReceiver.class);
Intent stop_intent = new Intent(MainActivity.this, StopReceiver.class);
Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent click_intent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);

//Create 'running' notification
notif = new NotificationCompat.Builder(MainActivity.this);
// Get a channel ID
String channelID;
if(Build.VERSION.SDK_INT >= 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);
Expand All @@ -414,17 +423,17 @@ 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));
}
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));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/hijacker/ReaverFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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<Void, String, Boolean>{
String pinDelay, lockedDelay;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/hijacker/RootFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -189,17 +189,17 @@ List<RootFile> 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<temp.length; i++){
full_name += temp[i] + ' ';
full_name.append(temp[i]).append(' ');
}
if(full_name.charAt(full_name.length() - 1)==' '){
full_name = full_name.substring(0, full_name.length() - 1);
full_name = new StringBuilder(full_name.substring(0, full_name.length() - 1));
}
if(!full_name.contains(" -> ")){
if(!full_name.toString().contains(" -> ")){
result.add(new RootFile(absolutePath + (absolutePath.length()==1 ? "" : '/') + full_name));
}
}
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/com/hijacker/SendLogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -133,7 +133,7 @@ protected Boolean doInBackground(Void... params){
}
}
private class ReportTask extends AsyncTask<Void, String, Boolean>{
String bugReport = "";
StringBuilder bugReport = new StringBuilder();
@Override
protected Boolean doInBackground(Void... params){
report = new File(Environment.getExternalStorageDirectory() + "/report.txt");
Expand All @@ -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;
Expand Down Expand Up @@ -183,19 +184,19 @@ public void onRestart(View v){
}
public void stopAll(){
ArrayList<Integer> pids = new ArrayList<>();
String processes[] = {
String[] processes = {
"airodump-ng",
"aireplay-ng",
"aircrack-ng",
"mdk3",
"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;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hijacker/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int findIndex(List<Tile> list, Tile tile, Comparator<Tile> 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;
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<resources>
<string name="app_name" translatable="false">Hijacker</string>
<string name="DEFAULT_CHANNEL_ID" translatable="false">Hijacker_Notification_Channel</string>

<!-- Toolbar -->
<string name="stop_aireplay">Stop Aireplay</string>
Expand Down Expand Up @@ -297,8 +298,8 @@
<string name="done">Done</string>

<!-- UpdateConfirmDialog -->
<string name="update_title">New update available</string>
<string name="update_text">There is a new update available.</string>
<string name="update_title">Update available</string>
<string name="update_text">There is an update available.</string>
<string name="latest_version">Latest Version</string>
<string name="current_version">Current Version</string>

Expand Down

0 comments on commit dc28351

Please sign in to comment.