Add nethunter app folder to env path

We can remove system symlink if we just add nethunter app folder to path.  Will save a lot of hassle hopefully.

Signed-off-by: binkybear <binkybear@nethunter.com>
This commit is contained in:
binkybear 2017-01-23 21:36:25 -06:00
parent a25ff7f0d4
commit 3ba9c54ea8
2 changed files with 2 additions and 32 deletions

View File

@ -98,7 +98,7 @@ public class ShellTermSession extends GenericTermSession {
}
String[] env = new String[3];
env[0] = "TERM=" + settings.getTermType();
env[1] = "PATH=" + path;
env[1] = "PATH=" + path + ":/data/data/com.offsec.nethunter/files/scripts/";
env[2] = "HOME=" + settings.getHomePath();
// Log.d("Initialize Sess", settings.getShell());
mProcId = createSubprocess(mShell, env);

View File

@ -906,16 +906,10 @@ public class Term extends Activity implements UpdateCallback, SharedPreferences.
if(CheckRoot.isDeviceRooted()){
Log.d("isDeviceRooted","Device is rooted!");
String filename = "/system/bin/bootkali_login";
String chroot_dir = "/data/local/nhsystem/kali-armhf"; // Not sure if I can wildcard this
File filePath = new File(filename);
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if(!isSymlink(filePath)){
NotFound(filename);
} else if (!dir_exists(chroot_dir)){
if (!dir_exists(chroot_dir)){
NotFound(chroot_dir);
} else {
TermSession session = null;
@ -934,9 +928,6 @@ public class Term extends Activity implements UpdateCallback, SharedPreferences.
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
} else {
// ALERT! WHY YOU NO ROOT!
Log.d("isDeviceRooted","Device is not rooted!");
@ -992,27 +983,6 @@ public class Term extends Activity implements UpdateCallback, SharedPreferences.
return output;
}
// Check for symlink for bootkali
// http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links/813730#813730
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public boolean isSymlink(File file) throws IOException {
Log.d("SYMLINK FILE TO CHECK: ", String.valueOf(file));
Log.d("SYMLINK REAL PATH: ", String.valueOf(file.getCanonicalFile()));
String bootkali_sys = "/system/bin/bootkali_login";
String bootkali_true = "/data/data/com.offsec.nethunter/files/scripts/bootkali_login";
// RunAsRootOutput: Check if /sys bootkali is symbolic and if bootkali_login exists in app folder
// return string 'True' if it does
String command = "[ -L \"" + bootkali_sys + "\" ] && [ -f \"" + bootkali_true + "\" ] && echo 'True'";
String output = RunAsRootOutput(command);
Log.d("SYMLINK RunAsRoot ", output);
// Backup if above command messes up: Get symlink true value
String Bootkali = String.valueOf(file.getCanonicalFile());
return (Objects.equals(Bootkali, bootkali_true)) || (output.equals("True"));
}
public boolean dir_exists(String dir_path)
{