Mod Security Attack Protection Class Activity 2 - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

Common Attack Type Protection

Now your web server is ready to protect against common attack types like XSS, SQL Injection, Protocol Violation, etc. as we have installed Core Rule and turned on Rule Engine.

XSS Attack

  • Open a browser and request a simulated bad page from your server with the <script> tag at the end of the URL. Such as:
  • Monitor the modesec_audit.log in the /var/log/httpd folder

image

  • As you can see Mod Security blocks this request as it contains <script> tag which is the root of a XSS attack.

image

Directory Traversal Attack:

Directory traversal attacks can create a lot of damage by accessing system related files that should not be available to web users. For example /etc/passwd, .htaccess, etc.

  • Open a browser and attempt a simulated directory traversal using a URL like the one below.
    • http://server-ip/?../../boot

image

  • Monitor the modsec_audit.log in the /var/log/httpd folder
  • As you can see Mod Security blocks request as it contains directory traversal.

I had issues with viewing the full logs in nano, so I went in the nano configuarion file and made it so that the lines wrapped and that each line has line numbers.

  • nano ~/.nanorc
    • It won't have anything in the file
  • add set softwrap and set linenumbers to the nano file

image

Telnet web client

As we have done the last few weeks, use telnet to the web server and attempt to load the page.

make sure to enable port 80 in the httpd.conf fileto use mod_evasive because it cannot handle SSl (which is port 443)

  • use <script> in the GET page request parameter.

image

image

⚠️ **GitHub.com Fallback** ⚠️