当前位置:网站首页>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()
边栏推荐
- Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
- Cesium dynamic diffusion point effect
- 实现一个自定义布局的扫码功能
- es面試題
- Set status bar color
- 【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
- 2022低压电工考试题模拟考试题库模拟考试平台操作
- Jvm-01 (phased learning)
- [graduation season] graduate seniors share how to make undergraduate more meaningful
- Oracle creates a user with read-only permission in four simple steps
猜你喜欢
How to solve MySQL master-slave delay problem
Leetcode question brushing (10) - sequential question brushing 46 to 50
STM32__05—PWM控制直流电机
Face++ realizes face detection in the way of flow
How does MySQL solve the problem of not releasing space after deleting a large amount of data
As a software testing engineer, will you choose the bank post? Laolao bank test post
QT implementation interface jump
超图iServer rest服务之feature查询
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
QT实现界面跳转
随机推荐
Additional: information desensitization;
What are the common proxy servers and what are the differences?
研发中台拆分过程的一些心得总结
OpenCASCADE7.6编译
CSDN insertion directory in 1 second
Divorce for 3 years to discover the undivided joint property, or
how to come in an investnent bank team
oracle创建只读权限的用户简单四步走
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
Flutter un élément au milieu, l'élément le plus à droite
Questions d'entrevue
剑指 Offer 31. 栈的压入、弹出序列
leetcode373. Find and minimum k-pair numbers (medium)
RTL8189FS如何关闭Debug信息
Kibana操控ES
DNS domain name resolution
A quick understanding of analog electricity
Formatting logic of SAP ui5 currency amount display
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview
A quick understanding of digital electricity