MCPcopy Index your code
hub / github.com/cSploit/android / remount

Method remount

cSploit/src/org/csploit/android/core/ExecChecker.java:176–224  ·  view source on GitHub ↗

check if we can execute binaries in dir after remounting it without the noexec mount flag. @param dir the directory to check

(String dir)

Source from the content-addressed store, hash-verified

174 * @param dir the directory to check
175 */
176 private boolean remount(String dir) {
177 BufferedReader mounts = null;
178 String line,mountpoint,tmp;
179
180 try {
181 // find the mountpoint
182 mounts = new BufferedReader(new FileReader("/proc/mounts"));
183
184 mountpoint = null;
185
186 while((line = mounts.readLine()) != null) {
187 tmp = line.split(" ")[1];
188 if( line.contains("noexec") &&
189 dir.startsWith(tmp) &&
190 (mountpoint == null || tmp.length() > mountpoint.length())) {
191 mountpoint = tmp;
192 }
193 }
194
195 if(mountpoint == null)
196 return false;
197
198 // remount
199 if(System.getTools().raw.run(String.format("mount -oremount,exec '%s'", mountpoint))!=0) {
200 Logger.warning(String.format("cannot remount '%s' with exec flag", mountpoint));
201 return false;
202 }
203
204 // check it now
205 if(user(dir)) {
206 synchronized (this) {
207 if(modifiedMountpoit != null && !modifiedMountpoit.equals(mountpoint))
208 restoreMountpoint(modifiedMountpoit);
209 modifiedMountpoit = mountpoint;
210 resolvedDir = dir;
211 }
212 return true;
213 }
214 } catch (Exception e) {
215 System.errorLogging(e);
216 } finally {
217 if(mounts!=null) {
218 try { mounts.close(); }
219 catch (IOException ignored) { }
220 }
221 }
222
223 return false;
224 }
225
226 private void restoreMountpoint(String mountpoint) {
227 try {

Callers 1

canExecuteInDirMethod · 0.95

Calls 8

getToolsMethod · 0.95
warningMethod · 0.95
userMethod · 0.95
restoreMountpointMethod · 0.95
errorLoggingMethod · 0.95
formatMethod · 0.80
runMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected