Are these strange URLs that are being loaded to access our site hackers or what?

Those are attempts to break the query syntax.

If the site returns an error message the would be hacker knows the query is vulnerable to an injection attack (due to using user supplied input directly in the query)

OK, I did wonder what that was, it does appear from time to time and I think itā€™s people, not bots. I would have expected the closing quote to be followed by some kind of injection. But I suppose they are just testing first to see if it will work, before wasting time trying an injection, is that it?
I guess the preg replace takes care of that, stripping all but numbers, plus the sql account opening the database is read only.

I donā€™t know exactly what they do, but they sure spend a lot of bandwidth looking for vulnerable sites.

Unfortunately, despite repeated admonitiona to filter and sanitize all user supplied input there are plenty of sites where the dev is either a newbie or ā€œtoo busy to do it now, Iā€™ll get to that laterā€ or any number of other excuses reasons

Yes, I think you are totally right.
Since I became aware of these MySQL hacks, I wrote code to detail these actions, and they are exactly about some real sick vermons out there trying to find vulnerability on a site to then engage in their MySQL injection, etc. attempts.

While I think my code is coping with the attempted attacks, I am just in the process of tightening up the security of my databases. While it is clear that people are trying, I think itā€™s better to be safe than sorry.
What Iā€™m doing is re-organising my databases and tables. In the beginning, in my wisdom, I just created a database and put various tables in it. What Iā€™m now doing is having separate databases, for tables of public and private data.
The public data is the stuff displayed on the website which people are quite free to read there. The private will hold more sensitive stuff such as user names, passwords, emails and phone numbers, things the site visitors donā€™t see. There is nothing of any real value there, like card/bank details, though contact data could be used for spamming or sold to spammers. I donā€™t know if the would-be hackers are fishing for data or just wanting to cause a nuisance by deleting my data. Who knows?
Any way, accessing more than one database will make some scripts a little more complex.
I just have a simple question about re-using a variable to access databases. I use include files to open the connections, like this:-

$db = mysqli_connect("$db_host","$db_username","$db_pass","$db_name") ;

So $db is my connection.
Say for example I connect to a private database to get user data to establish user permissions. Then if the user has Admin permissions I add another insert that opens a connection to a Public database with editing permissions. It uses the same variable $db
My question is must I close the first connection before opening the new one?

mysqli_close($db);

Or does re-using the same variable do that for me by overwriting it?
I know I could use a different variable for different databases, but that would complicate things for me. I donā€™t need both at the same time, just one after the other, as described.

Iā€™m fairly certain the variable would be over-written. But if you are done with it I see no harm in closing it just to be sure.

1 Like

I thought it would be overwritten, but was uncomfortable about the possibility of leaving a connection open. I suppose I should play on the safe side and close everything to be sure.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.