sqlmap源码解析(二)

sqlmap源码解析(二)

init()

_basicOptionValidation

这里检查了所有的参数的正确性并给出使用建议


sqlmap源码解析(二)_第1张图片
-w856

_listTamperingFunctions

这里有一个可以列举tamper 的方法=。=
以前居然不知道

sqlmap源码解析(二)_第2张图片
-w848

-w651

可以找到用--list-tamper就可以打开
sqlmap源码解析(二)_第3张图片
-w918

__priority__通过这个做标识符来匹配下面的介绍

_setTamperingFunctions

加载插件

首先判断文件存在不存在以及更改工作路径等事情
然后用内置函数import()将文件导入

-w540

在对插件的优先级进行判断

_setTrafficOutputFP

没想到sqlmap还可以将http记录到文件中
只要-t参数就好了

_setHostname

从url中取出hostname

_doSearch

之前全是很简单的给请求头赋值
这里看样子有点意思了

    This function performs search dorking, parses results
    and saves the testable hosts into the knowledge base.

可以直接获得google搜索的结果
可以这样用
sqlmap -g "inurl:\".php?id=1\""
不过我的命令行好像连接不到google

_setBulkMultipleTargets()

sqlmap 的 -m参数
getFileItems
在这里读取文件
将文件中的url一个一个读取放到kb.target

_setSitemapTargets

sqlmap的-x的参数
通过parseSitemap来解析target
将url从Sitemap中提取出来

_setCrawler

--crawl:从起始位置爬站深度
如果没有标签
访问一个网站用
r'(?i)]+href="(?P[^>"]+)"'这个正则
将别的url提取出来

checkSameHost

sqlmap 在爬虫的时候对相同url的处理

findPageForms

Parses given page content for possible forms (Note: still not implemented for Python3)

>> findPageForms('
', '') set([(u'/input.php', 'POST', u'id=1', None, None)])

从form中获得所有的参数

使用了clientform的ParseResponse来解析


sqlmap源码解析(二)_第4张图片
-w427

没了解过这个第三方库以后学习一下

loadBoundaries

sqlmap源码解析(二)_第5张图片
-w203

接下来都是一些set来初始化的
sqlmap源码解析(二)_第6张图片
-w689

这两个差不多最后都用了 parseXmlNode来解析了xml

parseXmlNode

    for element in node.getiterator("boundary"):
        boundary = AttribDict()

        for child in element.getchildren():
            if child.text:
                values = cleanupVals(child.text, child.tag)
                boundary[child.tag] = values
            else:
                boundary[child.tag] = None

        conf.boundaries.append(boundary)

    for element in node.getiterator("test"):
        test = AttribDict()

        for child in element.getchildren():
            if child.text and child.text.strip():
                values = cleanupVals(child.text, child.tag)
                test[child.tag] = values
            else:
                if len(child.getchildren()) == 0:
                    test[child.tag] = None
                    continue
                else:
                    test[child.tag] = AttribDict()

                for gchild in child.getchildren():
                    if gchild.tag in test[child.tag]:
                        prevtext = test[child.tag][gchild.tag]
                        test[child.tag][gchild.tag] = [prevtext, gchild.text]
                    else:
                        test[child.tag][gchild.tag] = gchild.text

        conf.tests.append(test)

差不多就是解析处理了之后放入到conf中

update

--update这个命令行可以更新
首先先检查有没有.git文件
然后会询问要不要通过zip来下载安装

一个通过https://github.com/sqlmapproject/sqlmap/zipball/master下来zip来更新

另一个这样更新git checkout . && git pull %s HEAD

后记

终于看完了init要往下继续看了=。=
是我看的太不认真了

你可能感兴趣的:(sqlmap源码解析(二))