Tag Info

New answers tagged

1

The following solution is based on nothing but xxd (one of the tools mentioned in the question), Bash and GNU sed. It assumes that the input consists of complete bytes (groups of eight letters), arbitrarily separated by newlines. The approach is: Strip all newlines. Group letters into four-letter groups terminated by spaces. Filter these quadgraphs into ...


3

These answers are half correct, because virtualization is a choice but there is another. May I present... History First there was UNIX, circa 1972 Then the Timeline Split In 1977, for $90, Bob Fabry and others, compiled/built the first versions of BSD, short for Berkeley Systems Distribution. In 1991, Linus Torvalds posted in a Newsgroup, about ...


1

Hardware Emulation Not directly! Yes as rocky said, you have to virtualize it with VirtualBox, VMWare Fusion, which will match your CPU type. There's also Qemu, which will virtualize different CPU types i.e. Intel or Power etc. Software Emulation There is also software layer emulation, with programs like WiNE, and my own emulayer program(WiP) Both of ...


2

The only way I know that this can be done via some sort of virtualization. For example, you could use vagrant which is a wrapper of sorts around Oracle's VBox or VMware's vmplayer. The other thing that is sometimes done is put this in a container such as docker.


1

It's not really that hard: just look for your start string, and name and match your tail string. Otherwise, try at least to get close. You don't really need all that hexadecimal, but using it: fold -w2 <hexfile | sed -e:t -e's/[[:xdigit:]]\{2\}$/\\x&/ /f[af]$/N;/\(.\)..\1$/!s/.*\n/&\\x/;t /^.*\(.\)\(\n.*\)\n\(.*\n\).*/!bt s//\3\3\3 ...


1

Outputs to great meuh's answer where he used data data26.6.2015.txt. #1 $ cat 27.6.2015_1.sh && sh 27.6.2015_1.sh xxd -r -p <data26.6.2015.txt >/tmp/f1 size=$(stat -c '%s' /tmp/f1) pat=$(echo -e '\xfa\xfa\xfa\xfa') set -- 0 $(ggrep -b -a -o "$pat" /tmp/f1 | sed 's/:.*//') $size i=2 while [ $# -ge 2 ] do start=$1 end=$2 let ...


1

You can operate on the binary file without needing to go through xxd. I ran your data back through xxd and used grep -b to show me the byte offsets of your pattern (converted from hex to chars \xfa) in the binary file. I removed with sed the matched characters from the output to leave just the numbers. I then set the shell positional args to the resulting ...


1

If I understand your question correctly, you want to extract an uploaded file from a requests that consists of: a line consisting of dashes followed by hexadecimal digits; a bunch more non-empty lines (headers); an empty line; the content to extract; a line break; a repeat of the first line; where line breaks are a CRLF sequence, and the content can ...


5

Another perl: perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' Proof: $ echo ABBBAAAABBBBBABBABBBABBB | \ perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' | \ od -tx1 0000000 70 fb 77 0000003 The above reads input one line at a time. It's up to you to make sure the lines are exactly what ...


1

Perl: my $len = 24; my $str = "ABBBAAAABBBBBABBABBBABBB\n"; $str =~ s/\s//g; (my $bin = $str) =~ y/AB/01/; my $val = oct("0b".$bin); printf "%s -> %s -> %X\n", $str, $bin, $val; my ($filename, $fh) = ("temp.out"); # write the file open $fh, '>', $filename; print $fh pack("N", $val); # this actually writes 4 bytes close $fh; # now read it, ...


3

{ printf '2i[q]sq[?z0=qPl?x]s?l?x' tr -dc AB | tr AB 01 | fold -b24 } <infile | dc In making the following statement, @lcd047 has pretty well nailed my earlier state of confusion: You seem to be confused by the output of od. Use od -tx1 to look at bytes. od -x reads words, and on little endian machines that swaps bytes. I didn't follow ...


0

Busybox is highly configurable, so the answer will depend on what was compiled in. Here are some options. catv -v will show nulls as `^@'. split -l 1 will create files xaa xab etc each with one line in it.


3

For large files using sort will be slow. I wrote a short C program to solve the equivalent problem (see this gist for Makefile with tests): #include <stdio.h> #define BUFFERLEN 4096 int main(){ // This program reads standard input and calculate frequencies of different // bytes and present the frequences for each byte value upon exit. // ...


0

It bends the use of grep a bit grep -r -I -l . But it will list all non binary file in current directory. Using mostly the -I switch to exclude binary


0

It should work, file * | egrep -v 'ELF|executable' | awk '{print $1}' | sed -e 's/://g' | xargs ls -l



Top 50 recent answers are included