0×01:简介
在运用GoogleHack进行SQL注入点查询时,手艺的办法一般为经过谷歌语法的inurl判别是否存在动态查询参数,然后对查询的网站url进行手艺判别是否存在SQL注入缝隙,如or 1=1 , or 1=2, 加单引号等 *** 。
在实践履行过程中,能够经过爬虫技能,定位谷歌搜索特定句子查询出的或许存在缝隙的URLS。并将这些URL经过IO写入文件中,便利履行后续的扫描作业。
这时候或许有观众要问,这个功用现已集成到了SQLMAP的谷歌模块中了,经过运用sqlmap -g 搜索句子就能够直接进行批量化扫描了。可是在笔者实践测验中发现,对英文字母的搜索句子如:https://www.google.com.hk/search?q=inurl:php?id= ,SQLMAP能够正确的进行查询,经过测验发现其测验的句子契合咱们真真实谷歌环境中搜索到的网址。可是一旦咱们有特别的需求,如搜索特定区域的url,搜索存在中文字符的网站内容的url如:
https://www.google.com.hk/search?q=inurl:php?id= -site:stackoverflow.com -site:php.net intext:王小强
则SQLMAP会主动过滤intext句子中的中文,回来不加过滤后的成果。
在实践测验中,英文字母的intext不受影响。
基于此,咱们能够运用Python爬虫获取到谷歌搜索的URL生成TXT文件,在运用SQLMAP(或其他SQL扫描东西),进行二次扫描。
0×02:Python爬虫爬取链接
因为谷歌对灵敏句子的安全措施,首先要设置署理池和定制头
代码如下:
import requests
from lxml import etree
import io
import sys
proxies = { "http": "http://142.93.130.xxx:8118", "https": "http://31.220.51.xxx:80" }
headers={
'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'accept-encoding':'gzip, deflate, sdch, br',
'cache-control':'max-age=0',
'upgrade-insecure-requests':'1',
'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0',
'Referer': 'https://www.google.com.hk/',
//cookie可加可不加
r=requests.get('https://www.google.com.hk/search?q=inurl:php?id= -site:stackoverflow.com -site:php.net intext:王小强&lr=lang_zh-CN&num=5000',headers=headers,)
然后运用requests库恳求谷歌的搜索句子
r=requests.get('https://www.google.com.hk/search?q=inurl:php?id= -site:stackoverflow.com -site:php.net intext:王小强&lr=lang_zh-CN&num=5000',headers=headers,)
其间对lr标签设置能够只回来中文成果。
然后运用xpath定位咱们需求的成果的DOM地址
e=etree.HTML(r.text)
# print(e.xpath('//div/node()'))
name=e.xpath('//h3[@class="997c-289a-7f68-0714 LC20lb"]/node()')
url=e.xpath('//cite[@class="289a-7f68-0714-9122 iUh30"]/node()')
# print(name)
# print(url)
filename='ip.txt'
with open(filename,'w',encoding='utf-8') as f:
for i in url:
f.write(i+'n')
# print(name)
# print(url)
class的姓名能够依据实践情况中的成果进行更改。
最终将成果写入txt文件中即可。
0×03:Url存活性查验
在实践中咱们发现,这样得到的IP地址有很多是没有呼应的,假如对一切的地址进行扫描,会十分费时吃力,咱们要进行二次过滤,运用Python批量对地址进行恳求, 过滤掉不呼应或呼应过慢的网页。
详细代码完成如下
import socket
import asyncio
import sys
import queue
import threading
import requests
iplist=[]
class socket1():
def __init__(self,i):
self.i=i
# print(target)
def scan(self,ip,i):
# print("start scan")
# print(s.connect_ex((self.target,80)))
# for i in range(1,100):
# print(i)
s=requests.get(ip,timeout=6)
if s.status_code==200:
# print(ip,'open')
iplist.append(ip)
def worker(self,q):
while not q.empty():
ip=str(q.get())
if ('http' or 'https') in ip:
ip=ip
else:
ip='http://'+ip
print(ip)[1][2][3]黑客接单网