()
| 21876 | |
| 21877 | @app.route('/api/search', methods=['POST']) |
| 21878 | def search(): |
| 21879 | d = request.json |
| 21880 | # Retrocompatibilita': alcune chiamate legacy inviano {t, p} |
| 21881 | t = str(d.get('target', d.get('t', ''))).strip() |
| 21882 | p = d.get('platform', d.get('p')) |
| 21883 | |
| 21884 | if p == 'holehe': |
| 21885 | return jsonify(core.holehe_scan(t)) |
| 21886 | if p == 'gmail': |
| 21887 | out = [] |
| 21888 | jobs = {} |
| 21889 | with ThreadPoolExecutor(max_workers=3) as ex: |
| 21890 | jobs[ex.submit(core.analyze_gmail_osint, t)] = "gmail" |
| 21891 | jobs[ex.submit(core.ghunt_email_scan, t)] = "ghunt" |
| 21892 | jobs[ex.submit(core.holehe_scan, t, 2.0, 5, 80)] = "holehe" |
| 21893 | |
| 21894 | try: |
| 21895 | completed = as_completed(jobs, timeout=8) |
| 21896 | for fut in completed: |
| 21897 | kind = jobs.get(fut) |
| 21898 | try: |
| 21899 | res = fut.result() |
| 21900 | if isinstance(res, list): |
| 21901 | out.extend(res[:80]) |
| 21902 | elif res: |
| 21903 | out.append(res) |
| 21904 | except Exception: |
| 21905 | if kind == "holehe": |
| 21906 | out.append({"username": t, "type": "Holehe", "info": {"Status": "Timeout/errore Holehe"}, "main_img": "https://cdn-icons-png.flaticon.com/512/732/732200.png", "status_code": 206, "url": ""}) |
| 21907 | except Exception: |
| 21908 | out.append({"username": t, "type": "Gmail OSINT", "info": {"Status": "Risposta parziale: una sorgente e' lenta"}, "main_img": "https://cdn-icons-png.flaticon.com/512/281/281764.png", "status_code": 206, "url": ""}) |
| 21909 | |
| 21910 | if not any(r for r in out if isinstance(r, dict) and str(r.get("type", "")).startswith("Gmail OSINT")): |
| 21911 | out.insert(0, core.analyze_gmail_osint(t)) |
| 21912 | return jsonify(out) |
| 21913 | |
| 21914 | if p == 'messaging': |
| 21915 | img, info, tg_l, wa_l = run_async(core.analyze_phone(t)) |
| 21916 | info['__tg_link'] = tg_l; info['__wa_link'] = wa_l |
| 21917 | base = {"username": t, "type": "Messaging", "info": info, "main_img": img, "status_code": 200, "url": ""} |
| 21918 | extra = [] |
| 21919 | try: |
| 21920 | extra = core.ignorant_scan(t) |
| 21921 | except Exception: |
| 21922 | extra = [] |
| 21923 | return jsonify([base] + (extra if isinstance(extra, list) else [extra])) |
| 21924 | elif p == 'gdrive': |
| 21925 | return jsonify([core.analyze_gdrive_doc(t)]) |
| 21926 | elif p == 'finance': |
| 21927 | res = [] |
| 21928 | try: |
| 21929 | for s, cm in CRYPTO_MAP.items(): |
| 21930 | if re.match(cm['regex'], t): |
| 21931 | c_info, c_graph = core.get_crypto_data(t, cm['name'], s) |
| 21932 | res.append({"username": t, "type": cm['name'], "info": c_info, "main_img": cm['icon'], "status_code": 200, "url": cm['explorer']+t, "graph_data": c_graph}) |
| 21933 | rev_i, rev_s = core.check_revolut(t) |
| 21934 | if rev_s == 200: res.append({"username": t, "type": "Revolut", "info": rev_i, "main_img": REV_ICON, "status_code": rev_s, "url": f"https://revolut.me/{t}"}) |
| 21935 | pp_i, pp_u, pp_s = core.check_paypal(t) |
nothing calls this directly
no test coverage detected