Remove strings(1)
This commit is contained in:
parent
1341e4aa02
commit
db5c83c918
@ -25,7 +25,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \
|
|||||||
ramdisk rarpd rawspeed rcp rdate readall readclock \
|
ramdisk rarpd rawspeed rcp rdate readall readclock \
|
||||||
readfs reboot remsync rev rget rlogin rlogind rmdir \
|
readfs reboot remsync rev rget rlogin rlogind rmdir \
|
||||||
rotate rsh rshd sed service setup shar acksize \
|
rotate rsh rshd sed service setup shar acksize \
|
||||||
sleep slip sort spell split srccrc strings ackstrip \
|
sleep slip sort spell split srccrc ackstrip \
|
||||||
stty su sum svclog swapfs swifi sync synctree sysenv \
|
stty su sum svclog swapfs swifi sync synctree sysenv \
|
||||||
syslogd tail talk talkd tar tcpd tcpdp tcpstat tee telnet \
|
syslogd tail talk talkd tar tcpd tcpdp tcpstat tee telnet \
|
||||||
telnetd term termcap tget time tinyhalt top touch tr \
|
telnetd term termcap tget time tinyhalt top touch tr \
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
PROG= strings
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
@ -1,139 +0,0 @@
|
|||||||
/* strings - print ASCII strings in a file Author: Peter S. Housel */
|
|
||||||
|
|
||||||
/*
|
|
||||||
This is a version of the BSD "strings" program for Minix. It is used
|
|
||||||
to search a file for printable strings. To install,
|
|
||||||
|
|
||||||
cc -o strings strings.c
|
|
||||||
chmem =8000 strings
|
|
||||||
|
|
||||||
Command: strings - search file for printable strings
|
|
||||||
Syntax: strings [-] [-o] [-len] file ...
|
|
||||||
Flags: - Search the entire file. If this option is not given, only
|
|
||||||
the initialized data segment of files that appear to be
|
|
||||||
"a.out" format is searched.
|
|
||||||
-o Print the offset (in octal) with each string.
|
|
||||||
-len Use "len" as the minimum string length. The default is 4.
|
|
||||||
|
|
||||||
Examples: strings core
|
|
||||||
strings -o a.out > str
|
|
||||||
|
|
||||||
Strings searches the specified file(s) for printable ASCII strings (four
|
|
||||||
or more printable characters followed by a newline or a null) and writes
|
|
||||||
them to the standard output. This can be used to find out, for example, to
|
|
||||||
find out what program a "core" file came from, what kinds of error messages
|
|
||||||
are in an executable, or to see ASCII data hidden in a "binary" data file.
|
|
||||||
|
|
||||||
P.S. The program doesn't use the "a.out.h" file posted last week by
|
|
||||||
Dick van Veen, both because it was written before then, and because
|
|
||||||
not everybody has a.out.h yet. Future revisions probably ought to, though.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* Minix (8086 version) dependant definitions */
|
|
||||||
#define SMALLMAGIC 0x04100301L /* small model a.out magic number */
|
|
||||||
#define SEPARATEMAGIC 0x04200301L /* separate instruction/data a.out */
|
|
||||||
|
|
||||||
#define HDR_MAGIC 0 /* 0'th long magic number */
|
|
||||||
#define HDR_HSIZE 1 /* 1'st long size of header */
|
|
||||||
#define HDR_TSIZE 2 /* 2'nd long size of text */
|
|
||||||
#define HDR_DSIZE 3 /* 3'rd long size of init'ed data */
|
|
||||||
#define HDR_BSIZE 4 /* 4'th long size of bss */
|
|
||||||
#define HDR_TOTMEM 6 /* 6'th long total memory */
|
|
||||||
|
|
||||||
#define HDR_LEN 8 /* total length of header */
|
|
||||||
|
|
||||||
/* Miscellaneous definitions */
|
|
||||||
#define STRLEN 4 /* default minimum string length */
|
|
||||||
#define STRBUF 512 /* buffer length for strings */
|
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char **argv));
|
|
||||||
_PROTOTYPE(void strings, (char *filename));
|
|
||||||
_PROTOTYPE(void usage, (void));
|
|
||||||
|
|
||||||
int strmin = STRLEN; /* minimum string length */
|
|
||||||
int printoff = 0; /* print octal offset of each str */
|
|
||||||
int objall = 0; /* search entire a.out file, not */
|
|
||||||
|
|
||||||
/* Just initialized data segment */
|
|
||||||
|
|
||||||
int main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
while ((++argv, --argc) && '-' == (*argv)[0]) {
|
|
||||||
if (!strcmp(*argv, "-"))
|
|
||||||
++objall;
|
|
||||||
else if (!strcmp(*argv, "-o"))
|
|
||||||
++printoff;
|
|
||||||
else if (isdigit((*argv)[1]))
|
|
||||||
strmin = atoi(&(*argv)[1]);
|
|
||||||
else
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == argc) usage();
|
|
||||||
while (argc--) strings(*argv++);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void strings(filename)
|
|
||||||
char *filename;
|
|
||||||
{
|
|
||||||
char buf[STRBUF]; /* the strings buffer */
|
|
||||||
char *bufptr; /* pointer into the strings buffer */
|
|
||||||
FILE *input; /* input file */
|
|
||||||
long header[HDR_LEN]; /* buffer for reading the header */
|
|
||||||
long offset; /* file offset */
|
|
||||||
long limit; /* limit, if doing data segment only */
|
|
||||||
int c; /* input character */
|
|
||||||
|
|
||||||
if (NULL == (input = fopen(filename, "r"))) {
|
|
||||||
fprintf(stderr, "strings: ");
|
|
||||||
perror(filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (HDR_LEN == fread(header, sizeof(long), (size_t)HDR_LEN, input)
|
|
||||||
&& (SMALLMAGIC == header[HDR_MAGIC]
|
|
||||||
||SEPARATEMAGIC == header[HDR_MAGIC]) && !objall) {
|
|
||||||
offset = header[HDR_HSIZE] + header[HDR_TSIZE]; /* object file */
|
|
||||||
limit = offset + header[HDR_DSIZE];
|
|
||||||
} else {
|
|
||||||
offset = 0L;
|
|
||||||
limit = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(input, offset, 0);
|
|
||||||
bufptr = buf;
|
|
||||||
|
|
||||||
while (!limit || offset < limit) {
|
|
||||||
if (EOF == (c = getc(input))) break;
|
|
||||||
if ((('\0' == c || '\n' == c) && bufptr - buf >= strmin)
|
|
||||||
|| (bufptr - buf == STRBUF - 1)) {
|
|
||||||
*bufptr = '\0';
|
|
||||||
if (printoff) printf("%lo:", offset - (bufptr - buf));
|
|
||||||
puts(buf);
|
|
||||||
bufptr = buf;
|
|
||||||
} else if ((' ' <= c && c < 0177) || '\t' == c)
|
|
||||||
*bufptr++ = c;
|
|
||||||
else
|
|
||||||
bufptr = buf;
|
|
||||||
|
|
||||||
++offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
void usage()
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: strings [-] [-o] [-num] file ...\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
@ -18,7 +18,7 @@ MAN= acd.1 anm.1 ar.1 ash.1 asize.1 at.1 banner.1 basename.1 \
|
|||||||
profile.1 ps.1 pwd.1 rcp.1 readall.1 readfs.1 recwave.1 \
|
profile.1 ps.1 pwd.1 rcp.1 readall.1 readfs.1 recwave.1 \
|
||||||
ref.1 remsync.1 rget.1 rlogin.1 rmdir.1 rsh.1 rz.1 \
|
ref.1 remsync.1 rget.1 rlogin.1 rmdir.1 rsh.1 rz.1 \
|
||||||
shar.1 acksize.1 sleep.1 sort.1 soundoff.1 soundon.1 spell.1 \
|
shar.1 acksize.1 sleep.1 sort.1 soundoff.1 soundon.1 spell.1 \
|
||||||
split.1 strings.1 strip.1 stty.1 su.1 sum.1 svc.1 \
|
split.1 strip.1 stty.1 su.1 sum.1 svc.1 \
|
||||||
synctree.1 sysenv.1 sz.1 tail.1 tee.1 telnet.1 template.1 \
|
synctree.1 sysenv.1 sz.1 tail.1 tee.1 telnet.1 template.1 \
|
||||||
term.1 termcap.1 tget.1 time.1 top.1 tr.1 true.1 \
|
term.1 termcap.1 tget.1 time.1 top.1 tr.1 true.1 \
|
||||||
truncate.1 tsort.1 tty.1 umount.1 uname.1 unexpand.1 uniq.1 \
|
truncate.1 tsort.1 tty.1 umount.1 uname.1 unexpand.1 uniq.1 \
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
.TH STRINGS 1
|
|
||||||
.SH NAME
|
|
||||||
strings \- print all the strings in a binary file
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBstrings\fR [\fB\-\fR] [\fB\-o\fR]\fR [\fB\-\fIn\fR] \fIfile ...\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH OPTIONS
|
|
||||||
.FL "\-" "search whole file, not just data seg"
|
|
||||||
.FL "\-o" "Print octal offset of each string"
|
|
||||||
.FL "\-\fIn" "\fIn\fR is minimum length string (default = 4)"
|
|
||||||
.SH EXAMPLES
|
|
||||||
.EX "strings \-5 a.out" "Print the strings > 4 chars in \fIa.out\fR"
|
|
||||||
.EX "strings \- /bin/sh" "Search entire shell file (text and data)"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
\fIStrings\fR looks for sequences of ASCII characters followed by a zero
|
|
||||||
byte.
|
|
||||||
These are usually strings. This program is typically used to help identify
|
|
||||||
unknown binary programs
|
|
Loading…
x
Reference in New Issue
Block a user