From 65a5e7b577eb316289fe75ff9b15284adb004b69 Mon Sep 17 00:00:00 2001 From: loviuz Date: Fri, 5 Feb 2021 00:02:51 +0100 Subject: [PATCH] Moved debug mode to json file --- hcra.php | 11 ++--- params.json | 135 +++++++++++++++++++++++++++------------------------- 2 files changed, 74 insertions(+), 72 deletions(-) diff --git a/hcra.php b/hcra.php index 5f2c3b7..5cc54be 100644 --- a/hcra.php +++ b/hcra.php @@ -12,12 +12,6 @@ if( count($argv) < 2 ){ exit(); } -if( count($argv) == 3 ){ - if( $argv[2] == 'DEBUG' ){ - $debug = true; - } -} - if( !file_exists($argv[1]) ){ usage(); echo $colors->getColoredString(' @@ -43,9 +37,10 @@ It does not seems a good JSON file!', 'green').' exit(); } +$debug = $requests['configuration']['debug']; // Loop through URLs :-) -echo $pointer." Found ".$colors->getColoredString( count($requests), 'yellow')." requests!\n\n"; +echo $pointer." Found ".$colors->getColoredString( count($requests['urls']), 'yellow')." requests!\n\n"; @@ -55,7 +50,7 @@ $s = 1; // Placeholder for values extracted by regexp $all_values = []; -foreach ($requests as $request) { +foreach ($requests['urls'] as $request) { $new_values = []; // Apply regexp substitution on url, body and headers with previous values diff --git a/params.json b/params.json index 171f939..a021607 100644 --- a/params.json +++ b/params.json @@ -1,66 +1,73 @@ -[ +{ + "configuration": { - "url": "http://localhost/mysite/", - "method": "GET", - "headers": null, - "body": null, - "header-regexp": [ - { - "cookie": "/Set-Cookie: (.+?)$/" - } - ], - "body-regexp": null - }, - { - "url": "http://localhost/mysite/", - "method": "POST", - "headers": { - "Cookie": "§cookie§", - "Content-Type": "application/x-www-form-urlencoded" - }, - "body": "username=admin&password=s3cr3t", - "header-regexp": [ - { - "next_url": "/Location: (.+)/" - } - ], - "body-regexp": null, - "extra_guzzle_options": [ - { - "allow_redirects": false - } - ] - }, - { - "url": "http://localhost§next_url§", - "method": "GET", - "headers": { - "Cookie": "§cookie§" - }, - "body": null, - "header-regexp": null, - "body-regexp": [ - { - "email": "/

Your email is (.+)!<\\/p>/" - } - ] - }, - { - "url": "http://localhost§next_url§?email=§email§", - "method": "GET", - "headers": { - "Cookie": "§cookie§" - }, - "body": null, - "header-regexp": [ - { - "flag1": "/Set-Cookie: flag2=(.+?);/" - } - ], - "body-regexp": [ - { - "flag2": "/

Congratulations, the flag is: (.+?)<\\/p>/" - } - ] + "debug": false } -] \ No newline at end of file + , + "urls": [ + { + "url": "http://localhost/mysite/", + "method": "GET", + "headers": null, + "body": null, + "header-regexp": [ + { + "cookie": "/Set-Cookie: (.+?)$/" + } + ], + "body-regexp": null + }, + { + "url": "http://localhost/mysite/", + "method": "POST", + "headers": { + "Cookie": "§cookie§", + "Content-Type": "application/x-www-form-urlencoded" + }, + "body": "username=admin&password=s3cr3t", + "header-regexp": [ + { + "next_url": "/Location: (.+)/" + } + ], + "body-regexp": null, + "extra_guzzle_options": [ + { + "allow_redirects": false + } + ] + }, + { + "url": "http://localhost§next_url§", + "method": "GET", + "headers": { + "Cookie": "§cookie§" + }, + "body": null, + "header-regexp": null, + "body-regexp": [ + { + "email": "/

Your email is (.+)!<\\/p>/" + } + ] + }, + { + "url": "http://localhost§next_url§?email=§email§", + "method": "GET", + "headers": { + "Cookie": "§cookie§" + }, + "body": null, + "header-regexp": [ + { + "flag1": "/Set-Cookie: flag2=(.+?);/" + } + ], + "body-regexp": [ + { + "flag2": "/

Congratulations, the flag is: (.+?)<\\/p>/" + } + ] + } + ] +}