#!/usr/bin/python2.7
#simpan dengan nama service.py
import socket
def find_service_name():
list_port=[22,23,25,80,21,53,110,123,137,138,139,194,220]
for port in list_port:
print "Port: %s => service name %s" %(port, socket.getservbyport(port,'tcp'))
if __name__ == '__main__':
find_service_name()
Pada socket.getservbyport(port,'tcp'), didefinisikan untuk port (22,23,25,80,21,53,110,123,137,138,139,194,220) dengan jenis port yaitu protokol tcp
$ python service.py
Port: 22 => service name ssh
Port: 23 => service name telnet
Port: 25 => service name smtp
Port: 80 => service name http
Port: 21 => service name ftp
Port: 53 => service name domain
Port: 110 => service name pop3
Port: 123 => service name ntp
Port: 137 => service name netbios-ns
Port: 138 => service name netbios-dgm
Port: 139 => service name netbios-ssn
Port: 194 => service name irc
Port: 220 => service name imap3
No comments:
Post a Comment