From owner-svn-ports-all@freebsd.org Thu Mar 12 09:13:38 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1B77259DB6; Thu, 12 Mar 2020 09:13:38 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48dNRQ0Cgsz4HSW; Thu, 12 Mar 2020 09:13:38 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8DF8622F40; Thu, 12 Mar 2020 09:13:37 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02C9DbP8059671; Thu, 12 Mar 2020 09:13:37 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02C9Da6P059664; Thu, 12 Mar 2020 09:13:36 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202003120913.02C9Da6P059664@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Thu, 12 Mar 2020 09:13:36 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r528280 - in head/security: . py-angr py-angr/files X-SVN-Group: ports-head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: in head/security: . py-angr py-angr/files X-SVN-Commit-Revision: 528280 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2020 09:13:38 -0000 Author: 0mp Date: Thu Mar 12 09:13:35 2020 New Revision: 528280 URL: https://svnweb.freebsd.org/changeset/ports/528280 Log: New port: security/py-angr 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 PR: 244562 Requested by: lwhsu@ (via wiki.freebsd.org/WantedPorts) Reviewed by: kaktus (local patches for native_log.c) Differential Revision: https://reviews.freebsd.org/D23935 Added: head/security/py-angr/ head/security/py-angr/Makefile (contents, props changed) head/security/py-angr/distinfo (contents, props changed) head/security/py-angr/files/ head/security/py-angr/files/patch-native_Makefile (contents, props changed) head/security/py-angr/files/patch-native_log.c (contents, props changed) head/security/py-angr/files/patch-setup.py (contents, props changed) head/security/py-angr/pkg-descr (contents, props changed) Modified: head/security/Makefile Modified: head/security/Makefile ============================================================================== --- head/security/Makefile Thu Mar 12 09:03:04 2020 (r528279) +++ head/security/Makefile Thu Mar 12 09:13:35 2020 (r528280) @@ -844,6 +844,7 @@ SUBDIR += py-acme SUBDIR += py-acme-tiny SUBDIR += py-ailment + SUBDIR += py-angr SUBDIR += py-argon2-cffi SUBDIR += py-artifacts SUBDIR += py-asyncssh Added: head/security/py-angr/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/Makefile Thu Mar 12 09:13:35 2020 (r528280) @@ -0,0 +1,97 @@ +# $FreeBSD$ + +PORTNAME= angr +DISTVERSION= 8.20.1.7 +CATEGORIES= security devel python +MASTER_SITES= CHEESESHOP +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} +DISTFILES= ${DISTNAME}${EXTRACT_SUFX} + +MAINTAINER= 0mp@FreeBSD.org +COMMENT= Multi-architecture binary analysis toolkit + +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pyvex>=${DISTVERSION}:security/py-pyvex@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}unicorn>0:emulators/py-unicorn@${PY_FLAVOR} +LIB_DEPENDS= libunicorn.so:emulators/unicorn +RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}ailment>=${DISTVERSION}:security/py-ailment@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}cachetools>=0:devel/py-cachetools@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}capstone>=3.0.5:devel/py-capstone@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}cffi>=1.7.0:devel/py-cffi@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}claripy>=${DISTVERSION}:math/py-claripy@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}cle>=${DISTVERSION}:devel/py-cle@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}dpkt>=0:net/py-dpkt@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}GitPython>=0:devel/py-gitpython@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}itanium_demangler>=0:devel/py-itanium_demangler@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}mulpyplexer>=0:devel/py-mulpyplexer@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}networkx>=2.0:math/py-networkx@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}progressbar2>=0:misc/py-progressbar2@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}protobuf>=0:devel/py-protobuf@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}psutil>=0:sysutils/py-psutil@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pycparser>2.18:devel/py-pycparser@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}rpyc>0:devel/py-RPyC@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}sortedcontainers>=0:devel/py-sortedcontainers@${PY_FLAVOR} +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}nose>=0:devel/py-nose@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}keystone-engine>=0:devel/py-keystone-engine@${PY_FLAVOR} \ + z3>=0:math/z3 + +USES= gmake localbase python:3.5+ +USE_GITHUB= nodefault +GH_TUPLE= ${PORTNAME}:${PORTNAME}:6b1a0825cbe156e2d32c577ba47ff50920f005aa:tests \ + ${PORTNAME}:binaries:f2de6d7a0474d22130ffadd042327536a6fda114:binaries +USE_PYTHON= autoplist distutils + +TEST_ENV= ${MAKE_ENV} NOSE_EXCLUDE="${_NOSE_EXCLUDE}" + +# Problem: the following tests require PySoot: https://github.com/angr/pysoot +_EXCLUDED_TESTS+= test_simple1 +_EXCLUDED_TESTS+= test_simple2 +_EXCLUDED_TESTS+= test_fauxware +_EXCLUDED_TESTS+= test_cmd_line_args +_EXCLUDED_TESTS+= test_jni_version_information +_EXCLUDED_TESTS+= test_jni_global_and_local_refs +_EXCLUDED_TESTS+= test_jni_object_operations +_EXCLUDED_TESTS+= test_jni_string_operations +_EXCLUDED_TESTS+= test_jni_field_access +_EXCLUDED_TESTS+= test_jni_method_calls +_EXCLUDED_TESTS+= test_jni_primitive_datatypes +_EXCLUDED_TESTS+= test_jni_object_arrays +_EXCLUDED_TESTS+= test_jni_array_operations +_EXCLUDED_TESTS+= test_method_calls +_EXCLUDED_TESTS+= test_array_operations +_EXCLUDED_TESTS+= test_multiarray_operations +_EXCLUDED_TESTS+= test_loading +_EXCLUDED_TESTS+= test_toggling_of_simstate +# Problem: "TypeError: %d format: a number is required, not NoneType" +_EXCLUDED_TESTS+= test_fastmem.* +# Problem: "angr.errors.AngrIncongruencyError: Different constraints!" +_EXCLUDED_TESTS+= test_similarity_fauxware +# Problem: "IndexError: list index out of range" +_EXCLUDED_TESTS+= test_self_modifying_code +# Problem: "Exception: Not a valid binary file: '/bin/false'" +_EXCLUDED_TESTS+= test_project + +# Create a regular expression out of the excluded tests. +_NOSE_EXCLUDE= (${_EXCLUDED_TESTS:S, ,|,gW}) + +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 + +pre-test: + @${LN} -Fs ${WRKSRC_tests}/tests ${WRKSRC}/tests + @${LN} -Fs ${WRKSRC_binaries} ${WRKDIR}/binaries + +do-test: + @(cd ${WRKSRC}/tests && ${SETENV} ${TEST_ENV} nosetests-${PYTHON_VER} -v) + +.include Added: head/security/py-angr/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/distinfo Thu Mar 12 09:13:35 2020 (r528280) @@ -0,0 +1,7 @@ +TIMESTAMP = 1583576024 +SHA256 (angr-8.20.1.7.tar.gz) = f6c67806240b5ee5e309ec7565ef756107afb11f62d5424e474e0b0cc0637cea +SIZE (angr-8.20.1.7.tar.gz) = 894100 +SHA256 (angr-angr-6b1a0825cbe156e2d32c577ba47ff50920f005aa_GH0.tar.gz) = ff0156bd839d02ad4b11351cf5747b59b9a419f58ca79ef4ab4ab49bab197925 +SIZE (angr-angr-6b1a0825cbe156e2d32c577ba47ff50920f005aa_GH0.tar.gz) = 1228522 +SHA256 (angr-binaries-f2de6d7a0474d22130ffadd042327536a6fda114_GH0.tar.gz) = 7bdc710d10db37d3105038eb4efda1b39e9d1149ecfaf35b1157381fe7275a4a +SIZE (angr-binaries-f2de6d7a0474d22130ffadd042327536a6fda114_GH0.tar.gz) = 56385140 Added: head/security/py-angr/files/patch-native_Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/files/patch-native_Makefile Thu Mar 12 09:13:35 2020 (r528280) @@ -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 Added: head/security/py-angr/files/patch-native_log.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/files/patch-native_log.c Thu Mar 12 09:13:35 2020 (r528280) @@ -0,0 +1,24 @@ +--- native/log.c.orig 2019-04-16 21:08:57 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,11 @@ 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__ ++ dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, (pid_t)pthread_getthreadid_np, 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; Added: head/security/py-angr/files/patch-setup.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/files/patch-setup.py Thu Mar 12 09:13:35 2020 (r528280) @@ -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: Added: head/security/py-angr/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/py-angr/pkg-descr Thu Mar 12 09:13:35 2020 (r528280) @@ -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