将时间还原到2019年6月之前,扫描器的世界大多还停留在AWVS这样的主动扫描器,被动扫描曾被提出作为浏览器插件火热过一段时间,可惜效率太低等多种问题束缚着它的发展。随着Xray的发布,一款免费好用的被动扫描器从很多方面都带火了自动化漏洞扫描的风潮。
-
https://github.com/0Kee-Team/crawlergo
-
https://github.com/knownsec/LSpider
LSpider想要做到什么?
爬虫基础
-
配置Chrome Headless
self.chrome_options.add_argument('--headless')
self.chrome_options.add_argument('--disable-gpu')
self.chrome_options.add_argument('--no-sandbox')
self.chrome_options.add_argument('--disable-images')
self.chrome_options.add_argument('--ignore-certificate-errors')
self.chrome_options.add_argument('--allow-running-insecure-content')
self.chrome_options.add_argument('blink-settings=imagesEnabled=false')
self.chrome_options.add_argument('--omnibox-popup-count="5"')
self.chrome_options.add_argument("--disable-popup-blocking")
self.chrome_options.add_argument("--disable-web-security")
self.chrome_options.add_argument("--disk-cache-size=1000")
if os.name == 'nt':
chrome_downloadfile_path = "./tmp"
else:
chrome_downloadfile_path = '/dev/null'
prefs = {
'download.prompt_for_download': True,
'profile.default_content_settings.popups': 0,
'download.default_directory': chrome_downloadfile_path
}
desired_capabilities = self.chrome_options.to_capabilities()
if IS_OPEN_CHROME_PROXY:
logger.info("[Chrome Headless] Proxy {} init".format(CHROME_PROXY))
desired_capabilities['acceptSslCerts'] = True
desired_capabilities['acceptInsecureCerts'] = True
desired_capabilities['proxy'] = {
"httpProxy": CHROME_PROXY,
"ftpProxy": CHROME_PROXY,
"sslProxy": CHROME_PROXY,
"noProxy": None,
"proxyType": "MANUAL",
"class": "org.openqa.selenium.Proxy",
"autodetect": False,
}
self.driver.set_page_load_timeout(15)
self.driver.set_script_timeout(5)
self.origin_url = url
self.driver.implicitly_wait(5)
self.driver.get(url)
if cookies:
self.add_cookie(cookies)
self.driver.implicitly_wait(10)
self.driver.get(url)
-
模拟点击以及智能填充
links = self.driver.find_elements_by_xpath('//a')
link = links[i]
href = link.get_attribute('href')
self.driver.execute_script(
"atags = document.getElementsByTagName('a');for(i=0;i<=atags.length;i++) { if(atags[i]){atags[i].setAttribute('target', '')}}")
if link.is_displayed() and link.is_enabled():
link.click()
self.check_back()
if submit_button.is_displayed() and submit_button.is_enabled():
action = ActionChains(self.driver)
action.move_to_element(submit_button).perform()
submit_button.click()
智能表单填充
form -> 文本中出现login、登录、sign等
button -> outerHTML出现login、user、pass等
input -> outerHTML出现登录、注册等关键词
a -> 文本出现login、登录、sign等
当前页面满足上述任一条件时,则会记录下来到相应的位置(后续会提到)。然后会尝试填充页面的所有框框。
inputs = self.driver.find_elements_by_xpath("//input")
self.driver.execute_script(
"itags = document.getElementsByTagName('input');for(i=0;i<=itags.length;i++) { if(itags[i]){itags[i].removeAttribute('style')}}")
input_lens = len(inputs)
if not inputs:
return
for i in range(input_lens):
try:
input = inputs[i]
# 移动鼠标
# 如果标签没有隐藏,那么移动鼠标
if input.is_enabled() and input.is_displayed():
action = ActionChains(self.driver)
action.move_to_element(input).perform()
-
结果去重
BLACK_DOMAIN_NAME_LIST = ['docs', 'image', 'static', 'blogs']
https://lorexxar.cn/2020/10/30/whitebox-2/
就会被泛化为AAAB
BLACK_PATH_NAME = ['static', 'upload', 'docs', 'js', 'css', 'font', 'image']
whitebox-2
,如果不同,则判定为拥有1个不同点。且如果当前B段为路径的最后一部分,举例子为:https://lorexxar.cn/2020/10/30/whitebox-2/a.php
完成整体架构
对于一个扫描器来说,最重要的就是稳定以及速度。
-
加入登录页面检查以及紧急队列
-
通过webhook+企业微信应用管理任务进度
写在LSpider之后
往 期 热 门
(点击图片跳转)
本文始发于微信公众号(Seebug漏洞平台):为被动扫描器量身打造一款爬虫 —LSpider
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论