安全矩阵

 找回密码
 立即注册
搜索
楼主: oldmoon

胡逸芳的学习日记

[复制链接]

30

主题

60

帖子

447

积分

中级会员

Rank: 3Rank: 3

积分
447
 楼主| 发表于 2021-3-20 21:28:21 | 显示全部楼层
本帖最后由 oldmoon 于 2021-3-20 21:58 编辑

《Metasploit》

目录

前言在看《Web安全攻防--渗透测试实战指南》时,第五章msf部分结合着《Metasploit魔鬼训练营》(诸葛建伟等)来看,作为补充和拓展,内容会充实宽广且系统许多。
《Metasploit...》第一章“初识”不予赘述。第二章及后篇谈我随书复盘过程中的Q&A,还有一些自我总结。
纸上得来终觉浅,绝知此事要躬行。
尽量不断续。

一、靶场环境搭建1.网络环境拓扑图原书中的 BT5攻击机 不知为何没有在压缩包里找见,所以就换成了自己的 Kali2xface 。

2.搭建过程中的 Q&A(1)Kali2xface(NAT模式)IP:10.10.10.128
因为这是我自己用着的机子,并不是随书文件现成的,用的过程中可能会欠缺工具,只能边看边查漏补缺。
由于其他的靶机都设置了静态IP,10.10.10.0/24,所以这里也要设置一下,让他们处在同一个网段,才能进行下面的测试。
  • 虚拟机 -- 虚拟网络环境 -- NAT模式设置 -- 将子网地址改成10.10.10.0

  • 配置静态IP地址
修改过程需要root权限,修改完毕之后重启网卡,重启主机
root@kali430:~# sudo nano /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 10.10.10.128netmask 255.255.255.0network 10.10.10.0broadcast 10.10.10.255root@kali430:~# sudo /etc/init.d/networking restartroot@kali430:~# shutdown -r now
  • 模拟以域名方式访问其他靶机门户网站服务器、后台服务器和网关服务器
root@kali430:~# sudo nano /etc/hosts10.10.10.128  attacker.dvssc.com10.10.10.129  www.dvssc.com10.10.10.130  service.dvssc.com10.10.10.154  gate.dvssc.com
完成
(2)metasploitable-Linux (桥接模式 + NAT模式)IP 1:10.10.10.254
IP 2:192.168.10.254
  • 配置静态IP地址
修改过程需要root权限,修改完毕之后重启网卡,重启主机
root@metasploitable:~# sudo nano /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 10.10.10.254netmask 255.255.255.0network 10.10.10.0broadcast 10.10.10.255auto eth1iface eth0 inet staticaddress 192.168.10.254netmask 255.255.255.0network 192.168.10.0broadcast 192.168.10.255root@metasploitable:~# sudo /etc/init.d/networking restartroot@metasploitable:~# shutdown -r now
  • 配置路由功能
修改 systcl.conf 文件,打开数据包路由转发功能
root@metasploitable:~# sudo nano /etc/sysctl.conf......net.ipv4.ip_forward = 1......
  • 设置NAT路由转发功能
root@metasploitable:~# sudo /sbin/iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE###############192.168.0/24是我们VMnet1虚拟网段的IP地址范围,eth0是连接NAT模式VMnet8虚拟网段的网络适配器。但通过输入以上命令设置的转发规则在重启之后会失效所以我们需要在 /etc/rc.local 文件中添加以上命令设置开机自启动(Linux启动的最后阶段会执行rc.local 文件中的命令)且此命令需要 root 权限(一般情况下不建议使用sudo,本机测试可随意)###############
(3)OWASP (NAT模式)IP:10.10.10.129
(4)Win2K3(NAT模式)IP:10.10.10.130
(5)WinXP (仅主机模式)模拟企业内网的VMnet1虚拟网段
IP:192.168.10.128
(6)一些问题
  • 防火墙(iptables) 配置 / 设置问题(iptables详解)
https://blog.csdn.net/m493096871/article/details/84931952
  • iptables: No chain/target/match by that name.
https://blog.csdn.net/qq_24452475/article/details/83901620
  • 配置好后同网段两主机间只能单向ping通问题
http://blog.chinaunix.net/uid-25749499-id-280959.html

二、情报收集信息收集环节需要完成的任务:
  • 确定渗透测试目标的范围
  • 发现渗透目标的安全漏洞与脆弱点,为后续攻击打下基础
测试站点:www.testfire.net(包含许多典型Web漏洞的模拟银行网站)
资产收集过程中的两种情况:
  • 该网站是某机构的唯一门户网站,那么该机构内部所有与网站连接的设备均在渗透测试范围内
  • 该网站是某个站群的一个子站,那么应当把仅与该网站有关的资产和其他同级或上级网站资产划清界限
1.流程图(候补)
2.外围信息收集(1)搜索引擎
  • IP地理位置查询
GeoIP(国外):http://www.maxmind.com
QQ纯真数据库(国内):http://www.cz88.net
  • 信息查询(地理位置、服务器操作系统类型、服务器运行状况...)
netcraft:
https://searchdns.netcraft.com/
https://toolbar.netcraft.com/site_report?url=http://www.testfire.net(testfire.net exchanged to your testing url)
  • 反查域名
IP2Domain(国外):http://www.ip-adress.com/reverse_ip
(国内):
去查网(这玩意一直显示系统维护中,貌似被禁用了):http://www.7c.com
  • Google
Google黑客数据库:https://www.exploit-db.com/google-hacking-database?
Google语法:
#有时web服务器会将没有默认页面的目录以文件列表方式显示,这些目录中可能隐藏网站源代码甚至后端数据库连接口令parent directory site:testfire.net特殊扩展名 / 文件:.inc :可能包含网站配置信息,如数据库用户名/口令等.bak :通常为文本编辑器在编辑源代码后留下的备份文件,可能有某段程序源码.txt / .sql :一般包含网站运行的SQL脚本,可能会泄露数据库结构等信息robots.txt :告知搜索引擎抓取网页应遵守的规则,比如那些目录和文件不应当被抓取等#查询特定类型的文件如doc、xls等site:testfire.net filetype:xls#筛选网站中容易出现SQL注入的页面(登录页)site:testfire.net inurl:login
(2)metasploit辅助模块
  • whois域名注册信息查询
#使用whois查询时需去掉www、ftp等前缀#这是由于机构在注册域名时通常会注册一个上层域名,其子域名由自身的域名服务器管理,在whois可能查询不到msf5 > whois testfire.com exec: whois testfire.com   Domain Name: TESTFIRE.COM   Registry Domain ID: 8364165_DOMAIN_COM-VRSN   Registrar WHOIS Server: whois.corporatedomains.com   Registrar URL: http://cscdbs.com   Updated Date: 2020-07-19T05:07:16Z   Creation Date: 1999-07-23T13:54:46Z   Registry Expiry Date: 2021-07-23T13:54:46Z   Registrar: CSC Corporate Domains, Inc.   Registrar IANA ID: 299   Registrar Abuse Contact Email: domainabuse@cscglobal.com   Registrar Abuse Contact Phone: 8887802723   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited   Name Server: NS.ALMADEN.IBM.COM   Name Server: NS.WATSON.IBM.COM   DNSSEC: unsigned   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/>>> Last update of whois database: 2021-03-20T01:46:23Z <<<For more information on Whois status codes, please visit https://icann.org/epp
  • 暴力猜解网站目录(brute_dirs、dir_listing、dir_scanner等)
msf5 > use auxiliary/scanner/http/dir_scannermsf5 auxiliary(scanner/http/dir_scanner) > show optionsModule options (auxiliary/scanner/http/dir_scanner):   Name        Current Setting                                          Required  Description   ----        ---------------                                          --------  -----------   DICTIONARY  /usr/share/metasploit-framework/data/wmap/wmap_dirs.txt  no        Path of word dictionary to use   PATH        /                                                        yes       The path  to identify files   Proxies                                                              no        A proxy chain of format type:host:port[,type:host:port][...]   RHOSTS                                                               yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'   RPORT       80                                                       yes       The target port (TCP)   SSL         false                                                    no        Negotiate SSL/TLS for outgoing connections   THREADS     1                                                        yes       The number of concurrent threads (max one per host)   VHOST                                                                no        HTTP server virtual hostmsf5 auxiliary(scanner/http/dir_scanner) > set THREADS 50THREADS => 50msf5 auxiliary(scanner/http/dir_scanner) > set RHOSTS www.testfire.netRHOSTS => www.testfire.netmsf5 auxiliary(scanner/http/dir_scanner) > exploit Detecting error code Using code '404' as not found for 65.61.137.117[+] Found http://65.61.137.117:80/[SecCheck]/ 404 (65.61.137.117)[+] Found http://65.61.137.117:80/admin/ 403 (65.61.137.117)[+] Found http://65.61.137.117:80/bank/ 404 (65.61.137.117) Scanned 1 of 1 hosts (100% complete) Auxiliary module execution completed#dir_scanner辅助模块发现网站一个隐藏目录Admin,未开放浏览权限,但存在于服务器上,因服务器返回 HTTP403(没有权限浏览此目录),而非HTTP404(未找到此文件)
  • 网站中邮件地址搜索(search_email_collector)
search_email_collector要求提供一个邮箱后缀(域名),它并不是通过直接遍历网站页面的方式获取邮件地址,而是通过多个搜索引擎的查询结果分析使用此后缀的邮件地址,使用它就能够很方便地获取某个机构的大量邮件地址。
如:testfire.net 模拟了一个名为altoromutual的电子银行站点,可以遍历出以@altoromutual.com为后缀的邮件地址。
msf5 auxiliary(scanner/http/dir_scanner) > use auxiliary/gather/search_email_collectormsf5 auxiliary(gather/search_email_collector) > show optionsModule options (auxiliary/gather/search_email_collector):   Name           Current Setting  Required  Description   ----           ---------------  --------  -----------   DOMAIN                          yes       The domain name to locate email addresses for   OUTFILE                         no        A filename to store the generated email list   SEARCH_BING    true             yes       Enable Bing as a backend search engine   SEARCH_GOOGLE  true             yes       Enable Google as a backend search engine   SEARCH_YAHOO   true             yes       Enable Yahoo! as a backend search enginemsf5 auxiliary(gather/search_email_collector) > set DOMAIN altoromutual.comDOMAIN => altoromutual.commsf5 auxiliary(gather/search_email_collector) > exploit Harvesting emails ..... Searching Google for email addresses from altoromutual.com[-] Auxiliary triggered a timeout exception Auxiliary module execution completed#虽然请求超时但是其实是可以用的
(3)一些工具
  • 域名查询
nslookup:
root@kali430:~# nslookup> set type=A> testfire.netServer:                192.168.31.1Address:        192.168.31.1#53Non-authoritative answer:Name:        testfire.netAddress: 65.61.137.117> exit
dig:
#dig语法:dig @<DNS服务器> <待查询的域名>#可在带查询后面加上A、NS、MX等选项,用以查找特定类型的DNS记录(默认为A)root@kali430:~# dig @ns.watson.ibm.com testfire.net; <<>> DiG 9.11.16-2-Debian <<>> @ns.watson.ibm.com testfire.net; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 27206;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1;; WARNING: recursion requested but not available;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096; COOKIE: 57359d65ded0add87b23fa746055ed626d7b8a55883aa021 (good);; QUESTION SECTION:;testfire.net.                        IN        A;; Query time: 255 msec;; SERVER: 129.34.20.80#53(129.34.20.80);; WHEN: 六 3月 20 20:41:04 CST 2021;; MSG SIZE  rcvd: 69
  • 搜索引擎辅助搜索工具
Windows应用程序:
SiteDigger
Search Diggity
  • IP路由侦察
traceroute:
root@kali430:~# traceroute 202.112.36.29traceroute to 202.112.36.29 (202.112.36.29), 30 hops max, 60 byte packets 1  XiaoQiang (192.168.31.1)  2.122 ms  3.293 ms  3.195 ms 2  192.168.1.1 (192.168.1.1)  5.193 ms  5.078 ms  4.954 ms 3  172.16.55.254 (172.16.55.254)  4.831 ms  4.768 ms  5.124 ms 4  172.16.1.1 (172.16.1.1)  5.001 ms  4.885 ms  5.568 ms 5  210.35.184.129 (210.35.184.129)  5.279 ms  5.634 ms  5.434 ms 6  * * * 7  210.35.171.254 (210.35.171.254)  7.154 ms  7.160 ms  7.371 ms 8  210.35.191.241 (210.35.191.241)  6.596 ms  7.057 ms  6.974 ms 9  101.4.112.201 (101.4.112.201)  8.177 ms  8.076 ms  7.948 ms10  202.127.216.241 (202.127.216.241)  17.841 ms  17.999 ms  17.880 ms11  101.4.117.38 (101.4.117.38)  28.573 ms  26.764 ms  26.686 ms12  101.4.112.1 (101.4.112.1)  34.841 ms  36.479 ms  37.440 ms13  101.4.113.110 (101.4.113.110)  36.600 ms 101.4.118.222 (101.4.118.222)  36.096 ms  35.973 ms14  101.4.113.218 (101.4.113.218)  36.981 ms 101.4.113.205 (101.4.113.205)  36.340 ms  36.117 ms15  202.112.36.29 (202.112.36.29)  61.244 ms  51.105 ms  47.223 ms

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-3-29 23:34 , Processed in 0.015162 second(s), 17 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表