search
Homephp教程php手册三步堵死SQL注入漏洞

三步堵死SQL注入漏洞

Jun 13, 2016 am 10:05 AM
sqlexistrightdatahourwhat isinjectionloopholesuserofprogramwritewebsiteenter

SQL注入是什么?
  许多网站程序在编写时,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患。用户可以提交一段数据库查询代码(一般是在浏览器地址栏进行,通过正常的www端口访问),根据程序返回的结果,获得某些想得知的数据,这就是所谓的SQL Injection,即SQL注入。
网站的恶梦——SQL注入
  SQL注入通过网页对网站数据库进行修改。它能够直接在数据库中添加具有管理员权限的用户,从而最终获得系统管理员权限。黑客可以利用获得的管理员权限任意获得网站上的文件或者在网页上加挂木马和各种恶意程序,对网站和访问该网站的网友都带来巨大危害。
防御SQL注入有妙法
  第一步:很多新手从网上下载SQL通用防注入系统的程序,在需要防范注入的页面头部用 来防止别人进行手动注入测试(如图1)。


图1
  可是如果通过SQL注入分析器就可轻松跳过防注入系统并自动分析其注入点(图2)。然后只需要几分钟,你的管理员账号及密码就会被分析出来(图3)。


图2


图3

  第二步:对于注入分析器的防范,笔者通过实验,发现了一种简单有效的防范方法。首先我们要知道SQL注入分析器是如何工作的。在操作过程中,发现软件并不是冲着“admin”管理员账号去的,而是冲着权限(如flag=1)去的。这样一来,无论你的管理员账号怎么变都无法逃过检测。

  第三步:既然无法逃过检测,那我们就做两个账号,一个是普通的管理员账号,一个是防止注入的账号,为什么这么说呢?笔者想,如果找一个权限最大的账号制造假象,吸引软件的检测,而这个账号里的内容是大于千字以上的中文字符,就会迫使软件对这个账号进行分析的时候进入全负荷状态甚至资源耗尽而死机。下面我们就来修改数据库吧。

  1.对表结构进行修改。将管理员的账号字段的数据类型进行修改,文本型改成最大字段255(其实也够了,如果还想做得再大点,可以选择备注型),密码的字段也进行相同设置。

  2.对表进行修改。设置管理员权限的账号放在ID1,并输入大量中文字符(最好大于100个字)。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.