from curl_cffi import requests
import json,time
hosts=['mein-portal.baloise.de','infoportal.baloise.de','maklerportal.baloise.de','si-portal.baloise.de','vertriebsservice.baloise.de','zeus-portal.baloise.de']
apps=['portal_ao','portal_mo','portal_si','portal_bvs','portal_zeus','venta','sas_va','antragsfreigabe','bsi_crm','guidewire_pc','guidewire_bc','guidewire_cc','guidewire_cm','el_account_linking','el_account_linking2','Easylogin','easylogin','default']
h0={'X-Bug-Bounty':'dwbzn'}
for host in hosts:
 for app in apps:
  try:
   s=requests.Session(impersonate='chrome')
   s.get(f'https://{host}/auth/',headers=h0,allow_redirects=False,timeout=15,toadex_capture=False)
   csrf=s.cookies.get('CSRFT759-S') or ''
   h={**h0,'X-Same-Domain':'1','X-CSRFT759':csrf,'Content-Type':'application/json','Accept':'application/json,application/vnd.api+json'}
   r=s.post(f'https://{host}/auth/rest/public/authentication/applications/{app}/access',headers=h,data='null',allow_redirects=False,timeout=15,toadex_capture=False)
   try:j=r.json()
   except:j={}
   meta=j.get('meta',{}); err=(j.get('errors') or [{}])[0]
   print('\t'.join(map(str,[host,app,r.status_code,len(r.content),meta.get('nextAuthStep',''),meta.get('forwardUrl',''),meta.get('uiSettings',{}).get('path',''),err.get('code',''),r.headers.get('X-Forward-URL',''),r.headers.get('location','')])))
  except Exception as e: print(host,app,'ERR',repr(e),sep='\t')
