From d985e85dc166df53ff2e0e5c642f16b4a0e51107 Mon Sep 17 00:00:00 2001 From: Brock <8274634@@qq.com> Date: Sat, 22 Nov 2014 04:18:16 -0500 Subject: [PATCH] tcpscan2.py --- tcpscan2.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 tcpscan2.py diff --git a/tcpscan2.py b/tcpscan2.py new file mode 100755 index 0000000..72f1f05 --- /dev/null +++ b/tcpscan2.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +# +# author: Brock | 老妖(laoyaogg@qq.com) +# date: 2014-11-15 +# ver: 0.5 +# + +import sys, os +import socket +import getopt + +def detect_port(host, port): + s = socket.socket() + s.settimeout(1) + try: + s.connect((host, port)) + s.send('GET / HTTP/1.0\n\n') + buf = s.recv(1024) + print port, buf[:buf.find('\n')] + except socket.timeout: + pass + except socket.error: + pass + + s.close() + +ports = (21, 22, 23, 25, 53, 69, 80, 110, 135, 137, 139, 445, 1025, + 1194, 1433, 1521, 3306, 3389, 5900, 8000, 8080) +for port in ports: + detect_port(sys.argv[1], port) +