mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 04:33:28 +00:00
204 lines
11 KiB
Markdown
204 lines
11 KiB
Markdown
# 3260 - Pentesting ISCSI
|
||
|
||
<details>
|
||
|
||
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
||
|
||
- Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||
|
||
- Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||
|
||
- Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
|
||
- **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
||
|
||
- **Share your hacking tricks by submitting PRs to the [hacktricks repo](https://github.com/carlospolop/hacktricks) and [hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)**.
|
||
|
||
</details>
|
||
|
||
## Basic Information
|
||
|
||
> In computing, **iSCSI** is an acronym for **Internet Small Computer Systems Interface**, an Internet Protocol (IP)-based storage networking standard for linking data storage facilities. It provides block-level access to storage devices by carrying SCSI commands over a TCP/IP network. iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances. It can be used to transmit data over local area networks (LANs), wide area networks (WANs), or the Internet and can enable location-independent data storage and retrieval.
|
||
>
|
||
> The protocol allows clients (called initiators) to send SCSI commands (CDBs) to storage devices (targets) on remote servers. It is a storage area network (SAN) protocol, allowing organizations to consolidate storage into storage arrays while providing clients (such as database and web servers) with the illusion of locally attached SCSI disks. It mainly competes with Fibre Channel, but unlike traditional Fibre Channel which usually requires dedicated cabling, iSCSI can be run over long distances using existing network infrastructure.
|
||
|
||
**Default port:** 3260
|
||
|
||
```
|
||
PORT STATE SERVICE VERSION
|
||
3260/tcp open iscsi?
|
||
```
|
||
|
||
## Enumeration
|
||
|
||
```
|
||
nmap -sV --script=iscsi-info -p 3260 192.168.xx.xx
|
||
```
|
||
|
||
This script will indicate if authentication is required.
|
||
|
||
### [Brute force](../generic-methodologies-and-resources/brute-force.md#iscsi)
|
||
|
||
### [Mount ISCSI on Linux](https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Virtualization/How\_to\_set\_up\_and\_use\_iSCSI\_target\_on\_Linux)
|
||
|
||
**Note:** You may find that when your targets are discovered, they are listed under a different IP address. This tends to happen if the iSCSI service is exposed via NAT or a virtual IP. In cases like these, `iscsiadmin` will fail to connect. This requires two tweaks: one to the directory name of the node automatically created by your discovery activities, and one to the `default` file contained within this directory.
|
||
|
||
For example, you are trying to connect to an iSCSI target on 123.123.123.123 at port 3260. The server exposing the iSCSI target is actually at 192.168.1.2 but exposed via NAT. isciadm will register the _internal_ address rather than the _public_ address:
|
||
|
||
```
|
||
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
|
||
[...]
|
||
```
|
||
|
||
This command will create a directory in your filesystem like this:
|
||
|
||
```
|
||
/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/192.168.1.2\,3260\,1/
|
||
```
|
||
|
||
Within the directory, there is a default file with all the settings necessary to connect to the target.
|
||
|
||
1. Rename `/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/192.168.1.2\,3260\,1/` to `/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/`
|
||
2. Within `/etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/default`, change the `node.conn[0].address` setting to point to 123.123.123.123 instead of 192.168.1.2. This could be done with a command such as `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`
|
||
|
||
You may now mount the target as per the instructions in the link.
|
||
|
||
### [Mount ISCSI on Windows](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee338476\(v=ws.10\)?redirectedfrom=MSDN)
|
||
|
||
## **Manual enumeration**
|
||
|
||
```bash
|
||
sudo apt-get install open-iscsi
|
||
```
|
||
|
||
First of all you need to **discover the targets** name behind the 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
|
||
```
|
||
|
||
_Note that it will show the I**P and port of the interfaces** where you can **reach** those **targets**. It can even **show internal IPs or different IPs** from the one you used._
|
||
|
||
Then you **catch the 2nd part of the printed string of each line** (_iqn.1992-05.com.emc:fl1001433000190000-3-vnxe_ from the first line) and **try to login**:
|
||
|
||
```bash
|
||
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.
|
||
```
|
||
|
||
Then, you can **logout** using `–logout`
|
||
|
||
```bash
|
||
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.
|
||
```
|
||
|
||
We can find **more information** about it by just using **without** any `--login`/`--logout` parameter
|
||
|
||
```bash
|
||
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
|
||
```
|
||
|
||
**There is a script to automate basic subnet enumeration process available at** [**iscsiadm**](https://github.com/bitvijays/Pentest-Scripts/tree/master/Vulnerability\_Analysis/isciadm)
|
||
|
||
## **Shodan**
|
||
|
||
* `port:3260 AuthMethod`
|
||
|
||
## **References**
|
||
|
||
{% embed url="https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html" %}
|
||
|
||
<details>
|
||
|
||
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
||
|
||
- Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||
|
||
- Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||
|
||
- Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
|
||
- **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
||
|
||
- **Share your hacking tricks by submitting PRs to the [hacktricks repo](https://github.com/carlospolop/hacktricks) and [hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)**.
|
||
|
||
</details>
|