3 # Convert proxmark3 trace or wav files to formats to be used by Inspectrum
5 # Converts proxmark3 trace to cs8 (Complex 8-bit signed integer samples, eg HackRF IQ format)
6 # and .wav to cs16 (Complex 16-bit signed integer samples, eg BladeRF IQ format)
8 # -samy kamkar, https://samy.pl
10 # we use `sox` to convert, set this to full path if preferred
15 die "usage: $0 [/path/to/sox (optional)] <pm3.trace or file.wav> [...more traces]\n" unless @ARGV;
16 $SOX = shift if $ARGV[0] =~ m/(?:[\/\\]|^)sox
$/;
17 trace_conv
($_) for @ARGV;
24 my @run = ($SOX, qw
/$file -t raw -e signed-integer -b 16 $file.cs16/);
25 run_rewrite
($file, @run);
26 print "Wrote $file.cs16\n\n";
30 my $f = "/tmp/pm3.trace." . rand();
31 open(F
, ">$f") || die "Can't write to $f: $!";
32 open(IN
, "<$file") || die "Can't read $file: $!";
41 # upsample 100x and pad 2nd channel with zeroes
42 my @run = ($SOX, qw
/-t s8 -r 1 -c 1 -v 0.5 $file -t s8 -r 100 -c 2 $file.cs8 remix 1 0/);
43 run_rewrite
($f, @run);
45 # pad file since inspectrum doesn't handle small files so well
46 open(OUT
, ">$file.cs8") || die $!;
47 open(IN
, "<$f.cs8") || die $!;
49 print OUT
"\0" x
(1024 * 1024);
54 print "Wrote $file.cs8\n\n";
60 my ($file, @run) = @_;
61 s/\$file/$file/ foreach @run;
62 print "Running: @run\n";
64 my $ret = system(@run);
65 die "Failed: $! ($ret)\ndo you have $run[0] installed?\n" if $ret;