/ sharder.py
sharder.py
 1  import os
 2  import base64
 3  from cryptography.fernet import Fernet
 4  
 5  def generate_shards(input_file, shard_size=1024):
 6      print(f"[+] Starting Fragmentation on {input_file}...")
 7      
 8      # Generate a unique key for this 'Recirculation' loop
 9      key = Fernet.generate_key()
10      f = Fernet(key)
11      
12      with open(input_file, 'rb') as source:
13          data = source.read()
14          
15      # Encrypt the entire payload before shredding
16      encrypted_data = f.encrypt(data)
17      encoded_data = base64.b64encode(encrypted_data)
18      
19      # Create the 'Ghost' fragments
20      os.makedirs('shards', exist_ok=True)
21      
22      total_shards = (len(encoded_data) // shard_size) + 1
23      for i in range(total_shards):
24          chunk = encoded_data[i*shard_size : (i+1)*shard_size]
25          with open(f"shards/sys_log_part_{i}.shard", 'wb') as shard_file:
26              # We wrap the shard in 'Noise' to look like a log entry
27              shard_file.write(b"TIMESTAMP: 2025-12-25 | LOG_LEVEL: INFO | DATA: " + chunk)
28              
29      with open("shards/master.key", "wb") as key_file:
30          key_file.write(key)
31          
32      print(f"[!] Created {total_shards} Fragments. Key secured in master.key.")
33  
34  if __name__ == "__main__":
35      # For testing, we'll create a dummy payload
36      with open("payload.bin", "wb") as f:
37          f.write(os.urandom(5120)) # 5KB dummy payload
38          
39      generate_shards("payload.bin")