Skip to content

Instantly share code, notes, and snippets.

View gauravssnl's full-sized avatar
😸
use code::latest ;

GAURAV gauravssnl

😸
use code::latest ;
View GitHub Profile
@gauravssnl
gauravssnl / build-rust-code-for-android.sh
Last active November 15, 2024 21:37
Cross compile Rust code for Android OS multiple architectures
export NDK_HOME_TOOLCHAIN_BIN="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
RUSTFLAGS="-C linker=${NDK_HOME_TOOLCHAIN_BIN}/aarch64-linux-android30-clang" cargo build --target aarch64-linux-android
RUSTFLAGS="-C linker=${NDK_HOME_TOOLCHAIN_BIN}/armv7a-linux-androideabi30-clang" cargo build --target armv7-linux-androideabi
RUSTFLAGS="-C linker=${NDK_HOME_TOOLCHAIN_BIN}/x86_64-linux-android30-clang" cargo build --target x86_64-linux-android
RUSTFLAGS="-C linker=${NDK_HOME_TOOLCHAIN_BIN}/i686-linux-android30-clang" cargo build --target i686-linux-android
@gauravssnl
gauravssnl / Test.java
Last active November 13, 2024 20:57
JNI example to call java method (example : System.out.println)
class Test {
static {
System.loadLibrary("hello");
}
public static void main(String[] args) {
System.out.println("Test OK");
System.out.println(stringFromJNI());
}
@gauravssnl
gauravssnl / SampleEncPrefs.kt
Created January 30, 2024 15:23 — forked from scottyab/SampleEncPrefs.kt
Simple example of using EncrypredSharedPreferences
package com.scottyab.whatsnewplayground.data
import android.content.Context
import android.content.SharedPreferences
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKeys
import com.scottyab.whatsnewplayground.BuildConfig
internal class SampleEncPrefs(context: Context) {
@gauravssnl
gauravssnl / SignatureCheck.java
Created January 30, 2024 15:22 — forked from scottyab/SignatureCheck.java
Simple Android signature check. Please note: This was created in 2013, not actively maintained and may not be compatible with the latest Android versions. It's not particularly difficult for an attacker to decompile an .apk, find this tamper check, replace the APP_SIGNATURE with theirs and rebuild (or use method hooking to return true from `vali…
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
public class TamperCheck {
//we store the hash of the signture for a little more protection
private static final String APP_SIGNATURE = "1038C0E34658923C4192E61B16846";
@gauravssnl
gauravssnl / SimpleApkV2.java
Created January 30, 2024 14:58 — forked from vvb2060/SimpleApkV2.java
SimpleApkV2
// package me.piebridge;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.AppComponentFactory;
import android.content.pm.ApplicationInfo;
import android.util.Log;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipFile;
@gauravssnl
gauravssnl / hiddenapibypass.cpp
Created January 30, 2024 14:56 — forked from vvb2060/hiddenapibypass.cpp
`JNI_OnLoad` called by system
jint JNI_OnLoad(JavaVM *jvm, void *) {
JNIEnv *env;
jclass clazz;
if (jvm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
return JNI_ERR;
}
jclass vm = env->FindClass("dalvik/system/VMRuntime");
jclass string = env->FindClass("java/lang/String");
@gauravssnl
gauravssnl / am_proc_start.cpp
Created January 30, 2024 14:55 — forked from vvb2060/am_proc_start.cpp
monitor app process start
#include <unistd.h>
#include <string>
#include <cinttypes>
#include <android/log.h>
#include <sys/system_properties.h>
using namespace std;
extern "C" {
.segment "HEADER"
.byte "NES", $1A ; Constant
.byte 2 ; 2 x 16KB PRG ROM
.byte 1 ; 1 x 8KB CHR ROM
.segment "CHARS"
;-------------------------------------------------------------
; CREATE SPRITES
;-------------------------------------------------------------
; The following creates one sprite. The following two bitmaps
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)