Test sql/js injection attack

please give some tips to test sql/js injection attack, how should I test them to make sure if I actually did escape anything?

For SQL, are you using prepared statements? If yes, then it’s perfect.

What you shouldn’t do is something like:

$variable = $_GET['var'];
$sql = 'SELECT * FROM table WHERE abc=' . $variable;

For JS, what are you doing in JavaScript? Are you using Ajax? Are you adding HTML elements dynamically to the page? Are you reading information in JS from the user or an external source (Ajax, API, etc.)?

Inevitably i think i should use something like you said! For example if on a client listing page i want to see only client with id=$_GET[‘id’] in WHERE clause. This is why i still need to test them if this is escaped. Or any better idea?

You cannot. Each SQL must be checked individually.
There are some tools that will analyze your website (send random requests to test security flaws - injections and xss) but this is not 100% safe.
Also, use PDO and prepared statements. This is the best security that you can get.

As about tools you said, please give links of some free ones.

The only good and free I know is SQL Map (it is Python)
There are lots of tutorials on YouTube
http://www.youtube.com/results?search_query=sqlmap+tutorial OR
http://www.youtube.com/results?search_query=sqlmap+in+action
=>
http://www.youtube.com/watch?v=BKDKMJt9Sp0
http://www.youtube.com/watch?v=-F1nBasky6E
and others

The paid solution is www.acunetix.com (didn’t test it) but it has good reviews.