There's one episode of TG where they look at all the features of some muscle car looking thing, and then Jeremy says "now let's take a look at the monster under bonnet" but like... So weirdly. My girlfriend didn't understand why I rewound the episode 3 times to hear it again
The drop table command is injected into the code, supposing that there are still lines of code after the injection, using two dashes would make sure those lines are commented out and not executed. Therefore the sql code would only execute up to the drop table command.
Because the remaining fragment of whatever code you injected into is probably invalid and will crash, preventing return, possibly rolling back a transaction and certainly easier to spot
Correct me if this is out of date, but don't most common SQL implementations force a commit when you execute a Drop, so the rollback wouldn't even matter?
Suppressing possible errors lets you see if the injected code worked or not - maybe you're guessing the table name or can't tell if it actually got dropped or not, and maybe you'll hit gold and have the error from the DB server dumped to you in production code.
Plus in general you're not simply dropping tables when you do SQL injection, that's just common vandalism and doesn't achieve anything.
View all comments
Show parent comment
61
u/MrShlash Dec 02 '18
I’m curious, why didn’t you add —— after the semicolon?