Index: security/Makefile =================================================================== --- security/Makefile +++ security/Makefile @@ -843,6 +843,7 @@ SUBDIR += py-YubiOTP SUBDIR += py-acme SUBDIR += py-acme-tiny + SUBDIR += py-angr SUBDIR += py-argon2-cffi SUBDIR += py-artifacts SUBDIR += py-asyncssh Index: security/py-angr/Makefile =================================================================== --- /dev/null +++ security/py-angr/Makefile @@ -0,0 +1,34 @@ +# $FreeBSD$ + +PORTNAME= angr +PORTVERSION= 8.20.1.7 +CATEGORIES= security devel python +MASTER_SITES= CHEESESHOP +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= 0mp@FreeBSD.org +COMMENT= Multi-architecture binary analysis toolkit + +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}bitstring>0:devel/py-bitstring@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pyvex>0:security/py-pyvex@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}unicorn>0:emulators/py-unicorn@${PY_FLAVOR} +LIB_DEPENDS= libunicorn.so:emulators/unicorn + +USES= gmake localbase python +USE_PYTHON= autoplist distutils + +post-patch: + @${REINPLACE_CMD} -e 's|%%CC%%|${CC}|g' \ + -e 's|%%CXX%%|${CXX}|g' \ + -e 's|%%CFLAGS%%|${CFLAGS}|g' \ + -e 's|%%LDFLAGS%%|${LDFLAGS}|g' \ + -e 's|%%LIBS%%|${LIBS}|g' \ + ${WRKSRC}/native/Makefile + +post-install: + @${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/${PORTNAME}/lib/angr_native.so + +.include Index: security/py-angr/distinfo =================================================================== --- /dev/null +++ security/py-angr/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1583167724 +SHA256 (angr-8.20.1.7.tar.gz) = f6c67806240b5ee5e309ec7565ef756107afb11f62d5424e474e0b0cc0637cea +SIZE (angr-8.20.1.7.tar.gz) = 894100 Index: security/py-angr/files/patch-native_Makefile =================================================================== --- /dev/null +++ security/py-angr/files/patch-native_Makefile @@ -0,0 +1,24 @@ +--- native/Makefile.orig 2020-03-02 20:56:13 UTC ++++ native/Makefile +@@ -2,15 +2,18 @@ UNAME := $(shell uname) + ifeq ($(UNAME), Darwin) + LIB_ANGR_NATIVE=angr_native.dylib + endif ++ifeq ($(UNAME), FreeBSD) ++ LIB_ANGR_NATIVE=angr_native.so ++endif + ifeq ($(UNAME), Linux) + LIB_ANGR_NATIVE=angr_native.so + endif + +-CC := gcc +-C++C := g++ ++CC := %%CC%% ++C++C := %%CXX%% + CFLAGS := -I "${UNICORN_INCLUDE_PATH}" -I "${PYVEX_INCLUDE_PATH}" \ + -L "${UNICORN_LIB_PATH}" -L "${PYVEX_LIB_PATH}" \ +- -O3 -fPIC -std=c++11 ++ %%CFLAGS%% %%LDFLAGS%% %%LIBS%% -fPIC -std=c++11 + ifneq ($(DEBUG), ) + CFLAGS := $(CFLAGS) -O0 -g + endif Index: security/py-angr/files/patch-native_log.c =================================================================== --- /dev/null +++ security/py-angr/files/patch-native_log.c @@ -0,0 +1,27 @@ +--- native/log.c.orig 2020-03-02 23:36:13 UTC ++++ native/log.c +@@ -34,6 +34,9 @@ + #include + + #include ++#ifdef __FreeBSD__ ++#include ++#endif + + static int log_fd = STDERR_FILENO; + static bool log_fd_isatty = true; +@@ -107,7 +110,14 @@ void logLog(enum llevel_t ll, const char *fn, int ln, + dprintf(log_fd, "%s", logLevels[ll].prefix); + } + if (logLevels[ll].print_funcline) { ++#ifdef __FreeBSD__ ++ pid_t tid = 0; ++ // XXX: No error handling. ++ syscall(SYS_thr_self, &tid); ++ dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, (pid_t)tid, fn, ln); ++#else + dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, (pid_t)syscall(__NR_gettid), fn, ln); ++#endif + } + + va_list args; Index: security/py-angr/files/patch-setup.py =================================================================== --- /dev/null +++ security/py-angr/files/patch-setup.py @@ -0,0 +1,11 @@ +--- setup.py.orig 2020-03-02 20:55:10 UTC ++++ setup.py +@@ -68,7 +68,7 @@ def _build_native(): + pass + + cmd1 = ['nmake', '/f', 'Makefile-win'] +- cmd2 = ['make'] ++ cmd2 = ['gmake'] + for cmd in (cmd1, cmd2): + try: + if subprocess.call(cmd, cwd='native', env=env) != 0: Index: security/py-angr/pkg-descr =================================================================== --- /dev/null +++ security/py-angr/pkg-descr @@ -0,0 +1,24 @@ +angr is a platform-agnostic binary analysis framework in a form of a suite +of Python 3 libraries that let you load a binary and do a lot of cool things +to it: + +- Disassembly and intermediate-representation lifting +- Program instrumentation +- Symbolic execution +- Control-flow analysis +- Data-dependency analysis +- Value-set analysis (VSA) +- Decompilation + +The most common angr operation is loading a binary: + + p = angr.Project('/bin/bash') + +If you do this in an enhanced REPL like IPython, you can use tab-autocomplete +to browse the top-level-accessible methods and their docstrings. + +angr is brought to you by the Computer Security Lab at UC Santa Barbara, SEFCOM +at Arizona State University, their associated CTF team, Shellphish, the open +source community, and @rhelmot. + +WWW: https://github.com/angr/angr