If I have a PHP site hosted on Apache and someone hacks it using SQL injection, is there a way I can find out exactly which script caused this by looking at my web server logs?
Or using some other way?
If I have a PHP site hosted on Apache and someone hacks it using SQL injection, is there a way I can find out exactly which script caused this by looking at my web server logs?
Or using some other way?
I've been using this Linux command string to identify possible SQL injections:
You could add in other key terms as well, but those were the ones I was finding in my logs.
To generate a list of offending IP addresses, get a little fancier:
Which tallies up the offending IPs by the number of instances:
If your web server logs are logging the query parameters, then search for known SQL (e.g.
SELECT
) through the logs.If they're not logging query parameters, then you're unlikely to find anything by searching the logs, rather you'll have to look for patterns - for example a repeated URL that wouldn't normally be repeated.
I use a similar approach to Ken, but I prefer
awk
.To get a top 10 IP list. This will also search any old access logs which were gzipped with
logrotate
.