← Intel
Oct 5, 2026 · HackerOnStreet

Sql injection using Parameters (P

Using Sql for testing db is much batter almost every one know about it how to use in basic way. all know there are many ways that we can… Sql injection using Parameters (P-DB-b-1) Using Sql for testing db is much batter almost every one

sql injectionsql injection parameterssqlinjectionparameterscommentreserrortestqueryrequestconst
Sql injection using Parameters (P

Quick overview

FieldDetail
Topiccomment
GuideSql injection using Parameters (P
Tagscomment, res, error, sql, test, get
LengthAbout 1310 words
Practice ruleAuthorized labs only — stay ethical

Using Sql for testing db is much batter almost every one know about it how to use in basic way. all know there are many ways that we can…


Sql injection using Parameters (P-DB-b-1)

Using Sql for testing db is much batter almost every one know about it how to use in basic way. all know there are many ways that we can test sql injection . My name is Imran a person who always try to find loop hole in web application maybe your app will be next.

Version 0.02 :

This is basic Version but you will get much batter understanding of SQL injection and Sql Other scripts.

in Future we will see using other tools with Sqlmap fro batter results

To we will see how can we use Sqlmap to find sql injection in public server. and also try to make our own web application that will be a good target to find app. wit hour app we will see how can we use Sql injection in protected web application.

Mothed will are going to fallow in this one that will be Parameters that is one of best way

async function get_comment(req, res) {
try {
let comment_id = req.query.id;

// Validate comment_id to ensure it is a non-empty string or a positive integer
if (!comment_id || isNaN(comment_id) || parseInt(comment_id) <= 0) {
res.status(400).send('Invalid comment ID');
return;
}

// Use parameterized query to prevent SQL injection
let sql_query = "SELECT * FROM comments WHERE id = ?";
let comment = await db.execute_query(sql_query, [comment_id]);

// Check if comment exists
if (comment.length === 0) {
res.status(404).send('Comment not found');
return;
}

let html = template.render(comment);
res.html(html);
} catch (error) {
console.error(error);
res.status(500).send('Internal Server Error');
}
}

For Parameter Testing :

Parameters testing on of best way to test SQL injection.Reason Patameter testing can help you to ideintyfy the diffrent issue like SQL injection , XSS , html injection.

const { expect } = require('chai');

describe('get_comment', () => {
it('should return the comment HTML when a valid comment ID is provided', async () => {
const req = { query: { id: '123' } };
const res = {
html: (html) => {
expect(html).to.be.a('string');
// Add additional assertions as needed
},
status: () => res,
send: () => res,
};

await get_comment(req, res);
});

it('should return a 400 Bad Request when an invalid comment ID is provided', async () => {
const req = { query: { id: 'invalid' } };
const res = {
status: (statusCode) => {
expect(statusCode).to.equal(400);
return res;
},
send: (message) => {
expect(message).to.equal('Invalid comment ID');
},
};

await get_comment(req, res);
});

it('should return a 404 Not Found when a non-existing comment ID is provided', async () => {
const req = { query: { id: '999' } };
const res = {
status: (statusCode) => {
expect(statusCode).to.equal(404);
return res;
},
send: (message) => {
expect(message).to.equal('Comment not found');
},
};

await get_comment(req, res);
});

it('should return a 500 Internal Server Error when an error occurs during execution', async () => {
const req = { query: { id: '123' } };
const res = {
status: (statusCode) => {
expect(statusCode).to.equal(500);
return res;
},
send: (message) => {
expect(message).to.equal('Internal Server Error');
},
};

// Mock an error by throwing an exception
const db = {
execute_query: () => {
throw new Error('Database connection error');
},
};

// Execute the function in a try/catch block to capture the error
try {
await get_comment(req, res);
} catch (error) {
// Ensure that the error is logged to the console
expect(console.error.called).to.be.true;
}
});
});

Basic Sql injection using Request Matheds :

Request hoding or if you want use Curl mathed you can test XSS Sql even CSRF and others kind of testing using Request matheds.

if you have issue in using Curl you can use burp Suite for this job.Burpsuite help you to Pos the request and sand same request more then 1 time.

# Test case: Valid comment ID
curl -X GET 'http://localhost:8000/comment?id=123'

# Test case: Invalid comment ID
curl -X GET 'http://localhost:8000/comment?id=invalid'

# Test case: Non-existing comment ID
curl -X GET 'http://localhost:8000/comment?id=999'

# Test case: Error during execution
curl -X GET 'http://localhost:8000/comment?id=123' -H 'X-Error-Simulate: true'
# Test case: Valid request with all parameters
curl -X POST 'http://localhost:8000/user' \
-H 'Content-Type: application/json' \
-d '{"name": "John Doe", "age": 30, "email": "john@example.com"}'

# Test case: Request missing required parameter (name)
curl -X POST 'http://localhost:8000/user' \
-H 'Content-Type: application/json' \
-d '{"age": 25, "email": "jane@example.com"}'

# Test case: Request with only required parameter (name)
curl -X POST 'http://localhost:8000/user' \
-H 'Content-Type: application/json' \
-d '{"name": "Jane Smith"}'

# Test case: Request with invalid age value
curl -X POST 'http://localhost:8000/user' \
-H 'Content-Type: application/json' \
-d '{"name": "Alice", "age": "twenty-five", "email": "alice@example.com"}'

# Test case: Request with empty email
curl -X POST 'http://localhost:8000/user' \
-H 'Content-Type: application/json' \
-d '{"name": "Bob", "age": 45, "email": ""}'
Photo by Stephen Phillips - Hostreviews.co.uk on Unsplash

python3 sqlmap.py “https://www...x.x.x..com/en/login.php?destination=%2Forchis%2F6%3FPHPSESSID%3D&PHPSESSID=" — level=5 — risk=3 — banner — dump-all

Tip :

if userlogin.php?id=1 you find and its not workign always use diffrent mathed. there can i one best soloution for this. always change patameters

For example:

/en/product-list.php?id=8&Last_id=1 in this case we can see that it has

  • product-list.php?id=8
  • &Last_id=1

we can replace parameter or add new Spactial Ctactors some time can make issue In Proforming attacks

TIP 2:

if in anycase you get database name stop using other db injection matheds.that can help you to safe your time

like In this i try to test by Changing id dont only see if there is any id.

some time target is availabe its very important to use

sqlmap -u “http:yoursite.com/shop?has_sku=&seopath=-$$best\-sellers" — dbms=mysql — level=5 — risk=3

Enhanced User Retrieval with Modular Function in Python :

As we Know Code is organized into a function fetch_users_by_username() for better reusability and separation of concerns. User input is obtained dynamically using input().

import sqlite3

def fetch_users_by_username(username):
# Establish a connection to the database
with sqlite3.connect('example.db') as conn:
# Create a cursor object
cursor = conn.cursor()

# Execute a prepared statement
query = "SELECT * FROM users WHERE username = ?"
cursor.execute(query, (username,))

# Fetch the results
results = cursor.fetchall()
return results

# Example user input
user_input = input("Enter a username: ")

# Fetch users from the database
users = fetch_users_by_username(user_input)

# Display the results
for user in users:
print(user)

The function takes a username parameter and returns results, enhancing modularity. Function separation allows for easy addition of error handling, validation, and more database operations. Adapt the code as per your database configuration and requirements.

Frequently asked questions

What is this guide about comment?

Sql injection using Parameters (P explains practical, ethical notes on comment. Use it as a structured walkthrough — then practice only in authorized labs.

Who is this comment article for?

Readers who want clear, street-level guidance on comment without hype. Beginners and intermediate practitioners both benefit.

How do I practice comment safely?

Stay in scope: systems you own or have written permission to test. Keep notes, verify findings, and never attack live targets without authorization.