codexual

Ubuntu (Mod Security)

Oct 18th, 2017
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. // You Commands / Content is below all this junk, but you should read this junk if you support me! <3
  2.  
  3. // Codexual @ NuLLocK.com
  4. // YouTube.com/Codexual
  5. // Twitter.com/Codexual
  6. // Facebook.com/Codexual
  7. // Instagram.com/Codexual
  8. // Snapchat.com/add/Codexual
  9. // Twitch.tv/Codexual
  10. // Mixer.com/Codexual
  11. //
  12. // Gaming
  13. // https://steamcommunity.com/id/Codexual
  14. // Xbox - Codexual
  15. // PS4 - Codexual
  16. //
  17. // Hey Viewer, I would like to thank you. Speaking of being thankful, if you truly support my work, or just wanna be a good sport. // All I all of you is to follow me on my social media, like my content on all social media if you see me post something, and share // my content when you see me post something. Everything does help out, thank you again!
  18. //
  19. // Every Saturday I do a Q/A video, so if you have a question you may ask me at http://nullock.com/askme - Look for the Q/A video on
  20. // my YouTube Channel! (:
  21.  
  22. sudo apt-get update
  23. sudo apt-get install libapache2-mod-security2 -y
  24. //sudo apachectl -M | grep --color security2
  25. sudo mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
  26. sudo service apache2 reload
  27.  
  28. //Config Mod_Security
  29. sudo sed -i "s/SecRuleEngine DetectionOnly/SecRuleEngine On/" /etc/modsecurity/modsecurity.conf
  30. sudo sed -i "s/SecResponseBodyAccess On/SecResponseBodyAccess Off/" /etc/modsecurity/modsecurity.conf
  31. SecRequestBodyLimit 13107200
  32. SecRequestBodyNoFilesLimit 131072
  33. SecRequestBodyInMemoryLimit 131072
  34.  
  35. //Testing an SQL Injection
  36. mysql -u root -p
  37. > create database sample;
  38. > connect sample;
  39.  
  40. > create table users(username VARCHAR(100),password VARCHAR(100));
  41. > insert into users values('sammy','password');
  42. > quit;
  43.  
  44. sudo nano /var/www/html/login.php
  45.  
  46. ' or true --
  47.  
  48. //Enable CRS
  49. sudo nano /etc/apache2/mods-enabled/security2.conf
  50.  
  51. IncludeOptional "/usr/share/modsecurity-crs/*.conf"
  52. IncludeOptional "/usr/share/modsecurity-crs/activated_rules/*.conf"
  53.  
  54.  
  55. cd /usr/share/modsecurity-crs/activated_rules/
  56. sudo ln -s ../base_rules/modsecurity_crs_41_sql_injection_attacks.conf .
  57. sudo service apache2 reload
  58. sudo rm /var/www/html/login.php
  59.  
  60. //Writing Your Own Rules
  61. sudo nano /var/www/html/form.php
  62.  
  63. sudo nano /etc/modsecurity/modsecurity_custom_rules.conf
  64.  
  65. SecRule REQUEST_FILENAME "form.php" "id:'400001',chain,deny,log,msg:'Spam detected'"
  66. SecRule REQUEST_METHOD "POST" chain
  67. SecRule REQUEST_BODY "@rx (?i:(blockedword1|blockedword2))"
  68.  
  69. sudo service apache2 reload
  70.  
  71. sudo rm /var/www/html/form.php
Advertisement
Add Comment
Please, Sign In to add comment