GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 补充文件 · shadowce/linuxKernelRoot@37f5533

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • PermissionManager
    • .gitignore
    • appKey.jks
    • app
      • .gitignore
      • build.gradle
      • proguard-rules.pro
      • src
        • androidTest/java/com/linux/permissionmanager
          • ExampleInstrumentedTest.java
        • main
          • AndroidManifest.xml
          • cpp
            • CMakeLists.txt
            • root.cpp
          • java/com/linux/permissionmanager
            • MainActivity.java
            • UsbDebugSwitchHelper.java
          • res
            • drawable-v24
              • ic_launcher_foreground.xml
            • drawable
              • ic_launcher_background.xml
            • layout
              • activity_main.xml
            • mipmap-anydpi-v26
              • ic_launcher.xml
              • ic_launcher_round.xml
            • mipmap-hdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-mdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xxhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xxxhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • values-night
              • themes.xml
            • values
              • colors.xml
              • strings.xml
              • themes.xml
        • test/java/com/linux/permissionmanager
          • ExampleUnitTest.java
    • build.gradle
    • gradle.properties
    • gradlew.bat
    • gradlew
    • gradle/wrapper
      • gradle-wrapper.jar
      • gradle-wrapper.properties
    • settings.gradle
  • README.md
  • suTest
    • .gitignore
    • app
      • .gitignore
      • build.gradle
      • proguard-rules.pro
      • src
        • androidTest/java/com/linux/sutest
          • ExampleInstrumentedTest.java
        • main
          • AndroidManifest.xml
          • java/com/linux/sutest
            • MainActivity.java
          • res
            • drawable-v24
              • ic_launcher_foreground.xml
            • drawable
              • ic_launcher_background.xml
            • layout
              • activity_main.xml
            • menu
              • menu_main.xml
            • mipmap-anydpi-v26
              • ic_launcher.xml
              • ic_launcher_round.xml
            • mipmap-hdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-mdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xxhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • mipmap-xxxhdpi
              • ic_launcher.png
              • ic_launcher_round.png
            • navigation
              • nav_graph.xml
            • values-night
              • themes.xml
            • values
              • colors.xml
              • dimens.xml
              • strings.xml
              • themes.xml
        • test/java/com/linux/sutest
          • ExampleUnitTest.java
    • build.gradle
    • gradle.properties
    • gradlew.bat
    • gradlew
    • gradle/wrapper
      • gradle-wrapper.jar
      • gradle-wrapper.properties
    • settings.gradle
  • su
    • jni
      • Android.mk
      • Application.mk
    • pts.cpp
    • pts.hpp
    • simple_su.cpp
    • socket.cpp
    • socket.hpp
    • su.cpp
    • su.h
    • su.vcxproj.filters
    • su.vcxproj.user
    • su.vcxproj
    • su_client.h
    • su_daemon.h
  • testRoot
    • README.md
    • adb64_inject.h
    • env64_inject.cpp
    • env64_inject.h
    • jni
      • Android.mk
    • maps_helper.cpp
    • maps_helper.h
    • ptrace_arm64_utils.cpp
    • ptrace_arm64_utils.h
    • testRoot.cpp
    • testRoot.h
    • testRoot.vcxproj.filters
    • testRoot.vcxproj

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎PermissionManager/.gitignore‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
Collapse file

‎PermissionManager/app/.gitignore‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Collapse file

‎PermissionManager/app/build.gradle‎

Copy file name to clipboard
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 29
7+
buildToolsVersion "29.0.3"
8+
9+
defaultConfig {
10+
applicationId "com.linux.permissionmanager"
11+
minSdkVersion 26
12+
targetSdkVersion 29
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
externalNativeBuild {
18+
cmake {
19+
cppFlags "-std=c++17"
20+
abiFilters "arm64-v8a" //需要什么构架的so,就在这边添加即
21+
}
22+
}
23+
}
24+
25+
buildTypes {
26+
release {
27+
minifyEnabled false
28+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29+
}
30+
}
31+
externalNativeBuild {
32+
cmake {
33+
path "src/main/cpp/CMakeLists.txt"
34+
version "3.10.2"
35+
}
36+
}
37+
compileOptions {
38+
sourceCompatibility JavaVersion.VERSION_1_8
39+
targetCompatibility JavaVersion.VERSION_1_8
40+
}
41+
}
42+
43+
dependencies {
44+
45+
implementation 'androidx.appcompat:appcompat:1.2.0'
46+
implementation 'com.google.android.material:material:1.3.0'
47+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
48+
testImplementation 'junit:junit:4.+'
49+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
50+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
51+
}
Collapse file

‎PermissionManager/app/proguard-rules.pro‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Collapse file

‎PermissionManager/app/src/androidTest/java/com/linux/permissionmanager/ExampleInstrumentedTest.java‎

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.linux.permissionmanager;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.linux.permissionmanager", appContext.getPackageName());
25+
}
26+
}
Collapse file

‎PermissionManager/app/src/main/AndroidManifest.xml‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.linux.permissionmanager">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.PermissionManager">
12+
<activity android:name="com.linux.permissionmanager.MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Collapse file

‎PermissionManager/app/src/main/cpp/CMakeLists.txt‎

Copy file name to clipboard
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# For more information about using CMake with Android Studio, read the
2+
# documentation: https://d.android.com/studio/projects/add-native-code.html
3+
4+
# Sets the minimum version of CMake required to build the native library.
5+
6+
cmake_minimum_required(VERSION 3.10.2)
7+
8+
# Declares and names the project.
9+
10+
project("permissionmanager")
11+
12+
# Creates and names a library, sets it as either STATIC
13+
# or SHARED, and provides the relative paths to its source code.
14+
# You can define multiple libraries, and CMake builds them for you.
15+
# Gradle automatically packages shared libraries with your APK.
16+
17+
add_library( # Sets the name of the library.
18+
root
19+
20+
# Sets the library as a shared library.
21+
SHARED
22+
23+
# Provides a relative path to your source file(s).
24+
../../../../../testRoot/adb_inject.cpp
25+
../../../../../testRoot/ptrace_arm64_utils.cpp
26+
root.cpp)
27+
28+
# Searches for a specified prebuilt library and stores the path as a
29+
# variable. Because CMake includes system libraries in the search path by
30+
# default, you only need to specify the name of the public NDK library
31+
# you want to add. CMake verifies that the library exists before
32+
# completing its build.
33+
34+
find_library( # Sets the name of the path variable.
35+
log-lib
36+
37+
# Specifies the name of the NDK library that
38+
# you want CMake to locate.
39+
log )
40+
41+
# Specifies libraries CMake should link to your target library. You
42+
# can link multiple libraries, such as libraries you define in this
43+
# build script, prebuilt third-party libraries, or system libraries.
44+
45+
target_link_libraries( # Specifies the target library.
46+
root
47+
48+
# Links the target library to the log library
49+
# included in the NDK.
50+
${log-lib} )
Collapse file

‎PermissionManager/app/src/main/cpp/root.cpp‎

Copy file name to clipboard
+112Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#include <jni.h>
2+
#include <string>
3+
#include <stdio.h>
4+
#include <string.h>
5+
#include <unistd.h>
6+
#include <sstream>
7+
#include <sys/capability.h>
8+
9+
#include "../../../../../testRoot/super_root.h"
10+
#include "../../../../../testRoot/adb_inject.h"
11+
12+
using namespace std;
13+
string getCapabilityInfo()
14+
{
15+
struct __user_cap_header_struct cap_header_data;
16+
cap_user_header_t cap_header = &cap_header_data;
17+
18+
struct __user_cap_data_struct cap_data_data;
19+
cap_user_data_t cap_data = &cap_data_data;
20+
21+
cap_header->pid = getpid();
22+
cap_header->version = _LINUX_CAPABILITY_VERSION_3; //_1、_2、_3
23+
24+
if (capget(cap_header, cap_data) < 0) {
25+
return "FAILED capget()";
26+
// perror("FAILED capget()");
27+
//exit(1);
28+
}
29+
stringstream sstrCapInfo;
30+
sstrCapInfo << "Cap data effective:"<<(uint64_t *) cap_data->effective<<", permitted:"<<(uint64_t *) cap_data->permitted<<", inheritable:"<<(uint64_t *) cap_data->inheritable<<"\n";
31+
sstrCapInfo << "now getuid()="<< getuid() <<",geteuid()="<< geteuid() <<",getgid()="<< getgid() <<",getegid()="<< getegid() << "\n";
32+
33+
FILE * fp = popen("getenforce", "r");
34+
if (fp)
35+
{
36+
char cmd[512] = { 0 };
37+
fread(cmd, 1, sizeof(cmd), fp);
38+
pclose(fp);
39+
40+
sstrCapInfo<< "SELinux status: "<< cmd;
41+
}
42+
43+
return sstrCapInfo.str();
44+
}
45+
46+
extern "C" JNIEXPORT jstring JNICALL
47+
Java_com_linux_permissionmanager_MainActivity_getCapabilityInfo(
48+
JNIEnv* env,
49+
jobject /* this */) {
50+
return env->NewStringUTF(getCapabilityInfo().c_str());
51+
}
52+
53+
extern "C" JNIEXPORT jint JNICALL
54+
Java_com_linux_permissionmanager_MainActivity_getRoot(
55+
JNIEnv* env,
56+
jobject /* this */,
57+
jlong rootKey) {
58+
return get_root(rootKey);
59+
}
60+
extern "C" JNIEXPORT jint JNICALL
61+
Java_com_linux_permissionmanager_MainActivity_disableSElinux(
62+
JNIEnv* env,
63+
jobject /* this */,
64+
jlong rootKey) {
65+
return safe_disable_selinux(rootKey);
66+
}
67+
68+
extern "C" JNIEXPORT jint JNICALL
69+
Java_com_linux_permissionmanager_MainActivity_enableSElinux(
70+
JNIEnv* env,
71+
jobject /* this */,
72+
jlong rootKey) {
73+
return safe_enable_selinux(rootKey);
74+
}
75+
76+
extern "C" JNIEXPORT jstring JNICALL
77+
Java_com_linux_permissionmanager_MainActivity_runRootCmd(
78+
JNIEnv* env,
79+
jobject /* this */,
80+
jlong rootKey,
81+
jstring cmd) {
82+
83+
const char *str1 = env->GetStringUTFChars(cmd, 0);
84+
string strCmd= str1;
85+
env->ReleaseStringUTFChars(cmd, str1);
86+
87+
char szResult[0x1000] = {0};
88+
ssize_t ret = safe_run_root_cmd(rootKey, strCmd.c_str(), szResult, sizeof(szResult));
89+
stringstream sstr;
90+
sstr << "runRootCmd ret val:" << ret << ", result:" << szResult;
91+
return env->NewStringUTF(sstr.str().c_str());
92+
}
93+
94+
extern "C" JNIEXPORT jstring JNICALL
95+
Java_com_linux_permissionmanager_MainActivity_runAdbShell(
96+
JNIEnv* env,
97+
jobject /* this */,
98+
jlong rootKey,
99+
jstring shell,
100+
jboolean keepAdbRoot) {
101+
102+
const char *str1 = env->GetStringUTFChars(shell, 0);
103+
string strShell= str1;
104+
env->ReleaseStringUTFChars(shell, str1);
105+
106+
char szResult[0x1000] = {0};
107+
ssize_t inject = safe_inject_adb_process_run_shell_wrapper(rootKey, strShell.c_str(), keepAdbRoot, szResult, sizeof(szResult));
108+
//ssize_t inject = safe_inject_adb_process_run_shell_wrapper(rootKey, strShell.c_str(), NULL, 0);
109+
stringstream sstr;
110+
sstr << "runAdbShell ret val:" << inject << ", result:" << szResult;
111+
return env->NewStringUTF(sstr.str().c_str());
112+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.