1 | docker exec -it <docker_name> /bin/bash -c "stty cols `tput cols` rows `tput lines` && bash" |
MacOS Keyboard Shortcuts
Good MacOS Software
-
Browse and open files directly from archives.
-
Windows-like window manipulation.
-
Keep using trackpad in the natural way while using the mouse scroll in the reverse way.
-
HammerSpoon config file for windows management, etc.
How to Modify jar File
Android Reverse Engineering
safasdf
asdf
Java Reflection
Import
1 | import java.lang.reflect.*; |
Get Class, Field and Method Objects
1 | Class<?> class = ClassforName("<className>""); |
Make private fields or methods accessible
1 | field.setAccessible(true); |
Read and write fields
1 | field.get(Object instance); // return the value(return type: Object) |
Invoke methods
1 | method.invoke(Object instance, Object... args); // return Object |
Modify final fields
1. Get the final field
1 | // First get the final field we want to modify |
2. Cancel the final bit
For general JVM
1 | Field modifiersField = Field.class.getDeclaredField("modifiers"); |
For Android
The member of Field representing modifiers is different. modifiers
-> accessFlags
1 | Field modifiersField = Field.class.getDeclaredField("accessFlags"); |
Reference
java.lang.Class
java.lang.reflect.Method
java.lang.reflect.Field
Java Reflection Tutorial
Install SGX
For Ubuntu 16.04 LTS.
Download the following installation packages from https://01.org/intel-software-guard-extensions/downloads
- Intel(R) SGX driver:
sgx_linux_x64_driver.bin
- Intel(R) SGX PSW:
sgx_linux_x64_psw_<version>.bin
- Intel(R) SGX SDK:
sgx_linux_x64_sdk_<version>.bin
1 | # Intel(R) SGX PSW Dependecies |
Reference
Intel® Software Guard Extensions for Linux* OS
Intel_SGX_Installation_Guide_Linux_2.0_Open_Source
Intel_SGX_SDK_Developer_Reference_Linux_2.0_Open_Source
Intel_SGX_Developer_Guide
Intel® Software Guard Extensions Programming Reference
How to Check If an App is System App or Not
Definition
The definition of system app is not very clear. There are at least three different definitions:
- Apps in system partition (
/system
)- These apps will get the flag
ApplicationInfo.FLAG_SYSTEM
- If an updated version is installed (probably not under
/system
), it will getApplicationInfo.FLAG_UPDATED_SYSTEM_APP
- These apps will get the flag
- Apps signed with platform signature
- These apps will be granted
signature
level permission - The signature is checked in PackageManagerService.java
- These apps will be granted
- Apps in
/system/priv-apps
and/system/framework
- These apps will get the flag
ApplicationInfo.PRIVATE_FLAG_PRIVILEGED
- The flag is set in PackageManagerService.java
- These apps will be granted
signatureOrSystem
level permissions (corresponding to theSystem
insignatureOrSystem
) - For Samsung, apps in
/system/carrier/priv-app
and/odm/priv-app
will also get this flag
- These apps will get the flag
Check
1 | import android.content.pm.ApplicationInfo; |
Reference
Definition of PRIVATE_FLAG_PRIVILEGED in ApplicationInfo.java
How to check if application is system app or not (By signed signature)
Android permission element
How to Sign Android App with Platform Signature
1 | java -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk |
signapk.jar can be found under <root-of-android-source-tree>/out/host/<your-host>/framework/
platform.x509.pem and platform.pk8 can be found under <root-of-android-source-tree>/build/target/product/security/
Grant an App the System Uid (Optional)
In the AndroidManifest.xml of your application: in the <manifest>
tag, add the attribute android:sharedUserId="android.uid.system"
.
Reference
GCC Optimization Levels
Print the specific optimization flags corresponding to preconfigured optimization levels.
1 | # gcc -c -Q -O{level} --help=optimizers |