#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = ["curl-cffi>=0.15.0"]
# ///
from curl_cffi import requests
from concurrent.futures import ThreadPoolExecutor,as_completed
import json
hosts=['api.baloise.de','api2.baloise.de']
ports=[2124,4401,7443,7980,8080,8343,8443,8999,9443]
headers={'X-Bug-Bounty':'dwbzn','Accept':'application/json','Content-Type':'application/x-www-form-urlencoded'}
data='grant_type=password&username=skip&password=auth'
def one(x):
 h,p=x
 try:
  r=requests.post(f'https://{h}:{p}/oimapi/auth/v1.0/token',headers=headers,data=data,proxy='socks5h://127.0.0.1:1090',timeout=12,impersonate='chrome',toadex_capture=False)
  return {'host':h,'port':p,'status':r.status_code,'len':len(r.content),'type':r.headers.get('content-type'),'loc':r.headers.get('location'),'body':r.text[:240]}
 except Exception as e:return {'host':h,'port':p,'error':repr(e)}
with ThreadPoolExecutor(max_workers=4) as ex:
 for f in as_completed([ex.submit(one,x) for x in [(h,p) for h in hosts for p in ports]]):
  print(json.dumps(f.result(),ensure_ascii=False),flush=True)
