| 12511 | return target.replace("https://", "").replace("http://", "").split('/')[0].strip() |
| 12512 | |
| 12513 | def ip_rdap_lookup(self, ip): |
| 12514 | ip = ip.strip() |
| 12515 | rdap_servers = [ |
| 12516 | "https://rdap.arin.net/registry/ip/", |
| 12517 | "https://rdap.ripe.net/ip/", |
| 12518 | "https://rdap.apnic.net/ip/", |
| 12519 | "https://rdap.lacnic.net/rdap/ip/", |
| 12520 | "https://rdap.afrinic.net/rdap/ip/", |
| 12521 | ] |
| 12522 | headers = {"Accept": "application/rdap+json"} |
| 12523 | for base in rdap_servers: |
| 12524 | try: |
| 12525 | r = requests.get(base + ip, headers=headers, timeout=6) |
| 12526 | if r.status_code == 200: |
| 12527 | j = r.json() |
| 12528 | out = {"Status": " RDAP OK"} |
| 12529 | if j.get("handle"): out["Handle"] = str(j.get("handle")) |
| 12530 | if j.get("name"): out["Name"] = str(j.get("name")) |
| 12531 | if j.get("type"): out["Type"] = str(j.get("type")) |
| 12532 | if j.get("startAddress"): out["Start"] = str(j.get("startAddress")) |
| 12533 | if j.get("endAddress"): out["End"] = str(j.get("endAddress")) |
| 12534 | if j.get("country"): out["Country"] = str(j.get("country")) |
| 12535 | if j.get("parentHandle"): out["Parent"] = str(j.get("parentHandle")) |
| 12536 | if j.get("events"): |
| 12537 | evs = [] |
| 12538 | for ev in j.get("events", []): |
| 12539 | try: |
| 12540 | evs.append(f"{ev.get('eventAction','')}: {ev.get('eventDate','')}") |
| 12541 | except: |
| 12542 | continue |
| 12543 | if evs: out["Events"] = " | ".join(evs[:6]) |
| 12544 | return out |
| 12545 | except: |
| 12546 | continue |
| 12547 | return {"Status": " RDAP non disponibile"} |
| 12548 | |
| 12549 | def shodan_host(self, ip): |
| 12550 | key = (self.creds.get("shodan_key") or "").strip() |