From 09316776e565463287e5abf5232b9b29fbed9860 Mon Sep 17 00:00:00 2001 From: loviuz Date: Sat, 23 Jan 2021 15:26:56 +0100 Subject: [PATCH] Added support to Guzzle options --- hcra.php | 13 +++++++++---- params.json | 49 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/hcra.php b/hcra.php index 7be472c..5f2c3b7 100644 --- a/hcra.php +++ b/hcra.php @@ -85,16 +85,21 @@ foreach ($requests as $request) { echo $colors->getColoredString('[>]', 'red').' '.$colors->getColoredString('BODY :', 'cyan').' '.$colors->getColoredString($request['body'], 'yellow').' '; + $guzzle_options = [ + 'body' => $request['body'], + 'headers' => $headers, + ]; + + if( isset($request['extra_guzzle_options']) ){ + $guzzle_options = array_merge( $guzzle_options, $request['extra_guzzle_options'][0] ); + } // Execute the request! $client = new \GuzzleHttp\Client(); $response = $client->request( $request['method'], replace_values($request['url'], $all_values), - [ - 'body' => $request['body'], - 'headers' => $headers, - ] + $guzzle_options ); // Get values from regexp on headers diff --git a/params.json b/params.json index cf52e44..171f939 100644 --- a/params.json +++ b/params.json @@ -1,19 +1,36 @@ [ { - "url": "http://localhost/mysite/login", - "method": "POST", + "url": "http://localhost/mysite/", + "method": "GET", "headers": null, - "body": "username=admin&password=s3cr3t", + "body": null, "header-regexp": [ - { - "next_url": "/Location: (.+?)$/" - }, { "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", @@ -24,18 +41,26 @@ "header-regexp": null, "body-regexp": [ { - "email": "/

Your email is: (.+?)<\\/p>/" + "email": "/

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

Congratulations, the flag is: (.+?)<\\/p>/" + } + ] } ] \ No newline at end of file