Skip to content
HackInvasionCybersecurity Knowledge Hub
SQL injection defense, part 3: detection, logging, and ongoing protection

SQL injection defense, part 3: detection, logging, and ongoing protection

Originally published in 2016 when this blog covered offensive tutorials; rewritten in 2026 with a defensive focus.

Authorization notice: All security testing must only be done on systems you own or are explicitly authorized to assess. The vulnerable-site target list this post once contained has been removed. This is the third installment of our SQL injection defense series — parts 1 and 2 covered finding and fixing injection flaws; this part covers what comes after the fix: detection, logging, and ongoing protection.

Why detection still matters after you've fixed the code

Parameterized queries eliminate SQL injection at the source — but no codebase stays fixed by accident. New code ships, dependencies change, legacy endpoints resurface, and regressions happen. A detection layer catches what secure coding misses and tells you when someone is actively probing your applications, which is intelligence worth having.

Log what matters

You can't detect what you don't record. Make sure these are captured and centralized:

  • Full request details on database-backed endpoints: URL, parameters, user agent, source IP, and session identity.
  • Database error events with the failing query context (logged server-side, never returned to the user): syntax errors, type-conversion failures, and permission denials.
  • Query performance telemetry: execution time per query pattern. Time-based blind injection shows up as anomalous delays.
  • Authentication and session events tied to the same requests, so you can correlate a probe with an account.
  • WAF/edge block events — even blocked attempts are signal; a rising block rate against one endpoint means someone is working on it.

Build alerts that fire on real attacks

Turn the telemetry into detection rules in your SIEM:

  • Error-rate anomalies: alert when database errors spike on an endpoint relative to its baseline — classic injection probing.
  • Signature matches: flag requests containing SQL keywords, comment sequences, or stacked-query syntax in parameters that should never contain them. Tune to your application's normal input to control false positives.
  • Behavioral anomalies: a single client cycling through many parameter values, unusually large result sets served to low-privilege sessions, or response-time patterns consistent with blind extraction.
  • Known-bad correlation: match source IPs and request fingerprints against threat intelligence feeds of active scanners.

Ongoing protection: keep the fix fixed

  • Test in legal labs continuously: DVWA, bWAPP, and WebGoat remain the right places to train your team and validate scanner coverage — never someone else's production site.
  • Scan every release: integrate SAST and DAST into CI/CD so new injection flaws are caught before deployment, not after.
  • Re-audit data access: periodically review database account privileges — least privilege drifts over time as features are added.
  • Keep the WAF tuned: update rule sets, review what's being blocked, and investigate repeated blocks rather than ignoring them.
  • Run tabletop exercises: walk through a "we're being probed" scenario so your team knows who triages the alert, who checks the code, and when to escalate to incident response.

Measure it

Track mean time to detect probing, the number of injection findings per release, and the percentage of database-backed endpoints covered by alerting. If those numbers improve quarter over quarter, your program is working.

Series wrap-up

Part 1 taught you to find injection flaws in your own applications using safe labs. Part 2 covered remediation — parameterized queries, least privilege, and layered controls. This part closes the loop: log the right things, alert on the right patterns, and keep testing so the flaw stays fixed. SQL injection is a solved problem technically; the remaining work is operational discipline.

WordPress Security Checklist

WordPress Security Checklist

Image result for wordpress




WordPress Security Checklist

Basic Checklist :

1.  Rename user Admin to something else.
2.  Change the ID field on the first user from 1 to something else.
3.  Enforce strong password requirements for all system users
4.  Don‟t let anybody but admins see available WP updates.
5.  Remove the ability for non-admins to modify theme files.
6.  Tweak the database so tables aren‟t prefixed with wp_.
7.  Don‟t use the MySQL root user to access the database.
8.  Limit the MySQL account used to the site database only.
9.  Restrict the MySQL account so it can‟t perform destructive actions (i.e. DROP,
etc.)
10. Give the MySQL account a very long, randomised password.
11. Don‟t allow the server‟s root user access via SSH. Use an account with SUDO
privileges instead.
12. Ensure all the secret key fields in wp-config.php are completed with 16-bit SHA
keys.
13. Disallow indexes on all site folders.
14. Hide the admin area.
15. Rename the wp-content directory to something else.
16. Block bad hosts and agents with blacklists.
17. Make any .htaccess files and wp-config.php non-writeable.
18. Make the admin area inaccessible outside of work hours (handle this one with care)
19. Schedule regular database backups.
20. Restrict the length of allowed URLs to 255 characters or less.
21. Require SSL connections on the admin area (if possible; this one has an on-cost attached)
22. If possible, install and run server-side antivirus software such as ClamAV.
23. Consider restricting the server‟s FTP service to only accept connections from certain, whitelisted IP addresses (only applicable if you have at least one static IP).
24. When deploy complete, consider stopping the server‟s FTP service completely.
You can always temporarily switch it on again if required.
25. If your web server is allowing proxying (for example, if you‟re load-balancing),
ensure it‟s not configured as an open HTTP proxy.
26. Remove any open SMTP proxies on your server.


Wordpress Security

Wordpress Security

Pheww...!! Its been so long that i haven't posted something interesting. I really apologize for the delay. Lets Get Started :D

In my previous tutorials, I have explained how to hack a website (that was for educational purpose only) and how to upload a shell also. Now its time to secure your website from various attacks. 

Image result for what is wordpress

What is WordPress? 

Its and open source website creation written in PHP or is the easiest and most powerful blogging and website content management system . 

With the increase in Digital Market, more and more people are creating their website to show their presence in this Digital World so there is a need to secure that world also.



WordPress Security 

1. Disable custom HTML when possible

Add this code in wp-config.php file
define( 'DISALLOW_UNFILTERED_HTML',true );

2. Remove all Default posts and comments

Remove all default posts and comments. If malicious hackers find those on your site,then it may indicate to them that you have a new wordpress site which can be easily cracked.

just to this file "wp-includes/general-template.php"

function the_generator( $type ){
echo apply_filters("the_generator',get_the_generator($type),$type)."\n";
}
After Security

function the_generator($type){
#echo apply_filters('the_generator',get_the_generator($type),$type)."\n";
}

note: make sure a hash is applied next to the echo command .

3. Delete wp-admin/install.php and wp-admin/upgrade.php

Be sure to delete /wp-admin/install.php and /wp-admin/upgrade.php after every wordpress installation or upgrade. 

4. Hide indexes


 Just open .htaccess file and type this code

 Options –indexes   


 5.  Block Some Crucial directories
Your site's wp-includes/ directory is the most important one to block.

Find the .htaccess file there and insert

  RewriteRule ^(wp-includes)\/.*$ ./ [NC,R=301,L] 

If there are subdirectories, then use this code

 RewriteRule ^(wp-includes|subdirectory-name-here)\/.*$ ./ [NC,R=301,L] 

6.  Secure your Admin page with YUBICO

 http://www.yubico.com/   = PAID Plugin 

7.  Limit Login Attempts


Limit the number of login attempts possible both through normal login as well as using auth cookies.

http://wordpress.org/extend/plugins/login-lockdown/



8.  Server Side Scanning Online FREE

Web-malware continues to evolve making it challenging to detect using only HTTP fingerprinting techniques, such as the ones Site Check is restricted to.



9. Install Wordpress Security Scan Plugin


This  is  a  good  plugin  which  scans  your  Wordpress  installation  and  give  the  suggestion accordingly. This plugin will check for below things:

·     Passwords
·     File Permissions
·     Database Security
·     Wordpress Admin protection 




10. Automatically Backup your site



11. Two Factor Authenticator

The Google Authenticator plugin for Wordpress gives you two-factor authentication using the
Google Authenticator app for Android/iPhone/Blackberry.


12. Using .htaccess file as a FIREWALL

 RedirectMatch 403 \[ 
 
13. Clean out Old Unneeded Core Files

Clean out old unneeded core files with help from this free Wordpress plugin:



14. Activate Akismet Plugin

To block the comment spam automatically using Akismet Which a Wordpress plugin

15. Monitoring Your Wordpress


16. Hide Your Login Page


17. Content Security

 Try checking http://copyscape.com/


18. Check for Exploits

 http://wordpress.org/extend/plugins/exploit-scanner/                                                                

19. Select Email Address as Your Login Key


20. Change Database Prefix Plugin

 
21. Keep a log of Wordpress PHP and Database Errors


22. Outstanding Security Plugin




23. Website Defender Plugin


24. Maintenance Mode Plugin




Amit Vijayan

Amit Vijayan
Hack Ethically

About Me


I am an engineering student and i am very dedicated about Ethical Hacking. I have been learning "Ethical Hacking" for about 4 years now.
Though I'am not a pro hacker but also not a noob. I have enough knowledge to give others like me, a start for their Ethical Hacking & Cyber Security. As i keep learning new things, i keep updating them on the blog from basic to advanced level.
I started Ethical Hacking as a hobby which has now turned into my passion and i'am sure i will turn it into my profession through this blog.

Always be an Ethical Hacker.