aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/scanmem
diff options
context:
space:
mode:
authordanfe <danfe@FreeBSD.org>2014-08-28 18:40:16 +0800
committerdanfe <danfe@FreeBSD.org>2014-08-28 18:40:16 +0800
commita117d1c252e20e75f4ce2b55464ed85a7b1ec746 (patch)
tree4bd4215f64e1545ad8bdf0c0fe86e6ae87916d42 /sysutils/scanmem
parent3ba0fa650ea57ebdf6c1254951f533ba8cbf89d0 (diff)
downloadfreebsd-ports-gnome-a117d1c252e20e75f4ce2b55464ed85a7b1ec746.tar.gz
freebsd-ports-gnome-a117d1c252e20e75f4ce2b55464ed85a7b1ec746.tar.zst
freebsd-ports-gnome-a117d1c252e20e75f4ce2b55464ed85a7b1ec746.zip
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/
Diffstat (limited to 'sysutils/scanmem')
-rw-r--r--sysutils/scanmem/Makefile31
-rw-r--r--sysutils/scanmem/distinfo2
-rw-r--r--sysutils/scanmem/files/patch-commands.c11
-rw-r--r--sysutils/scanmem/files/patch-handlers.c58
-rw-r--r--sysutils/scanmem/files/patch-interrupt.h11
-rw-r--r--sysutils/scanmem/files/patch-maps.c28
-rw-r--r--sysutils/scanmem/files/patch-maps.h10
-rw-r--r--sysutils/scanmem/files/patch-ptrace.c61
-rw-r--r--sysutils/scanmem/pkg-descr8
9 files changed, 220 insertions, 0 deletions
diff --git a/sysutils/scanmem/Makefile b/sysutils/scanmem/Makefile
new file mode 100644
index 000000000000..5edf21c5f12c
--- /dev/null
+++ b/sysutils/scanmem/Makefile
@@ -0,0 +1,31 @@
+# Created by: Alexey Dokuchaev <danfe@FreeBSD.org>
+# $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 <bsd.port.mk>
diff --git a/sysutils/scanmem/distinfo b/sysutils/scanmem/distinfo
new file mode 100644
index 000000000000..409829006af1
--- /dev/null
+++ b/sysutils/scanmem/distinfo
@@ -0,0 +1,2 @@
+SHA256 (scanmem-0.13_.tar.gz) = 36f6b99e26c171dc1caa59e5338f4369391224c8e9b5506bf96a5382831e27b1
+SIZE (scanmem-0.13_.tar.gz) = 240619
diff --git a/sysutils/scanmem/files/patch-commands.c b/sysutils/scanmem/files/patch-commands.c
new file mode 100644
index 000000000000..3558fa885533
--- /dev/null
+++ b/sysutils/scanmem/files/patch-commands.c
@@ -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) {
diff --git a/sysutils/scanmem/files/patch-handlers.c b/sysutils/scanmem/files/patch-handlers.c
new file mode 100644
index 000000000000..fa7515b1f999
--- /dev/null
+++ b/sysutils/scanmem/files/patch-handlers.c
@@ -0,0 +1,58 @@
+--- handlers.c.orig 2012-03-26 06:25:08 UTC
++++ handlers.c
+@@ -34,7 +34,6 @@
+ #include <signal.h>
+ #include <assert.h>
+ #include <setjmp.h>
+-#include <alloca.h>
+ #include <strings.h> /*lint -esym(526,strcasecmp) */
+ #include <string.h>
+ #include <stdbool.h>
+@@ -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" */
diff --git a/sysutils/scanmem/files/patch-interrupt.h b/sysutils/scanmem/files/patch-interrupt.h
new file mode 100644
index 000000000000..0a7228050288
--- /dev/null
+++ b/sysutils/scanmem/files/patch-interrupt.h
@@ -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 */
diff --git a/sysutils/scanmem/files/patch-maps.c b/sysutils/scanmem/files/patch-maps.c
new file mode 100644
index 000000000000..fa84434fa71c
--- /dev/null
+++ b/sysutils/scanmem/files/patch-maps.c
@@ -0,0 +1,28 @@
+--- maps.c.orig 2011-01-13 09:22:33 UTC
++++ maps.c
+@@ -31,7 +31,6 @@
+ #include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <alloca.h>
+ #include <stdbool.h>
+ #include <unistd.h>
+
+@@ -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;
diff --git a/sysutils/scanmem/files/patch-maps.h b/sysutils/scanmem/files/patch-maps.h
new file mode 100644
index 000000000000..41aa26937e1b
--- /dev/null
+++ b/sysutils/scanmem/files/patch-maps.h
@@ -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 <sys/types.h>
+ #include "list.h"
+
+ /* determine what regions we need */
diff --git a/sysutils/scanmem/files/patch-ptrace.c b/sysutils/scanmem/files/patch-ptrace.c
new file mode 100644
index 000000000000..b301e358fe20
--- /dev/null
+++ b/sysutils/scanmem/files/patch-ptrace.c
@@ -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 <time.h>
+ #include <sys/types.h>
+@@ -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/<pid>/mem here */
++ /* TODO: may use /compat/linux/proc/<pid>/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/<pid>/mem here */
++/* TODO: may use /compat/linux/proc/<pid>/mem here */
+ bool write_array(pid_t target, void *addr, const void *data, int len)
+ {
+ int i,j;
diff --git a/sysutils/scanmem/pkg-descr b/sysutils/scanmem/pkg-descr
new file mode 100644
index 000000000000..e00296cc151e
--- /dev/null
+++ b/sysutils/scanmem/pkg-descr
@@ -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/