当前位置:网站首页>Batch detect whether there is CDN in URL - high accuracy
Batch detect whether there is CDN in URL - high accuracy
2022-07-02 02:32:00 【Mountains and rivers'】
Read the Internet and say url Batch testing cdn The script of is not much and inaccurate , Write here
General judgment cdn The method is as follows
The global ping
According to the ip More than one address is used cdn, This is the most reliable method
- Multiple locations ping The server - Website speed measurement - Webmaster Tools Home of stationmaster
- The global Ping test , On-line ping Tools - Network tools The fastest
- https://whoer.net/zh/ping The global ping
nslookup
1. nslookup Default resolution
Use "nslookup domain name ", If the goal has CDN service , that “ Non authoritative response ” Medium “addresses” Medium IP Count >=2 individual , But there will also be false positives
2. Different DNS Domain name resolution
Different DNS Comparison of domain name resolution , Determine whether it uses CDN. Different DNS If the analysis results are different , There is a good chance that CDN service
So we can judge whether it is used according to these two points cdn
Batch test scripts
If you quote global ping Of api Interface for testing , The detection efficiency will be limited by the server network speed and the possibility of being blocked ip The risk of . Use here nslookup Conduct multiple tests , To confirm whether to use cdn, Accuracy rate 99%
cdn.py
from subprocess import PIPE, Popen
import re
import os
from colorama import init,Fore
init(autoreset=True)
import argparse
def args():
parser = argparse.ArgumentParser(description='cdn Batch test scripts ')
parser.add_argument('-f',type=str,help=' Batch testing , Please put url Put it in txt In the document , One line at a time ')
args = parser.parse_args()
ssrc = """
______ _____________ ____
/ ___/ / ___/\_ __ \_/ ___\
\___ \ \___ \ | | \/\ \___
/____ >/____ > |__| \___ >
\/ \/ \/
Author: Mountains and rivers
"""
print(ssrc)
if args.f:
filename = args.f
if os.path.exists(filename):
check_cdn(filename)
else:
print(" The file name entered does not exist !")
def check_cdn(filename):
result_list = []
for url in open(filename,'r'):
url = url.replace("\n","")
ip = url.replace("http://","").replace("https://","").replace("/","").replace("\n","")
proc = Popen('nslookup %s' %(ip),stdin=None,stdout=PIPE,stderr=PIPE,shell=True)
outinfo, errinfo = proc.communicate()
info = outinfo.decode('gbk')
ip_list = re.findall(r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}",info,re.S)
if len(ip_list) >= 3:
print(Fore.RED+"[-]",url," There is cdn")
continue
if len(ip_list) == 1:
print(Fore.BLUE+"[-]",url," request timeout ")
continue
if len(ip_list) == 2:
# Second judgment , Improve accuracy
proc = Popen('nslookup %s 223.5.5.5' %(ip),stdin=None,stdout=PIPE,stderr=PIPE,shell=True)
outinfo, errinfo = proc.communicate()
info1 = outinfo.decode('gbk')
ip_list1 = re.findall(r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}",info1,re.S)
if len(ip_list1) >= 3:
print(Fore.RED+"[-]",url," There is cdn")
continue
if len(ip_list1) ==2:
name1 = re.findall(r' name :.*Address:.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})',info,re.S)[0]
name2 = re.findall(r' name :.*Address:.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})',info1,re.S)[0]
if name1 != name2:
print(Fore.RED+"[-]",url," There is cdn")
continue
if name1 == name2:
print(Fore.GREEN+"[+] %s non-existent cdn \t real ip: %s" %(url,name2))
result_list.append(name2)
lis = list(set(result_list))
if len(lis):
for r in lis:
with open("result.txt",'a') as f:
f.write(r+"\n")
print(" detection complete , non-existent cdn Of url ip Save in current path 'result.txt'")
if not len(lis):
print(" detection complete !")
if __name__ == '__main__':
args()
边栏推荐
- [Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
- Open that kind of construction document
- CSDN article underlined, font color changed, picture centered, 1 second to understand
- The basic steps of using information theory to deal with scientific problems are
- [punch in questions] integrated daily 5-question sharing (phase II)
- How to execute an SQL in MySQL
- 连通块模板及变式(共4题)
- trading
- Ar Augmented Reality applicable scenarios
- 2022 safety officer-c certificate examination questions and mock examination
猜你喜欢
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
Types of exhibition items available in the multimedia interactive exhibition hall
Summary of some experiences in the process of R & D platform splitting
研发中台拆分过程的一些心得总结
附加:信息脱敏;
QT实现界面跳转
LFM信号加噪、时频分析、滤波
Jvm-01 (phased learning)
MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent
随机推荐
Sword finger offer 29 Print matrix clockwise
Comparative analysis of MVC, MVP and MVVM, source code analysis
LFM signal denoising, time-frequency analysis, filtering
STM32__ 05 - PWM controlled DC motor
A quick understanding of digital electricity
CSDN insertion directory in 1 second
Face++ realizes face detection in the way of flow
What is the function of the headphone driver
QT uses sqllite
QT使用sqllite
QT implementation interface jump
STM32F103——两路PWM控制电机
Sword finger offer 31 Stack push in and pop-up sequence
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview
Software testing learning notes - network knowledge
Open that kind of construction document
AcWing 245. Can you answer these questions (line segment tree)
Email picture attachment
Leetcode face T10 (1-9) array, ByteDance interview sharing
批量检测url是否存在cdn—高准确率