美文网首页
phpd代码审计

phpd代码审计

作者: liamu | 来源:发表于2017-08-07 23:06 被阅读33次

*获取源码

*网站结构

*入口文件

*配置文件

*过滤功能

审计方法-通读全文法
disable_functions
disable_classes
safe_mode=off
safe_mode_exec_dir=/var/www/html
file_uploads=on
upload_max_filesize=8M
文件上传目录
upload_tmp_dir=
用户访问目录限制
open_basedir=
display_error=on
error_reporting=E_ALL
error_log=
log_errors=on
log_errors_max_length=1024
magic_quotes_gpc=On
magic_quotes_runtime=Off
allow_url_fopen = on
allow_url_include = Off

常见危险函数及特殊函数

eval()
assert()
preg_replace()
preg_replace("/test/e",$_GET['h'],"just test");
?h=phpinfo(),phpinfo()将会执行

create_function()
call_user_func()
call_func_array()

require
include
require_once
include_once

命令执行函数

exec()
passthru()
proc_open()
shell_exec()
system()
popen()

文件操作函数
copy
file_get_contents
file_put_contents
file
fopen
move_uploaded_file
readfile
rename
rmdir
unlink & delete

特殊函数
phpinfo()
symlink()
getenv()
putenv()
dl()

配置相关
ini_get()
ini_set
ini_alter
ini_restore

数字判断
is_numeric

数组相关
in_array

变量覆盖

parse_str()
mb_parse_str
extract()
import_request_variables()

列目录
glob

无参数获取信息
get_defined_vars
get_defined_constants
get_defined_functions
get_includes_files

<?php 
error_reporting(E_ALL);

print_r($_GET);

print_r($_POST);

echo "The var \$test is ".(isset($test)?"defined :\$test=$test":"undefined");

$tag_var = 'short tags';
?>

<?= $tag_var?>
<?php echo system('whoami');
print_r(scandir(dirname(__FILE__)));
echo "\r\n";
print_r(scandir(dirname(__FILE__)."/../"));




@eval('echo "test"');
echo "\r\n";
echo 'test';

assert('system("whoami");');

preg_replace("/test/e", "phpinfo();", "just test");
$cfunc = create_function('$v', 'return system($v);');
$cfunc('whoami');

$sfunc = 'sys'.'tem';
$sfunc('whoami');


function test($var){
    echo 'callable test '.$var;
}
call_user_func('test','amu');
call_user_func('system','whoami');



?>
<?php 
/*
echo "\r\n<br/>allow_url_include=".(ini_get('allow_url_include')?'On':'Off');
echo "\r\n<br/>allow_url_fopen=".(ini_get('allow_url_fopen')?'On':'Off');
echo "\r\n";
include($_GET['v']);
*/

/*
echo shell_exec('ping 127.0.0.1');
echo shell_exec('ping '.$_GET["v"]);//?v=127.0.0.1 | whoami
*/
/*
file_put_contents('fpc.test', 'test');
file_put_contents('fpc.test', file_get_contents("http://www.baidu.com"));
unlink('fpc.test');
*/

/*
var_dump(getenv('test'));
putenv('test=123');
echo "\r\ntest=".getenv('test');
*/

/*
echo "\r\n<br/>display_errors=".(ini_get('display_errors')?'On':'Off');
ini_set("display_errors", 0);
echo "\r\n<br/>display_errors=".(ini_get('display_errors')?'On':'Off');
*/

/*
echo "is_numeric :";
var_dump(is_numeric($_GET["v"]));//?v=127'   ?v=0e1   ?v=0x123
echo "\r\n";
echo "output :".$_GET["v"];
echo "\r\n";
echo "intval :".intval($_GET["v"]);
*/


/*
$v = 1;
var_dump(in_array($v, array("1",2,3)));
echo "\r\n";;

$a = '1abc';  // '1abc' == 1
in_array($a, array(1,2,3));//in_array($a, array(1,2,3),true);
in_array($a, array("2",2,3));
*/

/*
$str = "first=value&arr[]=foobar&arr[]=baz";
echo "<pre>";
parse_str($str,$array);
print_r($array);

var_dump(isset($first));

parse_str($str);
var_dump(isset($first));
echo "\$arr[0]=$arr[0]";
echo "\$arr[1]=$arr[1]";
*/

/*
echo "<pre>";
print_r(glob("t*.php"));
*/


echo "<pre>";
$test = 'test';
print_r(get_defined_vars());

define("TEST", 'test');
echo "<pre>";
print_r(get_defined_constants(true));

function abc(){}
print_r(get_defined_functions());
 ?>
<?php
$password = 'sfdsfsdfsdfdffdfdf';
if (isset($_POST['passwd'])) {
    $pass = $_POST['passwd'];
    if ($pass === $_POST['passwd']) {
        webshell();
    } else {
        echo "password is error";
    }
    
} else {
    echo '<form action="" method=post><input type="text" name="passwd" /><input type="submit" name="login" value="login"></form>';
    exit;
}

function webshell(){
    echo "this is a test";
}

Xdebug的配置PHP.ini

xdebug.auto_trace = 1
xdebug.trace_format = 0
xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug"
xdebug.trace_options = 0

xdebug.collect_params = 4
xdebug.collect_return = 1
xdebug.collect_vars = 1
xdebug.collect_assignments = 1

xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug"
xdebug.profiler_output_name = "cache.out.%t-%s"

xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
zend_extension="D:\phpStudy\php\php-5.4.45\ext\php_xdebug.dll"

相关文章

  • phpd代码审计

    *获取源码 *网站结构 *入口文件 *配置文件 *过滤功能 审计方法-通读全文法disable_functions...

  • 【代码审计】PHP代码审计

    1. 概述 代码审核,是对应用程序源代码进行系统性检查的工作。它的目的是为了找到并且修复应用程序在开发阶段存在的一...

  • 代码审计

    代码审计工具 1、三款自动化代码审计工具教程2、seay源代码审计系统 PHP核心配置详解 注意PHP各个版本中配...

  • 🎐代码审计

    ?源代码审计分为白盒、黑盒、灰盒 白盒:拥有源代码进行审计黑盒:不知道源代码的情况下进行渗透审计灰盒:介于黑盒与白...

  • 2021-12-06-java代码审计初步认知

    一、代码审计的定义代码审计是一种以发现安全漏洞,程序错误和程序违规为目标的源代码分析技能。 二、代码审计需要的能力...

  • 代码审计初尝

    @(代码审计学习笔记) [TOC] 代码审计初尝 [图片上传失败...(image-f76662-15823837...

  • 代码审计思路之PHP代码审计

    00×0 前言 最近也是边挖src边审计代码,总结下最近的php代码审计的一些思路,我一般按照顺序往下做,限于能力...

  • 代码审计从入门到放弃(三) & phplimit

    前言 接着前面的代码审计从入门到放弃(一) & function、代码审计从入门到放弃(二) & pcrewaf ...

  • [代码审计] XIAO CMS审计

    XIAO CMS审计 翻安全客的时候看到xiao cms爆了6个cve审计一下 任意目录删除 上传任意文件 很明显...

  • 攻防世界(进阶)--WEB--8.Web_php_unseria

    考察点:php代码审计 1.进入场景,得到php代码 2.化简代码,审计 3.写脚本 得到参数:TzorNDoiR...

网友评论

      本文标题:phpd代码审计

      本文链接:https://www.haomeiwen.com/subject/nsjzlxtx.html