Python实现的Google IP 可用性检测脚本
需要 Python 3.4+,一个参数用来选择测试搜索服务还是 GAE 服务。测试 GAE 服务的话需要先修改开头的两个变量。从标准输入读取 IP 地址或者 IP 段(形如 192.168.0.0/16)列表,每行一个。可用 IP 输出到标准输出。实时测试结果输出到标准错误。50 线程并发。
checkgoogleip
#!/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()

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。

PHP適合網頁開發和快速原型開發,Python適用於數據科學和機器學習。 1.PHP用於動態網頁開發,語法簡單,適合快速開發。 2.Python語法簡潔,適用於多領域,庫生態系統強大。

Python更適合初學者,學習曲線平緩,語法簡潔;JavaScript適合前端開發,學習曲線較陡,語法靈活。 1.Python語法直觀,適用於數據科學和後端開發。 2.JavaScript靈活,廣泛用於前端和服務器端編程。

PHP起源於1994年,由RasmusLerdorf開發,最初用於跟踪網站訪問者,逐漸演變為服務器端腳本語言,廣泛應用於網頁開發。 Python由GuidovanRossum於1980年代末開發,1991年首次發布,強調代碼可讀性和簡潔性,適用於科學計算、數據分析等領域。

VS Code可以在Windows 8上運行,但體驗可能不佳。首先確保系統已更新到最新補丁,然後下載與系統架構匹配的VS Code安裝包,按照提示安裝。安裝後,注意某些擴展程序可能與Windows 8不兼容,需要尋找替代擴展或在虛擬機中使用更新的Windows系統。安裝必要的擴展,檢查是否正常工作。儘管VS Code在Windows 8上可行,但建議升級到更新的Windows系統以獲得更好的開發體驗和安全保障。

VS Code 可用於編寫 Python,並提供許多功能,使其成為開發 Python 應用程序的理想工具。它允許用戶:安裝 Python 擴展,以獲得代碼補全、語法高亮和調試等功能。使用調試器逐步跟踪代碼,查找和修復錯誤。集成 Git,進行版本控制。使用代碼格式化工具,保持代碼一致性。使用 Linting 工具,提前發現潛在問題。

在 VS Code 中,可以通過以下步驟在終端運行程序:準備代碼和打開集成終端確保代碼目錄與終端工作目錄一致根據編程語言選擇運行命令(如 Python 的 python your_file_name.py)檢查是否成功運行並解決錯誤利用調試器提升調試效率

VS Code 擴展存在惡意風險,例如隱藏惡意代碼、利用漏洞、偽裝成合法擴展。識別惡意擴展的方法包括:檢查發布者、閱讀評論、檢查代碼、謹慎安裝。安全措施還包括:安全意識、良好習慣、定期更新和殺毒軟件。
