Giter VIP home page Giter VIP logo

smtshell-api's Introduction

SMTShell-API

SMTShell-API is an Android library that provides methods for executing shell commands and loading shared objects as the system user (UID 1000) on Samsung devices that are running SMTShell.

Including this in your project

project build.gradle

allprojects {
    repositories {
        // other repos here
        maven { url "https://jitpack.io" }  // <--- add this
    }
}

app/module build.gradle

dependencies {
    implementation 'com.github.BLuFeNiX:SMTShell-API:1.0'
}

Get permissions

Declare one or both of these, and arrange for your user to grant them as per usual:

<uses-permission android:name="smtshell.permission.SYSTEM_COMMAND" />
<uses-permission android:name="smtshell.permission.LOAD_LIBRARY" />

API Methods

executeCommand

executeCommand(Context context, String cmd) executeCommand(Context context, String cmd, CommandCallback cb)

SMTShellAPI.executeCommand(context, "ls -la /data/data/android/", new SMTShellAPI.CommandCallback() {
    @Override
    public void onComplete(String stdout, String stderr, int exitCode) {
        Log.d(TAG, "stdout: " + stdout);
        Log.d(TAG, "stderr: " + stderr);
        Log.d(TAG, "exit code: " + exitCode);
    }
});

loadLibrary

loadLibrary(Context context, String path) loadLibrary(Context context, String path, LoadLibraryCallback cb)

Load a shared object as the system (UID 1000).

SMTShellAPI.loadLibrary(this, getApplicationInfo().nativeLibraryDir + "/" + "libsmtshell.so", new SMTShellAPI.LoadLibraryCallback() {
    @Override
    public void onComplete(boolean success) {
        if (success) {
            // library loaded!
        } else {
            // something went wrong!
        }
    }
});

Note: Callback will not fire if your shared object blocks the incoming thread (i.e., with an onload constructor).

ping

ping(Context context)

Pings the API. You can capture the result with a dynamic broadcast receiver:

BroadcastReceiver mApiReadyReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        // API is ready!
    }
};

@Override
protected void onResume() {
    super.onResume();
    registerReceiver(mApiReadyReceiver, new IntentFilter(SMTShellAPI.ACTION_API_READY));
    SMTShellAPI.ping(this);
}

@Override
protected void onPause() {
    super.onPause();
    unregisterReceiver(mApiReadyReceiver);
}

You can also monitor the API going down (because the user killed it) via a recevier:

registerReceiver(mApiDeathReceiver, new IntentFilter(SMTShellAPI.ACTION_API_DEATH_NOTICE));

smtshell-api's People

Contributors

blufenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

smtshell-api's Issues

Tasker Support

Hi, I am trying to use this in Tasker. I tried via the API method without success. I can use the netcat reverse shell way but it seems insecure, so I'd rather use API. Is there any way this can be implemented?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.