Skip to content

Commit

Permalink
Added -R (redact) option to replace output with X's (#39)
Browse files Browse the repository at this point in the history
* updated with blind redact data feature

* fixed redact code to make more sense.

* updated usage to add -R option for redact

* revert change to fix warning

* cleaned up formatting

* changed command line option to -R for redact

* fixed formatting
  • Loading branch information
lcashdol authored Jul 28, 2023
1 parent 9e2171b commit 1af4ce3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pocs/cpus/zenbleed/zenbleed.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static uint64_t maxleak;

static bool asciionly = true;
static bool secretonly = false;
static bool redact = false;

// Minor variations in alignment seem to make the exploit work better on
// different SKUs. These are some variants to try and see what works best.
Expand Down Expand Up @@ -101,10 +102,11 @@ static void * thread_leak_consumer(void *param)

// Escape any confusing characters
if (*s == '"' || *s == '\\')
fputc('\\', stdout);
if (!redact) fputc('\\', stdout);
// Print normal ascii.
if (isalnum(*s) || ispunct(*s)) {
fputc(*s, stdout);
if (!redact) fputc(*s, stdout);
else fputc('X',stdout);
} else if (isspace(*s)) {
fputc(' ', stdout);
} else {
Expand Down Expand Up @@ -232,6 +234,7 @@ static void print_help()
logmsg(" -t N Give up after this many seconds.");
logmsg(" -n N Set nice level, can improve results on some systems.");
logmsg(" -a Print all data, not just ASCII strings.");
logmsg(" -R Redact output data with X's.");
logmsg(" -s Only print the magic hammer value (used for benchmarking).");
logmsg(" -p STR Pattern mode, try to continue string STR based on sampling leaked values.");
logmsg(" -q Quiet, reduce verbosity.");
Expand All @@ -258,7 +261,7 @@ int main(int argc, char **argv) {
pattern = 0; // String to search for.
cores = 0; // Which cpus to run on.

while ((opt = getopt(argc, argv, "r:qp:sat:n:hH:c:v:m:")) != -1) {
while ((opt = getopt(argc, argv, "r:qRp:sat:n:hH:c:v:m:")) != -1) {
switch (opt) {
case 'v': variant = atoi(optarg);
break;
Expand All @@ -280,6 +283,8 @@ int main(int argc, char **argv) {
break;
case 'q': quiet = true;
break;
case 'R': redact = true;
break;
case 'r': cores = optarg;
break;
default:
Expand Down

0 comments on commit 1af4ce3

Please sign in to comment.