处理awvs10.5扫描后生成的xml文件
简单介绍
Awvs是一个常见Web漏洞扫描工具。
如果想搭建一个自动化扫描的云平台,那么里面的Web扫描模块,可以选用awvs作为扫描引擎。 可以用php写好前端页面,然后下发命令,在后端用python去接受扫描命令的参数,如url。
这个时候后端的就调用awvs去扫描,awvs扫描后会生成一个report.xml。这个时候能写一个处理这个xml文件的python脚本就至关重要了。
这个awvs出来的结果,它的xml的格式是非常整齐的。
SiteFile id="10"
Nameconference.php/Name
URL/investor/conference.php/URL
FullURLhttp://www.weikeng.com.tw/investor/conference.php/FullURL
Inputs
Variable Name="lan" Type="URL encoded GET"
/Variable
/Inputs
Variations
Variation
URLhttp://www.weikeng.com.tw/investor/conference.php?lan=tw/URL
PostData![CDATA[]]/PostData
/Variation
Variation
URLhttp://www.weikeng.com.tw/investor/conference.php?lan=en/URL
PostData![CDATA[]]/PostData
/Variation
/Variations
/SiteFile
SiteFile id="11"
Namequarterly.php/Name
URL/investor/quarterly.php/URL
FullURLhttp://www.weikeng.com.tw/investor/quarterly.php/FullURL
Inputs
Variable Name="lan" Type="URL encoded GET"
/Variable
/Inputs
Variations
Variation
URLhttp://www.weikeng.com.tw/investor/quarterly.php?lan=tw/URL
PostData![CDATA[]]/PostData
/Variation
Variation
URLhttp://www.weikeng.com.tw/investor/quarterly.php?lan=en/URL
PostData![CDATA[]]/PostData
/Variation
/Variations
/SiteFile
这个脚本就以 SiteFile id="xx"为单位,遍历去提取当中有用的信息。如URL,FullURL,路径,Get方式和post方式的变量和变量值等等。。
如何存放数据?
我是定义了一个字典,去装这其中的数据。
#初始化一个字典,用来装载数据
sitefile ={ "StartUrl":StartUrl, #起始地址
"FileName":"",#文件名 不是文件不要入,文件夹的话,该字段为0
"URL":"",
"FullURL":"", #完整的url
"Dir1":"", #1级文件夹
"Dir2":"", #2级文件夹
"Dir3":"", #3级文件夹
"DirLen":"", #目录深度
"GVariation1": "",#get方式的变量
"GVariation2": "",#get方式的变量
"PVariation1": "",#post方式的变量
"PVariation2": "",
"PValue1": "",#PVariation1的值
"PValue2": "",
"OthersDir":""#超过3级后的所有路径
}
最终效果
由于字典是无序的,所以输出有点乱~~
但是如果字典方便取值,maybe u can have a good idea!!!hhhhh
完整代码:
备注:
发在t00ls论坛上后,有人回复说结果有点乱。
maybe 你可以用prettytable处理一下,可是我不是为了好看哈哈
因为这还有别的用途~~~