logo

blog

My website can't be that messy, right? git clone https://anongit.hacktivis.me/git/blog.git/

gen-drink-me.sh (1317B)


  1. #!/bin/sh
  2. for i in $(seq 13 1)
  3. do
  4. echo "generating drink-me-$i.html"
  5. # Generate non-evil version so nginx will use brotli_static
  6. # and a simple curl at it will not show the evil
  7. printf \
  8. '<!DOCTYPE html>
  9. <html>
  10. <head><meta charset="utf-8"><title>drink me %d</title></head>
  11. <body>
  12. <main>
  13. <p><a href="./drink-me-%d.html">prev</a> - <a href="./drink-me-%d.html">next</a></p>
  14. <q>%s</q>
  15. </main>
  16. </body>
  17. </html>
  18. ' \
  19. "$i" \
  20. $((i - 1)) \
  21. $((i + 1)) \
  22. "$(fortune)" \
  23. > "drink-me-$i.html"
  24. size=$(wc -c <"drink-me-$i.html")
  25. chmod +r "drink-me-$i.html"
  26. # == Generate evil-brotli version ==
  27. # NodeJS string limit: 536870888 (24 bytes less than exactly 512MiB)
  28. # ((8^10)/2)-(8*10) ~= 512 MiB
  29. # ((8^11)/2)-(8*11) ~= 4 GiB
  30. # ((8^12)/2)-(8*12) ~= 32 GiB
  31. # ((8^13)/2)-(8*13) ~= 256 GiB
  32. evil_size=$(echo "${size}+((8^${i})/2)-(8*${i})" | bc)
  33. echo "generating drink-me-$i.html.br (${evil_size} bytes)"
  34. {
  35. printf \
  36. '<!DOCTYPE html>
  37. <html>
  38. <head><meta charset="utf-8"><title>drink me %d</title></head>
  39. <body>
  40. <main>
  41. <p><a href="./drink-me-%d.html">prev</a> - <a href="./drink-me-%d.html">next</a></p>
  42. ' \
  43. "$i" \
  44. $((i - 1)) \
  45. $((i + 1))
  46. yes '
  47. <p><a href="#">'
  48. } \
  49. | head -c "${evil_size}" \
  50. | brotli -f -Z -o "drink-me-$i.html.br"
  51. chmod +r "drink-me-$i.html.br"
  52. done