-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsegmented10k.pl
executable file
·52 lines (40 loc) · 1.58 KB
/
segmented10k.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/perl -w
use strict;
my $DRY_RUN = 0;
# script out running tests
my $outputdir = "SavedOutputs/10k";
# test for existence of outputdir
my @bytearrays = ();
# add a push of the filename within ByteArrays/ that you want to execute and their execution options
# filenames can not have spaces in them or option parse will fail
for (my $i = 0; $i < 10; $i++) {
my $str = "randfill-10240kb:11-cd80.rawshell;-x -f " . ($i*1024) . " -c 1024";
push @bytearrays, $str;
}
# consider making byte arrays allow options as well
# for each file to test
foreach my $bytearray (@bytearrays) {
# create the script that the guest will load, it needs the bytearray filename and options
$bytearray =~ m/^(.*);(.*)$/;
$bytearray = $1;
my $options = $2;
print "making firstRan.sh with: $bytearray and $options\n";
if (!$DRY_RUN) {
open (FIRST_RAN, ">firstRan.sh");
print FIRST_RAN "#! /bin/sh\n./shellcode-wrapper -i $bytearray $options\n";
close FIRST_RAN;
# run the system on that byte array
# consider replacing this with the make run commands (so I can edit and compile while a batch is running)
`make run`;
}
# change the input filename into the name that we want to store the file as
my $file_out = $bytearray;
$options =~ s/.*-f\s*(\d+).*-c\s*(\d+)\s*/$1-$2/;
$file_out =~ s/\.[a-z]*$/-$options.txt/; # change extension to txt
print "storing debug.txt into $outputdir/$file_out\n";
# store the file in a safe place
if (!$DRY_RUN) {
`cp s2e-last/debug.txt $outputdir/$file_out`;
}
} # end foreach bytearray to execute
exit;