#!/usr/bin/env python3
import subprocess,re,concurrent.futures
ips=[f'193.134.75.{i}' for i in range(1,255)]
def one(ip):
 cmd=['curl','--toadex-no-capture','-sk','--http1.1','--path-as-is','--connect-timeout','1','--max-time','3','--resolve',f'va.baloise.de:443:{ip}','-H','X-Bug-Bounty: dwbzn','-i','https://va.baloise.de/SASBIWS/services/Version?wsdl']
 try:r=subprocess.run(cmd,capture_output=True,timeout=4)
 except: return None
 raw=r.stdout
 m=list(re.finditer(br'HTTP/\S+\s+(\d+)[^\r\n]*\r?\n',raw))
 if not m:return None
 mm=m[-1]; sep=raw.find(b'\r\n\r\n',mm.start()); sl=4
 if sep<0: sep=raw.find(b'\n\n',mm.start());sl=2
 hdr=raw[mm.start():sep].decode('latin1','replace'); body=raw[sep+sl:]
 loc=srv=''
 for l in hdr.splitlines():
  if l.lower().startswith('location:'):loc=l.split(':',1)[1].strip()
  if l.lower().startswith('server:'):srv=l.split(':',1)[1].strip()
 sig=','.join(dict.fromkeys(x.decode() for x in re.findall(br'(?i)Axis|SAS|Airlock|Misdirected|no Route matched|Unauthorized|Forbidden|Service|check-login|Bad Request',body)))
 return ip,mm.group(1).decode(),len(body),srv,loc,sig,re.sub(r'\s+',' ',body[:120].decode('latin1','replace'))
with concurrent.futures.ThreadPoolExecutor(max_workers=64) as ex:
 rows=[x for x in ex.map(one,ips) if x]
for x in rows:
 print('\t'.join(map(str,x)))
