/// <summary> /// Checks if system directories are writable. /// </summary> /// <returns><c>true</c>, if one or more system directories are writable, <c>false</c> otherwise.</returns> private static bool CheckForRwPaths() { var result = false; var lines = RootCheckerUtils.ReaderFor("mount"); foreach (var line in lines) { // Split lines into parts var args = line.Split(' '); if (args.Length < 4) { // If we don't have enough options per line, skip this and log an error Log.Error("CheckForRWPaths", $"Error formatting mount line: {line}"); continue; } var mountPoint = args[1]; var mountOptions = args[3]; foreach (var pathToCheck in RootCheckerConstants.PathsThatShouldNotBeWriteable) { if (mountPoint.Equals(pathToCheck, StringComparison.InvariantCultureIgnoreCase)) { // Split options out and compare against "rw" to avoid false positives if (mountOptions.Split(',').Any(option => option.Equals("rw", StringComparison.InvariantCultureIgnoreCase))) { Log.Info("CheckForRWPaths", $"{pathToCheck} path is mounted with rw permissions! {line}"); result = true; } } } } return(result); }
/// <summary> /// Checks for busy box binary. /// </summary> /// <returns><c>true</c>, if for busy box binary was checked, <c>false</c> otherwise.</returns> private static bool CheckForBusyBoxBinary() => RootCheckerUtils.CheckForBinary("busybox");
/// <summary> /// Checks for several dangerous properties (ro.debuggable == 1 or ro.secure==0) /// </summary> /// <returns><c>true</c>, if dangerous properties are found, <c>false</c> otherwise.</returns> private static bool CheckForDangerousProps() { var activeProps = RootCheckerUtils.ReaderFor("getprop"); return(activeProps.Contains("[ro.secure]: [0]") || activeProps.Contains("[ro.debuggable]: [1]")); }
/// <summary> /// Checks for su binary. /// </summary> /// <returns><c>true</c>, if for su binary was checked, <c>false</c> otherwise.</returns> private static bool CheckForSuBinary() => RootCheckerUtils.CheckForBinary("su");