├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── CMakeLists.txt │ ├── cpp │ ├── notes.cpp │ ├── notes.h │ ├── pork.cpp │ └── pork.h │ ├── java │ └── com │ │ └── pork │ │ └── MainActivity.java │ └── res │ ├── drawable │ ├── ic_launcher_background.xml │ └── ic_launcher_foreground.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-anydpi │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-mdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── values-night │ └── themes.xml │ ├── values │ ├── colors.xml │ ├── strings.xml │ └── themes.xml │ └── xml │ ├── backup_rules.xml │ └── data_extraction_rules.xml ├── build.gradle ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 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 16 | #built application files 17 | *.apk 18 | *.ap_ 19 | *.aab 20 | 21 | # files for the dex VM 22 | *.dex 23 | 24 | # Java class files 25 | *.class 26 | 27 | # generated files 28 | bin/ 29 | gen/ 30 | 31 | # Local configuration file (sdk path, etc) 32 | local.properties 33 | 34 | # Windows thumbnail db 35 | Thumbs.db 36 | 37 | # OSX files 38 | .DS_Store 39 | 40 | # Android Studio 41 | *.iml 42 | .idea 43 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 44 | .gradle 45 | build/ 46 | .navigation 47 | captures/ 48 | output.json 49 | 50 | #NDK 51 | obj/ 52 | .externalNativeBuild 53 | /app/release/ 54 | /venv/ 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Pork ctf 2 | 3 | This is a CTF challenge I made for fun. 4 | Finding the vulnerability is pretty hard, but exploiting it is super easy once you understand the 5 | vuln. 6 | 7 | # The challenge: 8 | 9 | There is a simple notes server that allows you to create, read and delete notes. 10 | 11 | The server runs on a regular android application, and the notes are stored in the app file-system. 12 | 13 | Your goal is to get the flag from the ADMIN user notes. 14 | 15 | ## Running the challenge: 16 | 17 | 1. Build the android app using Android Studio or ./gradlew assemble or download the pre-built apk 18 | from the releases. 19 | 2. Install the app on an android emulator or device. 20 | 3. Run the app regularly and the server will be started. 21 | 22 | ## Given details: 23 | 24 | 1. The admin username is "ADMIN". 25 | 2. It can be solved. 26 | 27 | ## Common setup problems: 28 | 29 | 1. Make sure you change the cmake version in the ./app/build.gradle to the one you have installed. 30 | 2. You can run logcat to see the logs of the app, also you can run `netstat -ate` to check if the 31 | server is running. 32 | 3. I have tested the challenge on a Samsung Galaxy S8+ Android 9 real device. If the challenge 33 | doesn't work on 34 | your device please let me know. **UPDATE**: I have tested the challenge on a Pixel 39 Android 14 35 | emulator and it's fine. 36 | 37 | ## Solvers: 38 | 39 | | Name | GMT | 40 | |:------------------------------------:|:----------------:| 41 | | YL | 11.1.2025, 10:08 | 42 | | [Ed Lustig](https://linktr.ee/DTR4K) | 12.1.2025, 9:03 | 43 | 44 | ## Writeups: 45 | 46 | Here is my own writeup for the challenge: 47 | [My Writeup](https://schwartzblat.github.io/posts/pork-ctf-writeup/) 48 | 49 | ## Contact: 50 | 51 | Having a problem with the challenge? 52 | 53 | Got the flag in a special way? 54 | 55 | Wanna check if you're on the right path? 56 | 57 | Contact me at [alon.ponch@gmail.com](mailto:alon.ponch@gmail.com). 58 | 59 | ## Credits: 60 | 61 | Only to me :) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.application) 3 | } 4 | 5 | android { 6 | namespace 'com.pork' 7 | compileSdk 34 8 | 9 | defaultConfig { 10 | applicationId "com.pork" 11 | minSdk 28 12 | targetSdk 34 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | externalNativeBuild { 18 | cmake { 19 | cppFlags '' 20 | } 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_11 32 | targetCompatibility JavaVersion.VERSION_11 33 | } 34 | externalNativeBuild { 35 | cmake { 36 | path file('src/main/CMakeLists.txt') 37 | version '3.22.1' // Change it to your cmake version 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # For more information about using CMake with Android Studio, read the 3 | # documentation: https://d.android.com/studio/projects/add-native-code.html. 4 | # For more examples on how to use CMake, see https://github.com/android/ndk-samples. 5 | 6 | # Sets the minimum CMake version required for this project. 7 | cmake_minimum_required(VERSION 3.22.1) 8 | 9 | # Declares the project name. The project name can be accessed via ${ PROJECT_NAME}, 10 | # Since this is the top level CMakeLists.txt, the project name is also accessible 11 | # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level 12 | # build script scope). 13 | project("pork") 14 | 15 | # Creates and names a library, sets it as either STATIC 16 | # or SHARED, and provides the relative paths to its source code. 17 | # You can define multiple libraries, and CMake builds them for you. 18 | # Gradle automatically packages shared libraries with your APK. 19 | # 20 | # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define 21 | # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} 22 | # is preferred for the same purpose. 23 | # 24 | # In order to load a library into your app from Java/Kotlin, you must call 25 | # System.loadLibrary() and pass the name of the library defined here; 26 | # for GameActivity/NativeActivity derived applications, the same library name must be 27 | # used in the AndroidManifest.xml file. 28 | add_library(${CMAKE_PROJECT_NAME} SHARED 29 | # List C/C++ source files with relative paths to this CMakeLists.txt. 30 | cpp/pork.cpp cpp/notes.cpp) 31 | 32 | # Specifies libraries CMake should link to your target library. You 33 | # can link libraries from various origins, such as libraries defined in this 34 | # build script, prebuilt third-party libraries, or Android system libraries. 35 | target_link_libraries(${CMAKE_PROJECT_NAME} 36 | # List libraries link to the target library 37 | android 38 | log) 39 | -------------------------------------------------------------------------------- /app/src/main/cpp/notes.cpp: -------------------------------------------------------------------------------- 1 | #include "notes.h" 2 | 3 | void check_path(const char *user) { 4 | // Check if the user is valid (only alphanumeric characters): 5 | uint32_t i = 0; 6 | for (i = 0; user[i] != '\0'; i++) { 7 | if (!isalnum(user[i])) { 8 | pthread_exit(nullptr); 9 | } 10 | } 11 | if (i > MAX_USERNAME_LENGTH || i == 0) { 12 | pthread_exit(nullptr); 13 | } 14 | } 15 | 16 | bool user_exists(const char *user) { 17 | check_path(user); 18 | return fs::exists(USERS_PATH / user); 19 | } 20 | 21 | 22 | void create_user(const char *user, const char *password) { 23 | if (user_exists(user)) { 24 | return; 25 | } 26 | fs::create_directory(USERS_PATH / user); 27 | std::ofstream password_file(USERS_PATH / user / PASSWORD_FILE, std::ios::out); 28 | password_file << password; 29 | } 30 | 31 | 32 | bool can_login(const char *user, const char *password) { 33 | if (!user_exists(user)) { 34 | return false; 35 | } 36 | std::ifstream password_file(USERS_PATH / user / PASSWORD_FILE, std::ios::in); 37 | std::stringstream real_password; 38 | real_password << password_file.rdbuf(); 39 | return real_password.str() == password; 40 | } 41 | 42 | 43 | uint8_t get_notes_count(const char *user) { 44 | if (!user_exists(user)) { 45 | return -1; 46 | } 47 | // returns the number of notes the user has: 48 | int count = -1; 49 | for (const auto &_: fs::directory_iterator(USERS_PATH / user)) { 50 | count++; 51 | } 52 | return count; 53 | } 54 | 55 | 56 | void create_note(const char *user, const std::string ¬e) { 57 | if (!user_exists(user)) { 58 | return; 59 | } 60 | const uint8_t new_note_index = get_notes_count(user); 61 | if (new_note_index > 200) { 62 | return; 63 | } 64 | fs::path note_path = USERS_PATH / user / std::to_string(new_note_index); 65 | std::ofstream note_file(note_path, std::ios::out); 66 | note_file << note; 67 | } 68 | 69 | std::string get_note(const char *user, uint8_t index) { 70 | if (!user_exists(user)) { 71 | return ""; 72 | } 73 | if (index >= get_notes_count(user)) { 74 | return ""; 75 | } 76 | fs::path note_path = USERS_PATH / user / std::to_string(index); 77 | if (!fs::exists(note_path)) { 78 | return ""; 79 | } 80 | std::ifstream note_file(note_path, std::ios::in); 81 | std::stringstream note; 82 | note << note_file.rdbuf(); 83 | return note.str(); 84 | } 85 | 86 | void delete_note(const char *user, uint8_t index) { 87 | if (!user_exists(user)) { 88 | return; 89 | } 90 | fs::path note_path = USERS_PATH / user / std::to_string(index); 91 | fs::remove(note_path); 92 | } -------------------------------------------------------------------------------- /app/src/main/cpp/notes.h: -------------------------------------------------------------------------------- 1 | #ifndef PORK_NOTES_H 2 | #define PORK_NOTES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #endif //PORK_NOTES_H 11 | 12 | namespace fs = std::filesystem; 13 | const fs::path USERS_PATH = "/data/data/com.pork/users/"; 14 | const fs::path PASSWORD_FILE = "password"; 15 | #define MAX_USERNAME_LENGTH 18 16 | 17 | 18 | void check_path(const char *user); 19 | 20 | void create_user(const char *user, const char *password); 21 | 22 | bool can_login(const char *user, const char *password); 23 | 24 | void create_note(const char *user, const std::string ¬e); 25 | 26 | void delete_note(const char *user, uint8_t index); 27 | 28 | std::string get_note(const char *user, uint8_t index); 29 | 30 | uint8_t get_notes_count(const char *user); 31 | 32 | bool user_exists(const char *user); -------------------------------------------------------------------------------- /app/src/main/cpp/pork.cpp: -------------------------------------------------------------------------------- 1 | #include "pork.h" 2 | 3 | 4 | int initialize_socket(struct sockaddr_in *address) { 5 | int socket_fd = socket(AF_INET, SOCK_STREAM, 0); 6 | if (socket_fd == -1) { 7 | return -1; 8 | } 9 | address->sin_family = AF_INET; 10 | address->sin_addr.s_addr = INADDR_ANY; 11 | address->sin_port = htons(PORT); 12 | if (bind(socket_fd, (struct sockaddr *) address, sizeof(*address)) < 0) { 13 | return -1; 14 | } 15 | if (listen(socket_fd, 10) < 0) { 16 | return -1; 17 | } 18 | return socket_fd; 19 | } 20 | 21 | void fail_if_admin(const std::string &text) { 22 | if (text.find(STRONG_USERNAME) != std::string::npos) { 23 | pthread_exit(nullptr); 24 | } 25 | } 26 | 27 | std::unique_ptr recv_sized(int sock, uint8_t *size) { 28 | // Receiving a buffer with a custom size 29 | if (recv(sock, size, 1, 0) != 1) { 30 | close(sock); 31 | pthread_exit(nullptr); 32 | }; 33 | if (*size == 0xff) { 34 | // No overflows allowed 35 | close(sock); 36 | pthread_exit(nullptr); 37 | } 38 | if (*size == 0) { 39 | return nullptr; 40 | } 41 | std::unique_ptr buffer = std::make_unique(*size + 1); 42 | buffer[*size] = '\0'; 43 | int received = recv(sock, buffer.get(), *size, MSG_WAITALL); 44 | if (received != *size) { 45 | close(sock); 46 | pthread_exit(nullptr); 47 | } 48 | // Admin can log in locally, but not remotely 49 | fail_if_admin(buffer.get()); 50 | return buffer; 51 | } 52 | 53 | 54 | void socket_send(int sock, const char *message) { 55 | uint8_t size = strlen(message); 56 | send(sock, &size, 1, 0); 57 | send(sock, message, size, 0); 58 | } 59 | 60 | void close_socket_and_send(int sock, const char *message) { 61 | if (message != nullptr) { 62 | socket_send(sock, message); 63 | } 64 | close(sock); 65 | pthread_exit(nullptr); 66 | } 67 | 68 | 69 | char *get_stack_safe() { 70 | // Getting the safe address from the stack 71 | pthread_t self = pthread_self(); 72 | pthread_attr_t attr; 73 | pthread_getattr_np(self, &attr); 74 | char *stack; 75 | size_t stack_size; 76 | // Getting the start of the stack page 77 | pthread_attr_getstack(&attr, reinterpret_cast(&stack), &stack_size); 78 | pthread_attr_destroy(&attr); 79 | return stack + STACK_OFFSET; 80 | } 81 | 82 | const char *get_current_user() { 83 | // Getting the current user from the stack in a safe way 84 | const char *stack = get_stack_safe(); 85 | return stack + strlen(stack) + 1; 86 | } 87 | 88 | void set_current_user(const std::string &username, const std::string &password) { 89 | // Setting the current user on the stack in a safe way 90 | char *stack = get_stack_safe(); 91 | memcpy(stack, password.c_str(), password.length()); 92 | *reinterpret_cast(stack + password.length()) = '\0'; 93 | memcpy(stack + strlen(stack) + 1, username.c_str(), username.length()); 94 | if (username.empty()) { 95 | // No need to null terminate the username 96 | return; 97 | } 98 | *reinterpret_cast(stack + strlen(stack) + 1 + username.length()) = '\0'; 99 | } 100 | 101 | void login(int sock) { 102 | uint8_t size; 103 | auto user = recv_sized(sock, &size); 104 | if (user == nullptr) { 105 | close_socket_and_send(sock, "Invalid username"); 106 | } 107 | check_path(user.get()); 108 | if (size > MAX_USERNAME_LENGTH) { 109 | close_socket_and_send(sock, "Username is too long"); 110 | } 111 | auto password = recv_sized(sock, &size); 112 | set_current_user(user.get(), password.get()); 113 | if (user_exists(user.get())) { 114 | if (!can_login(user.get(), get_stack_safe())) { 115 | close_socket_and_send(sock, "Invalid password"); 116 | } 117 | } else { 118 | create_user(user.get(), get_stack_safe()); 119 | } 120 | } 121 | 122 | void logout() { 123 | set_current_user("", ""); 124 | } 125 | 126 | void change_password(int sock) { 127 | uint8_t size; 128 | auto password = recv_sized(sock, &size); 129 | if (password == nullptr) { 130 | close_socket_and_send(sock, "You can't set an empty password"); 131 | } 132 | set_current_user(get_current_user(), password.get()); 133 | if (!user_exists(get_current_user())) { 134 | close_socket_and_send(sock, "User does not exist"); 135 | } 136 | std::ofstream password_file(USERS_PATH / get_current_user() / PASSWORD_FILE, std::ios::out); 137 | password_file << password.get(); 138 | } 139 | 140 | void create_note_action(int sock) { 141 | const char *user = get_current_user(); 142 | if (user == nullptr || !user_exists(user)) { 143 | close_socket_and_send(sock, "User does not exist"); 144 | } 145 | uint8_t size; 146 | auto note = recv_sized(sock, &size); 147 | if (note == nullptr) { 148 | note = std::make_unique(1); 149 | note[0] = '\0'; 150 | } 151 | create_note(user, note.get()); 152 | if (get_notes_count(user) == HIGH_NUMBER_OF_NOTES && fork() != 0) { 153 | pthread_exit(nullptr); 154 | } 155 | } 156 | 157 | void delete_note_action(int sock) { 158 | const char *user = get_current_user(); 159 | if (user == nullptr || !user_exists(user)) { 160 | close_socket_and_send(sock, "User does not exist"); 161 | } 162 | uint8_t index; 163 | recv(sock, &index, 1, 0); 164 | delete_note(user, index); 165 | } 166 | 167 | void get_note_action(int sock) { 168 | const char *user = get_current_user(); 169 | if (user == nullptr || !user_exists(user)) { 170 | close_socket_and_send(sock, "User does not exist"); 171 | } 172 | uint8_t index; 173 | recv(sock, &index, 1, 0); 174 | socket_send(sock, get_note(user, index).c_str()); 175 | } 176 | 177 | void *handle_client(int sock) { 178 | while (sock != -1) { 179 | // Read message type: 180 | uint8_t buffer; 181 | if (recv(sock, &buffer, 1, 0) == -1) { 182 | close_socket_and_send(sock, "Failed to receive message type"); 183 | } 184 | switch (buffer) { 185 | case LOGIN: 186 | login(sock); 187 | break; 188 | case LOGOUT: 189 | logout(); 190 | break; 191 | case CHANGE_PASSWORD: 192 | change_password(sock); 193 | break; 194 | case CREATE_NOTE: 195 | create_note_action(sock); 196 | break; 197 | case DELETE_NOTE: 198 | delete_note_action(sock); 199 | break; 200 | case GET_NOTE: 201 | get_note_action(sock); 202 | break; 203 | // Let the client decide how to optimize the connection: 204 | case MOVE_TO_THREAD: 205 | // Move the connection to a new thread 206 | pthread_t thread; 207 | pthread_create(&thread, nullptr, reinterpret_cast(handle_client), 208 | reinterpret_cast(sock)); 209 | // The current thread will exit 210 | pthread_exit(nullptr); 211 | break; 212 | case DISCONNECT: 213 | close(sock); 214 | return nullptr; 215 | default: 216 | socket_send(sock, "Invalid message type"); 217 | } 218 | } 219 | return nullptr; 220 | } 221 | 222 | extern "C" 223 | JNIEXPORT jint JNICALL 224 | Java_com_pork_MainActivity_initialize(JNIEnv *env, jobject clazz) { 225 | if (fork() != 0) { 226 | // I don't want to block the UI thread 227 | return 0; 228 | } 229 | // Check if the users directory exists and create it if it doesn't 230 | if (mkdir(USERS_PATH.c_str(), 0777) == -1) { 231 | if (errno != EEXIST) { 232 | return -1; 233 | } 234 | // Users directory already exists; 235 | } 236 | create_user(STRONG_USERNAME, STRONG_PASSWORD); 237 | set_current_user(STRONG_USERNAME, STRONG_PASSWORD); 238 | if (get_notes_count(STRONG_USERNAME) == 0) { 239 | create_note(STRONG_USERNAME, CTF_FLAG); 240 | } 241 | // Erasing the password from the stack 242 | char *stack = get_stack_safe(); 243 | memset(stack, 0, strlen(STRONG_PASSWORD)); 244 | struct sockaddr_in address{}; 245 | int socket_fd, sock; 246 | socklen_t addrlen = sizeof(address); 247 | if ((socket_fd = initialize_socket(&address)) == -1) { 248 | return -1; 249 | } 250 | LOGD("Server started listening on port %d", PORT); 251 | while ((sock = accept(socket_fd, (struct sockaddr *) &address, &addrlen)) != -1) { 252 | // Connection accepted 253 | pthread_t thread; 254 | pthread_create(&thread, nullptr, reinterpret_cast(handle_client), 255 | reinterpret_cast(sock)); 256 | } 257 | LOGD("Failed to accept connection, errno: %d", errno); 258 | return 0; 259 | } 260 | -------------------------------------------------------------------------------- /app/src/main/cpp/pork.h: -------------------------------------------------------------------------------- 1 | #ifndef PORK_PORK_H 2 | #define PORK_PORK_H 3 | 4 | #endif //PORK_PORK_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "notes.h" 20 | 21 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "PORK", __VA_ARGS__) 22 | 23 | typedef void *(*thread_func_t)(void *); 24 | constexpr int PORT = 8888; 25 | 26 | enum Actions { 27 | LOGIN = 0, 28 | LOGOUT = 1, 29 | CHANGE_PASSWORD = 2, 30 | CREATE_NOTE = 3, 31 | DELETE_NOTE = 4, 32 | GET_NOTE = 5, 33 | MOVE_TO_THREAD = 6, 34 | DISCONNECT = 7 35 | }; 36 | // Jump over the stack page guard: 37 | #define STACK_OFFSET (0x69 + PAGE_SIZE * 2) 38 | 39 | #define STRONG_USERNAME "ADMIN" // You know the username 40 | #define STRONG_PASSWORD "WOWWWThisIsTheStrongestPasswordEver123!@#" // You don't know the password 41 | #define HIGH_NUMBER_OF_NOTES 0x69 42 | 43 | const std::string CTF_FLAG = "FLAG{this_is_a_fake_flag}"; -------------------------------------------------------------------------------- /app/src/main/java/com/pork/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.pork; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends Activity { 7 | 8 | static { 9 | System.loadLibrary("pork"); 10 | } 11 | 12 | private native int initialize(); 13 | 14 | 15 | public void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | this.initialize(); 19 | } 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | pork 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | alias(libs.plugins.android.application) apply false 4 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. For more details, visit 12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | agp = "8.7.3" 3 | 4 | [libraries] 5 | 6 | [plugins] 7 | android-application = { id = "com.android.application", version.ref = "agp" } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Schwartzblat/pork_ctf/e0106c6af5014cb17ebef6cebb59a7d839fff949/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 03 20:00:47 IST 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google { 4 | content { 5 | includeGroupByRegex("com\\.android.*") 6 | includeGroupByRegex("com\\.google.*") 7 | includeGroupByRegex("androidx.*") 8 | } 9 | } 10 | mavenCentral() 11 | gradlePluginPortal() 12 | } 13 | } 14 | dependencyResolutionManagement { 15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | rootProject.name = "pork" 23 | include ':app' 24 | --------------------------------------------------------------------------------