From owner-svn-ports-head@FreeBSD.ORG Thu Aug 28 10:40:19 2014 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 01F64112; Thu, 28 Aug 2014 10:40:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E0B361F86; Thu, 28 Aug 2014 10:40:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7SAeIox068289; Thu, 28 Aug 2014 10:40:18 GMT (envelope-from danfe@FreeBSD.org) Received: (from danfe@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7SAeGLx067928; Thu, 28 Aug 2014 10:40:16 GMT (envelope-from danfe@FreeBSD.org) Message-Id: <201408281040.s7SAeGLx067928@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: danfe set sender to danfe@FreeBSD.org using -f From: Alexey Dokuchaev Date: Thu, 28 Aug 2014 10:40:16 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r366391 - in head/sysutils: . scanmem scanmem/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2014 10:40:19 -0000 Author: danfe Date: Thu Aug 28 10:40:16 2014 New Revision: 366391 URL: http://svnweb.freebsd.org/changeset/ports/366391 QAT: https://qat.redports.org/buildarchive/r366391/ Log: Add quick and dirty port of scanmem, a simple interactive debugging utility for Linux, used to locate the address of a variable in an executing process. WWW: http://code.google.com/p/scanmem/ Added: head/sysutils/scanmem/ head/sysutils/scanmem/Makefile (contents, props changed) head/sysutils/scanmem/distinfo (contents, props changed) head/sysutils/scanmem/files/ head/sysutils/scanmem/files/patch-commands.c (contents, props changed) head/sysutils/scanmem/files/patch-handlers.c (contents, props changed) head/sysutils/scanmem/files/patch-interrupt.h (contents, props changed) head/sysutils/scanmem/files/patch-maps.c (contents, props changed) head/sysutils/scanmem/files/patch-maps.h (contents, props changed) head/sysutils/scanmem/files/patch-ptrace.c (contents, props changed) head/sysutils/scanmem/pkg-descr (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Thu Aug 28 10:36:27 2014 (r366390) +++ head/sysutils/Makefile Thu Aug 28 10:40:16 2014 (r366391) @@ -861,6 +861,7 @@ SUBDIR += scalpel SUBDIR += scan_ffs SUBDIR += scanbuttond + SUBDIR += scanmem SUBDIR += schedutils SUBDIR += scprotect SUBDIR += screen Added: head/sysutils/scanmem/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/Makefile Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,31 @@ +# Created by: Alexey Dokuchaev +# $FreeBSD$ + +PORTNAME= scanmem +PORTVERSION= 0.13 +CATEGORIES= sysutils +MASTER_SITES= GOOGLE_CODE +DISTNAME= ${PORTNAME}-${PORTVERSION}_ + +MAINTAINER= danfe@FreeBSD.org +COMMENT= Locate and modify a variable in an executing process + +LICENSE= GPLv3 + +ONLY_FOR_ARCHS= i386 amd64 +ONLY_FOR_ARCHS_REASON= requires linprocfs(5) + +USES= readline +GNU_CONFIGURE= yes + +WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} + +PLIST_FILES= bin/scanmem man/man1/scanmem.1.gz +PORTDOCS= README + +OPTIONS_DEFINE= DOCS + +post-patch: + @${REINPLACE_CMD} -e 's,/proc/,/compat/linux&,' ${WRKSRC}/configure + +.include Added: head/sysutils/scanmem/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/distinfo Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,2 @@ +SHA256 (scanmem-0.13_.tar.gz) = 36f6b99e26c171dc1caa59e5338f4369391224c8e9b5506bf96a5382831e27b1 +SIZE (scanmem-0.13_.tar.gz) = 240619 Added: head/sysutils/scanmem/files/patch-commands.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-commands.c Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,11 @@ +--- commands.c.orig 2010-01-19 07:37:07 UTC ++++ commands.c +@@ -104,7 +104,7 @@ bool execcommand(globals_t * vars, const + + np = commands->head; + +- str = tok = strdupa(commandline); ++ str = tok = strdup(commandline); + + /* tokenize command line into an argument vector */ + for (argc = 0; tok; argc++, str = NULL) { Added: head/sysutils/scanmem/files/patch-handlers.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-handlers.c Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,58 @@ +--- handlers.c.orig 2012-03-26 06:25:08 UTC ++++ handlers.c +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + #include /*lint -esym(526,strcasecmp) */ + #include + #include +@@ -123,9 +122,9 @@ bool handler__set(globals_t * vars, char + } else { + /* there is a '=', value+1 points to value string. */ + +- /* use strndupa() to copy the matchids into a new buffer */ ++ /* use strndup() to copy the matchids into a new buffer */ + settings[block].matchids = +- strndupa(argv[block + 1], ++ strndup(argv[block + 1], + (size_t) (settings[block].value++ - argv[block + 1])); + } + +@@ -161,7 +160,7 @@ bool handler__set(globals_t * vars, char + + /* remove any delay suffix from the value */ + settings[block].value = +- strndupa(settings[block].value, ++ strndup(settings[block].value, + (size_t) (delay - settings[block].value)); + } /* if (strchr('/')) */ + } /* for(block...) */ +@@ -207,7 +206,7 @@ bool handler__set(globals_t * vars, char + unsigned num = 0; + + /* create local copy of the matchids for strtok() to modify */ +- lmatches = strdupa(settings[block].matchids); ++ lmatches = strdup(settings[block].matchids); + + /* now seperate each match, spearated by commas */ + while ((id = strtok(lmatches, ",")) != NULL) { +@@ -545,7 +544,7 @@ bool handler__dregion(globals_t * vars, + if (*argv[1] == '!') { + invert = true; + /* create a copy of the argument for strtok(), +1 to skip '!' */ +- block = strdupa(argv[1] + 1); ++ block = strdup(argv[1] + 1); + + /* check for lone '!' */ + if (*block == '\0') { +@@ -561,7 +560,7 @@ bool handler__dregion(globals_t * vars, + + } else { + invert = false; +- block = strdupa(argv[1]); ++ block = strdup(argv[1]); + } + + /* loop for every number specified, eg "1,2,3,4,5" */ Added: head/sysutils/scanmem/files/patch-interrupt.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-interrupt.h Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,11 @@ +--- interrupt.h.orig 2009-12-14 15:15:26 UTC ++++ interrupt.h +@@ -10,7 +10,7 @@ + /* small header file to manage interrupted commands */ + + static sigjmp_buf jmpbuf; /* used when aborting a command due to interrupt */ +-static sighandler_t oldsig; /* reinstalled before longjmp */ ++static sig_t oldsig; /* reinstalled before longjmp */ + static unsigned intused; + + /* signal handler to handle interrupt during a commands */ Added: head/sysutils/scanmem/files/patch-maps.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-maps.c Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,28 @@ +--- maps.c.orig 2011-01-13 09:22:33 UTC ++++ maps.c +@@ -31,7 +31,6 @@ + #include + #include + #include +-#include + #include + #include + +@@ -56,7 +55,7 @@ bool readmaps(pid_t target, list_t * reg + return false; + + /* construct the maps filename */ +- snprintf(name, sizeof(name), "/proc/%u/maps", target); ++ snprintf(name, sizeof(name), "/compat/linux/proc/%u/maps", target); + + /* attempt to open the maps file */ + if ((maps = fopen(name, "r")) == NULL) { +@@ -110,7 +109,7 @@ bool readmaps(pid_t target, list_t * reg + break; + } + /* test if the region is mapped to the executable */ +- snprintf(exename, sizeof(exename), "/proc/%u/exe", target); ++ snprintf(exename, sizeof(exename), "/compat/linux/proc/%u/exe", target); + if((linkbuf_size = readlink(exename, linkbuf, MAX_LINKBUF_SIZE)) > 0) + { + linkbuf[linkbuf_size] = 0; Added: head/sysutils/scanmem/files/patch-maps.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-maps.h Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,10 @@ +--- maps.h.orig 2010-01-14 08:52:26 UTC ++++ maps.h +@@ -23,6 +23,7 @@ + #ifndef _MAPS_INC + #define _MAPS_INC /* include guard */ + ++#include + #include "list.h" + + /* determine what regions we need */ Added: head/sysutils/scanmem/files/patch-ptrace.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/files/patch-ptrace.c Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,61 @@ +--- ptrace.c.orig 2012-04-22 03:04:11 UTC ++++ ptrace.c +@@ -22,11 +22,13 @@ + + #include "config.h" + ++#if 0 + /* for pread */ + # ifdef _XOPEN_SOURCE + # undef _XOPEN_SOURCE + # endif + # define _XOPEN_SOURCE 500 ++#endif + + #include + #include +@@ -376,7 +378,7 @@ bool checkmatches(globals_t * vars, + return detach(vars->target); + } + +-/* read region using /proc/pid/mem */ ++/* read region using /compat/linux/proc/pid/mem */ + ssize_t readregion(pid_t target, void *buf, size_t count, unsigned long offset) + { + char mem[32]; +@@ -384,7 +386,7 @@ ssize_t readregion(pid_t target, void *b + ssize_t len; + + /* print the path to mem file */ +- snprintf(mem, sizeof(mem), "/proc/%d/mem", target); ++ snprintf(mem, sizeof(mem), "/compat/linux/proc/%d/mem", target); + + /* attempt to open the file */ + if ((fd = open(mem, O_RDONLY)) == -1) { +@@ -498,7 +500,7 @@ bool searchregions(globals_t * vars, sca + } + + #else +- /* cannot use /proc/pid/mem */ ++ /* cannot use /compat/linux/proc/pid/mem */ + nread = r->size; + #endif + /* print a progress meter so user knows we havent crashed */ +@@ -632,7 +634,7 @@ bool setaddr(pid_t target, void *addr, c + return false; + } + +- /* TODO: may use /proc//mem here */ ++ /* TODO: may use /compat/linux/proc//mem here */ + /* assume that sizeof(save.int64_value) (int64_t) is multiple of sizeof(long) */ + for (i = 0; i < sizeof(saved.int64_value); i += sizeof(long)) + { +@@ -687,7 +689,7 @@ bool read_array(pid_t target, void *addr + #endif + } + +-/* TODO: may use /proc//mem here */ ++/* TODO: may use /compat/linux/proc//mem here */ + bool write_array(pid_t target, void *addr, const void *data, int len) + { + int i,j; Added: head/sysutils/scanmem/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/scanmem/pkg-descr Thu Aug 28 10:40:16 2014 (r366391) @@ -0,0 +1,8 @@ +Scanmem is a simple interactive debugging utility for Linux, used to locate +the address of a variable in an executing process. This can be used for the +analysis or modification of a hostile process on a compromised machine, +reverse engineering, or as a "pokefinder" to cheat at video games. + +It requires linprocfs(5) to be mounted under /compat/linux/proc to operate. + +WWW: http://code.google.com/p/scanmem/