加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

聊一聊SQLMAP在举办SQL注入时的整个流程

发布时间:2019-07-05 20:54:25 所属栏目:建站 来源:sher10ck
导读:许多小搭档在发明可能判定出注入的时辰,大大都选择就是直接上sqlmap,功效每每也不尽人意,于是就有设法来写写 sqlmap 从执行到判定注入,到底产生了什么? 本文就用我们看的见的角度来说明,看看sqlmap到底发送了什么payload,这些payload是怎么出来的,
副问题[/!--empirenews.page--]

许多小搭档在发明可能判定出注入的时辰,大大都选择就是直接上sqlmap,功效每每也不尽人意,于是就有设法来写写 sqlmap 从执行到判定注入,到底产生了什么?

本文就用我们看的见的角度来说明,看看sqlmap到底发送了什么payload,这些payload是怎么出来的,不深入代码层面。

测试情形:

  1. sqlmap(1.3.6.58#dev)  
  2. Burp Suite  
  3. http://attack.com?1.php?id=1 

测试方法

操作 sqlmap 的 proxy 参数,我们将署理配置为 8080 端口用 burpsuite 举办抓包。

  1. sqlmap.py -u "http://attack.com?1.php?id=1" --proxy="http://127.0.0.1:8080" 

(测试了好久仿佛当地搭建的情形无法抓包,以是就找了有注入点的网站,裂痕已上报给裂痕平台)

抓取到的包如下 :

聊一聊SQLMAP在举办SQL注入时的整个流程

sqlmap 的筹备事变

我们也调查到,sqlmap 默认发送的 User-Agent 是这样的。

  1. User-Agent: sqlmap/1.3.6.58#dev (http://sqlmap.org) 

所觉得了停止被 waf 可能日记内里记录,我们一样平常可以添加一个 --random-agent 参数在后头。

起首我们的 sqlmap 会持续发送出很大都据包来检测方针网站是否不变:

  1. GET /xxxx.php?id=1 HTTP/1.1 
  2. Host: www.xxxx.xxx 
  3. Accept: */* 
  4. User-Agent: sqlmap/1.3.6.58#dev (http://sqlmap.org) 
  5. Connection: close 
  6. Cache-Control: no-cache 
  7.  
  8. [INFO] testing connection to the target URL 
  9. [INFO] testing if the target URL content is stable 
  10. [INFO] target URL content is stable 

接下来会检测是否为 dynamic,和上面的哀求包对比,sqlmap 修改了 id 后头的值。

  1. GET /xxxx.php?id=2324 HTTP/1.1 
  2. Host: www.xxx.xxx 
  3. Accept: */* 
  4. User-Agent: sqlmap/1.3.6.58#dev (http://sqlmap.org) 
  5. Connection: close 
  6. Cache-Control: no-cache 
  7.  
  8. [INFO] testing if GET parameter 'id' is dynamic 

看不懂这是什么骚操纵,我们来看看源码内里怎么说 (sqlmaplibcontrollerchecks.py)。

  1. def checkDynParam(place, parameter, value): 
  2.     """ 
  3.     This function checks if the URL parameter is dynamic. If it is 
  4.     dynamic, the content of the page differs, otherwise the 
  5.     dynamicity might depend on another parameter. 
  6.     """ 

按照输出语句的要害词查找,我追踪到了这个 checkDynParam 函数,或许的浸染就是修改我们此刻获取到的参数值,看修改前后的页面返回是否沟通(有的时辰注入有多个参数,那么有些无关紧急的参数修改后页面是没有变革的),如有变革(可能嗣魅这个参数是真实有用的),sqlmap 才会走到下一步。

下一步的数据包和成果如下:

  1. GET /xxxx.php?id=1%27.%29%2C%2C.%28.%29%22 HTTP/1.1 
  2. Host: www.xxx.xxx 
  3. Accept: */* 
  4. User-Agent: sqlmap/1.3.6.58#dev (http://sqlmap.org) 
  5. Connection: close 
  6. Cache-Control: no-cache 
  7.  
  8. [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL') 

我们将上面的 url 编码解码:

  1. /xxxx.php?id=1%27.%29%2C%2C.%28.%29%22 
  2. /xxxx.php?id=1'.),,.(.)" 

这几个字符串就能判定是 MySQL 数据库?又是什么骚操纵,再看看源码吧 (sqlmaplibcontrollerckecks.py):

  1. infoMsg += " (possible DBMS: '%s')" % Format.getErrorParsedDBMSes() 

找到了一条语句,跟踪这个 getErrorParsedDBMSes() 函数。

  1. def getErrorParsedDBMSes(): 
  2.         """ 
  3.         Parses the knowledge base htmlFp list and return its values 
  4.         formatted as a human readable string. 
  5.  
  6.         @return: list of possible back-end DBMS based upon error messages 
  7.         parsing. 
  8.         @rtype: C{str} 
  9.         """ 

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读