com.android.reverse.util.Logger Java Examples

The following examples show how to use com.android.reverse.util.Logger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessBuilderHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.ProcessBuilder", ClassLoader.getSystemClassLoader(),
			"start");
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Create New Process ->");
			ProcessBuilder pb = (ProcessBuilder) param.thisObject;
			List<String> cmds = pb.command();
			StringBuilder sb = new StringBuilder();
			for(int i=0 ;i <cmds.size(); i++){
			   sb.append("CMD"+i+":"+cmds.get(i)+" ");
			}
			Logger.log_behavior("Command" + sb.toString());
		}
	});
}
 
Example #2
Source File: DexFileInfoCollecter.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
/**
     * @param mCookies
     * @return 所有可用的dexFile的mCookie
     */

    public static long[] parseMCookies(Object mCookies) {

        if (mCookies instanceof Integer) {
            return new long[]{(Integer) mCookies};
        } else if (mCookies instanceof Long) {
            return new long[]{(Long) mCookies};
        } else if (mCookies instanceof long[]) {
            long[] cookies = ((long[]) mCookies);
            long[] longs = new long[cookies.length - 1];
//            sdk23开始的art虚拟机中,mCookie为long[],其中第一个为oatFile,余下的为(o)dexFile
//            摘自源码:
//            constexpr size_t kOatFileIndex = 0;
//            constexpr size_t kDexFileIndexStart = 1;
            System.arraycopy(cookies, 1, longs, 0, longs.length);
            return longs;
        } else {
            //没有满足的情况
            Logger.log("bad mCookies at " + DexFileInfoCollecter.class.getName() + "#" + "parseMCookies(Object) :" + mCookies);
            return null;
        }


    }
 
Example #3
Source File: ConnectivityManagerHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	
	Method setMobileDataEnabledmethod = RefInvoke.findMethodExact(
			"android.net.ConnectivityManager", ClassLoader.getSystemClassLoader(),
			"setMobileDataEnabled",boolean.class);
	hookhelper.hookMethod(setMobileDataEnabledmethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			boolean status = (Boolean) param.args[0];
			Logger.log("Set MobileDataEnabled = "+status);
		}
	});
	
}
 
Example #4
Source File: AlarmManagerHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	
	Method setImplmethod = RefInvoke.findMethodExact(
			"android.app.AlarmManager", ClassLoader.getSystemClassLoader(),
			"setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class);
	hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			Logger.log_behavior("The Alarm Information:");
			PendingIntent intent = (PendingIntent) param.args[4];
			if(intent != null)
			   descPendingIntent(intent);
			Logger.log_behavior("TriggerAtMillis = "+param.args[1]);
			Logger.log_behavior("windowMillis = "+param.args[2]);
			Logger.log_behavior("intervalMillis = "+param.args[3]);

		}
	});
	
}
 
Example #5
Source File: ProcessBuilderHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.ProcessBuilder", ClassLoader.getSystemClassLoader(),
			"start");
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Create New Process ->");
			ProcessBuilder pb = (ProcessBuilder) param.thisObject;
			List<String> cmds = pb.command();
			StringBuilder sb = new StringBuilder();
			for(int i=0 ;i <cmds.size(); i++){
			   sb.append("CMD"+i+":"+cmds.get(i)+" ");
			}
			Logger.log_behavior("Command" + sb.toString());
		}
	});
}
 
Example #6
Source File: RuntimeHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {

	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.Runtime", ClassLoader.getSystemClassLoader(),
			"exec", String[].class,String[].class,File.class);
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Create New Process ->");
			String[] progs = (String[]) param.args[0];
			for(int i=0 ;i <progs.length; i++){
			   Logger.log_behavior("Command" + i + " = "+progs[i]);
			}
		}
	});
	
}
 
Example #7
Source File: AudioRecordHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method startRecordingMethod = RefInvoke.findMethodExact(
			"android.media.AudioRecord", ClassLoader.getSystemClassLoader(),
			"startRecording");
	hookhelper.hookMethod(startRecordingMethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Audio Recording ->");
		}
	});
	
}
 
Example #8
Source File: DumpClassCommandHandler.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void doAction() {
	String[] loadClass = DexFileInfoCollecter.getInstance().dumpLoadableClass(mCookie);
	if (loadClass != null) {
		Logger.log("Start Loadable ClassName ->");
		String className = null;
		for (int i = 0; i < loadClass.length; i++) {
			className = loadClass[i];
			if (!this.isFilterClass(className)) {
				Logger.log("ClassName = " + className);
			}
		}
		Logger.log("End Loadable ClassName");
	}else{
		Logger.log("Can't find class loaded by the dex");
	}
}
 
Example #9
Source File: ActivityThreadHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	try {
		Class receiverDataClass = Class.forName("android.app.ActivityThread$ReceiverData");
		if (receiverDataClass != null) {
			Method handleReceiverMethod = RefInvoke.findMethodExact("android.app.ActivityThread", ClassLoader.getSystemClassLoader(),
					"handleReceiver", receiverDataClass);
			hookhelper.hookMethod(handleReceiverMethod, new AbstractBahaviorHookCallBack() {

				@Override
				public void descParam(HookParam param) {
					Logger.log_behavior("The Receiver Information:");
					Object data = param.args[0];
					Logger.log_behavior(data.toString());
					
				}
			});
		}
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
}
 
Example #10
Source File: AudioRecordHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method startRecordingMethod = RefInvoke.findMethodExact(
			"android.media.AudioRecord", ClassLoader.getSystemClassLoader(),
			"startRecording");
	hookhelper.hookMethod(startRecordingMethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Audio Recording ->");
		}
	});
	
}
 
Example #11
Source File: ActivityThreadHook.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	try {
		Class receiverDataClass = Class.forName("android.app.ActivityThread$ReceiverData");
		if (receiverDataClass != null) {
			Method handleReceiverMethod = RefInvoke.findMethodExact("android.app.ActivityThread", ClassLoader.getSystemClassLoader(),
					"handleReceiver", receiverDataClass);
			hookhelper.hookMethod(handleReceiverMethod, new AbstractBahaviorHookCallBack() {

				@Override
				public void descParam(HookParam param) {
					Logger.log_behavior("The Receiver Information:");
					Object data = param.args[0];
					Logger.log_behavior(data.toString());
					
				}
			});
		}
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #12
Source File: ActivityThreadHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	try {
		Class receiverDataClass = Class.forName("android.app.ActivityThread$ReceiverData");
		if (receiverDataClass != null) {
			Method handleReceiverMethod = RefInvoke.findMethodExact("android.app.ActivityThread", ClassLoader.getSystemClassLoader(),
					"handleReceiver", receiverDataClass);
			hookhelper.hookMethod(handleReceiverMethod, new AbstractBahaviorHookCallBack() {

				@Override
				public void descParam(HookParam param) {
					Logger.log_behavior("The Receiver Information:");
					Object data = param.args[0];
					Logger.log_behavior(data.toString());
					
				}
			});
		}
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #13
Source File: RuntimeHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {

	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.Runtime", ClassLoader.getSystemClassLoader(),
			"exec", String[].class,String[].class,File.class);
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			Logger.log_behavior("Create New Process ->");
			String[] progs = (String[]) param.args[0];
			for(int i=0 ;i <progs.length; i++){
			   Logger.log_behavior("Command" + i + " = "+progs[i]);
			}
		}
	});
	
}
 
Example #14
Source File: ProcessBuilderHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.ProcessBuilder", ClassLoader.getSystemClassLoader(),
			"start");
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Create New Process ->");
			ProcessBuilder pb = (ProcessBuilder) param.thisObject;
			List<String> cmds = pb.command();
			StringBuilder sb = new StringBuilder();
			for(int i=0 ;i <cmds.size(); i++){
			   sb.append("CMD"+i+":"+cmds.get(i)+" ");
			}
			Logger.log_behavior("Command" + sb.toString());
		}
	});
}
 
Example #15
Source File: DumpClassCommandHandler.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override
public void doAction() {
	// TODO Auto-generated method stub
	String[] loadClass = DexFileInfoCollecter.getInstance().dumpLoadableClass(dexpath);
	if (loadClass != null) {
		Logger.log("Start Loadable ClassName ->");
		String className = null;
		for (int i = 0; i < loadClass.length; i++) {
			className = loadClass[i];
			if (!this.isFilterClass(className)) {
				Logger.log("ClassName = " + className);
			}
		}
		Logger.log("End Loadable ClassName");
	}else{
		Logger.log("Can't find class loaded by the dex");
	}
}
 
Example #16
Source File: CommandBroadcastReceiver.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(final Context arg0, Intent arg1) {
	if (INTENT_ACTION.equals(arg1.getAction())) {
		try {
			int pid = arg1.getIntExtra(TARGET_KEY, 0);
			if (pid == android.os.Process.myPid()) {
				String cmd = arg1.getStringExtra(COMMAND_NAME_KEY);
				final CommandHandler handler = CommandHandlerParser
						.parserCommand(cmd);
				if (handler != null) {
					new Thread(new Runnable() {
						@Override
						public void run() {
							handler.doAction();
						}
					}).start();
				}else{
					Logger.log("the cmd is invalid");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example #17
Source File: DexBackedMethod.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public DexBackedMethod(@Nonnull DexReader reader,
                       @Nonnull DexBackedClassDef classDef,
                       int previousMethodIndex) {
    this.dexFile = reader.dexBuf;
    this.classDef = classDef;

    // large values may be used for the index delta, which cause the cumulative index to overflow upon
    // addition, effectively allowing out of order entries.
    int methodIndexDiff = reader.readLargeUleb128();
    this.methodIndex = methodIndexDiff + previousMethodIndex;
    this.accessFlags = reader.readSmallUleb128();
    this.codeOffset = reader.readSmallUleb128();
    Logger.log("the codeoffset :" +this.codeOffset);
    this.methodAnnotationSetOffset = 0;
    this.parameterAnnotationSetListOffset = 0;
}
 
Example #18
Source File: AlarmManagerHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	
	Method setImplmethod = RefInvoke.findMethodExact(
			"android.app.AlarmManager", ClassLoader.getSystemClassLoader(),
			"setImpl",int.class,long.class,long.class,long.class,PendingIntent.class,WorkSource.class);
	hookhelper.hookMethod(setImplmethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			Logger.log_behavior("The Alarm Information:");
			PendingIntent intent = (PendingIntent) param.args[4];
			descPendingIntent(intent);
			Logger.log_behavior("TriggerAtMillis = "+param.args[1]);
			Logger.log_behavior("windowMillis = "+param.args[2]);
			Logger.log_behavior("intervalMillis = "+param.args[3]);

		}
	});
	
}
 
Example #19
Source File: DexBackedMethod.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public DexBackedMethod(@Nonnull DexReader reader,
                       @Nonnull DexBackedClassDef classDef,
                       int previousMethodIndex) {
    this.dexFile = reader.dexBuf;
    this.classDef = classDef;

    // large values may be used for the index delta, which cause the cumulative index to overflow upon
    // addition, effectively allowing out of order entries.
    int methodIndexDiff = reader.readLargeUleb128();
    this.methodIndex = methodIndexDiff + previousMethodIndex;
    this.accessFlags = reader.readSmallUleb128();
    this.codeOffset = reader.readSmallUleb128();
    Logger.log("the codeoffset :" +this.codeOffset);
    this.methodAnnotationSetOffset = 0;
    this.parameterAnnotationSetListOffset = 0;
}
 
Example #20
Source File: ReverseXposedModule.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
	// TODO Auto-generated method stub
	if(lpparam.appInfo == null || 
			(lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) !=0){
		return;
	}else if(lpparam.isFirstApplication && !ZJDROID_PACKAGENAME.equals(lpparam.packageName)){
	  Logger.PACKAGENAME = lpparam.packageName;
	  Logger.log("the package = "+lpparam.packageName +" has hook");
	  Logger.log("the app target id = "+android.os.Process.myPid());
	  PackageMetaInfo pminfo = PackageMetaInfo.fromXposed(lpparam);
	  ModuleContext.getInstance().initModuleContext(pminfo);
	  DexFileInfoCollecter.getInstance().start();
	  LuaScriptInvoker.getInstance().start();
	  ApiMonitorHookManager.getInstance().startMonitor();
	}else{
		
	}
}
 
Example #21
Source File: ConnectivityManagerHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	
	Method setMobileDataEnabledmethod = RefInvoke.findMethodExact(
			"android.net.ConnectivityManager", ClassLoader.getSystemClassLoader(),
			"setMobileDataEnabled",boolean.class);
	hookhelper.hookMethod(setMobileDataEnabledmethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			boolean status = (Boolean) param.args[0];
			Logger.log("Set MobileDataEnabled = "+status);
		}
	});
	
}
 
Example #22
Source File: DexBackedMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public DexBackedMethod(@Nonnull DexReader reader,
                       @Nonnull DexBackedClassDef classDef,
                       int previousMethodIndex) {
    this.dexFile = reader.dexBuf;
    this.classDef = classDef;

    // large values may be used for the index delta, which cause the cumulative index to overflow upon
    // addition, effectively allowing out of order entries.
    int methodIndexDiff = reader.readLargeUleb128();
    this.methodIndex = methodIndexDiff + previousMethodIndex;
    this.accessFlags = reader.readSmallUleb128();
    this.codeOffset = reader.readSmallUleb128();
    Logger.log("the codeoffset :" +this.codeOffset);
    this.methodAnnotationSetOffset = 0;
    this.parameterAnnotationSetListOffset = 0;
}
 
Example #23
Source File: ContextImplHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method registerReceivermethod = RefInvoke.findMethodExact(
			"android.app.ContextImpl", ClassLoader.getSystemClassLoader(),
			"registerReceiver", BroadcastReceiver.class,IntentFilter.class);
	hookhelper.hookMethod(registerReceivermethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub				
			Logger.log_behavior("Register BroatcastReceiver");
			Logger.log_behavior("The BroatcastReceiver ClassName = "+param.args[0].getClass().toString());
			if(param.args[1] != null){
			   String intentstr = descIntentFilter((IntentFilter) param.args[1]);
			   Logger.log_behavior("Intent Action = ["+intentstr+"]");
			}
		}
	});
}
 
Example #24
Source File: ActivityThreadHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	try {
		Class receiverDataClass = Class.forName("android.app.ActivityThread$ReceiverData");
		if (receiverDataClass != null) {
			Method handleReceiverMethod = RefInvoke.findMethodExact("android.app.ActivityThread", ClassLoader.getSystemClassLoader(),
					"handleReceiver", receiverDataClass);
			hookhelper.hookMethod(handleReceiverMethod, new AbstractBahaviorHookCallBack() {

				@Override
				public void descParam(HookParam param) {
					Logger.log_behavior("The Receiver Information:");
					Object data = param.args[0];
					Logger.log_behavior(data.toString());
					
				}
			});
		}
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #25
Source File: AudioRecordHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method startRecordingMethod = RefInvoke.findMethodExact(
			"android.media.AudioRecord", ClassLoader.getSystemClassLoader(),
			"startRecording");
	hookhelper.hookMethod(startRecordingMethod, new AbstractBahaviorHookCallBack() {
		
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Audio Recording ->");
		}
	});
	
}
 
Example #26
Source File: RuntimeHook.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {

	Method execmethod = RefInvoke.findMethodExact(
			"java.lang.Runtime", ClassLoader.getSystemClassLoader(),
			"exec", String[].class,String[].class,File.class);
	hookhelper.hookMethod(execmethod, new AbstractBahaviorHookCallBack() {			
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Logger.log_behavior("Create New Process ->");
			String[] progs = (String[]) param.args[0];
			for(int i=0 ;i <progs.length; i++){
			   Logger.log_behavior("Command" + i + " = "+progs[i]);
			}
		}
	});
	
}
 
Example #27
Source File: NetWorkHook.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override
public void startHook() {
	// HttpURLConnection
	Method openConnectionMethod = RefInvoke.findMethodExact("java.net.URL", ClassLoader.getSystemClassLoader(), "openConnection");
	hookhelper.hookMethod(openConnectionMethod, new AbstractBahaviorHookCallBack() {
		@Override
		public void descParam(HookParam param) {
			URL url = (URL) param.thisObject;
			Logger.log_behavior("Connect to URL ->");
			Logger.log_behavior("The URL = " + url.toString());
		}
	});

	if(Build.VERSION.SDK_INT < 23){
		httpHook = new ApacheHttpHook();

		httpHook.startHook();

	}



}
 
Example #28
Source File: DumpMemCommandHandler.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Override
public void doAction() {
	// TODO Auto-generated method stub
	String memfilePath = ModuleContext.getInstance().getAppContext().getFilesDir()+"/"+dumpFileName;
       MemDump.dumpMem(memfilePath,start, length);       
       Logger.log("the mem data save to ="+ memfilePath);
}
 
Example #29
Source File: NotificationManagerHook.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Override
public void startHook() {
	// TODO Auto-generated method stub
	Method notifyMethod = RefInvoke.findMethodExact("android.app.NotificationManager", ClassLoader.getSystemClassLoader(), "notify",int.class,Notification.class);
	hookhelper.hookMethod(notifyMethod, new AbstractBahaviorHookCallBack() {
		@Override
		public void descParam(HookParam param) {
			// TODO Auto-generated method stub
			Notification notification = (Notification) param.args[1];
			Logger.log_behavior("Send Notification ->"); 
			Logger.log_behavior(notification.toString()); 
		}
	});
}
 
Example #30
Source File: DexFileInfoCollecter.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public String[] dumpLoadableClass(String dexPath) {
	int mCookie = this.getCookie(dexPath);
	if (mCookie != 0) {
		return (String[]) RefInvoke.invokeStaticMethod("dalvik.system.DexFile", "getClassNameList", new Class[] { int.class },
				new Object[] { mCookie });
	} else {
		Logger.log("the cookie is not right");
	}
	return null;

}