From 41284bd0f27ce2d7a568c9ae7f5ab9b8880c8264 Mon Sep 17 00:00:00 2001 From: hael Date: Thu, 14 Aug 2025 16:40:27 +0000 Subject: [PATCH] openssl rand hex --- scan.php | 22 +++++++++++++--------- version.html | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scan.php b/scan.php index c238e40..eed1967 100644 --- a/scan.php +++ b/scan.php @@ -361,23 +361,25 @@ switch ($_GET["op"]) { continue; // do NOT regenerate values } - if (intval($field_arr[3])==0) $len = 10; // default length - else $len = $field_arr[3]; + $gen_arr = explode("|",$field_arr[1]); - if ($field_arr[1]=="openssl") { - if ($field_arr[2]=="hex") $command = "openssl rand -hex $len"; - elseif ($field_arr[2]=="base64") $command = "openssl rand -base64 $len"; + if (intval($gen_arr[2])==0) $len = 10; // default length + else $len = $gen_arr[2]; + + if ($gen_arr[0]=="openssl") { + if ($gen_arr[1]=="hex") $command = "openssl rand -hex $len"; + elseif ($gen_arr[1]=="base64") $command = "openssl rand -base64 $len"; else $command = "openssl rand $len"; // raw $output = shell_exec($command); if ($output === null) $output = "OPENSSL_ERROR"; } else { - if ($field_arr[1]=="random") $base = rand(100000,999999); - elseif ($field_arr[1]=="time") $base = time(); - elseif ($field_arr[1]!="") $base = $field_arr[1]; // fix string + if ($gen_arr[0]=="random") $base = rand(100000,999999); + elseif ($gen_arr[0]=="time") $base = time(); + elseif ($gen_arr[0]!="") $base = $gen_arr[0]; // fix string else $base = rand(100000,999999); // default - if (in_array($field_arr[2],$algos)) $base = hash($field_arr[2],$base); + if (in_array($gen_arr[1],$algos)) $base = hash($gen_arr[1],$base); else $base = hash("md5",$base); // default alg $output = substr($base,0,$len); @@ -385,6 +387,8 @@ switch ($_GET["op"]) { $fields["$field_key"] = $output; } } + //var_dump($fields); exit; // TEMP - test generated values + $payload = base64_encode(json_encode($fields, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); $arr = array("NAME" => $_GET["additional"], "ACTION" => $_GET["op"], "PAYLOAD" => $payload); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); diff --git a/version.html b/version.html index 63b283b..cbb8cba 100644 --- a/version.html +++ b/version.html @@ -1 +1 @@ -1.1.16 +1.1.17