aboutsummaryrefslogtreecommitdiff
path: root/sysutils/memfetch
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2004-11-27 21:26:55 +0000
committerPav Lucistnik <pav@FreeBSD.org>2004-11-27 21:26:55 +0000
commit3bbf98e002049de1d5eea71f5fb54349e19098c3 (patch)
tree2dfe02e227ecdc94080a7342d5b6e622f6e9e770 /sysutils/memfetch
parenta71b91d3f754a3152104a88c125c60c7e1d07c6f (diff)
downloadports-3bbf98e002049de1d5eea71f5fb54349e19098c3.tar.gz
ports-3bbf98e002049de1d5eea71f5fb54349e19098c3.zip
Notes
Diffstat (limited to 'sysutils/memfetch')
-rw-r--r--sysutils/memfetch/Makefile36
-rw-r--r--sysutils/memfetch/distinfo2
-rw-r--r--sysutils/memfetch/files/patch-Makefile13
-rw-r--r--sysutils/memfetch/files/patch-memfetch.c111
-rw-r--r--sysutils/memfetch/pkg-descr16
-rw-r--r--sysutils/memfetch/pkg-message5
-rw-r--r--sysutils/memfetch/pkg-plist4
7 files changed, 187 insertions, 0 deletions
diff --git a/sysutils/memfetch/Makefile b/sysutils/memfetch/Makefile
new file mode 100644
index 000000000000..c83b7e226fcc
--- /dev/null
+++ b/sysutils/memfetch/Makefile
@@ -0,0 +1,36 @@
+# New ports collection makefile for: memfetch
+# Date created: 25 Nov 2004
+# Whom: Yonatan <onatan@gmail.com>
+#
+# $FreeBSD$
+#
+
+PORTNAME= memfetch
+PORTVERSION= 0.05b
+CATEGORIES= sysutils
+MASTER_SITES= http://lcamtuf.coredump.cx/soft/
+DISTNAME= ${PORTNAME}
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= onatan@gmail.com
+COMMENT= Utility to dump process memory
+
+WRKSRC= ${WRKDIR}/${PORTNAME}
+USE_PERL5_RUN= yes
+
+USE_GETOPT_LONG=yes
+CFLAGS+= ${CPPFLAGS}
+MAKE_ENV+= LDFLAGS="${LDFLAGS}"
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin
+ ${INSTALL_SCRIPT} ${WRKSRC}/mffind.pl ${PREFIX}/bin
+.if !defined(NOPORTDOCS)
+ ${MKDIR} ${DOCSDIR}
+ ${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
+.endif
+
+post-install:
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.mk>
diff --git a/sysutils/memfetch/distinfo b/sysutils/memfetch/distinfo
new file mode 100644
index 000000000000..7f8afe120f9d
--- /dev/null
+++ b/sysutils/memfetch/distinfo
@@ -0,0 +1,2 @@
+MD5 (memfetch.tgz) = cda6080b905436c11ec996e19c4a5563
+SIZE (memfetch.tgz) = 12435
diff --git a/sysutils/memfetch/files/patch-Makefile b/sysutils/memfetch/files/patch-Makefile
new file mode 100644
index 000000000000..c83916124c58
--- /dev/null
+++ b/sysutils/memfetch/files/patch-Makefile
@@ -0,0 +1,13 @@
+--- Makefile.orig Thu Nov 25 15:30:12 2004
++++ Makefile Thu Nov 25 15:31:32 2004
+@@ -7,8 +7,8 @@
+ #
+
+ FILE = memfetch
+-CFLAGS = -Wall -O9
+-CC = gcc
++CFLAGS?= -Wall -O9
++CC ?= gcc
+
+ all: $(FILE)
+
diff --git a/sysutils/memfetch/files/patch-memfetch.c b/sysutils/memfetch/files/patch-memfetch.c
new file mode 100644
index 000000000000..a90349ebdcbe
--- /dev/null
+++ b/sysutils/memfetch/files/patch-memfetch.c
@@ -0,0 +1,111 @@
+--- memfetch.c.orig Mon Oct 20 20:04:45 2003
++++ memfetch.c Thu Nov 25 15:51:00 2004
+@@ -20,6 +20,8 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <sys/uio.h>
++#include <sys/types.h>
+ #include <sys/ptrace.h>
+ #include <fcntl.h>
+ #include <string.h>
+@@ -27,7 +29,8 @@
+ #include <signal.h>
+ #include <time.h>
+ #include <sys/mman.h>
+-#include <asm/page.h>
++/* #include <asm/page.h> */
++#include <sys/param.h>
+ #include <getopt.h>
+ #include <errno.h>
+
+@@ -49,7 +52,7 @@
+ fprintf(outfile,"** Error message: " x); \
+ fclose(outfile); \
+ } \
+- if (tracepid>0) ptrace(PTRACE_DETACH,tracepid,0,lastsig); \
++ if (tracepid>0) ptrace(PT_DETACH,tracepid,0,lastsig); \
+ exit(1); \
+ }
+
+@@ -74,6 +77,7 @@
+ " -a - skip non-anonymous maps (libraries etc)\n"
+ " -w - write index file to stdout instead of mfetch.lst\n"
+ " -m - avoid mmap(), helps prevent hanging on some 2.2 boxes\n"
++ " - this is the only way to go on FreeBSD, for now.\n"
+ " -S xxx - dump segment containing address xxx (hex) only\n",myname);
+ exit(3);
+ }
+@@ -124,7 +128,7 @@
+ if (kill(tracepid,0))
+ fatal("Process does not exist or is not accessible.\n");
+
+- if (ptrace(PTRACE_ATTACH,tracepid,0,0))
++ if (ptrace(PT_ATTACH,tracepid,0,0))
+ fatal("Cannot attach to this process (already traced?).\n");
+
+ if ( wait(&st)<=0 || !WIFSTOPPED(st) ) {
+@@ -149,7 +153,7 @@
+
+ while (1) {
+
+- ptrace(PTRACE_CONT,tracepid,0,lastsig);
++ ptrace(PT_CONTINUE,tracepid,0,lastsig);
+
+ if (wait(&st)<=0) {
+ debug("[-] Process gone before receiving a fault signal.\n");
+@@ -198,7 +202,7 @@
+
+ leavewait: // GOTOs for president!
+
+- sprintf(tmp,"/proc/%d/maps",tracepid);
++ sprintf(tmp,"/proc/%d/map",tracepid);
+ mapfile=fopen(tmp,"r");
+
+ if (!mapfile) fatal("Cannot open %s for reading.\n",tmp);
+@@ -237,8 +241,8 @@
+ int* writeptr;
+ char mapped=1;
+
+- if (sscanf(tmp,"%x-%x",&st,&en)!=2) {
+- debug("[!] Parse error in /proc/%d/maps (mockery?): %s",tracepid,tmp);
++ if (sscanf(tmp,"%x %x",&st,&en)!=2) {
++ debug("[!] Parse error in /proc/%d/map (mockery?): %s",tracepid,tmp);
+ continue;
+ }
+
+@@ -280,7 +284,7 @@
+ st,len);
+
+ if (avoid_mmap) writeptr=MAP_FAILED; else {
+- for (i=st;i<=en;i+=PAGE_SIZE) ptrace(PTRACE_PEEKDATA,tracepid,i,0);
++ for (i=st;i<=en;i+=PAGE_SIZE) ptrace(PT_READ_D,tracepid,(caddr_t)i,0);
+ writeptr=mmap(0,len,PROT_READ,MAP_PRIVATE,memfile,st);
+ }
+
+@@ -292,7 +296,7 @@
+ if (lseek(memfile,st,SEEK_SET)!=st || read(memfile,writeptr,len)!=len) {
+ debug("[S] ");
+ for (i=0;i<len/4;i++)
+- writeptr[i]=ptrace(PTRACE_PEEKDATA,tracepid,st+i*4,0);
++ writeptr[i]=ptrace(PT_READ_D,tracepid,(caddr_t)st+i*4,0);
+ } else debug("[N] ");
+
+ }
+@@ -308,14 +312,14 @@
+
+ }
+
+- if (!dumpcnt) fatal("No matching entries found in /proc/%d/maps.\n",tracepid);
++ if (!dumpcnt) fatal("No matching entries found in /proc/%d/map.\n",tracepid);
+
+ if (!textout) fprintf(outfile,"# End of file.\n");
+
+ debug("[*] Done (%d matching). Have a nice day.\n",dumpcnt);
+
+ fclose(outfile);
+- ptrace(PTRACE_DETACH,tracepid,0,lastsig);
++ ptrace(PT_DETACH,tracepid,0,lastsig);
+
+ exit(0);
+
diff --git a/sysutils/memfetch/pkg-descr b/sysutils/memfetch/pkg-descr
new file mode 100644
index 000000000000..f2dea6e4d7b8
--- /dev/null
+++ b/sysutils/memfetch/pkg-descr
@@ -0,0 +1,16 @@
+Memfetch is a very simple utility that can be used to dump process memory of
+any userspace process running on the system without affecting its execution.
+Why bother? Well, quite often it is desirable to see what code and what data
+actually resides in memory under some pid (/proc entries are not always
+accurate). Debuggers like gdb are pretty good for examining small sections
+of code or memory, but are pretty much useless for massive comparison,
+sophisticated searches and such. It's good to be able to retrieve full
+memory image to run it thru grep, strings, your favorite viewer or any other
+tool. Quite obviously, I developed this code not because it's extremely
+difficult to do it on your own, but because it is a valuable shell utility
+for all kinds of deep hacking activities that simply saves you time.
+
+Memfetch is a convenient screenshot grabber for ssh or screen sessions, by
+the way ;-)
+
+WWW: http://lcamtuf.coredump.cx/
diff --git a/sysutils/memfetch/pkg-message b/sysutils/memfetch/pkg-message
new file mode 100644
index 000000000000..ae01e0cca472
--- /dev/null
+++ b/sysutils/memfetch/pkg-message
@@ -0,0 +1,5 @@
+
+Security Warning:
+This port requires that you mount procfs(5) filesystem in /proc.
+Please note that this can pose a security risk.
+
diff --git a/sysutils/memfetch/pkg-plist b/sysutils/memfetch/pkg-plist
new file mode 100644
index 000000000000..be81dec16587
--- /dev/null
+++ b/sysutils/memfetch/pkg-plist
@@ -0,0 +1,4 @@
+bin/memfetch
+bin/mffind.pl
+%%PORTDOCS%%%%DOCSDIR%%/README
+%%PORTDOCS%%@dirrm %%DOCSDIR%%