Loading... # 实训第六天 1. 网站漏洞回顾(LNMP) 环境搭建——LiteXP、phpstudy Sqli-labs、XSS-labs、upload-labs 2. php代码学习 ![image-20220717100801077.png](http://xherlock.top/usr/uploads/2022/07/2539579523.png) ![image-20220717103236671.png](http://xherlock.top/usr/uploads/2022/07/3084772444.png) ![image-20220717103354800.png](http://xherlock.top/usr/uploads/2022/07/3193604932.png) 编写连接security数据库的php脚本 ~~~php <?php echo "<h1>查询结果</h1>"; $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "security"; try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare("SELECT username, password FROM users WHERE id=:id"); $stmt->bindParam(':id', $id); echo 'search id =<span style="font-size:30px;"> '; $id = $_POST['id']; echo $id; echo '</span><br>'; echo 'search result:<br>'; $stmt->execute(); foreach ($stmt as $row) { echo '<b style="font-size:30px;">username: '.$row['username'].'</b><br>'; echo '<b style="font-size:30px;">password: '.$row['password'].'</b>'; } } catch (PDOException $e) { echo "Error: " . $e->getMessage(); } $conn = null; ?> ~~~ ![image-20220717111942784.png](http://xherlock.top/usr/uploads/2022/07/2771751128.png) 尝试sql注入失败 ![image-20220717112756657.png](http://xherlock.top/usr/uploads/2022/07/3786408455.png) ![image-20220717112719037.png](http://xherlock.top/usr/uploads/2022/07/2110229657.png) ![image-20220717161814343.png](http://xherlock.top/usr/uploads/2022/07/3430932209.png) 最后修改:2022 年 07 月 18 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 1 如果觉得我的文章对你有用,请随意赞赏