summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhklbgd <hklbgd_assange@oosm.org>2019-06-01 21:11:43 +0200
committerhklbgd <hklbgd_assange@oosm.org>2019-06-01 21:11:43 +0200
commitefcf9ac3de59e6651bd7e732f778506d9b1d3d80 (patch)
tree8b3dd4e97831338c8e0b2cb5cbbf0121fc7e95bb
parent4b1e385c02c00d7cc2a22fedb176e4db6032daba (diff)
add getPortInfo function
-rwxr-xr-xtmap22
1 files changed, 22 insertions, 0 deletions
diff --git a/tmap b/tmap
index 1d61f97..fac70d3 100755
--- a/tmap
+++ b/tmap
@@ -9,6 +9,28 @@ import threading
VERSION='1.2.1'
+def getPortInfo(port, portfile):
+ """
+ Get info about service commonly used on this port
+ """
+ ## Read every line until EOF
+ while (line = f.readline()) != '':
+ ## Don't read lines that are commented out
+ if line[0] == '#':
+ pass
+
+ ## Split line using tab as delimiter and read the port number
+ split_line = line.split('\t')
+ portnum = split_line[1].split('/')[0]
+
+ ## If portnum equals port return the name of service
+ if int(portnum) != port:
+ pass
+ else:
+ return split_line[0]
+ return "portinfo_error"
+
+
def getBanner(host, port, wait, notor):
"""
Receive first 80 bytes from port, return string of received data