Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- fopen without privileges --SKIPIF-- <?php if (!extension_loaded('pcap')) { echo '..
Decoded Output download
skip pcap ext not loadedskip posix not loaded
Did this file decode correctly?
Original Code
--TEST--
fopen without privileges
--SKIPIF--
<?php
if (!extension_loaded('pcap')) { echo 'skip pcap ext not loaded'; }
if (!extension_loaded('posix')) { echo 'skip posix not loaded'; }
if (posix_getuid()) { echo 'skip root only'; }
?>
--FILE--
<?php
declare(strict_types = 1);
require('helpers.php');
$dev = current(array_keys(net_get_interfaces()));
if (!$dev) {
die('Cannot find any viable network devices');
}
$user = posix_getpwnam('daemon');
if (empty($user) || empty($user['uid'])) {
die('Cannot find a suitable non-root user');
}
posix_setuid($user['uid']);
posix_seteuid($user['uid']);
posix_setgid($user['gid']);
posix_setegid($user['gid']);
$fp = fopen('pcap://' . $dev, 'r');
var_dump($fp);
?>
--EXPECTF--
Warning: fopen(): Cannot open raw sockets (check privileges or CAP_NET_RAW capability) in %s on line %d
Warning: fopen(pcap://%s): %s to open stream: operation failed in %s on line %d
bool(false)
Function Calls
posix_getuid | 1 |
extension_loaded | 2 |
Stats
MD5 | 88966b1244680517c74c558a69ab2aa8 |
Eval Count | 0 |
Decode Time | 195 ms |