level 13
Runtime.getRuntime().exec("echo "+System.getEnv("USER"));
2019年03月02日 13点03分
2
level 14
但新问题来了,我改用whoami来获取当前权限。如果用/system/bin/sh来执行的话会显示当前应用的用户名,如果用/system/bin/su来执行的话会显示root(如果软件未授权则会闪退)。如何判断软件是否已授权?
2019年03月02日 23点03分
4
level 14
public static boolean isRoot(){
Process process=null;
try{
process=Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","echo hello world"});
InputStreamReader ip=new InputStreamReader(process.getInputStream());
BufferedReader buf=new BufferedReader(ip);
return buf.readLine()!=null;
}catch(Exception e){
return false;
}finally{
process.destroy();
}
}
2019年03月03日 03点03分
8