Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fourth attempt :(

  • Loading branch information...
commit 8beadcca6bb9029161acca96e8d54ec82b1a6cc5 1 parent 9ee37b2
Simone Margaritelli authored
6 src/it/evilsocket/dsploit/core/Shell.java
View
@@ -40,7 +40,7 @@ public static boolean isRootGranted( ) {
boolean granted = false;
try {
- process = Runtime.getRuntime().exec("su");
+ process = Runtime.getRuntime().exec( System.getSuPath() );
writer = new DataOutputStream(process.getOutputStream());
reader = new BufferedReader( new InputStreamReader(process.getInputStream()) );
@@ -137,8 +137,8 @@ public static int exec( String command, OutputReceiver receiver ) throws IOExcep
libPath = System.getLibraryPath();
String[] envp = { "LD_LIBRARY_PATH=" + libPath + ":$LD_LIBRARY_PATH" };
- process = Runtime.getRuntime().exec( "su", envp );
-
+ process = Runtime.getRuntime().exec( System.getSuPath(), envp );
+
if( receiver != null ) receiver.onStart( command );
writer = new DataOutputStream( process.getOutputStream() );
31 src/it/evilsocket/dsploit/core/System.java
View
@@ -80,6 +80,7 @@
private static boolean mInitialized = false;
private static String mLastError = "";
+ private static String mSuPath = null;
private static UpdateManager mUpdateManager = null;
private static Context mContext = null;
private static WifiLock mWifiLock = null;
@@ -213,6 +214,36 @@ public static String getLibraryPath( ) {
return mContext.getFilesDir().getAbsolutePath() + "/tools/libs";
}
+ public static String getSuPath( ) {
+
+ if( mSuPath != null )
+ return mSuPath;
+
+ try
+ {
+ Process process = Runtime.getRuntime().exec( "which su" );
+ BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
+ String line = null;
+
+ while( ( line = reader.readLine() ) != null )
+ {
+ if( line.isEmpty() == false && line.startsWith("/") )
+ {
+ mSuPath = line;
+ break;
+ }
+ }
+
+ return mSuPath;
+ }
+ catch( Exception e )
+ {
+ errorLogging( TAG, e );
+ }
+
+ return "su";
+ }
+
private static void preloadServices( ) {
if( mServices == null || mPorts == null )
{

4 comments on commit 8beadcc

Ziggy

I can only guess the issues you're having with the LD_LIBRARY_PATH are due to some kernels not allowing the shell to export vars properly. Your best choice is using static binaries to fix this dynamic-libraries issue.

just my 2 cents.

Simone Margaritelli
Owner

Yep i'm starting to think this too :(

Simone Margaritelli
Owner

it's not so easy to find precompiled tools i need, i should install the ndk and compile them myself

Please sign in to comment.
Something went wrong with that request. Please try again.