網(wǎng)站滲透常用Python小腳本查詢同ip網(wǎng)站
旁站查詢來源:
http://dns.aizhan.com
http://s.tool.chinaz.com/same
http://i.links.cn/sameip/
http://www.ip2hosts.com/
效果圖如下:
以百度網(wǎng)站和小殘博客為例:


PS:直接調(diào)用以上4個(gè)旁注接口查詢同服服務(wù)器域名信息包含服務(wù)器類型 比如小殘博客使用的是Tengine
#!/usr/bin/env python
#encoding: utf-8
import re
import sys
import json
import time
import requests
import urllib
import requests.packages.urllib3
from multiprocessing import Pool
from BeautifulSoup import BeautifulSoup
requests.packages.urllib3.disable_warnings()
headers = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20'}
def links_ip(host):
'''
查詢同IP網(wǎng)站
'''
ip2hosts = []
ip2hosts.append("http://"+host)
try:
source = requests.get('http://i.links.cn/sameip/' + host + '.html', headers=headers,verify=False)
soup = BeautifulSoup(source.text)
divs = soup.findAll(style="word-break:break-all")
if divs == []: #抓取結(jié)果為空
print 'Sorry! Not found!'
return ip2hosts
for div in divs:
#print div.a.string
ip2hosts.append(div.a.string)
except Exception, e:
print str(e)
return ip2hosts
return ip2hosts
def ip2host_get(host):
ip2hosts = []
ip2hosts.append("http://"+host)
try:
req=requests.get('http://www.ip2hosts.com/search.php?ip='+str(host), headers=headers,verify=False)
src=req.content
if src.find('result') != -1:
result = json.loads(src)['result']
ip = json.loads(src)['ip']
if len(result)>0:
for item in result:
if len(item)>0:
#log(scan_type,host,port,str(item))
ip2hosts.append(item)
except Exception, e:
print str(e)
return ip2hosts
return ip2hosts
def filter(host):
'''
打不開的網(wǎng)站...
'''
try:
response = requests.get(host, headers=headers ,verify=False)
server = response.headers['Server']
title = re.findall(r'<title>(.*?)</title>',response.content)[0]
except Exception,e:
#print "%s" % str(e)
#print host
pass
else:
print host,server
def aizhan(host):
ip2hosts = []
ip2hosts.append("http://"+host)
regexp = r'''<a href="[^']+?([^']+?)/" rel="external nofollow" target="_blank">\1</a>'''
regexp_next = r'''<a rel="external nofollow" >%d</a>'''
url = 'http://dns.aizhan.com/%s/%d/'
page = 1
while True:
if page > 2:
time.sleep(1) #防止拒絕訪問
req = requests.get(url % (host , page) ,headers=headers ,verify=False)
try:
html = req.content.decode('utf-8') #取得頁面
if req.status_code == 400:
break
except Exception as e:
print str(e)
pass
for site in re.findall(regexp , html):
ip2hosts.append("http://"+site)
if re.search(regexp_next % (page+1 , page+1) , html) is None:
return ip2hosts
break
page += 1
return ip2hosts
def chinaz(host):
ip2hosts = []
ip2hosts.append("http://"+host)
regexp = r'''<a href='[^']+?([^']+?)' target=_blank>\1</a>'''
regexp_next = r'''<a href="javascript:" rel="external nofollow" val="%d" class="item[^"]*?">%d</a>'''
url = 'http://s.tool.chinaz.com/same?s=%s&page=%d'
page = 1
while True:
if page > 1:
time.sleep(1) #防止拒絕訪問
req = requests.get(url % (host , page) , headers=headers ,verify=False)
html = req.content.decode('utf-8') #取得頁面
for site in re.findall(regexp , html):
ip2hosts.append("http://"+site)
if re.search(regexp_next % (page+1 , page+1) , html) is None:
return ip2hosts
break
page += 1
return ip2hosts
def same_ip(host):
mydomains = []
mydomains.extend(ip2host_get(host))
mydomains.extend(links_ip(host))
mydomains.extend(aizhan(host))
mydomains.extend(chinaz(host))
mydomains = list(set(mydomains))
p = Pool()
for host in mydomains:
p.apply_async(filter, args=(host,))
p.close()
p.join()
if __name__=="__main__":
if len(sys.argv) == 2:
same_ip(sys.argv[1])
else:
print ("usage: %s host" % sys.argv[0])
sys.exit(-1)
大家可以發(fā)揮添加或者修改任意查詢接口。注意是這個(gè)里面的一些思路與代碼。
相關(guān)文章
Python3刪除排序數(shù)組中重復(fù)項(xiàng)的方法分析
這篇文章主要介紹了Python3刪除排序數(shù)組中重復(fù)項(xiàng)的方法,結(jié)合實(shí)例形式分析了Python3刪除排序數(shù)組重復(fù)項(xiàng)的原理、相關(guān)遍歷及刪除操作技巧,需要的朋友可以參考下2019-01-01
python怎樣判斷一個(gè)數(shù)值(字符串)為整數(shù)
這篇文章主要介紹了python怎樣判斷一個(gè)數(shù)值(字符串)為整數(shù)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02
Python函數(shù)默認(rèn)參數(shù)常見問題及解決方案
這篇文章主要介紹了Python函數(shù)默認(rèn)參數(shù)常見問題及解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-03-03
Python如何實(shí)現(xiàn)自動(dòng)發(fā)送郵件
對(duì)于一些每天需要發(fā)的報(bào)表或者是需要一次發(fā)送多份的報(bào)表,我們可以考慮借助Python來自動(dòng)發(fā)送郵件。本文主要介紹了如何利用Python實(shí)現(xiàn)自動(dòng)發(fā)送郵件,感興趣的小伙伴可以了解一下2021-11-11
Python使用sklearn庫(kù)實(shí)現(xiàn)的各種分類算法簡(jiǎn)單應(yīng)用小結(jié)
這篇文章主要介紹了Python使用sklearn庫(kù)實(shí)現(xiàn)的各種分類算法,結(jié)合實(shí)例形式分析了Python使用sklearn庫(kù)實(shí)現(xiàn)的KNN、SVM、LR、決策樹、隨機(jī)森林等算法實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-07-07

