国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現的Google IP 可用性檢測腳本

Python實現的Google IP 可用性檢測腳本

2020-06-10 09:51junjie Python

這篇文章主要介紹了Python實現的Google IP 可用性檢測腳本,本文腳本需要Python 3.4+環境,需要的朋友可以參考下

需要 Python 3.4+,一個參數用來選擇測試搜索服務還是 GAE 服務。測試 GAE 服務的話需要先修改開頭的兩個變量。從標準輸入讀取 IP 地址或者 IP 段(形如 192.168.0.0/16)列表,每行一個??捎?IP 輸出到標準輸出。實時測試結果輸出到標準錯誤。50 線程并發。

checkgoogleip

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
 
import sys
from ipaddress import IPv4Network
import http.client as client
from concurrent.futures import ThreadPoolExecutor
import argparse
import ssl
import socket
 
# 先按自己的情況修改以下幾行
APP_ID = 'your_id_here'
APP_PATH = '/fetch.py'
 
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations('/etc/ssl/certs/ca-certificates.crt')
 
class HTTPSConnection(client.HTTPSConnection):
 def __init__(self, *args, hostname=None, **kwargs):
  self._hostname = hostname
  super().__init__(*args, **kwargs)
 
 def connect(self):
  super(client.HTTPSConnection, self).connect()
 
  if self._tunnel_host:
   server_hostname = self._tunnel_host
  else:
   server_hostname = self._hostname or self.host
   sni_hostname = server_hostname if ssl.HAS_SNI else None
 
  self.sock = self._context.wrap_socket(self.sock,
                     server_hostname=sni_hostname)
  if not self._context.check_hostname and self._check_hostname:
   try:
    ssl.match_hostname(self.sock.getpeercert(), server_hostname)
   except Exception:
    self.sock.shutdown(socket.SHUT_RDWR)
    self.sock.close()
    raise
 
def check_ip_p(ip, func):
 if func(ip):
  print(ip, flush=True)
 
def check_for_gae(ip):
 return _check(APP_ID + '.appspot.com', APP_PATH, ip)
 
def check_for_search(ip):
 return _check('www.google.com', '/', ip)
 
def _check(host, path, ip):
 for chance in range(1,-1,-1):
  try:
   conn = HTTPSConnection(
    ip, timeout = 5,
    context = context,
    hostname = host,
   )
   conn.request('GET', path, headers = {
    'Host': host,
   })
   response = conn.getresponse()
   if response.status < 400:
    print('GOOD:', ip, file=sys.stderr)
   else:
    raise Exception('HTTP Error %s %s' % (
     response.status, response.reason))
   return True
  except KeyboardInterrupt:
   raise
  except Exception as e:
   if isinstance(e, ssl.CertificateError):
    print('WARN: %s is not Google\'s!' % ip, file=sys.stderr)
    chance = 0
   if chance == 0:
    print('BAD :', ip, e, file=sys.stderr)
    return False
   else:
    print('RE :', ip, e, file=sys.stderr)
 
def main():
 parser = argparse.ArgumentParser(description='Check Google IPs')
 parser.add_argument('service', choices=['search', 'gae'],
           help='service to check')
 args = parser.parse_args()
 func = globals()['check_for_' + args.service]
 
 count = 0
 with ThreadPoolExecutor(max_workers=50) as executor:
  for l in sys.stdin:
   l = l.strip()
   if '/' in l:
    for ip in IPv4Network(l).hosts():
     executor.submit(check_ip_p, str(ip), func)
     count += 1
   else:
    executor.submit(check_ip_p, l, func)
    count += 1
 print('%d IP checked.' % count)
 
if __name__ == '__main__':
 main()

 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日本网站在线免费观看 | 求av网址 | 91精品久久久久久久久久久 | 国产一级纯肉体一级毛片 | 国产亚洲精品美女久久久久久久久久 | 91精品久久久久久久久久 | 国产精品国产三级国产aⅴ中文 | 欧美日韩国产一区二区三区 | 午夜精品视频 | 一区二区免费在线观看 | 亚洲国产精品一区二区三区 | 亚洲欧美视频在线观看 | 精品国产一区二区三区在线观看 | 中文字幕在线精品 | 亚洲福利一区二区 | 免费视频一区二区 | 亚洲综合在线视频 | 亚洲一区二区三区在线播放 | 能直接看的av网站 | 久久在线视频 | 久久久一区二区三区 | 亚洲一区二区三区四区五区午夜 | 中文字幕在线永久在线视频 | 一区二区在线 | 欧美日韩精品免费 | 污视频免费 | 国产黄色一级大片 | 久久精品久久久久久 | 免费观看黄色大片 | 久久久久国产精品免费免费搜索 | 人人爱人人草 | 欧美a区| 欧美日韩亚洲一区二区 | 午夜午夜精品一区二区三区文 | 88av网站 | 中文一区 | 寡妇少妇高潮免费看蜜臀a 午夜免费电影 | 午夜精品电影 | 久久久久国产一区二区三区 | 免费观看一区二区三区毛片软件 | 亚洲天堂一区二区 |