├── Interactsh.py └── README.md /Interactsh.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | # @Author : RedTeamWing 4 | # @CreateTime: 2021/11/6 下午4:08 5 | # @FileName: Interactsh.py 6 | # @Blog:https://redteamwing.com 7 | import base64 8 | import json 9 | import codecs 10 | import random 11 | import requests 12 | from uuid import uuid4 13 | from Cryptodome.Cipher import AES 14 | from Cryptodome.Hash import SHA256 15 | from xid import XID 16 | from base64 import b64encode 17 | from Crypto import Random 18 | from Crypto.PublicKey import RSA 19 | from Crypto.Cipher import PKCS1_OAEP 20 | 21 | 22 | class Interactsh: 23 | def __init__(self): 24 | random_generator = Random.new().read 25 | guid = XID() 26 | rsa = RSA.generate(2048, random_generator) 27 | self.public_key = rsa.publickey().exportKey() 28 | self.private_key = rsa.exportKey() 29 | self.headers = { 30 | "Content-Type": "application/json" 31 | } 32 | self.secret = str(uuid4()) 33 | self.encoded = b64encode(self.public_key).decode("utf8") 34 | self.correlation_id = guid.string() 35 | self.Register() 36 | 37 | def Register(self): 38 | data = { 39 | "public-key": self.encoded, 40 | "secret-key": self.secret, 41 | "correlation-id": self.correlation_id 42 | } 43 | try: 44 | resp = requests.post("https://interactsh.com/register", headers=self.headers, data=json.dumps(data)) 45 | except Exception as e: 46 | return "error" 47 | 48 | def Poll(self): 49 | try: 50 | result = [] 51 | protocol_list = set() 52 | url = f"https://interactsh.com/poll?id={self.correlation_id}&secret={self.secret}" 53 | resp2 = requests.get(url) 54 | reps2 = json.loads(resp2.text) 55 | aes_key = reps2["aes_key"] 56 | data_list = reps2["data"] 57 | if data_list: 58 | for i in data_list: 59 | protocol, decrypt_data = self.DecryptData(aes_key, i) 60 | result.append(decrypt_data) 61 | protocol_list.add(protocol) 62 | return list(protocol_list), result 63 | except Exception as e: 64 | return "" 65 | 66 | def DecryptData(self, aes_key, data): 67 | private_key = RSA.importKey(self.private_key) 68 | cipher = PKCS1_OAEP.new(private_key, hashAlgo=SHA256) 69 | aes_plain_key = cipher.decrypt(base64.b64decode(aes_key)) 70 | decode = base64.b64decode(data) 71 | bs = AES.block_size 72 | iv = decode[:bs] 73 | cryptor = AES.new(key=aes_plain_key, mode=AES.MODE_CFB, IV=iv, segment_size=128) 74 | plain_text = cryptor.decrypt(decode) 75 | protocol = json.loads(plain_text[16:])["protocol"] 76 | return protocol, json.loads(plain_text[16:]) 77 | 78 | def GetDomain(self): 79 | domain = self.correlation_id 80 | while (len(domain) < 33): 81 | domain += chr(ord('a') + random.randint(1, 24)) 82 | domain += ".interactsh.com" 83 | return domain 84 | 85 | def Verify(self): 86 | a,b = self.Poll() 87 | if b: 88 | return b 89 | else: 90 | return False 91 | 92 | 93 | Interactsh = Interactsh() 94 | 95 | 96 | if __name__ == "__main__": 97 | Interactsh = Interactsh() 98 | domain = Interactsh.GetDomain() 99 | requests.get("http://" + domain, timeout=3) 100 | print(Interactsh.Poll()) 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Py-Interactsh 2 | Dnslog Interactsh的Py版接口查询 3 | 4 | ## Demo 5 | 6 | ``` 7 | Interactsh = Interactsh() 8 | domain = Interactsh.GetDomain() 9 | requests.get("http://" + domain, timeout=3) 10 | print(Interactsh.Poll()) 11 | ``` 12 | --------------------------------------------------------------------------------