/ weaver.py
weaver.py
 1  import os
 2  import base64
 3  from cryptography.fernet import Fernet
 4  
 5  def reassemble_shards(output_file):
 6      print("[+] Weaver Active. Initializing RAM Reassembly...")
 7      
 8      # Load the key - in the real 'Unstoppable' version, this is passed via memory, not a file
 9      with open("shards/master.key", "rb") as key_file:
10          key = key_file.read()
11      
12      f = Fernet(key)
13      full_encoded_data = b""
14      
15      # Identify and sort shards to ensure correct sequence
16      shard_files = sorted([f for f in os.listdir('shards') if f.endswith('.shard')], 
17                           key=lambda x: int(x.split('_')[-1].split('.')[0]))
18      
19      print(f"[*] Found {len(shard_files)} shards. Extracting from Noise...")
20      
21      for filename in shard_files:
22          with open(f"shards/{filename}", 'rb') as shard_file:
23              content = shard_file.read()
24              # Extract only the data after the 'DATA: ' tag (The Recirculation)
25              chunk = content.split(b"DATA: ")[1]
26              full_encoded_data += chunk
27              
28      # Decrypt and reassemble the 'Muscle'
29      try:
30          decrypted_data = f.decrypt(base64.b64decode(full_encoded_data))
31          
32          with open(output_file, 'wb') as f_out:
33              f_out.write(decrypted_data)
34              
35          print(f"[!] Reassembly Complete. {output_file} is live in the Shadow.")
36      except Exception as e:
37          print(f"[-] Reassembly Failed: {e}")
38  
39  if __name__ == "__main__":
40      reassemble_shards("recovered_payload.bin")