# Trouve le dossier OVH de chaque domaine via des fichiers témoins temporaires (supprimés à la fin).
import os, sys, secrets, ssl, urllib.request, glob
CTX = ssl.create_default_context()
home = os.path.expanduser('~')
dirs = [d for d in glob.glob(home + '/*/') if not os.path.basename(d.rstrip('/')).startswith(('bak', 'quarantine', 'lead-', 'partial-', 'spam-', 'sec2', 'nxdeploy'))]
cands = []
for d in dirs:
    cands.append(d.rstrip('/'))
    for sub in ('public', 'public_html', 'www'):
        if os.path.isdir(d + sub): cands.append(d + sub)
probes = {}
for c in cands:
    n = 'probe-' + secrets.token_hex(6) + '.txt'
    try:
        open(os.path.join(c, n), 'w').write(n); os.chmod(os.path.join(c, n), 0o644); probes[c] = n
    except Exception:
        pass
try:
    for dom in sys.argv[1:]:
        found = []
        for c, n in probes.items():
            for h in (dom, 'www.' + dom):
                try:
                    if urllib.request.urlopen(urllib.request.Request(f'https://{h}/{n}', headers={'User-Agent': 'Mozilla/5.0'}), timeout=10, context=CTX).read().decode().strip() == n:
                        found.append(c); break
                except Exception:
                    pass
            if found: break
        print(dom, found[0] if found else 'INTROUVABLE')
finally:
    for c, n in probes.items():
        try: os.remove(os.path.join(c, n))
        except Exception: pass
