mirror of https://github.com/dirtbags/fluffy.git
Provide examples for most commands, enhance pyesc, remove superfluous printfesc
This commit is contained in:
parent
5dd38fb4ea
commit
9079cc81b7
2
Makefile
2
Makefile
|
@ -7,6 +7,8 @@ TARGETS += printfesc
|
||||||
TARGETS += xor
|
TARGETS += xor
|
||||||
TARGETS += unhex
|
TARGETS += unhex
|
||||||
TARGETS += pcat
|
TARGETS += pcat
|
||||||
|
TARGETS += skip
|
||||||
|
TARGETS += hex
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
|
53
README.md
53
README.md
|
@ -42,15 +42,18 @@ Like the normal hd,
|
||||||
but with unicode characters to represent all 256 octets,
|
but with unicode characters to represent all 256 octets,
|
||||||
instead of using "." for unprintable characters.
|
instead of using "." for unprintable characters.
|
||||||
|
|
||||||
|
$ printf "\0\x01\x02\x03\x30\x52\x9a" | hd
|
||||||
|
00000000 00 01 02 03 30 52 9a ┆·☺☻♥0RÜ┆
|
||||||
|
00000007
|
||||||
|
|
||||||
|
|
||||||
### unhex: unescape hex
|
### unhex: unescape hex
|
||||||
|
|
||||||
Reads ASCII hex codes on stdin,
|
Reads ASCII hex codes on stdin,
|
||||||
writes those octets to stdout.
|
writes those octets to stdout.
|
||||||
|
|
||||||
The following pipe is equivalent to "cat":
|
$ echo 68 65 6c 6c 6f 0a | unhex
|
||||||
|
hello
|
||||||
./hd | cut -b 11-58 | ./unhex
|
|
||||||
|
|
||||||
|
|
||||||
### xor: xor mask octets
|
### xor: xor mask octets
|
||||||
|
@ -62,24 +65,27 @@ For a 16-value mask, the mask is applied to 16-octet chunks at a time.
|
||||||
|
|
||||||
The "-x" option treats values as hex.
|
The "-x" option treats values as hex.
|
||||||
|
|
||||||
The following pipe is equivalent to "cat":
|
$ printf 'hello' | xor 22; echo
|
||||||
|
~szzy
|
||||||
./xor 42 | ./xor -x 2A
|
$ printf 'hello' | xor 0x16; echo
|
||||||
|
~szzy
|
||||||
|
$ printf 'hello' | xor -x 16; echo
|
||||||
|
~szzy
|
||||||
|
$ printf 'bbbbbb' | xor 1 0; echo
|
||||||
|
cbcbcb
|
||||||
|
|
||||||
|
|
||||||
### skip: discard initial octets
|
### skip: discard initial octets
|
||||||
|
|
||||||
Throws away some initial octets from stdin,
|
Throws away some initial octets from stdin,
|
||||||
and sends the rest to stdout.
|
and sends the rest to stdout.
|
||||||
|
|
||||||
You could use `dd` for the same purpose.
|
You could use `dd` for the same purpose.
|
||||||
|
|
||||||
This skip command:
|
$ echo abcdefgh | dd skip=5 bs=1 status=none
|
||||||
|
fgh
|
||||||
skip 5
|
$ echo abcdefgh | skip 5
|
||||||
|
fgh
|
||||||
Is equivalent to this `dd` command:
|
|
||||||
|
|
||||||
dd skip=5 bs=1 status=none
|
|
||||||
|
|
||||||
|
|
||||||
### pcat: print text representation of pcap file
|
### pcat: print text representation of pcap file
|
||||||
|
@ -120,22 +126,19 @@ writing to output.
|
||||||
|
|
||||||
### hex: hex-encode input
|
### hex: hex-encode input
|
||||||
|
|
||||||
The opposite of `unhex`.
|
The opposite of `unhex`:
|
||||||
|
encoding all input into a single output line.
|
||||||
|
|
||||||
The following is the equivalent of `cat`:
|
$ printf "hello\nworld\n" | hex
|
||||||
|
68 65 6c 6c 6f 0a 77 6f 72 6c 64 0a
|
||||||
hex | unhex
|
|
||||||
|
|
||||||
|
|
||||||
### printfesc: printf escape input
|
|
||||||
|
|
||||||
Reads octets,
|
|
||||||
writes a string suitable for copy-paste into printf.
|
|
||||||
|
|
||||||
|
|
||||||
### pyesc: python escape input
|
### pyesc: python escape input
|
||||||
|
|
||||||
Escapes input octets for pasting into a python "print" statement.
|
Escapes input octets for pasting into a python "print" statement.
|
||||||
|
Also suitable for use as a C string,
|
||||||
|
a Go string,
|
||||||
|
and many other languages' string literals.
|
||||||
|
|
||||||
|
$ printf "hello\nworld\n" | pyesc
|
||||||
|
hello\nworld\n
|
||||||
|
|
9
hex.c
9
hex.c
|
@ -11,11 +11,16 @@ main(int argc, char *argv[])
|
||||||
if (EOF == c) {
|
if (EOF == c) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("%02x ", c);
|
|
||||||
if (7 == count % 8) {
|
if (count) {
|
||||||
|
putchar(' ');
|
||||||
|
if (0 == count % 8) {
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%02x", c);
|
||||||
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
40
printfesc.c
40
printfesc.c
|
@ -1,40 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
printf("printf ");
|
|
||||||
|
|
||||||
while (!feof(stdin)) {
|
|
||||||
int c = getchar();
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case EOF:
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
printf("\\n");
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
printf("\\r");
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
printf("\\t");
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
printf("\\\"");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (isprint(c)) {
|
|
||||||
putchar(c);
|
|
||||||
} else {
|
|
||||||
printf("\\%03o", c);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
putchar('\n');
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
10
pyesc.c
10
pyesc.c
|
@ -8,7 +8,17 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case EOF:
|
case EOF:
|
||||||
|
putchar('\n');
|
||||||
return 0;
|
return 0;
|
||||||
|
case 8:
|
||||||
|
printf("\\t");
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
printf("\\n");
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
printf("\\r");
|
||||||
|
break;
|
||||||
case 134:
|
case 134:
|
||||||
printf("\\\\");
|
printf("\\\\");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue