加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Kali Linux渗透测试——信息收集

发布时间:2023-01-05 08:30:52 所属栏目:Linux 来源:互联网
导读: 笔记内容参考安全牛课堂苑房弘老师的Kali Linux渗透测试教程
渗透测试标准(PTES:)的七个阶段:
1.前期交互阶段:讨论确定渗透测试范围、方式、限制条件等
2.情报收集阶段:通过主被动信息

笔记内容参考安全牛课堂苑房弘老师的Kali Linux渗透测试教程

渗透测试标准(PTES:)的七个阶段:

1.前期交互阶段:讨论确定渗透测试范围、方式、限制条件等

2.情报收集阶段:通过主被动信息收集,获取目标系统的服务、系统配置、网络拓扑等

3.威胁建模阶段:根据收集的信息,确认合适的渗透测试方法

4.漏洞分析阶段:分析目标系统漏洞,编写漏洞利用代码,确定可以突破的攻击点

5.渗透攻击阶段:入侵系统linux渗透,获取控制权

6.后渗透测试阶段:扩大攻击范围,入侵核心服务器,预置后门,实现持续控守,挖掘目标系统更多具有价值的信息

7.生成渗透测试报告:汇集关键情报、漏洞信息,分析安全防御系统的薄弱环节、补漏及升级方案等

文章目录

一、被动信息收集

被动信息收集即不向目标系统进行探测,不会留下任何痕迹。通过网络、公开渠道进行信息收集 。收集的内容包括IP地址段、域名信息、邮件地址、?档图?数据、公司地址、公司组织架构、联系电话 / 传真、?员姓名 / 职务、目标系统使?用的技术架构、公开的商业信息等。

(一)DNS信息收集

1.域名是分级的概念,而FQDN是域名下的主机(如:),注意两者不同。

2.域名记录类型:A、CNAME、PTR、MX、NS、TXT、TTL

3.DNS查询工具

4.DNS字典爆破

5.DNS域名注册信息

6.CDN、云平台

CDN及云平台主机并非公司的固有资产,实操时首先要对其进行判断,及时排除或绕过,避免事倍功半。

(二)搜索引擎信息收集

1.Shodan

全球最早开放的网络空间搜索引擎,主要针对服务器、网络摄像头、交换机、路由器等网络基础设备的IP做扫描,侧重于主机层面,常见filter:net、city、country、port、os、hostname、server

eg:

net:211.144.145.1/24 county:CN city:beijing port:22 os:windows hostname: server:apache HTTP/1.1 200 OK

2.Google

常见filter:+内容、-内容、intitle、intext、inurl、site、filetype

注意:

① +和-与后边的内容之间不能有空格,+内容和内容的检索结果是相同的

② 关键字之间的空格相当于逻辑与,大写OR表示逻辑或

③ 如果想同时检索一个类别中得多个参数,则用allintitle、allintext、allinurl,或者多个条件相与

④ google目前不支持country、city等定位关键词检索

eg:

intitle:"netbotz appliance" "ok" inurl:qq.txt

allintext:course math senior 效果等同于 intext:course intext:math intext:senior

3.钟馗之眼

中国首个半开放式的网络空间搜索引擎,由知道创宇创建,国产撒旦,主要针对网络设备指纹、域名、web服务器进行扫描,侧重于WEB应用层面,常见filter:cider、city、country、port、os、hostname、site、device、app、ver

eg:

app:apache ver:2.4 cider:211.144.145.1/24 county:CN city:beijing os:windows site:baidu.com

在高级搜索中有图形化界面可以使用

4.FOFA

由白帽汇推出了网络空间资产搜索引擎,主要针对路由器、交换机、防火墙等网络资产,常见filter:title、ip、port、ports、body、app、host、region、country

eg:

region="北京" && host="www.baidu.com" && app="apache" || app="nginx && ports="3389,80,445"

5.Censys

由密歇根大学和Rapid7公司共同合作完成,项目创建之初旨在用于学术研究,其所有数据都是免费的,除了针对网络设备作扫描外,还可以针对域名和证书进行查询,常见filter:protocols、tags、“”、location,支持and、or、not

eg:

protocols:("23/telnet" or "21/ftp") tags:scada location.country_code:US 80.http.get.status_code:[200 TO 300]

(三)公开漏洞信息平台

一些公开漏洞信息平台公布有系统和软件的最新漏洞信息,这对于1day漏洞的挖掘和利用非常有用,常见的平台如下:

(四)METADATE

图片的exif信息,可以用exiftool工具查看或修改。

二、主动信息收集

直接与目标系统交互通信,无法避免留下访问的痕迹,但可以使用第三方电脑进行探测,如控制僵尸转发扫描包。

(一)主机发现

1.二层发现

利用ARP协议发包探测,扫描速度快、可靠,但是不可路由

2. 三层发现

利用IP、ICMP协议发包探测,可路由,但是速度比二层发现慢,容易被边界防火墙过滤。

3. 四层发现

利用TCP、UDP协议发包探测,可路由且结果可靠,不太可能被防护墙过滤,甚至能发现所有端口都被过滤的主机,但是扫描速度较慢。

(二)端口扫描

端口对应网络服务及应用端程序,但是不能仅凭借端口来判断服务。

1.TCP端口扫描

僵尸扫描原理open

僵尸扫描原理close

图1 僵尸扫描原理

2.UDP端口扫描

(三)服务扫描

1. BANNER信息扫描

Banner中包含了软件开发商、软件名称、服务类型、版本号等信息,通过软件版本,可以直接发现已知的漏洞。

import socket
bangrab = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
bangrab.connect(("1.1.1.1",22))
bangrab.recv(4096)
bangrab.close()
exit()  #Banner不允许抓取,recv无返回将挂起

2.识别服务

可以通过Banner识别服务,也可以通过一些特征行为和响应字段识别

(四)操作系统识别

可以通过TTL等一些特征值进行识别,TTL起始值:

Windows:128(65-128)

Linux/Unix:64(1-64)

某些Unix:255

from scapy.all import *
win=1.1.1.1”
linu=1.1.1.2”
awin=sr1(IP(dst=win)/ICMP())
alinu=sr1(IP(dst=linu)/ICMP())
if alinu[IP].ttl<=64:
    print “host is Linux”
else:
    print “host is windows

(五)SNMP扫描

SNMP被称为信息的金矿,经常被错误配置,而且是明文传输,容易被抓包分析,默认端口为161/udp和162/udp。

(六)SMB扫描

SMB协议是微软历史上出现安全问题最多的协议,实现非常复杂,Windows系统默认开放,默认端口为139/tcp和445/tcp。

(七)SMTP扫描

简单邮件传输协议,是建立在FTP文件传输服务上的一种邮件服务,主要用于系统之间的邮件信息传递,默认端口为25/tcp。

(八)防火墙识别

通过检查回包,可以识别端口是否经过防火墙过滤(有一定误差)

防火墙端口识别

图2 防火墙端口识别

(九)WAF识别

WEB应用防火墙

信息收集部分最为重要的一个工具:NMAP,必须熟练掌握使用。

虽然在内网扫描尽量不要用这类人尽皆知的工具,但是熟知其工作方式和原理对于学习本身而言还是十分有必要的。

截取nmap version 7.80man手册内容如下:

SYNOPSIS
       nmap [Scan Type...] [Options] {target specification}
DESCRIPTION
       ...That table lists the port number and protocol, service name, and state. The
       state is either open, filtered, closed, or unfiltered.  Open means that an
       application on the target machine is listening for connections/packets on that 
       port.  Filtered means that a firewall, filter, or other network obstacle is 
       blocking the port so that Nmap cannot tell whether it is open or closed. Closed
       ports have no application listening on them, though they could open up at any 
       time. Ports are classified as unfiltered when they are responsive to Nmap's probes, 
       but Nmap cannot determine whether they are open or closed. Nmap reports the state
       combinations open|filtered and closed|filtered when it cannot determine which
       of the two states describe a port. ...
OPTIONS SUMMARY
       TARGET SPECIFICATION:
             -iL : Input from list of hosts/networks
       HOST DISCOVERY:
             -sL: List Scan - simply list targets to scan
             -sn: Ping Scan - disable port scan, only print out the available hosts that
                  responded to the host discovery probes
             -Pn: No Ping - treat all hosts as online -- skip host discovery
             -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
             -PO[protocol list]: IP Protocol Ping
             --traceroute: Trace hop path to each host
       SCAN TECHNIQUES:
             -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
             -sU: UDP Scan
             -sN/sF/sX: TCP Null, FIN, and Xmas scans
             -sI : Idle scan
             -sY/sZ: SCTP INIT/COOKIE-ECHO scans
             -sO: IP protocol scan
       PORT SPECIFICATION AND SCAN ORDER:
             -p : Only scan specified ports
               Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
             --exclude-ports : Exclude the specified ports from scanning
             -F: Fast mode - Scan fewer ports than the default scan
             -r: Scan ports consecutively - don't randomize
             --top-ports : Scan  most common ports
       SERVICE/VERSION DETECTION:
             -sV: Probe open ports to determine service/version info
             --version-intensity : Set from 0 (light) to 9 (try all probes)
             --version-light: Limit to most likely probes (intensity 2)
             --version-all: Try every single probe (intensity 9)
             --version-trace: Show detailed version scan activity (for debugging)
       SCRIPT SCAN:
             -sC: equivalent to --script=default
             --script=:  is a comma separated list of
                      directories, script-files or script-categories
             --script-args=: provide arguments to scripts
             --script-args-file=filename: provide NSE script args in a file
             --script-trace: Show all data sent and received
             --script-updatedb: Update the script database.
             --script-help=: Show help about scripts.
                       is a comma-separated list of script-files or
                      script-categories.
       OS DETECTION:
             -O: Enable OS detection
             --osscan-limit: Limit OS detection to promising targets
             --osscan-guess: Guess OS more aggressively
       FIREWALL/IDS EVASION AND SPOOFING:
             -f; --mtu : fragment packets (optionally w/given MTU)
             -D : Cloak a scan with decoys
             -S : Spoof source address
             -e : Use specified interface
             -g/--source-port : Use given port number
             --proxies : Relay connections through HTTP/SOCKS4 proxies
             --data : Append a custom payload to sent packets
             --data-string : Append a custom ASCII string to sent packets
             --data-length : Append random data to sent packets
             --ip-options : Send packets with specified ip options
             --ttl : Set IP time-to-live field
             --spoof-mac : Spoof your MAC address
       OUTPUT:
             -oN/-oX/-oS/-oG : Output scan in normal, XML, s|: Output in the three major formats at once
             -v: Increase verbosity level (use -vv or more for greater effect)
             -d: Increase debugging level (use -dd or more for greater effect)
             --open: Only show open (or possibly open) ports
             --packet-trace: Show all packets sent and received
       MISC:
             -6: Enable IPv6 scanning
             -A: Enable OS detection, version detection, script scanning, and traceroute
             -V: Print version number
             -h: Print this help summary page.

(十)WEB目录扫描

WEB目录扫描一般有两种技术:

现在一些工具都可以两种技术结合使用,暴破效率和准确性很大程度取决于字典的质量,常用工具简介如下:

1.DirBuster

Kali自带的图形化WEB目录扫描工具,OWASP的项目,界面如下所示,输入URL,选择暴破字典,自带字典在目录/usr/share/wordlists/dirbuster,建议将匹配模式改为URL Fuzz (关键字模糊匹配),提高扫描准确性,模糊匹配项为/{dir},dir为我们选择的字典内容。

请添加图片描述

2.御剑

经典WEB目录扫描神器,国产品牌,简单易用,一看就懂。注意御剑v1.1依赖Microsoft .NET Framework 4.6.1,分为命令行和GUI版,下载时选择GUI版。界面如下所示,选择字典激活后开始即可,v1.1做了很多优化,包括预判 (当目标无法连接3次则自动撤销任务)、爬虫 (针对首页爬取链接)。

请添加图片描述

3.Dirb

Kali自带的命令行WEB目录扫描工具,使用简单,命令格式为: dirb [] [options],每扫描出一个结果都会显示出来。dirb完全基于字典爆破,没有爬虫功能。

# 用户可以自定义字典
# 缺省字典放在/usr/share/dirb/wordlists目录中
dirb http://10.10.10.11/ common.txt -o output
# -z 指定每个请求间的延迟,单位ms
# -N 指定忽略的HTTP响应状态码
dirb http://10.10.10.11/ -z 100 -N 302 

4.BurpSuite

BurpSuite也可以对WEB目录进行扫描,虽然这不是BurpSuite专长,但这种基本功能还是具备的。在Intruder模块中设置字典匹配位置,用最简单的Sniper模式即可,选择好字典开始暴破就可以了。

请添加图片描述

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!