hacktricks/network-services-pentesting/3260-pentesting-iscsi.md
2023-08-03 19:12:22 +00:00

19 KiB
Raw Blame History

3260 - ISCSI 渗透测试

☁️ HackTricks 云 ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

基本信息

在计算机领域,iSCSIInternet Small Computer Systems Interface 的缩写它是一种基于互联网协议IP的存储网络标准用于连接数据存储设备。它通过在 TCP/IP 网络上传输 SCSI 命令提供对存储设备的块级访问。iSCSI 用于在企业内部传输数据并在远距离管理存储。它可以用于在局域网LAN、广域网WAN或互联网上传输数据并实现位置无关的数据存储和检索。

该协议允许客户端(称为发起者)向远程服务器上的存储设备(目标)发送 SCSI 命令CDBs。它是一种存储区域网络SAN协议允许组织将存储集中到存储阵列中同时为客户端如数据库和 Web 服务器)提供本地连接的 SCSI 磁盘的错觉。它主要与光纤通道竞争但与通常需要专用布线的传统光纤通道不同iSCSI 可以在现有的网络基础设施上长距离运行。

**默认端口:**3260

PORT     STATE SERVICE VERSION
3260/tcp open  iscsi?

枚举

iSCSI Discovery

iSCSI发现

iSCSI discovery is the process of identifying iSCSI targets on a network. There are two methods for discovering iSCSI targets:

iSCSI发现是识别网络上的iSCSI目标的过程。有两种方法可以发现iSCSI目标

  1. SendTargets: This method involves sending an iSCSI command to a specific IP address and port number. The target responds with a list of available targets.

  2. SendTargets这种方法涉及向特定的IP地址和端口号发送一个iSCSI命令。目标会回复一个可用目标的列表。

  3. iSNS: Internet Storage Name Service (iSNS) is a protocol that allows iSCSI initiators to discover and manage iSCSI targets. It uses a central iSNS server to maintain a database of available targets.

  4. iSNSInternet Storage Name ServiceiSNS是一种允许iSCSI初始化程序发现和管理iSCSI目标的协议。它使用一个中央iSNS服务器来维护一个可用目标的数据库。

iSCSI Target Discovery

iSCSI目标发现

Once the iSCSI targets have been discovered, the next step is to determine the available LUNs (Logical Unit Numbers) on each target. This can be done using the following methods:

一旦发现了iSCSI目标下一步是确定每个目标上可用的逻辑单元号LUNs。可以使用以下方法来完成

  1. iSCSI SendTargets: This method involves sending an iSCSI command to the target IP address and port number. The target responds with a list of available LUNs.

  2. iSCSI SendTargets这种方法涉及向目标IP地址和端口号发送一个iSCSI命令。目标会回复一个可用LUNs的列表。

  3. iSCSI Report LUNs: This method involves sending an iSCSI command to the target IP address and port number. The target responds with a list of available LUNs along with their attributes.

  4. iSCSI Report LUNs这种方法涉及向目标IP地址和端口号发送一个iSCSI命令。目标会回复一个可用LUNs及其属性的列表。

iSCSI Authentication

iSCSI身份验证

iSCSI authentication is used to ensure that only authorized initiators can access the iSCSI targets. There are several methods of iSCSI authentication:

iSCSI身份验证用于确保只有授权的初始化程序可以访问iSCSI目标。有几种iSCSI身份验证方法

  1. CHAP (Challenge-Handshake Authentication Protocol): This method involves a three-way handshake process between the initiator and the target. The initiator sends a CHAP request to the target, which responds with a CHAP challenge. The initiator then sends a CHAP response, and if it matches the target's challenge, authentication is successful.

  2. CHAPChallenge-Handshake Authentication Protocol这种方法涉及初始化程序和目标之间的三次握手过程。初始化程序向目标发送一个CHAP请求目标回复一个CHAP挑战。然后初始化程序发送一个CHAP响应如果它与目标的挑战匹配认证成功。

  3. Mutual CHAP: This method is similar to CHAP, but both the initiator and the target authenticate each other using CHAP.

  4. Mutual CHAP这种方法与CHAP类似但是初始化程序和目标都使用CHAP进行相互认证。

  5. IKE (Internet Key Exchange): This method uses a pre-shared key or digital certificates to authenticate the initiator and the target.

  6. IKEInternet Key Exchange:这种方法使用预共享密钥或数字证书来对初始化程序和目标进行身份验证。

iSCSI Security

iSCSI安全

To ensure the security of iSCSI communications, it is important to implement the following measures:

为了确保iSCSI通信的安全性重要的是要实施以下措施

  1. IPsec (Internet Protocol Security): IPsec can be used to encrypt and authenticate iSCSI traffic between the initiator and the target.

  2. IPsecInternet Protocol SecurityIPsec可以用于加密和认证初始化程序和目标之间的iSCSI流量。

  3. CHAP or Mutual CHAP: Enabling CHAP or Mutual CHAP authentication can help prevent unauthorized access to iSCSI targets.

  4. CHAP或Mutual CHAP启用CHAP或Mutual CHAP身份验证可以帮助防止未经授权访问iSCSI目标。

  5. Access Control Lists (ACLs): Implementing ACLs can restrict access to iSCSI targets based on IP addresses or initiator IQNs (iSCSI Qualified Names).

  6. 访问控制列表ACLs实施ACLs可以基于IP地址或初始化程序IQNsiSCSI Qualified Names限制对iSCSI目标的访问。

  7. Firewalls: Configuring firewalls to allow only authorized iSCSI traffic can help protect against unauthorized access.

  8. 防火墙配置防火墙只允许授权的iSCSI流量可以帮助防止未经授权的访问。

  9. Secure Network Segmentation: Isolating iSCSI traffic on a separate network segment can help prevent unauthorized access and reduce the attack surface.

  10. 安全网络分割将iSCSI流量隔离在一个单独的网络段上可以帮助防止未经授权的访问并减少攻击面。

iSCSI Vulnerabilities

iSCSI漏洞

There are several vulnerabilities that can be exploited in iSCSI implementations. Some common vulnerabilities include:

iSCSI实现中存在一些可以被利用的漏洞。一些常见的漏洞包括

  1. Weak Authentication: If weak authentication methods are used, attackers may be able to bypass authentication and gain unauthorized access to iSCSI targets.

  2. 弱身份验证如果使用弱身份验证方法攻击者可能能够绕过身份验证并未经授权地访问iSCSI目标。

  3. Default Credentials: If default credentials are not changed, attackers can easily guess or find them and gain unauthorized access.

  4. 默认凭据:如果默认凭据没有更改,攻击者可以轻松地猜测或找到它们并未经授权地访问。

  5. Insecure Configuration: Misconfigurations in iSCSI implementations can lead to vulnerabilities that can be exploited by attackers.

  6. 不安全的配置iSCSI实现中的配置错误可能导致攻击者可以利用的漏洞。

  7. Man-in-the-Middle Attacks: If iSCSI traffic is not properly encrypted, attackers can intercept and modify the traffic, leading to unauthorized access or data manipulation.

  8. 中间人攻击如果iSCSI流量没有正确加密攻击者可以拦截和修改流量导致未经授权的访问或数据篡改。

  9. Denial of Service (DoS): Attackers can launch DoS attacks against iSCSI targets, causing them to become unavailable to legitimate users.

  10. 拒绝服务DoS攻击者可以对iSCSI目标发起DoS攻击导致它们对合法用户不可用。

Countermeasures

对策

To mitigate the risks associated with iSCSI vulnerabilities, the following countermeasures can be implemented:

为了减轻与iSCSI漏洞相关的风险可以实施以下对策

  1. Strong Authentication: Implement strong authentication methods, such as CHAP or Mutual CHAP, to ensure only authorized initiators can access iSCSI targets.

  2. 强身份验证实施强身份验证方法如CHAP或Mutual CHAP以确保只有授权的初始化程序可以访问iSCSI目标。

  3. Change Default Credentials: Always change default credentials to unique and strong passwords to prevent unauthorized access.

  4. 更改默认凭据:始终将默认凭据更改为唯一且强密码,以防止未经授权的访问。

  5. Secure Configuration: Ensure that iSCSI implementations are properly configured and follow security best practices.

  6. 安全配置确保iSCSI实现已正确配置并遵循安全最佳实践。

  7. Encrypt iSCSI Traffic: Use IPsec or other encryption methods to protect iSCSI traffic from interception and modification.

  8. 加密iSCSI流量使用IPsec或其他加密方法保护iSCSI流量免受拦截和修改。

  9. Implement Access Controls: Use ACLs to restrict access to iSCSI targets based on IP addresses or initiator IQNs.

  10. 实施访问控制使用ACLs根据IP地址或初始化程序IQNs限制对iSCSI目标的访问。

  11. Monitor for Anomalies: Implement monitoring and logging mechanisms to detect and respond to any suspicious activity or unauthorized access attempts.

  12. 监控异常情况:实施监控和日志记录机制,以检测和响应任何可疑活动或未经授权的访问尝试。

  13. Regular Updates and Patching: Keep iSCSI implementations up to date with the latest security patches and updates to address any known vulnerabilities.

  14. 定期更新和修补及时更新iSCSI实现的最新安全补丁和更新以解决已知漏洞。

By implementing these countermeasures, the security of iSCSI implementations can be significantly improved, reducing the risk of unauthorized access and data breaches.

nmap -sV --script=iscsi-info -p 3260 192.168.xx.xx

此脚本将指示是否需要身份验证。

暴力破解

在Linux上挂载iSCSI

**注意:**您可能会发现当您的目标被发现时它们会列在不同的IP地址下。如果iSCSI服务通过NAT或虚拟IP公开通常会发生这种情况。在这种情况下iscsiadmin将无法连接。这需要对由您的发现活动自动创建的节点的目录名称进行两个调整,并对此目录中包含的default文件进行一个调整。

例如您正在尝试连接到位于123.123.123.123端口3260的iSCSI目标。公开iSCSI目标的服务器实际上位于192.168.1.2但通过NAT公开。iscsiadm将注册_internal_地址而不是_public_地址

iscsiadm -m discovery -t sendtargets -p 123.123.123.123:3260
192.168.1.2:3260,1 iqn.1992-05.com.emc:fl1001433000190000-3-vnxe
[...]

这个命令将在你的文件系统中创建一个目录,就像这样:

/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/192.168.1.2\,3260\,1/

在目录中,有一个默认文件,其中包含连接到目标所需的所有设置。

  1. /etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/192.168.1.2\,3260\,1/重命名为/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/
  2. /etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/default中,将node.conn[0].address设置更改为指向123.123.123.123而不是192.168.1.2。可以使用以下命令完成此操作:sed -i 's/192.168.1.2/123.123.123.123/g' /etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/default

现在,您可以按照链接中的说明挂载目标。

在Windows上挂载ISCSI

手动枚举

sudo apt-get install open-iscsi

首先您需要发现IP地址背后的目标名称

iscsiadm -m discovery -t sendtargets -p 123.123.123.123:3260
123.123.123.123:3260,1 iqn.1992-05.com.emc:fl1001433000190000-3-vnxe
[2a01:211:7b7:1223:211:32ff:fea9:fab9]:3260,1 iqn.2000-01.com.synology:asd3.Target-1.d0280fd382
[fe80::211:3232:fab9:1223]:3260,1 iqn.2000-01.com.synology:Oassdx.Target-1.d0280fd382

请注意它将显示您可以访问这些目标的接口的IP和端口。它甚至可以显示内部IP或与您使用的IP不同的IP。

然后,您捕获每行打印字符串的第二部分从第一行开始的_iqn.1992-05.com.emc:fl1001433000190000-3-vnxe_尝试登录

iscsiadm -m node --targetname="iqn.1992-05.com.emc:fl1001433000190000-3-vnxe" -p 123.123.123.123:3260 --login
Logging in to [iface: default, target: iqn.1992-05.com.emc:fl1001433000190000-3-vnxe, portal: 123.123.123.123,3260] (multiple)
Login to [iface: default, target: iqn.1992-05.com.emc:fl1001433000190000-3-vnxe, portal: 123.123.123.123,3260] successful.

然后,您可以使用logout命令注销

iscsiadm -m node --targetname="iqn.1992-05.com.emc:fl1001433000190000-3-vnxe" -p 123.123.123.123:3260 --logout
Logging out of session [sid: 6, target: iqn.1992-05.com.emc:fl1001433000190000-3-vnxe, portal: 123.123.123.123,3260]
Logout of [sid: 6, target: iqn.1992-05.com.emc:fl1001433000190000-3-vnxe, portal: 123.123.123.123,3260] successful.

我们可以通过仅使用任何--login/--logout参数来获取有关它的更多信息

iscsiadm -m node --targetname="iqn.1992-05.com.emc:fl1001433000190000-3-vnxe" -p 123.123.123.123:3260
# BEGIN RECORD 2.0-873
node.name = iqn.1992-05.com.emc:fl1001433000190000-3-vnxe
node.tpgt = 1
node.startup = manual
node.leading_login = No
iface.hwaddress = <empty>
iface.ipaddress = <empty>
iface.iscsi_ifacename = default
iface.net_ifacename = <empty>
iface.transport_name = tcp
iface.initiatorname = <empty>
iface.bootproto = <empty>
iface.subnet_mask = <empty>
iface.gateway = <empty>
iface.ipv6_autocfg = <empty>
iface.linklocal_autocfg = <empty>
iface.router_autocfg = <empty>
iface.ipv6_linklocal = <empty>
iface.ipv6_router = <empty>
iface.state = <empty>
iface.vlan_id = 0
iface.vlan_priority = 0
iface.vlan_state = <empty>
iface.iface_num = 0
iface.mtu = 0
iface.port = 0
node.discovery_address = 192.168.xx.xx
node.discovery_port = 3260
node.discovery_type = send_targets
node.session.initial_cmdsn = 0
node.session.initial_login_retry_max = 8
node.session.xmit_thread_priority = -20
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.nr_sessions = 1
node.session.auth.authmethod = None
node.session.auth.username = <empty>
node.session.auth.password = <empty>
node.session.auth.username_in = <empty>
node.session.auth.password_in = <empty>
node.session.timeo.replacement_timeout = 120
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 30
node.session.err_timeo.tgt_reset_timeout = 30
node.session.err_timeo.host_reset_timeout = 60
node.session.iscsi.FastAbort = Yes
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.session.iscsi.DefaultTime2Retain = 0
node.session.iscsi.DefaultTime2Wait = 2
node.session.iscsi.MaxConnections = 1
node.session.iscsi.MaxOutstandingR2T = 1
node.session.iscsi.ERL = 0
node.conn[0].address = 192.168.xx.xx
node.conn[0].port = 3260
node.conn[0].startup = manual
node.conn[0].tcp.window_size = 524288
node.conn[0].tcp.type_of_service = 0
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.auth_timeout = 45
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.conn[0].iscsi.MaxXmitDataSegmentLength = 0
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.DataDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD

有一个脚本可以自动化基本子网枚举过程,可以在 iscsiadm 找到。

Shodan

  • port:3260 AuthMethod

参考资料

{% embed url="https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html" %}

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥