proofofwork.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import random
  2. import hashlib
  3. import json
  4. import base64
  5. from datetime import datetime, timezone
  6. def generate_proof_token(required: bool, seed: str = "", difficulty: str = "", user_agent: str = None, proof_token: str = None):
  7. if not required:
  8. return
  9. if proof_token is None:
  10. screen = random.choice([3008, 4010, 6000]) * random.choice([1, 2, 4])
  11. # Get current UTC time
  12. now_utc = datetime.now(timezone.utc)
  13. parse_time = now_utc.strftime('%a, %d %b %Y %H:%M:%S GMT')
  14. proof_token = [
  15. screen, parse_time,
  16. None, 0, user_agent,
  17. "https://tcr9i.chat.openai.com/v2/35536E1E-65B4-4D96-9D97-6ADB7EFF8147/api.js",
  18. "dpl=1440a687921de39ff5ee56b92807faaadce73f13","en","en-US",
  19. None,
  20. "plugins−[object PluginArray]",
  21. random.choice(["_reactListeningcfilawjnerp", "_reactListening9ne2dfo1i47", "_reactListening410nzwhan2a"]),
  22. random.choice(["alert", "ontransitionend", "onprogress"])
  23. ]
  24. diff_len = len(difficulty)
  25. for i in range(100000):
  26. proof_token[3] = i
  27. json_data = json.dumps(proof_token)
  28. base = base64.b64encode(json_data.encode()).decode()
  29. hash_value = hashlib.sha3_512((seed + base).encode()).digest()
  30. if hash_value.hex()[:diff_len] <= difficulty:
  31. return "gAAAAAB" + base
  32. fallback_base = base64.b64encode(f'"{seed}"'.encode()).decode()
  33. return "gAAAAABwQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D" + fallback_base