探测TCP端口
代码
python
import socket
import sys
server = sys.argv[1]
ip, port = server.split(":")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ip, int(port)))
if result == 0:
print("open")
else:
print("timeout")
sock.close()
shell
py -3 -c "import base64;exec(base64.b64decode('aW1wb3J0IHNvY2tldAppbXBvcnQgc3lzCgpzZXJ2ZXIgPSBzeXMuYXJndlsxXQppcCwgcG9ydCA9IHNlcnZlci5zcGxpdCgiOiIpCgpzb2NrID0gc29ja2V0LnNvY2tldChzb2NrZXQuQUZfSU5FVCwgc29ja2V0LlNPQ0tfU1RSRUFNKQpyZXN1bHQgPSBzb2NrLmNvbm5lY3RfZXgoKGlwLCBpbnQocG9ydCkpKQppZiByZXN1bHQgPT0gMDoKICAgcHJpbnQoIm9wZW4iKQplbHNlOgogICBwcmludCgidGltZW91dCIpCnNvY2suY2xvc2UoKQ=='.encode()).decode())" 1.1.1.1:80