#NEWLINE# def get_ports_for_service( self , service , protocol ) : #NEWLINE# #INDENT# regexp = '(.*?)\t(.*?/.*?)\t(.*?)($|\t)(#.*){0,1}' #NEWLINE# re . compile ( regexp ) #NEWLINE# list = [ ] #NEWLINE# f = FileOperations . open ( self . get_nmap_services_file ( ) ) #NEWLINE# for line in f . readlines ( ) : #NEWLINE# #INDENT# if ( line . lower ( ) . find ( service ) >= 0 ) : #NEWLINE# #INDENT# match = re . findall ( prot , line ) #NEWLINE# if match : #NEWLINE# #INDENT# port = match [ 0 ] [ 1 ] . split ( '/' ) [ 0 ] #NEWLINE# prot = match [ 0 ] [ 1 ] . split ( '/' ) [ 1 ] #NEWLINE# if ( ( ( not protocol ) or ( protocol == prot ) ) and ( port not in list ) ) : #NEWLINE# #INDENT# list . append ( port ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# f . close ( ) #NEWLINE# return list