first commit
This commit is contained in:
commit
cd1e91bb99
287 changed files with 86425 additions and 0 deletions
1
rasta_exp/docker/apparecium/RASTA_VERSION
Normal file
1
rasta_exp/docker/apparecium/RASTA_VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
latest
|
9
rasta_exp/docker/apparecium/README.md
Normal file
9
rasta_exp/docker/apparecium/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# apparecium
|
||||
|
||||
- [source](https://github.com/askk/apparecium)
|
||||
- [fork](https://github.com/cogbee/apparecium)
|
||||
- [paper](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7098024&tag=1)
|
||||
- language: Python 2 (+some C++ in old version of androguard)
|
||||
- number of years without at least 1 commit since first commit: 9
|
||||
- License: MIT
|
||||
|
23
rasta_exp/docker/apparecium/latest/Dockerfile
Normal file
23
rasta_exp/docker/apparecium/latest/Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
|||
FROM ubuntu:22.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 git init /workspace/apparecium && \
|
||||
cd /workspace/apparecium && \
|
||||
git remote add origin https://github.com/askk/apparecium.git && \
|
||||
git fetch --depth=1 origin e27e108950e56b69f34fa97262c07d154b9163e8 && \
|
||||
git reset --hard FETCH_HEAD
|
||||
|
||||
RUN apt-get update && apt-get install -y python2.7 wget && \
|
||||
ln -s /usr/bin/python2.7 /usr/bin/python
|
||||
|
||||
RUN wget https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
|
||||
python2.7 get-pip.py && \
|
||||
rm get-pip.py && \
|
||||
python2.7 -m pip install pydot
|
||||
RUN sed -i 's#d3-visualization#/mnt#' /workspace/apparecium/dftest.py
|
||||
|
||||
COPY run.sh /
|
25
rasta_exp/docker/apparecium/latest/run.sh
Executable file
25
rasta_exp/docker/apparecium/latest/run.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/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"
|
||||
|
||||
|
||||
WORKDIR="/workspace/apparecium"
|
||||
cd ${WORKDIR}
|
||||
mkdir /mnt/data
|
||||
/usr/bin/time -o /mnt/report -q /usr/bin/timeout --kill-after=20s ${TIMEOUT} python dftest.py /mnt/${APK_FILENAME} > /mnt/stdout 2> /mnt/stderr
|
99
rasta_exp/docker/apparecium/test.py
Normal file
99
rasta_exp/docker/apparecium/test.py
Normal file
|
@ -0,0 +1,99 @@
|
|||
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 = "/workspace/apparecium"
|
||||
CMD = f"python runner.py {PATH_APK} >> '{GUEST_MNT}/stdout' 2>> '{GUEST_MNT}/stderr'; cp -r /workspace/apparecium/d3-visualization/data {GUEST_MNT}/"
|
||||
|
||||
TOOL_NAME = "apparecium"
|
||||
|
||||
# Version name -> folder name
|
||||
TOOL_VERSIONS = {
|
||||
"latest": "latest",
|
||||
"fork_latest": "fork_latest",
|
||||
}
|
||||
# Name of the default version (default folder = TOOL_VERSIONS[DEFAULT_TOOL_VERSION])
|
||||
DEFAULT_TOOL_VERSION = "latest"
|
||||
|
||||
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."""
|
||||
if (path / "data" / "app.apk.json").exists():
|
||||
return True
|
||||
l1 = False
|
||||
with (path / "stdout").open(errors="replace") as file:
|
||||
for line in file:
|
||||
if "Complete Analysis took" in line: # check if androguard worked
|
||||
l1 = True
|
||||
if (
|
||||
l1 and "\t\tDone in " in line
|
||||
): # check if apparecium worked after androguard
|
||||
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,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue