Skip to content

Commit

Permalink
tcpscan2.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Brock committed Nov 22, 2014
1 parent de4b9fd commit d985e85
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tcpscan2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

#
# author: Brock | 老妖([email protected])
# 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)

0 comments on commit d985e85

Please sign in to comment.