跳转至

扫描工具

Dirb

简历

Web Content Scanner。DIRB 是一个 Web内容扫描器。它查找现有(和/或隐藏)的 Web 对象。通过对 web 服务器发起基于字典的攻击并分析响应来工作的。

基础选项

使用格式:dirb [] [options]

Bash
选项:
    -a      <agent_string>   指定 user-agent
    -b      在给定的URL中,不进行压缩或合并 /../ 和 /./
    -c      <cookie_string>  指定 cookie
    -E      <certificate>   指定证书文件
    -f      NOT_FOUND(404)检测的微调。
    -H      <header_string>  指定请求头
    -i      不区分大小写进行搜索。
    -l      找到后打印 "Location" 标题。
    -N      <nf_code>     忽略指定的 HTTP code 的响应
    -o      <output_file>   保存输出到硬盘文件
    -p      <proxy[:port]>   指定代理
    -P      <proxy_username:proxy_password>  指定代理认证
    -r      不进行递归搜索
    -R      交互式递归。(询问要扫描哪个目录)
    -S      静默模式。不显示测试的单词。
    -t      URL 不强制使用 / 结尾。
    -u      <username:password>  指定用户名和密码
    -v      显示不存在页面
    -w      出现警告信息时不停止
    -x      <extensions_file>   使用 指定的字典文件 扩大搜索。
    -X      <extensions>   使用指定的 扩展名 进行搜索
    -z      <milisecs>      添加毫秒延迟,避免洪水攻击

基本使用

对目标进行基本扫描

Bash
 dirb http://192.168.186.131/
    dirb https://www.baidu.com  /usr/share/wordlists/dirb/big.txt
    dirb https://www.baidu.com/ -o output.txt /usr/share/wordlists/dirb/big.txt
    dirb https://www.baidu.com -X .php,.txt,.zip /usr/share/wordlists/dirb/big.txt
    dirb https://www.fi11sm30.com/  -X .php,.txt,.zip
    dirb http://www.baidu.com/ -z 100  

Nmap

简历

Nmap是一款网络扫描和主机检测的非常有用的工具。Nmap是不局限于仅仅收集信息和枚举,同时可以用来作为一个漏洞探测器或安全扫描器。它可以适用于winodws,linux,mac等操作系统

基本功能

(1)是扫描主机端口,嗅探所提供的网络服务

(2)是探测一组主机是否在线

(3)还可以推断主机所用的操作系统,到达主机经过的路由,系统已开放端口的软件版本

端口状态分析

Once we’ve gathered whether a host is active or not, the next step is to understand what state the scanned port is in. There are six different states:

  1. Open: a connection to the scanned port has been established.
  2. Closed: the TCP protocol indicates that the packet we received back contains an RST flag.
  3. Filtered: Nmap cannot correctly identify whether the scanned port is open or closed because either no response is returned from the target for the port or we get an error code from the target.
  4. Unfiltered: the port is accessible, but it cannot be determined whether it is open or closed.
  5. Open|filtered: this indicates that a firewall or packet filter may protect the port.
  6. Closed|filtered: impossible to determine if the scanned port is closed or filtered by a firewall.

常见命令

主机发现

Diff
iR                                    随机选择目标
-iL                                   从文件中加载IP地址
-sL                                   简单的扫描目标
-sn                                   Ping扫描-禁用端口扫描
-Pn                                   将所有主机视为在在线,跳过主机发现
-PS[portlist]                        (TCP SYN ping) 需要root权限
-PA[portlist]                        (TCP ACK ping)
-PU[portlist]                        (UDP  ping)
-PY [portlist]                       (SCTP ping)
-PE/PP/PM                             ICMP回显,时间戳和网络掩码请求探测
-PO[协议列表]                         IP协议Ping
-n/-R                                 从不执行DNS解析/始终解析[默认:有时]
--dns-servers                         指定自定义DNS服务器
--system-dns                          使用OS的dns服务器
--traceroute                          跟踪到每个主机的跃点路径

扫描技术

Diff
-sS                                    使用TCP的SYN进行扫描
-sT                                    使用TCP进行扫描
-sA                                    使用TCP的ACK进行扫描
-sU                                     UDP扫描
-sI                                     Idle扫描
-sF                                     FIN扫描
-b<FTP中继主机>                        FTP反弹扫描

端口规格和扫描顺序

Diff
-p                                        扫描指定端口
--exclude-ports                           从扫描中排除指定端口
-f                                        快速模式-扫描比默认扫描更少的端口
-r                                        连续扫描端口-不随机化
--top-ports                               扫描<number>最常用的端口

服务/版本探测

Diff
-sV                                         探测服务/版本信息
--version-intensity                         设置版本扫描强度(0-9)
--version-all                               尝试每个强度探测
--version-trace                             显示详细的版本扫描活动(用于调试)

脚本扫描

INI
-SC                                           等效于 --script=defult
--script = <lua scripts>,<lua scripts>        以逗号分隔的目录,脚本文件或脚本类别
--script-args = <n1=v1, n2=v2>                为脚本提供参数
--script-args-file=文件名                     从文件名中加载脚本参数
--script-trace                                显示发送和接受的所有数据
--script-updatedb                             更新脚本数据库
--script-help=<lua scripts>                   显示有关脚本的帮助

操作系统检测

Diff
-o                                            启用os检测
--osscan-limit                                将os检测限制为可能的目标
--osscan-guess                                推测操作系统检测结果

时间和性能

Diff
--host-timeout                           设置超时时间
--scan-delay                             设置探测之间的时间间隔
-T  <0-5>                                设置时间模板,值越小,IDS报警几率越低
Nmap command Description
-T0 Paranoid (0) Intrusion Detection System evasion.
-T1 Sneaky (1) Intrusion Detection System evasion.
-T2 Polite (2) slows down the scan to use less bandwidth.
-T3 Normal default speed.
-T4 Aggressive (4) speed scans, which require a reasonably fast and reliable network.
-T5 Insane (5) speeds scan, which requires an extra fast network.

防火墙/IDS规避和欺骗

Diff
-f                                          报文分段
-s                                          欺骗源地址
-g                                          使用指定的本机端口
--proxies <url,port>                        使用HTTP/SOCK4代理
-data<hex string>                           想发送的数据包中追加自定义的负载
--data-string                               将自定义的ACSII字符串附加到发送数据包中   
--data-length                               发送数据包时,附加随机数据
--spoof-mac                                 MAC地址欺骗
--badsum                                    发送带有虚假TCP/UNP/STCP校验和的数据包

输出

Diff
-oN                                          标准输出
-oX                                          XMl输出
-oS                                          script jlddi3
-oG                                          grepable
-oA                                          同时输出三种主要格式
-v                                           信息详细级别
-d                                           调试级别
--packet-trace                               跟踪发送和接收的报文
--reason                                     显示端口处于特殊状态的原因
--open                                       仅显示开放的端口

杂项

Diff
-6                                              启动Ipv6扫描
-A                                              启动Os检测,版本检测,脚本扫描和traceroute
-V                                              显示版本号
-h                                              帮助信息

详细用法

用法

实战常用

Bash
nmap -sL 192.168.1.0/28

列出IP段IP

Bash
sudo nmap -sn IP段

主机发现

Bash
sudo nmap -sT/-sS IP(sT更详细,sS更快)

sudo nmap --min-rate xxx IP(min-rate指定最小扫描速度,常用10000比较好)

sudo nmap -sT -sV -sC -O -p PORT IP -oA nmapscan/detial(详细扫描端口信息)

sudo nmap -sU --min-rate 10000 -p- IP -oA nmapscan/udp(udp扫描)

-oA path(指定存放扫描结果文件路径)
# 事实上-oG/-oN也能保存文件,但-oA为保存全格式的文件(xml,gnmap,nmap)

结合使用,端口扫描

Bash
sudo nmap --script=vuln -p PORT IP -oA nmapscan/vuln

漏洞扫描

Bash
grep open result.nmap | awk -F '/' 'print{$1}'
# result.nmap为扫描的结果
grep open result.nmap | awk -F '/' '{print $1}' | paste -sd ','
# 将提权到的端口以逗号分隔
ports=$(grep open result.nmap | awk -F '/' '{print $1}' | paste -sd ',')
# 赋值给一个变量,便于接下来进行扫描
nmap -p$ports -xxx
# 在光标到ports时可以按tab建进行补全

Nmap&SearchSploit

As we all know, Nmap has a very remarkable feature that let you save its output result in .xml format and we can identify each exploit associated with the nmap XML file.

Bash
nmap -sV 192.168.1.102 -oX result.xml

With the help of above command, we have saved the scanning result of nmap in an XML file, so that we can search the exploit related to scanned port/services.

Using –x option enables the examine parameter as well as –nmap option Checks all results in Nmap XML output with service version to find out related exploit with it.

Bash
searchsploit –x --nmap result.xml

Here you can observe that it is using verbose mode to examine XML file and had shown all possible exploit of running services.

代理扫描

Warning

ICMP and SYN scans cannot be tunnelled through socks proxies, so we must disable ping discovery (-Pn) and specify TCP scans (-sT) for this to work.

IDS and IPS Evasion

TTL Manipulation

Send some packets with a TTL enough to arrive to the IDS/IPS but not enough to arrive to the final system. And then, send another packets with the same sequences as the other ones so the IPS/IDS will think that they are repetitions and won't check them, but indeed they are carrying the malicious content.

Nmap option: --ttlvalue <value>

Avoiding signatures

Just add garbage data to the packets so the IPS/IDS signature is avoided.

Nmap option: --data-length 25

Fragmented Packets

Just fragment the packets and send them. If the IDS/IPS doesn't have the ability to reassemble them, they will arrive to the final host.

Nmap option: -f

Invalid checksum

Sensors usually don't calculate checksum for performance reasons. So an attacker can send a packet that will be interpreted by the sensor but rejected by the final host. Example:

Send a packet with the flag RST and a invalid checksum, so then, the IPS/IDS may thing that this packet is going to close the connection, but the final host will discard the packet as the checksum is invalid.

Uncommon IP and TCP options

A sensor might disregard packets with certain flags and options set within IP and TCP headers, whereas the destination host accepts the packet upon receipt.

Overlapping

It is possible that when you fragment a packet, some kind of overlapping exists between packets (maybe first 8 bytes of packet 2 overlaps with last 8 bytes of packet 1, and 8 last bytes of packet 2 overlaps with first 8 bytes of packet 3). Then, if the IDS/IPS reassembles them in a different way than the final host, a different packet will be interpreted. Or maybe, 2 packets with the same offset comes and the host has to decide which one it takes.

  • BSD: It has preference for packets with smaller offset. For packets with same offset, it will choose the first one.
  • Linux: Like BSD, but it prefers the last packet with the same offset.
  • First (Windows): First value that comes, value that stays.
  • Last (cisco): Last value that comes, value that stays.

Nikto(需要perl环境)

简历

Nikto 是一款开放源代码的、功能强大的WEB扫描评估软件,能对web服务器多种安全项目进行测试的扫描软件,去寻找已知有名的漏洞,能在230多种服务器上扫描出 2600多种有潜在危险的文件、CGI及其他问题,它可以扫描指定主机的WEB类型、主机名、特定目录、COOKIE、特定CGI漏洞、返回主机允许的 http模式等等。

使用说明

Nikto扫描需要主机目标IP、主机端口。默认扫描的是80端口。扫描主机目标IP地址可以使用选项-h(host)。下面将扫描IP为192.168.0.1的TCP 80端口,如下所示:

Bash
nkito.pl –h 192.168.0.1

也可以自定义扫描的端口,可以使用选项-p(port),下面将扫描IP为192.168.0.1的TCP 443端口,如下所示:

Bash
nikto.pl –h 192.168.0.1 –p 443....................

Nikto也可以同时扫描多个端口,使用选项-p(port),可以扫描一段范围(比如:80-90),也可以扫描多个端口(比如:80,88,90)。下面扫描主机的80/88/443端口,如下所示:

Bash
nikto.pl –h 192.168.0.1 –p 80,88,443..............

如果运行Nikto的主机是通过HTTP proxy来访问互联网的,也可以使用代理来扫描,使用选项-u(useproxy)。下面将通过HTTP proxy来扫描,如下所示:

Bash
Perl nikto.ph –h 192.168.0.1 –p 80 –u xxx

更新

Bash
nikto.ph –update

选项说明

Bash
-Cgidirs:扫描CGI目录。
-config:使用指定的config文件来替代安装在本地的config.txt文件
-dbcheck:选择语法错误的扫描数据库。
-evasion: 使用LibWhisker中对IDS的躲避技术,可使用以下几种类型:

1.随机URL编码(非UTF-8方式).........
2.自选择路径(/./)
3.虚假的请求结束
4.长的URL请求
5.参数隐藏
6.使用TAB作为命令的分隔符
7.大小写敏感
8.使用Windows路径分隔符替换/
9.会话重组


-findonly:仅用来发现HTTP和HTTPS端口,而不执行检测规则
-Format:指定检测报告输出文件的格式,默认是txt文件格式(csv/txt/htm/)
-host:目标主机,主机名、IP地址、主机列表文件。
-id:ID和密码对于授权的HTTP认证。格式:id:password/


-mutate:变化猜测技术

1.使用所有的root目录测试所有文件//
2.猜测密码文件名字
3.列举Apache的用户名字(/~user)
4.列举cgiwrap的用户名字(/cgi-bin/cgiwrap/~user)................


-nolookup:不执行主机名查找
-output:报告输出指定地点
-port:扫描端口指定,默认为80端口。
-Pause:每次操作之间的延迟时间


- Display:控制Nikto输出的显示

1.直接显示信息
2.显示的cookies信息
3.显示所有200/OK的反应
4.显示认证请求的URLs
5.Debug输出


-ssl:强制在端口上使用SSL模式
-Single:执行单个对目标服务的请求操作。
-timeout:每个请求的超时时间,默认为10秒


-Tuning:Tuning 选项控制Nikto使用不同的方式来扫描目标。

0.文件上传
1.日志文件
2.默认的文件
3.信息泄漏
4.注射(XSS/Script/HTML)
5.远程文件检索(Web 目录中)
6.拒绝服务
7.远程文件检索(服务器)
8.代码执行-远程shell
9.SQL注入
a.认证绕过
b.软件关联
g.属性(不要依懒banner的信息)
x.反向连接选项

-useproxy:使用指定代理扫描
-update:更新插件和数据库

Gobuster

详解

Enum4linux

介绍

SMB是一个协议名,全称是**Server Message Block**(服务器消息快协议),用于在计算机间共享文件、打印机、串口等,电脑上的网上邻居由它实现。一般**共享文件夹**和**打印机**使用较多 它是应用层(和表示层)协议,使用C/S架构

注意:smb的默认端口可能是**139**或者**445**,其工作的端口与其使用的协议有关。

正是由于smb被日常生活中大量运用于网上邻居,而网络设备都有可能存在这样那样的安全问题,这就导致了smb服务成为很多人眼中的敏感服务,也是攻击者比较愿意花时间探索的服务

在这样的背景下,一款强大的**smb服务专用扫描器**应运而生,他就是我们要今天介绍的工具——enum4linux

Enum4linux是用于枚举windows和Linux系统上的SMB服务的工具。可以轻松的从与**SMB服务**有关的目标中快速提取信息。

常用命令

实战中最常用的其实也就是使用**-a**指令,进行一次大范围信息探测,指令如下

Bash
enum4linux -a -o ip

工具的使用中,常用的固然是最好用的,但总有这么几个命令能在一些时候取得意料之外的效果,下面介绍的这四个就是我认为比较**好用**也比较**冷门**的命令

LDAP信息探测

通过LDAP 389 / TCP获取一些(有限的)信息(仅适用于DN)

Bash
enum4linux -l ip

获取操作系统信息

Bash
enum4linux -o ip 

通过RID循环枚举用户

Bash
enum4linux -r ip 

smbmap

SMBMap允许用户枚举整个域中的samba共享驱动器。用户可以使用该工具列出共享驱动器、驱动器权限、共享内容、上传/下载功能、文件名自动下载模式匹配,甚至远程执行命令。该工具原本的设计初衷是为了简化在大型网络中搜索潜在敏感数据的过程。

Text Only
smbmap -H 192.168.1.40

如上图所示,我们可以看到目标计算机有一些共享。对guest的共享,一定是公共共享。让我们使用该用户的凭据来枚举对特定用户的共享。

Text Only
smbmap -H 192.168.1.17 -u raj -p 123

参考文章:

渗透测试之SMB枚举指南 - 知乎 (zhihu.com)

第五十五课:与Smbmap结合攻击 | Micro8 (gitbook.io)

evil-winrm

Evil-winrm 工具最初是由 Hackplayers 团队开发的。开发该工具的目的是尽可能简化渗透测试,尤其是在 Microsoft Windows 环境中。 Evil-winrm 使用 PowerShell 远程协议 (PSRP),且系统和网络管理员经常使用Windows Remote Management 协议进行上传和管理。 WinRM 是一种基于对防火墙友好的SOAP 协议,可通过 HTTP默认 端口 5985 与 HTTP 传输一起使用。有关 PowerShell 远程处理的更多信息,请参考访问 Microsoft 的官方网站。

参考文章:https://www.cnblogs.com/backlion/p/17202253.html

CrackMapExec

CrackMapExec(CME)是一款后渗透利用工具,可帮助自动化大型活动目录(AD)网络安全评估任务。其缔造者@byt3bl33d3r称,该工具的生存概念是,“利用AD内置功能/协议达成其功能,并规避大多数终端防护/IDS/IPS解决方案。”

参考文章:

https://www.freebuf.com/sectool/184573.html

https://blog.csdn.net/qq_42077227/article/details/130279040