一、password=md5($pass,true)绕过这个是只能用于基于MySQL数据库进行的登录判断SQL注入绕过。这个问题的发生是在这个场景下。场景:$pass = md5($_POST['pass'],true); $sql = "SELECT * FROM admin where pass='$pass'"; $result = $conn->query($sql); if ($result->num_rows != 0) { echo "success"; //后续操作 } else { echo "password error or user not found!"; }这个场景看上去很安全是吧?直接将用户提交的密码字符串经过MD5加密后直接拼接在SQL语句中,按照常规思想确实没有办法进行SQL注入,但是这里我们可以构造一个十分巧妙的输入来使where子句永真。md5($pass, true)函数这个函数会返回$pass的MD5原始16字符二进制格式。这也是我们这次绕过的原理。
一、定义PHP中的弱比较运算符,可以实现一些比较奇怪的比较方法,常见于各种CTF题目的绕过中,使用两个等号 == 比较,只比较值,不比较类型。二、字符串与数字php中其中两种比较符号:\=\=:先将字符串类型转化成相同,再比较\=\=\=:先判断两种字符串的类型是否相等,再比较字符串和数字比较使用\=\=时,字符串会先转换为数字类型再比较var_dump('a' == 0);//true,此时a字符串类型转化成数字,因为a字符串开头中没有找到数字,所以转换为0var_dump('123a' == 123);//true,这里'123a'会被转换为123var_dump('a123' == 123);//false,因为php中有这样一个规定:字符串的开始部分决定了它的值,如果该字符串以合法的数字开始,则使用该数字至和它连续的最后一个数字结束,否则其比较时整体值为0。举例:var_dump('123a1' == 123);//truevar_dump('1233a' == 123);//false<、>、<=、>=都存在和\=\=相同的弱类型,原理相同!!!三、布
定义PHP反序列化可以将一个对象转换为一个字符串保存起来,这将导致类中的成员可被用户控制,同时PHP在反序列化时会触发一些魔术函数,若这些魔术函数中含有危险函数且危险函数的参数是类的成员变量,即可导致越权访问或者命令执行。主要涉及到两个函数:serialize($o):将对象序列化为字符串unserialize($str):将字符串反序列化为对象序列化字符串解析PHP序列化对象只会序列化对象的成员变量,对三个类型的成员变量有不同的标志方法。例:class Obj { public $int = 2; protected $str = "2"; private $a = "a"; } $o = new Obj(); echo serialize($o);O:3:"Obj":3:{s:3:"int";i:2;s:6:"%00*%00str";s:1:"2";s:6:"%00Obj%00a";s:1:"a"
漏洞简介本漏洞是由escapeshellarg()和escapeshellcmd()两个函数对同一个需要过滤的shell命令字符串依次进行转义导致的参数逃逸问题,可以执行主命令的其他选修参数。escapeshellarg()与escapeshellcmd()escapeshellarg() 将给字符串增加一个单引号并且能引用或者转码任何已经存在的单引号,这样以确保能够直接将一个字符串传入shell函数,并且还是确保安全的。对于用户输入的部分参数就应该使用这个函数。shell 函数包含 exec(), system() 执行运算符 。127.0.0.1' -d -v test =>'127.0.0.1'\'' -v -d a=1'escapeshellcmd() 对字符串中可能会欺骗 shell 命令执行任意命令的字符进行转义。 此函数保证用户输入的数据在传送到 exec() 或 system() 函数,或者 执行操作符 之前进行转义。反斜线(\)会在以下字符之前插入: \`|*?~<>^()[]{}$\, \x0A 和 \xFF。 ' 和 " 仅在不配
前置知识可变变量这是PHP的一个特性,允许一个变量中的内容作为变量名使用,作用上类似于其他的指针。代码示例$a = "Cat"; $b = "a"; $$b = "Dog"; echo $a;运行结果:Dogextract()函数extract()函数从数组中将变量导入到当前的符号表。该函数使用数组键名作为变量名,使用数组键值作为变量值。针对数组中的每个元素,将在当前符号表中创建对应的一个变量。该函数返回成功设置的变量数目。用PHP代码进行实现的话:foreach($my_array as $x => $y) { $$x = $y; }参考: 菜鸟教程代码示例$a = "Original"; $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse"); extract($my_array); e
Equinox
一个乐于分享的网安人