2626)
2727
2828
29- def Interpret (value : bytes | str , endian : str ) -> int :
29+ def interpret (value : bytes | str , endian : str ) -> int :
3030 """
3131 Interpret up to 8 bytes as unsigned integer
3232 endian: '>' = big-endian, '<' = little-endian
@@ -40,7 +40,7 @@ def Interpret(value: bytes | str, endian: str) -> int:
4040 return int .from_bytes (value , byteorder = byteorder , signed = False )
4141
4242
43- def Printable (value : bytes | str ) -> str :
43+ def printable (value : bytes | str ) -> str :
4444 """
4545 Make a string printable:
4646 - Remove NULLs
@@ -71,7 +71,7 @@ def apply_subst(match_obj, regex_match):
7171 return value .replace (old , new )
7272
7373
74- def expand_SUBST (template : str , regex_match ):
74+ def expand_subst (template : str , regex_match ):
7575 while True :
7676 m = SUBST_RE .search (template )
7777 if not m :
@@ -82,24 +82,24 @@ def expand_SUBST(template: str, regex_match):
8282 return template
8383
8484
85- def expand_I (template : str , match ):
85+ def expand_i (template : str , match ):
8686 def repl (m ):
8787 idx = int (m .group (1 ))
8888 endian = m .group (2 )
8989 try :
9090 captured = match .group (idx )
9191 except IndexError :
9292 return ""
93- return str (Interpret (captured , endian ))
93+ return str (interpret (captured , endian ))
9494
9595 return I_RE .sub (repl , template )
9696
9797
98- def expand_P (template : str , regex_match ):
98+ def expand_p (template : str , regex_match ):
9999 def repl (m ):
100100 i = int (m .group (1 ))
101101 try :
102- return Printable (regex_match .group (i ))
102+ return printable (regex_match .group (i ))
103103 except IndexError :
104104 return ""
105105
@@ -123,14 +123,16 @@ def repl(m):
123123
124124
125125def expand_template (template : str , regex_match ):
126- template = expand_SUBST (template , regex_match )
127- template = expand_P (template , regex_match )
128- template = expand_I (template , regex_match )
126+ template = expand_subst (template , regex_match )
127+ template = expand_p (template , regex_match )
128+ template = expand_i (template , regex_match )
129129 template = expand_place (template , regex_match )
130130 return template
131131
132132
133- class result :
133+ class Result :
134+ """Version fields (template, product, CPE, ...) extracted from a matched signature."""
135+
134136 def __init__ (
135137 self ,
136138 version_template = None ,
@@ -185,16 +187,16 @@ def get_probes_for_sslport(self):
185187 specific .append (p )
186188 return specific
187189
188- def Match_response (self , response , signature ):
190+ def match_response (self , response , signature ):
189191 if response is None :
190- return {"status" : False , "result" : result ()}
192+ return {"status" : False , "result" : Result ()}
191193
192194 if isinstance (response , str ):
193195 response = response .encode ("latin-1" , errors = "ignore" )
194196 regex = signature .regex
195197 match = regex .search (response )
196198 if not match :
197- return {"status" : False , "result" : result ()}
199+ return {"status" : False , "result" : Result ()}
198200
199201 version_ = signature .version_details
200202 version_template = product = info = hostname = None
@@ -220,7 +222,7 @@ def Match_response(self, response, signature):
220222
221223 return {
222224 "status" : True ,
223- "result" : result (
225+ "result" : Result (
224226 version_template = version_template ,
225227 product = product ,
226228 info = info ,
@@ -233,8 +235,8 @@ def Match_response(self, response, signature):
233235 ),
234236 }
235237
236- def check_match_service (self , Signatures , service ) -> bool :
237- for sig_ in Signatures :
238+ def check_match_service (self , signatures , service ) -> bool :
239+ for sig_ in signatures :
238240 if sig_ .service == service :
239241 return True
240242 return False
@@ -266,22 +268,22 @@ def probe_sequentially(self):
266268 self .port ,
267269 probe .probe_string ,
268270 probe .totalwaits ,
269- probe .tcpwrapperdms ,
271+ probe .tcpwrapped_ms ,
270272 )
271273 else :
272274 response = tcp_probe_ssl (
273275 self .host ,
274276 self .port ,
275277 probe .probe_string ,
276278 probe .totalwaits ,
277- probe .tcpwrapperdms ,
279+ probe .tcpwrapped_ms ,
278280 )
279281 else :
280282 response = udp_probe (self .host , self .port , probe .probe_string , probe .totalwaits )
281283
282284 if response is None :
283285 response = tcp_probe (
284- self .host , self .port , probe .probe_string , probe .totalwaits , probe .tcpwrapperdms
286+ self .host , self .port , probe .probe_string , probe .totalwaits , probe .tcpwrapped_ms
285287 )
286288
287289 if not response or response .get ("raw_bytes" ) is None :
@@ -290,8 +292,8 @@ def probe_sequentially(self):
290292 raw_response = response .get ("raw_bytes" )
291293
292294 # 1. Check Primary Signatures
293- for signature in probe .Signatures :
294- matched_data = self .Match_response (raw_response , signature )
295+ for signature in probe .signatures :
296+ matched_data = self .match_response (raw_response , signature )
295297 res_ = matched_data ["result" ]
296298 if matched_data ["status" ]:
297299 if signature .sig_type == "match" :
@@ -344,8 +346,8 @@ def probe_sequentially(self):
344346 if not fallback_probe :
345347 continue
346348
347- for signature in fallback_probe .Signatures :
348- matched_data = self .Match_response (raw_response , signature )
349+ for signature in fallback_probe .signatures :
350+ matched_data = self .match_response (raw_response , signature )
349351 res_ = matched_data ["result" ]
350352 if matched_data ["status" ]:
351353 if signature .sig_type == "match" :
0 commit comments