From 3f42bd9dad985c45b3e4d1665e7b60546fc9db1e Mon Sep 17 00:00:00 2001 From: MatrixEditor <58256046+MatrixEditor@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:50:21 +0100 Subject: [PATCH] Updated links to docs --- README.md | 4 ++-- bin/webui.sh | 2 +- mastf/MASTF/web/views/web_user.py | 3 +++ mastf/android/tools/apktool.py | 20 +++++++++++++++++++ mastf/core/files/handler.py | 8 ++++++-- mastf/core/files/tpl.py | 9 ++++----- mastf/templates/auth/sign-in.html | 2 +- mastf/templates/auth/sign-up.html | 2 +- mastf/templates/base.html | 4 ++-- mastf/templates/project/project-scanners.html | 2 +- mastf/templates/project/project-settings.html | 4 ++-- mastf/templates/setup/wizard.html | 2 +- requirements.txt | 3 ++- 13 files changed, 46 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index dde9e80..6d7c511 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ MAST-F is a comprehensive Mobile Application Security Testing Framework designed ## Documentation & Help -The documentation for MAST-F is available on [Github-Pages](https://mastframework.github.io/MAST-F/). It contains detailed information about the framework, its usage, configuration options, and various testing techniques. We highly recommend referring to the documentation to get started with MAST-F. Please visit the [Discussions](https://github.com/orgs/MAST-Framework/discussions) tab to ask questions or get help. +The documentation for MAST-F is available on [Github-Pages](https://mastframework.github.io/ mastf/). It contains detailed information about the framework, its usage, configuration options, and various testing techniques. We highly recommend referring to the documentation to get started with MAST-F. Please visit the [Discussions](https://github.com/orgs/MAST-Framework/discussions) tab to ask questions or get help. ## Key Features @@ -53,7 +53,7 @@ The above diagram provides an overview of the MAST-F project architecture. It sh ## Setup -To set up MAST-F, please follow the instructions provided in the documentation on [Github Pages](https://mastframework.github.io/MAST-F/). The setup process involves configuring the required dependencies and performing necessary configurations before running the containers. You can find the setup commands and detailed guidelines on the documentation page. To simply run the containers, just execute +To set up MAST-F, please follow the instructions provided in the documentation on [Github Pages](https://mastframework.github.io/ mastf/). The setup process involves configuring the required dependencies and performing necessary configurations before running the containers. You can find the setup commands and detailed guidelines on the documentation page. To simply run the containers, just execute ```bash ./bin/webui.sh [-d] ``` diff --git a/bin/webui.sh b/bin/webui.sh index 8dc80e4..4bea41c 100755 --- a/bin/webui.sh +++ b/bin/webui.sh @@ -56,7 +56,7 @@ if [[ -z "${VIRTUAL_ENV}" ]]; then exit 1 fi else - printf "[+] python venv already activate or run without venv:\n @: ${VIRTUAL_ENV}\n" + printf "[+] python venv already active or run without venv:\n @: ${VIRTUAL_ENV}\n" fi cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m\n" "${install_dir}"; exit 1; } diff --git a/mastf/MASTF/web/views/web_user.py b/mastf/MASTF/web/views/web_user.py index 794da5d..ea0a846 100644 --- a/mastf/MASTF/web/views/web_user.py +++ b/mastf/MASTF/web/views/web_user.py @@ -89,6 +89,9 @@ def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: if result.status_code == 409: messages.error(request, "Username already present or password too short") + if result.status_code == 405: + messages.error(request, "Registration not allowed") + return redirect("User-Registration") diff --git a/mastf/android/tools/apktool.py b/mastf/android/tools/apktool.py index ce8d18d..9ba20ca 100644 --- a/mastf/android/tools/apktool.py +++ b/mastf/android/tools/apktool.py @@ -23,7 +23,9 @@ to extract sources or resources separately or extract an APK file completely. """ +import os import subprocess +import apkInspector def extractrsc(apk_path: str, dest_path: str, apktool_path: str = "apktool") -> None: @@ -79,3 +81,21 @@ def run_apktool_decode( except subprocess.CalledProcessError as err: # Raise a RuntimeError if apktool fails to decode the APK file raise RuntimeError(err.stdout.decode()) from err + + +def apkinspector_extract(apk: apkInspector.headers.ZipEntry, dest_path: str) -> None: + cd = apk.central_directory + lh = apk.local_headers + error = apkInspector.extract.extract_all_files_from_central_directory( + apk, cd, lh, dest_path + ) + if error != 0: + raise RuntimeError(f"Failed to extract files from APK. error={error}") + + # convert manifest file + manifest_file = os.path.join(dest_path, "AndroidManifest.xml") + with open(manifest_file, "rb") as f: + xml_data = f.read() + + with open(manifest_file, "w", encoding="utf-8") as f: + f.write(apkInspector.axml.get_manifest(xml_data)) diff --git a/mastf/core/files/handler.py b/mastf/core/files/handler.py index 77d9add..28ef731 100644 --- a/mastf/core/files/handler.py +++ b/mastf/core/files/handler.py @@ -206,6 +206,8 @@ def apk_handler(src_path: pathlib.Path, dest_dir: pathlib.Path, settings, **kwar if observer: observer.update("Extracting APK file with apktool...") + # TODO: move to apkInspector as apktool may not be able to extract + # all resources apktool.extractrsc(str(src_path), str(contents), settings.APKTOOL) smali_dir = src / "smali" smali_dir.mkdir(exist_ok=True) @@ -218,8 +220,10 @@ def apk_handler(src_path: pathlib.Path, dest_dir: pathlib.Path, settings, **kwar dex_files = list(contents.glob(r"*/**/*.dex")) + list(contents.glob(r"*.dex")) for path in dex_files: logger.debug( - "Decompiling classes with %s: classes=%s -> to=%s" - % (tool, str(path), str(smali_dir)) + "Decompiling classes with %s: classes=%s -> to=%s", + tool, + str(path), + str(smali_dir), ) if observer: observer.update("Decompiling %s with %s to /src/smali", path.name, tool) diff --git a/mastf/core/files/tpl.py b/mastf/core/files/tpl.py index b4a5d7c..f1cfbe7 100644 --- a/mastf/core/files/tpl.py +++ b/mastf/core/files/tpl.py @@ -22,7 +22,6 @@ from typing import Generator, Any - def parse_name(full_name: str) -> tuple[str, str]: if not full_name: return None, None @@ -31,15 +30,15 @@ def parse_name(full_name: str) -> tuple[str, str]: gid, aid = full_name.split("::") return (gid, aid) - elif ":" in full_name: # group id : artifact id + if ":" in full_name: # group id : artifact id gid, aid = full_name.split(":") return (gid, aid) - elif "-" in full_name: # artifact id + if "-" in full_name: # artifact id return None, full_name - else: # only groupId - return full_name, None + # only groupId + return full_name, None class TPL: diff --git a/mastf/templates/auth/sign-in.html b/mastf/templates/auth/sign-in.html index d69ab0e..2c190be 100644 --- a/mastf/templates/auth/sign-in.html +++ b/mastf/templates/auth/sign-in.html @@ -10,7 +10,7 @@
diff --git a/mastf/templates/auth/sign-up.html b/mastf/templates/auth/sign-up.html index 07c400e..c9e759f 100644 --- a/mastf/templates/auth/sign-up.html +++ b/mastf/templates/auth/sign-up.html @@ -9,7 +9,7 @@ {% block page_body %}
- +
{% csrf_token %} diff --git a/mastf/templates/base.html b/mastf/templates/base.html index a31789e..5902a78 100644 --- a/mastf/templates/base.html +++ b/mastf/templates/base.html @@ -67,7 +67,7 @@ -

+

MAST-Framework @@ -280,7 +280,7 @@

-
  • Documentation
  • +
  • Documentation
  • License
  • Source code
  • diff --git a/mastf/templates/project/project-scanners.html b/mastf/templates/project/project-scanners.html index b84d377..2a7084d 100644 --- a/mastf/templates/project/project-scanners.html +++ b/mastf/templates/project/project-scanners.html @@ -9,7 +9,7 @@
    @@ -199,7 +199,7 @@

    Project ID

    diff --git a/mastf/templates/setup/wizard.html b/mastf/templates/setup/wizard.html index 641a6cf..98d4a82 100644 --- a/mastf/templates/setup/wizard.html +++ b/mastf/templates/setup/wizard.html @@ -10,7 +10,7 @@
    diff --git a/requirements.txt b/requirements.txt index 34972f0..3cda099 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,4 +21,5 @@ lief==0.14.0 google_play_scraper==1.2.6 nibarchive==1.1.0 umbrella-py==0.0.3 -caterpillar@git+https://github.com/MatrixEditor/caterpillar.git \ No newline at end of file +caterpillar@git+https://github.com/MatrixEditor/caterpillar.git +apkInspector \ No newline at end of file