Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Easy-to-use Android library for tampering detection, with a sample app included

License

apkunpacker/CheckBeer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CheckBeer

A lightweight native library for Android app security and anti-tampering checks. Easily integrate signature verification and tampering detection into your Android apps.

Note

Even though CheckBeer provides enhanced security, it is not a silver bullet. It is essential to follow security best practices and regularly update your app to maintain security effectiveness.

Features

  • Comprehensive security checks in native code
  • Minimal integration requirements
  • Customizable security validations
  • Individual check functions for granular control

Integration

1. Add Required Files

Copy these two files to your project's native code directory:

src/main/cpp/
├── CheckBeer.hpp
└── JNIHelper.hpp

2. Include Headers

In your native code, include the required headers:

#include "CheckBeer.hpp"
#include "JNIHelper.hpp"

3. Implement Checks

You can use individual checks or the complete verification:

// Complete signature verification
bool signatureBypass = checkSignatureBypass(env, context);
if (signatureBypass) {
    // Tampering detected
    // Handle security violation
}

// Or use individual checks as needed:
bool creatorCheck = checkCreator(env);
bool fieldCheck = checkField(env);
bool proxyCheck = checkPMProxy(env, context);
bool componentCheck = checkAppComponentFactory(env);
bool pathCheck = checkApkPaths(env, context);

Available Security Checks

Note

checkSignatureBypass performs all the following checks.

1. Package Creator Validation

bool checkCreator(JNIEnv* env);

Validates the integrity of PackageInfo's Parcelable.Creator

2. Field Structure Check

bool checkField(JNIEnv* env);

Verifies the CREATOR class structure for tampering

3. Package Manager Proxy Detection

bool checkPMProxy(JNIEnv* env, jobject context);

Ensures legitimate IPackageManager implementation

4. Component Factory Verification

bool checkAppComponentFactory(JNIEnv* env);

Validates App Component instantiation

5. APK Path Integrity

bool checkApkPaths(JNIEnv* env, jobject context);

Verifies APK location and permissions

Logging

All checks provide detailed logging with the tag "CheckBeer":

adb logcat | grep CheckBeer

Example Implementation

Here's a minimal example of using CheckBeer to verify app integrity in your native code:

#include "CheckBeer.hpp"
#include "JNIHelper.hpp"

extern "C" JNIEXPORT jboolean JNICALL
Java_com_example_app_SecurityCheck_verifyIntegrity(
        JNIEnv* env,
        jobject obj,
        jobject context) {
    
    bool suspicious = checkSignatureBypass(env, context);
    return suspicious;
}

Corresponding Java code:

public class SecurityCheck {
    
    public static native boolean verifyIntegrity(Context context);

    public void validateApp(Context context) {
        try {
            if (verifyIntegrity(context)) {
                throw new RuntimeException("Security violation detected!");
            }
        } catch (UnsatisfiedLinkError | Exception e) {
            // Handle errors if needed
        }
    }
}

Demo

Okay

Wrong1

Wrong2

Wrong3

License

This project is licensed under the MIT License.

Acknowledgements

About

Easy-to-use Android library for tampering detection, with a sample app included

Resources

License

Stars

Watchers

Forks

Packages

No packages published