MCPcopy Create free account
hub / github.com/Parimal-shaw/NMapify / normal_parser

Function normal_parser

NMapify.py:107–136  ·  view source on GitHub ↗
(normal_file_output)

Source from the content-addressed store, hash-verified

105 GenerateXML(new_list2)
106
107def normal_parser(normal_file_output):
108 normal_list2 = []
109 for lines in normal_file_output.splitlines():
110 #extract IP address
111 new_line1 = re.findall( r'Nmap scan report for (.+)', lines, re.DOTALL)
112 normal_list2.append(new_line1)
113 #print(new_line1)
114 #Extract Port Number
115 newline2 = re.findall('.*. open', lines, re.DOTALL)
116 newline2 = re.sub( ' open', '', str(newline2)).strip()
117 newline2 = re.sub( ' ', '', str(newline2))
118 #print(newline2)
119 normal_list2.append(newline2)
120 newline3 = newline2 = re.findall('open .*.', lines, re.DOTALL)
121 newline3 = re.sub( 'open ', '', str(newline3))
122 newline3 = re.sub( ' ', '', str(newline3))
123 #print(newline3)
124 normal_list2.append(newline3)
125 #print(normal_list2)
126 cleaned = []
127 for item in normal_list2:
128 if isinstance(item, list) and item: # Non-empty list
129 cleaned.append(item[0])
130 elif isinstance(item, str) and item not in ['[]', '']:
131 # Extract the value inside the string list
132 match = re.match(r"\['(.+?)'\]", item)
133 if match:
134 val = match.group(1)
135 cleaned.append(val)
136 GenerateXML(cleaned)
137
138def is_xml_file(file_path):
139 try:

Callers 1

NMapify.pyFile · 0.85

Calls 1

GenerateXMLFunction · 0.85

Tested by

no test coverage detected