Different Ways of Circumventing Suhosin 12-22-2015, 05:37 PM
#1
Hi, in this tutorial I'll be teaching you different ways of circumventing Suhosin in PHP in order to get command execution.
First, what is Suhosin?
From their website, http://www.suhosin.org -
Onto the tutorial
This tutorial assumes that you have already shelled the server or found a way to shell it.
Lets start off with the command execution functions that Suhosin usually blocks -
Some of them are different, but they all do at least one thing, execute commands on the server. However, we are unable to use those functions directly thanks to Suhosin disabling them.
But who said we had to play by the rules and use them directly? We can use some nice things called callback functions, and use the blocked functions indirectly. I'll be introducing one of them to you in this thread, and leave a list at the bottom so you can get creative yourself.
In this tutorial we're going to be using call_user_func() which is probably the easiest to use.
call_user_func() takes a callable callback as the first parameter (which will be our command execution function), and passes the remaining parameters as arguments in our callable callback function.
So how do we use this to circumvent Suhosin? It's really simple. We use one of the command execution functions as the first parameter and whatever command we want to execute as the second parameter. Here's what it would look like -
That would be the equivalent to running system('id');, the only difference is that the function is being passed through call_user_func() and therefor isn't being blocked by Suhosin. Obviously, you can replace "system" with any of the command execution functions mentioned earlier and it will work the same (unless you use proc_open, you'd have to change the parameters). Also, some command execution functions return output and others don't. If you test this and don't see any output, don't assume it doesn't work.
More callback functions
Here are some other callback functions you can play with to get command execution just in case the one above is blocked. Some require more little tweaks than others in order to work.
End
If anyone has a suggestion for the thread or thinks I should add something I missed just post below.
@Megan first one, is it good?
First, what is Suhosin?
From their website, http://www.suhosin.org -
Spoiler:
Suhosin (pronounced 'su-ho-shin') is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core. Suhosin comes in two independent parts, that can be used separately or in combination. The first part is a small patch against the PHP core, that implements a few low-level protections against buffer overflows or format string vulnerabilities and the second part is a powerful PHP extension that implements numerous other protections.
Onto the tutorial
This tutorial assumes that you have already shelled the server or found a way to shell it.
Lets start off with the command execution functions that Suhosin usually blocks -
Code:
system()
exec()
shell_exec()
`` (backticks, same as shell_exec())
passthru()
proc_open()But who said we had to play by the rules and use them directly? We can use some nice things called callback functions, and use the blocked functions indirectly. I'll be introducing one of them to you in this thread, and leave a list at the bottom so you can get creative yourself.
In this tutorial we're going to be using call_user_func() which is probably the easiest to use.
Code:
mixed call_user_func ( callable $callback [, mixed $parameter [, mixed $... ]] )call_user_func() takes a callable callback as the first parameter (which will be our command execution function), and passes the remaining parameters as arguments in our callable callback function.
So how do we use this to circumvent Suhosin? It's really simple. We use one of the command execution functions as the first parameter and whatever command we want to execute as the second parameter. Here's what it would look like -
PHP Code:
call_user_func('system', 'id');
That would be the equivalent to running system('id');, the only difference is that the function is being passed through call_user_func() and therefor isn't being blocked by Suhosin. Obviously, you can replace "system" with any of the command execution functions mentioned earlier and it will work the same (unless you use proc_open, you'd have to change the parameters). Also, some command execution functions return output and others don't. If you test this and don't see any output, don't assume it doesn't work.
More callback functions
Here are some other callback functions you can play with to get command execution just in case the one above is blocked. Some require more little tweaks than others in order to work.
Code:
mixed call_user_func_array ( callable $callback , array $param_arr )
array array_map ( callable $callback , array $array1 [, array $... ] )
void register_shutdown_function ( callable $callback [, mixed $parameter [, mixed $... ]] )End
If anyone has a suggestion for the thread or thinks I should add something I missed just post below.
@Megan first one, is it good?

![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)










![[Image: 7ajmN5P.jpg]](https://i.imgur.com/7ajmN5P.jpg)









![[Image: 9JVyFsC.png]](http://i.imgur.com/9JVyFsC.png)
). I should've probably used a different thread title.