from pathlib import Path from datetime import datetime,timezone from urllib.request import Request,build_opener,HTTPRedirectHandler from urllib.error import HTTPError from urllib.parse import urlparse import json,re OUT=Path(__file__).resolve().parent;BASE='https://portal-investidor.test' private=Path(json.loads((OUT/'C132-private-location.json').read_text(encoding='utf-8-sig'))['private_directory']) ids=[p.stem for p in (private/'diagnostics').glob('*.json') if re.fullmatch(r'[0-9A-HJKMNP-TV-Z]{26}',p.stem)] assert ids class NoRedirect(HTTPRedirectHandler): def redirect_request(self,req,fp,code,msg,headers,newurl):return None opener=build_opener(NoRedirect()) proof={'at':datetime.now(timezone.utc).isoformat(),'case':'C132','base':BASE,'anonymous':True,'credentials_tokens_cookies_sent':False,'TLS_bypass':False,'bodies_saved':False,'checks':[]} for path,label in [('/_inertia/devtools/entries','index'),('/_inertia/devtools/entries/'+ids[0],'retained_real_detail'),('/_inertia/devtools/entries/01ARZ3NDEKTSV4RRFFQ69G5FAV','arbitrary_detail'),('/login','login'),('/two-factor-challenge','MFA_requires_pending_login'),('/dashboard','dashboard_requires_authentication')]: try:r=opener.open(Request(BASE+path,headers={'Accept':'application/json' if label in ['index','retained_real_detail','arbitrary_detail'] else 'text/html'},method='GET'),timeout=25) except HTTPError as e:r=e with r:status=r.code;headers=r.headers;body=r.read() check={'label':label,'status':status,'path':'/_inertia/devtools/entries/{retained-id}' if label=='retained_real_detail' else path} if headers.get('Location'):check['redirect_path']=urlparse(headers['Location']).path if label=='login': check['login_form_present']=b'auth/login' in body or b'password' in body check['cookie_attributes_only']=[{'name':s.split('=',1)[0],'secure':'; secure' in s.lower(),'http_only':'; httponly' in s.lower(),'same_site_lax':'samesite=lax' in s.lower(),'path_root':'path=/' in s.lower()} for s in headers.get_all('Set-Cookie',[])] check['mixed_http_local_resource']=bool(re.search(rb'(?:src|href)=["\']http://portal-investidor\.test',body)) proof['checks'].append(check) assert status==404 if label in ['index','retained_real_detail','arbitrary_detail'] else status==200 if label=='login' else status in [302,303] proof['result']='contained_endpoints_verified';proof['normal_MFA_authenticated_dashboard']='Requires a legitimate existing owner login; anonymous routing is not MFA success.' (OUT/'C132-http-contained.json').write_text(json.dumps(proof,ensure_ascii=False,indent=2),encoding='utf-8');print(json.dumps(proof,ensure_ascii=True))