Guest User

BGGP6: Download & Polyglot

a guest
Nov 25th, 2025
33
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. Writeup for:
  2. https://github.com/binarygolf/BGGP/issues/164
  3.  
  4. Firstly... mistakes were made! I decided I'd like to create a polyglot to cover BGGP #2 and missed the spec that it needed to be a binary (well a binary or bytecode) polyglot, so I mistakenly set off creating a Shell & SQL polyglot that I was really pleased with...
  5.  
  6. /*: 2>/dev/null;curl https://binary.golf/5/5 #*/SELECT 6
  7.  
  8. This makes good use of comments, firstly /*.../* is a comment in SQL, so whatever I put in here is ignored, and the /* that's interpreted by Shell is a file, followed by no-op : with the error dissapearing into the dev/null black hole via 2>/dev/null. This handled the error from the file and I could tack on ;curl https://binary.golf/5/5 to download the contents for BGGP 5 and lastly the # char meant the */SELECT 6 to the right would be ignored.
  9.  
  10. This weird interspersing of comments and errors being sent to dev/null I was pleased with. It was only a few bytes and a valid Shell and SQL file as I saw it output 5 and 6 respectively when executing via command line, great!
  11.  
  12. Then while submitting this entry, I noticed the words, "binary polyglot", so actually read the spec and realised my effort was no good, it wasn't a binary at all. Damn! I'd need to work on this more.
  13.  
  14. So I did some research on ELF and PDF files as I knew they were commonly used for polyglots, but couldn't make it work with my own polyglot too (I was determined to still use it). Then I looked to zip files and was pleased to be reminded that the PK header didn't have to be at byte 0 and it would be looked for - which was perfect as I could put the polyglot I already had at the start. Nothing wasted!
  15.  
  16. Okay, time to make a zip file that displayed 2. I decided to make an empty file, with a filename 2 as that would be enough. (so you could unzip and see 2). Python would help me create this plus jam the polyglot at the start. I came up with...
  17.  
  18. import zipfile
  19. import io
  20. import os
  21.  
  22. # Create ZIP with empty file named "2"
  23. zip_buffer = io.BytesIO()
  24. with zipfile.ZipFile(zip_buffer, 'w', compression=zipfile.ZIP_STORED) as zf:
  25. zf.writestr('2', '') # Empty file named "2"
  26.  
  27. zip_data = zip_buffer.getvalue()
  28.  
  29. shell_sql = '/*: 2>/dev/null;curl https://binary.golf/5/5 #*/SELECT 6;'
  30. polyglot = shell_sql.encode() + zip_data
  31.  
  32. output_file = '6.zip'
  33. with open(output_file, 'wb') as f:
  34. f.write(polyglot)
  35.  
  36. os.chmod(output_file, 0o755)
  37.  
  38. But there was a problem. When trying to execute the SQL it would error:
  39.  
  40. 6
  41. Parse error near line 1: near "PK": syntax error
  42. PK
  43. ^--- error here
  44.  
  45. ...as it was reading the start of the zip file (the PK keader). I knew there was another type of comment syntax that could be used with SQL... the -- syntax, so I could add that just before PK to stop it being read as SQL. Now we had the following format:
  46.  
  47. /*: 2>/dev/null;curl https://binary.golf/5/5 #*/SELECT 6;--PK<rest of zip binary>
  48.  
  49. ...and it worked! Now we had zip as the binary host file, with Shell and SQL at the beginning and they were all executing what they shoud due to their respective commenting and the error I didn't want to see from Shell disappearing into dev/null:
  50.  
  51. └─▶ sh 6.zip
  52. Another #BGGP5 download!! @binarygolf https://binary.golf
  53.  
  54. └─▶ sqlite3 :memory: < 6.zip
  55. 6
  56.  
  57. └─▶ unzip -Z -1 6-polyglot.shql 2>/dev/null
  58. 2
  59.  
  60. I'd try to get the unzip command working without sending the error: "warning [6-polyglot.shql]: 59 extra bytes at beginning or within zipfile (attempting to process anyway)" but not sure if much could be done about that.
  61.  
  62. Now I was really happy - a Zip/Shell/SQL polyglot (BGGP 2) that downloaded the URL (BGGP 5) and output 6 also (BGGP 6)
Advertisement
Comments
  • Xorlaxel
    49 days
    # CSS 0.84 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • Xenmovyn
    42 days
    # CSS 0.06 KB | 0 0
    1. You literally stole this exploit from https://t.me/theprotocolone
Add Comment
Please, Sign In to add comment