first commit

This commit is contained in:
Jean-Marie Mineau 2023-11-15 15:59:13 +01:00
commit cd1e91bb99
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
287 changed files with 86425 additions and 0 deletions

View file

@ -0,0 +1 @@
mallodroid

View file

@ -0,0 +1,8 @@
# Mallodroid
- [source](https://github.com/sfahl/mallodroid)
- [fork](https://github.com/vishalkks/mallodroid)
- [paper](https://dl.acm.org/doi/10.1145/2382196.2382205)
- language: Python2
- number of years without at least 1 commit since first commit: 10
- License: LGPL

View file

@ -0,0 +1,17 @@
FROM ubuntu:16.04
# RUN sed -i -e "s/archive.ubuntu.com/old-releases.ubuntu.com/g" /etc/apt/sources.list
RUN apt-get update && apt-get install -y git time
RUN mkdir /workspace
RUN apt-get update && apt-get install -y python-pip
RUN git clone https://github.com/sfahl/mallodroid.git /workspace/mallodroid &&\
cd /workspace/mallodroid && git checkout 78f4e524be143c7776a7d4f9c62b035fa2bdd84a &&\
sed -i '428i\\ print "ee3d6c7015b83b3dc84b21a2e79506175f07c00ecf03e7b3b8edea4e445618bd: END OF ANALYSIS."' /workspace/mallodroid/mallodroid.py
RUN pip install androguard==3.0 # Python2 compatible
COPY run.sh /

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
APK_FILENAME=$1
export TIME="time: %e
kernel-cpu-time: %S
user-cpu-time: %U
max-rss-mem: %M
avg-rss-mem: %t
avg-total-mem: %K
page-size: %Z
nb-major-page-fault: %F
nb-minor-page-fault: %R
nb-fs-input: %I
nb-fs-output: %O
nb-socket-msg-received: %r
nb-socket-msg-sent: %s
nb-signal-delivered: %k
exit-status: %x"
/usr/bin/time -o /mnt/report -q /usr/bin/timeout --kill-after=20s ${TIMEOUT} python /workspace/mallodroid/mallodroid.py -f /mnt/${APK_FILENAME} > /mnt/stdout 2> /mnt/stderr

View file

@ -0,0 +1,96 @@
import datetime
import importlib.util
import logging
from typing import Any, Type
from pathlib import Path
if __name__ == "__main__":
import sys
sys.path.append(str(Path(__file__).resolve().parent.parent))
import orchestrator
errors = orchestrator.error_collector
utils = orchestrator.utils
TIMEOUT = 900
GUEST_MNT = "/mnt"
PATH_APK = f"{GUEST_MNT}/app.apk"
WORKDIR = "/"
CMD = f"python workspace/mallodroid/mallodroid.py -f {PATH_APK}"
TOOL_NAME = "mallodroid"
# Version name -> folder name
TOOL_VERSIONS = {
"mallodroid": "mallodroid",
"fork_mallodroid": "fork_mallodroid", # Don't work
}
# Name of the default version (default folder = TOOL_VERSIONS[DEFAULT_TOOL_VERSION])
DEFAULT_TOOL_VERSION = "mallodroid"
EXPECTED_ERROR_TYPES: list[Type[errors.LoggedError]] = [errors.PythonError]
def analyse_artifacts(path: Path) -> dict[str, Any]:
"""Analyse the artifacts of a test located at `path`."""
report = utils.parse_report(path / "report")
report["errors"] = list(
map(
lambda e: e.get_dict(),
errors.get_errors(path / "stderr", EXPECTED_ERROR_TYPES),
)
)
if report["timeout"]:
report["tool-status"] = "TIMEOUT"
elif check_success(path):
report["tool-status"] = "FINISHED"
else:
report["tool-status"] = "FAILED"
report["tool-name"] = TOOL_NAME
report["date"] = str(datetime.datetime.now())
report["apk"] = utils.sha256_sum(path / "app.apk").upper()
return report
def check_success(path: Path) -> bool:
"""Check if the analysis finished without crashing."""
stdout = path / "stdout"
with stdout.open("r", errors="replace") as f:
for line in f:
if (
"ee3d6c7015b83b3dc84b21a2e79506175f07c00ecf03e7b3b8edea4e445618bd: END OF ANALYSIS."
in line
):
return True
return False
if __name__ == "__main__":
import docker # type: ignore
args = orchestrator.get_test_args(TOOL_NAME)
tool_folder = Path(__file__).resolve().parent
api_key = orchestrator.get_androzoo_key()
if args.get_apk_info:
orchestrator.load_apk_info(args.apk_refs, args.androzoo_list, api_key)
client = docker.from_env()
logging.info("Command tested: ")
logging.info(f"[{WORKDIR}]$ {CMD}")
for apk_ref in args.apk_refs:
orchestrator.test_tool_on_apk(
client,
tool_folder,
api_key,
apk_ref,
args.tool_version,
args.keep_artifacts,
args.force_test,
)