怎么看网站是哪个系统做的,快印店网站建设84wzjs,设计官网需要留言吗,小米商城网站开发文档文章目录 文件上传类需求文件上传漏洞 文件下载类需求文件下载漏洞 扩展 留言板类#xff08;XSS漏洞#xff09;需求XSS漏洞 登录类需求cookie伪造漏洞万能密码登录 持续更新中… 文章中代码资源已上传资源#xff0c;如需要打包好的请点击PHP开发漏洞环境#xff08;SQL注… 文章目录 文件上传类需求文件上传漏洞 文件下载类需求文件下载漏洞 扩展 留言板类XSS漏洞需求XSS漏洞 登录类需求cookie伪造漏洞万能密码登录 持续更新中… 文章中代码资源已上传资源如需要打包好的请点击PHP开发漏洞环境SQL注入文件上传文件下载XSS万能密码session/cookie的学习等等
文件上传类
需求
1、在博客文件中生成上传文件的功能
2、只允许上传jpg、jpeg、png文件格式upload.php !DOCTYPE html
html
head title文件上传/title
/head
body
h2文件上传/h2
form action methodPOST enctypemultipart/form-data input typefile nameupload input typesubmit value上传
/form
/body
/html ?php
header(Content-Type: text/html; charsetUTF-8); //设置字符集
//获取文件名字
$name $_FILES[upload][name];
//获取上传文件的类型
$type $_FILES[upload][type];
//获取上传文件的大小
$size $_FILES[upload][size];
//获取上传文件的错误代码
$error $_FILES[upload][error];
//获取上传文件的临时文件名
$tmp_name $_FILES[upload][tmp_name]; echo $name . br;//打印
echo $type . br;
echo $size . br;
echo $error . br;
echo $tmp_name . br; if ($type image/jpeg || $type image/jpg || $type image/png) { if (!move_uploaded_file($tmp_name, upload/ . $name)) { echo 文件移动失败; } else { echo /upload/ . $name; echo 文件上传成功; }
} else { echo 文件类型不正确;
}
?文件上传漏洞 通过代码分析做了文件类型的判断只限于jpeg、png、jpg 三种类型进行上传那么上传php一句话木马会提示文件类型不正确并且在目录中未发现上传的文件 试想既然知道有限制那么我们能不能抓包修改文件类型呢 上传一个一句话木马文件文件后缀 .php ?php eval($_POST[cmd]);?修改为 Content-Type:image/png放包 发现上传成功并获取到了路径 进行漏洞利用 文件下载类
需求
1、创建一个文件下载的功能
2、在soft文件夹中提取所需要的东西
3、需要有选择框以供选择download.php !DOCTYPE html
html langen
head meta charsetUTF-8 title文件下载/title
/head
body
h1直接下载/h1
?php
// 获取文件路径
$filepath ../soft/; // 获取文件列表
$filenames scandir($filepath); // 创建下载表单
echo form action methodPOST;
echo 需要下载的文件select namename; // 生成文件下拉选项
foreach ($filenames as $filename) { if ($filename ! . $filename ! ..) { echo option value . $filename . . $filename . /option; }
} // 关闭下载表单
echo /select;
echo input typesubmit value下载;
echo /form; // 处理文件下载
if (isset($_POST[name])) { $name $_POST[name]; $file $filepath . $name; // 检查文件是否存在 if (file_exists($file)) { $filesize filesize($file); // 设置下载文件的相关头信息 header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename . $name . ); header(Content-Length: . $filesize); // 读取文件内容并输出给用户 readfile($file); exit; } else { echo 文件不存在; }
}
?
/body
/html文件下载漏洞 分析代码发现下载文件名由name决定那么我们就可以尝试构造任意文件名跳目录造成任意文件下载 抓包 修改文件名可以任意读取源代码造成任意文件下载读取漏洞 扩展 文件类漏洞还有如下漏洞类型不一一举例原理都差不多如 1、任意文件删除 2、任意文件写入 3、文件包含等等 WEB漏洞核心 1、可控变量 2、特定函数 留言板类XSS漏洞
需求
1、生成留言板功能
2、并写一个留言列表功能可以看到留言人的姓名和内容XSS漏洞 message.php !DOCTYPE html
html langen
head meta charsetUTF-8 title留言板/title
/head
body
h1留言板/h1 ?php
// 处理留言提交
if (isset($_POST[submit])) { $name $_POST[name]; $message $_POST[message]; $timestamp date(Y-m-d H:i:s); // 将留言信息保存到文件 $file messages.txt; $data $timestamp . - . $name . : . $message . \n; file_put_contents($file, $data, FILE_APPEND);
}
? form action methodPOST label forname姓名:/label input typetext namename idname requiredbr label formessage留言:/label textarea namemessage idmessage rows4 required/textareabr input typesubmit namesubmit value提交留言
/form hr h2留言列表/h2 ?php
// 读取留言列表
$file messages.txt;
if (file_exists($file)) { $messages file($file); // 显示留言列表 foreach ($messages as $message) { echo $message . br; }
} else { echo 暂无留言。;
}
?
/body
/html通过代码分析发现留言的信息都存在message.txt 文件里然后进行读取放到留言列表中这里可能造成存储型XSS漏洞那么我们试试构造JS语句看是否被执行。 点击提交留言发现存在xss漏洞并存储在message.txt 文件里每次刷新都会调用说明存在存储型XSS漏洞 登录类
需求
1、生成登录页面
2、使用session或cookie进行验证
3、登录时使用验证码校验
4、必须使用‘user1’账号才能登录管理员后台login.php(cookie验证) !DOCTYPE html
html langen
head meta charsetUTF-8 title登录页面/title link relstylesheet typetext/css href../login.css
/head
body
div classcontainer h2欢迎登录/h2 form actionlogin.php methodPOST div classform-group label forusername用户名:/label input typetext idusername nameusername required /div div classform-group label forpassword密码:/label input typepassword idpassword namepassword required /div div classform-group label forcaptcha验证码:/label input typetext idcaptcha namecaptcha required img srccaptcha.php alt验证码 /div button typesubmit namelogin登录/button /form/div
/body
/html ?php
session_start(); include(../config/conn.php); $username $_POST[username];
$password $_POST[password];
$captcha $_POST[captcha]; // 验证验证码 if (isset($_POST[login])) { if (isset($_SESSION[captcha]) strtolower($captcha) strtolower($_SESSION[captcha])) { // 验证用户名和密码 $sql SELECT * FROM pass WHERE username $username AND password $password; $result mysqli_query($conn, $sql); echo $sql;
/* if (mysqli_num_rows($result)) { echo 登录成功; header(location:../admin/admin_login.php); // 验证成功跳转到后台页面 setcookie(username, $username, 0, /); // 设置cookie } else { echo 用户名或密码错误; } } else { echo 验证码错误; }}
//
*/
//session验证 while ($row mysqli_fetch_array($result)) {//成功登录后 $_SESSION[username] $row[username];//将查询结果的数据进行赋值 header(location:../admin/admin_login.php);//验证成功跳转到后台页面 } }
} ?admin_login.php(登录校验) ?php
include (../config/login_check.php); //cookie验证 /*
session验证
header(Content-type:text/html;charsetutf-8);//编码
session_start();
if ($_SESSION[username]user1){ echo 登录成功这里是管理员后台;
}else{ echo 非法访问;
}
?
*/
?login_check.php (cookie验证) ?php
//1、先验证登录才进行代码操作
//2、cookie验证
//3、session验证
header(Content-type:text/html;charsetutf-8);//编码
$username $_COOKIE[username];//接受cookie
if ($username user1) {//只有当用户名为user1时才能登录到管理员后台 echo 登录成功这里是后台管理界面;
} elseif ($username ! ) {//其他用户验证成功 echo 登录成功;
} else { echo 非法访问;
}
?captcha.php 验证码 ?php
session_start(); // 生成随机验证码
$length 4; // 验证码长度
$characters 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ; // 验证码字符集
$captcha ;
for ($i 0; $i $length; $i) { $captcha . $characters[rand(0, strlen($characters) - 1)];
} // 存储验证码到 Session$_SESSION[captcha] $captcha; // 创建验证码图片
$imageWidth 110;
$imageHeight 80;
$image imagecreatetruecolor($imageWidth, $imageHeight);
$backgroundColor imagecolorallocate($image, 255, 255, 255);
$textColor imagecolorallocate($image, 0, 0, 0); // 填充背景色
imagefilledrectangle($image, 0, 0, $imageWidth, $imageHeight, $backgroundColor); // 绘制验证码文本
$textX ($imageWidth - 50) / 2;
$textY $imageHeight / 2 10;
imagestring($image, 5, $textX, $textY, $captcha, $textColor); // 输出验证码图片
header(Content-Type: image/png);
imagepng($image);
imagedestroy($image);
?验证是否符合需求 user1 管理登录后台 其他用户登录不前往管理员后台 cookie伪造漏洞 通过代码分析后端校验用户为 user1 即可登录到管理员后台 修改cookie为 user1刷新即可登录到管理元后台 万能密码登录 通过代码审计发现对数据库做校验的时候出现了一些问题如下 $sql SELECT * FROM pass WHERE username $username AND password $password;把 $username 替换成 如下 SELECT * FROM pass WHERE username 1 or 11 -- AND password $password这样就形成了万能密码登录 文章转载自: http://www.morning.qczpf.cn.gov.cn.qczpf.cn http://www.morning.dbsch.cn.gov.cn.dbsch.cn http://www.morning.twpq.cn.gov.cn.twpq.cn http://www.morning.rntby.cn.gov.cn.rntby.cn http://www.morning.phwmj.cn.gov.cn.phwmj.cn http://www.morning.sryhp.cn.gov.cn.sryhp.cn http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.bbjw.cn.gov.cn.bbjw.cn http://www.morning.mtbsd.cn.gov.cn.mtbsd.cn http://www.morning.gbfck.cn.gov.cn.gbfck.cn http://www.morning.qtrlh.cn.gov.cn.qtrlh.cn http://www.morning.rdlfk.cn.gov.cn.rdlfk.cn http://www.morning.sdktr.com.gov.cn.sdktr.com http://www.morning.rstrc.cn.gov.cn.rstrc.cn http://www.morning.nrjr.cn.gov.cn.nrjr.cn http://www.morning.qqnjr.cn.gov.cn.qqnjr.cn http://www.morning.pqryw.cn.gov.cn.pqryw.cn http://www.morning.fldk.cn.gov.cn.fldk.cn http://www.morning.tnyanzou.com.gov.cn.tnyanzou.com http://www.morning.hrtwt.cn.gov.cn.hrtwt.cn http://www.morning.fengnue.com.gov.cn.fengnue.com http://www.morning.qjxxc.cn.gov.cn.qjxxc.cn http://www.morning.dhrbj.cn.gov.cn.dhrbj.cn http://www.morning.wfttq.cn.gov.cn.wfttq.cn http://www.morning.tnhg.cn.gov.cn.tnhg.cn http://www.morning.bfwk.cn.gov.cn.bfwk.cn http://www.morning.krqhw.cn.gov.cn.krqhw.cn http://www.morning.pxspq.cn.gov.cn.pxspq.cn http://www.morning.mxnrl.cn.gov.cn.mxnrl.cn http://www.morning.cfnsn.cn.gov.cn.cfnsn.cn http://www.morning.kcxtz.cn.gov.cn.kcxtz.cn http://www.morning.qnjcx.cn.gov.cn.qnjcx.cn http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn http://www.morning.wylpy.cn.gov.cn.wylpy.cn http://www.morning.hkgcx.cn.gov.cn.hkgcx.cn http://www.morning.npmx.cn.gov.cn.npmx.cn http://www.morning.wmmtl.cn.gov.cn.wmmtl.cn http://www.morning.ftwlay.cn.gov.cn.ftwlay.cn http://www.morning.clgbb.cn.gov.cn.clgbb.cn http://www.morning.qgghr.cn.gov.cn.qgghr.cn http://www.morning.ccsdx.cn.gov.cn.ccsdx.cn http://www.morning.ndlww.cn.gov.cn.ndlww.cn http://www.morning.jbfzx.cn.gov.cn.jbfzx.cn http://www.morning.dxzcr.cn.gov.cn.dxzcr.cn http://www.morning.ndxss.cn.gov.cn.ndxss.cn http://www.morning.nbrkt.cn.gov.cn.nbrkt.cn http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn http://www.morning.ghphp.cn.gov.cn.ghphp.cn http://www.morning.xppj.cn.gov.cn.xppj.cn http://www.morning.ttrdr.cn.gov.cn.ttrdr.cn http://www.morning.dncgb.cn.gov.cn.dncgb.cn http://www.morning.yrjkp.cn.gov.cn.yrjkp.cn http://www.morning.ktyww.cn.gov.cn.ktyww.cn http://www.morning.cgbgc.cn.gov.cn.cgbgc.cn http://www.morning.rfwkn.cn.gov.cn.rfwkn.cn http://www.morning.yysqz.cn.gov.cn.yysqz.cn http://www.morning.dzdtj.cn.gov.cn.dzdtj.cn http://www.morning.grcfn.cn.gov.cn.grcfn.cn http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn http://www.morning.wiitw.com.gov.cn.wiitw.com http://www.morning.zsthg.cn.gov.cn.zsthg.cn http://www.morning.nqmdc.cn.gov.cn.nqmdc.cn http://www.morning.jcypk.cn.gov.cn.jcypk.cn http://www.morning.ngzkt.cn.gov.cn.ngzkt.cn http://www.morning.mbfj.cn.gov.cn.mbfj.cn http://www.morning.nytqy.cn.gov.cn.nytqy.cn http://www.morning.srxhd.cn.gov.cn.srxhd.cn http://www.morning.mzpd.cn.gov.cn.mzpd.cn http://www.morning.tdxnz.cn.gov.cn.tdxnz.cn http://www.morning.rglp.cn.gov.cn.rglp.cn http://www.morning.srnth.cn.gov.cn.srnth.cn http://www.morning.ggnjq.cn.gov.cn.ggnjq.cn http://www.morning.wfpmt.cn.gov.cn.wfpmt.cn http://www.morning.pxdgy.cn.gov.cn.pxdgy.cn http://www.morning.dbsch.cn.gov.cn.dbsch.cn http://www.morning.rfmzc.cn.gov.cn.rfmzc.cn http://www.morning.gnjtg.cn.gov.cn.gnjtg.cn http://www.morning.jfch.cn.gov.cn.jfch.cn http://www.morning.zybdj.cn.gov.cn.zybdj.cn http://www.morning.jrrqs.cn.gov.cn.jrrqs.cn