mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 17:59:20 -04:00
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/
This commit is contained in:
parent
2cac42ef5a
commit
8ed699c6a1
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=366391
10 changed files with 221 additions and 0 deletions
|
@ -861,6 +861,7 @@
|
|||
SUBDIR += scalpel
|
||||
SUBDIR += scan_ffs
|
||||
SUBDIR += scanbuttond
|
||||
SUBDIR += scanmem
|
||||
SUBDIR += schedutils
|
||||
SUBDIR += scprotect
|
||||
SUBDIR += screen
|
||||
|
|
31
sysutils/scanmem/Makefile
Normal file
31
sysutils/scanmem/Makefile
Normal file
|
@ -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>
|
2
sysutils/scanmem/distinfo
Normal file
2
sysutils/scanmem/distinfo
Normal file
|
@ -0,0 +1,2 @@
|
|||
SHA256 (scanmem-0.13_.tar.gz) = 36f6b99e26c171dc1caa59e5338f4369391224c8e9b5506bf96a5382831e27b1
|
||||
SIZE (scanmem-0.13_.tar.gz) = 240619
|
11
sysutils/scanmem/files/patch-commands.c
Normal file
11
sysutils/scanmem/files/patch-commands.c
Normal file
|
@ -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) {
|
58
sysutils/scanmem/files/patch-handlers.c
Normal file
58
sysutils/scanmem/files/patch-handlers.c
Normal file
|
@ -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" */
|
11
sysutils/scanmem/files/patch-interrupt.h
Normal file
11
sysutils/scanmem/files/patch-interrupt.h
Normal file
|
@ -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 */
|
28
sysutils/scanmem/files/patch-maps.c
Normal file
28
sysutils/scanmem/files/patch-maps.c
Normal file
|
@ -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;
|
10
sysutils/scanmem/files/patch-maps.h
Normal file
10
sysutils/scanmem/files/patch-maps.h
Normal file
|
@ -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 */
|
61
sysutils/scanmem/files/patch-ptrace.c
Normal file
61
sysutils/scanmem/files/patch-ptrace.c
Normal file
|
@ -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;
|
8
sysutils/scanmem/pkg-descr
Normal file
8
sysutils/scanmem/pkg-descr
Normal file
|
@ -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/
|
Loading…
Add table
Reference in a new issue