MAC OS X telnet 客户端
2021-01-04 00:29
标签:open fqdn bin python sed 客户端 sock exce main if name == ‘main‘: MAC OS X telnet 客户端 标签:open fqdn bin python sed 客户端 sock exce main 原文地址:https://blog.51cto.com/qinlouke/2529576
`#!/usr/local/bin/python3
import socket
import sys
import re
if len(sys.argv) != 3:
print("Usage: telnet [remote_ip | FQDN] [remote_port]")
exit()
if re.match(r"\d{1,5}",sys.argv[2]) is None:
print("remote port must be number")
exit()
hostname = sys.argv[1]
remote_port = int(sys.argv[2])
telnet_client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
telnet_client.connect((hostname,remote_port))
print(hostname+":"+str(remote_port)+" is open\n")
exit()
except Exception:
print(hostname+":"+str(remote_port)+" is closed\n")
exit()`
文章标题:MAC OS X telnet 客户端
文章链接:http://soscw.com/index.php/essay/39929.html