r/netsec • • Dec 20 '17

SQL Injection Cheat Sheet

https://sqlwiki.netspi.com/
1.1k Upvotes

29 comments sorted by

68

u/idunnomyusername Dec 21 '17

31

u/moderatorrater Dec 21 '17

Or http://sqlmap.org/. I'm all for knowing the principles behind injection attacks, but at the end of the day using a tool is going to be better for everything outside of education.

6

u/pm_me_your_findings Dec 21 '17

There have been times when i was able to find an sql injection manually but sqlmap didn't. Still sqlmap is superb when you have limited time to test an web apps.

2

u/746865626c617a Jan 02 '18

Once had to write a proxy to modify requests that sqlmap was doing. Time based injection, didn't feel like implementing myself

-1

u/sup3r_hero Dec 21 '17

Human injection?.... is that a joke?

9

u/big_money_metis Dec 21 '17

Please wake up

14

u/[deleted] Dec 21 '17

[removed] — view removed comment

7

u/CIa3xpl0i1_rw Dec 21 '17

If your antivirus scanner is acting on a file that contains the EICAR test string and has a total file length exceeding 128 characters, you've got a larger problem.

13

u/Paratwa Dec 21 '17

Edit : nevermind I need to learn how to click apparently. I am leaving the below to remind myself I should learn to read.

Original : This was written like a power point and doesn’t describe how they are done technically. To me learning how one was actually done via examples really showed me where applications would be vulnerable and were far more useful

6

u/failedgamor Dec 21 '17

Anyone got anything similar for XSS?

-4

u/[deleted] Dec 21 '17 edited Dec 21 '17

still in 2017 people manually testing for SQLi?

12

u/isilidurstilt Dec 21 '17

We're stuck in 2017 and this guy over here playing 4d chess in 2018.

-1

u/[deleted] Dec 21 '17

fixed :P

3

u/[deleted] Dec 21 '17

still in 2017 people manually testing for SQLi?

SQL injections shouldn't even be a major issue in 2017

0

u/UnfrightenedAjaia Dec 21 '17

"they can't guess the names of the columns" so it's okay actually /s

0

u/[deleted] Dec 21 '17

[deleted]

3

u/nylithic Dec 21 '17

Well it is a single page web app ;)

0

u/[deleted] Dec 21 '17

[deleted]

19

u/coinclink Dec 21 '17

You should not be escaping strings with custom code. That is exactly the wrong thing to do. You should use prepared statements for SQL. There are plenty of lightweight, well-maintained libraries out there that you can depend on. At a minimum, your language probably has built-in escape functions. It also certainly has built-in functions to verify input.

0

u/[deleted] Dec 21 '17

[deleted]

26

u/coinclink Dec 21 '17

Your reasoning is exactly what creates insecure software. This isn't 1995 or even 2005, dependencies aren't a big deal. Use code that is peer reviewed and regularly patched. Be innovative in your product, not with security.

6

u/yawkat Dec 21 '17

Wouldn't you still want to escape even if you use a library? It won't know if you meant ' as part of a SQL statement or if it's literal.

No, that is not how prepared statements work. There is no escaping necessary at all when using prepared statements.

4

u/Idontremember99 Dec 21 '17

In addition to what the others said: The library you are using to connect to the database should already support everything you need to use prepared statements so no extra dependency is needed. If it doesnt support it, then it's time to replace it.