Posted to tcl by cgm at Mon Apr 08 06:59:53 GMT 2024view raw

  1. # Return crap when script kiddies request php etc. files
  2.  
  3. package require httpd
  4.  
  5. rename Doc_NotFound Doc_NotFound.orig
  6.  
  7. proc Doc_NotFound sock {
  8. upvar #0 Httpd$sock data
  9. switch -glob $data(suffix) {
  10. *.php {set mimetype text/html}
  11. .* {set mimetype text/plain}
  12. default {tailcall Doc_NotFound.orig $sock}
  13. }
  14.  
  15. # return a random amount of random crap
  16. exec head -[expr {int(rand()*10000000)}]c /dev/urandom > htdocs/load_of_crap
  17. Httpd_ReturnFile $sock $mimetype htdocs/load_of_crap
  18. }