3260 - Pentesting ISCSI

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Informazioni di base

Da Wikipedia:

Nel campo dell'informatica, iSCSI è l'acronimo di Internet Small Computer Systems Interface, uno standard di rete di archiviazione basato su Internet Protocol (IP) per collegare strutture di archiviazione dati. Fornisce accesso a livello di blocco ai dispositivi di archiviazione trasportando comandi SCSI su una rete TCP/IP. iSCSI viene utilizzato per facilitare il trasferimento di dati su intranet e per gestire l'archiviazione su lunghe distanze. Può essere utilizzato per trasmettere dati su reti locali (LAN), reti geografiche (WAN) o Internet e può consentire l'archiviazione e il recupero dei dati indipendenti dalla posizione.

Il protocollo consente ai client (chiamati initiator) di inviare comandi SCSI (CDB) ai dispositivi di archiviazione (target) su server remoti. È un protocollo di rete di archiviazione (SAN), che consente alle organizzazioni di consolidare l'archiviazione in array di archiviazione fornendo contemporaneamente ai client (come database e server web) l'illusione di dischi SCSI collegati localmente. Concorre principalmente con Fibre Channel, ma a differenza del tradizionale Fibre Channel che di solito richiede cavi dedicati, iSCSI può essere eseguito su lunghe distanze utilizzando l'infrastruttura di rete esistente.

Porta predefinita: 3260

PORT     STATE SERVICE VERSION
3260/tcp open  iscsi?

Enumerazione

iSCSI Discovery

The first step in enumerating iSCSI targets is to perform an iSCSI discovery. This involves sending an iSCSI discovery request to the target's IP address and port number. The target will respond with a list of available iSCSI targets.

To perform an iSCSI discovery, you can use the iscsiadm command-line tool. Here is an example command:

iscsiadm -m discovery -t sendtargets -p <target_ip>:<port>

Replace <target_ip> with the IP address of the target and <port> with the port number. This command will send an iSCSI discovery request to the target and display the list of available targets.

iSCSI Target Enumeration

Once you have obtained the list of available iSCSI targets, you can proceed with enumerating each target to gather more information. This can include details such as the target's name, IQN (iSCSI Qualified Name), and supported authentication methods.

To enumerate an iSCSI target, you can use the iscsiadm command-line tool again. Here is an example command:

iscsiadm -m node -T <target_name> -p <target_ip>:<port> -l

Replace <target_name> with the name of the target, <target_ip> with the IP address, and <port> with the port number. This command will log in to the specified target and display detailed information about it.

iSCSI CHAP Authentication Enumeration

If the iSCSI target uses CHAP (Challenge-Handshake Authentication Protocol) for authentication, you can also enumerate the CHAP credentials. CHAP is a widely used authentication method in iSCSI.

To enumerate CHAP credentials, you can use the iscsiadm command-line tool once again. Here is an example command:

iscsiadm -m node -T <target_name> -p <target_ip>:<port> -o update -n node.session.auth.authmethod -v CHAP

Replace <target_name> with the name of the target, <target_ip> with the IP address, and <port> with the port number. This command will update the authentication method to CHAP and display the CHAP credentials.

By performing these enumeration techniques, you can gather valuable information about iSCSI targets and their authentication methods, which can be useful for further penetration testing activities.

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

Questo script indicherà se è richiesta l'autenticazione.

Nota: Potresti scoprire che quando i tuoi obiettivi vengono individuati, vengono elencati con un indirizzo IP diverso. Questo tende a succedere se il servizio iSCSI è esposto tramite NAT o un IP virtuale. In casi come questi, iscsiadmin non riuscirà a connettersi. Questo richiede due modifiche: una al nome della directory del nodo creato automaticamente dalle tue attività di scoperta e una al file default contenuto in questa directory.

Ad esempio, stai cercando di connetterti a un target iSCSI su 123.123.123.123 alla porta 3260. Il server che espone il target iSCSI è in realtà a 192.168.1.2 ma esposto tramite NAT. isciadm registrerà l'indirizzo interno anziché l'indirizzo pubblico:

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
[...]

Questo comando creerà una directory nel tuo filesystem come segue:

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

All'interno della directory, c'è un file predefinito con tutte le impostazioni necessarie per connettersi all'obiettivo.

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

  2. All'interno di /etc/iscsi/nodes/iqn.1992-05.com.emc:fl1001433000190000-3-vnxe/123.123.123.123\,3260\,1/default, cambia l'impostazione node.conn[0].address in modo che punti a 123.123.123.123 anziché a 192.168.1.2. Questo può essere fatto con un comando come 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

Ora puoi montare l'obiettivo seguendo le istruzioni nel link.

Enumerazione manuale

sudo apt-get install open-iscsi

Esempio da iscsiadm docs:

Prima di tutto devi scoprire il nome degli obiettivi dietro l'indirizzo 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

Nota che mostrerà l'IP e la porta delle interfacce a cui puoi raggiungere quei target. Può anche mostrare IP interni o IP diversi da quello che hai utilizzato.

Quindi cattura la seconda parte della stringa stampata di ogni riga (iqn.1992-05.com.emc:fl1001433000190000-3-vnxe dalla prima riga) e prova ad effettuare il login:

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.

Quindi, puoi effettuare il logout utilizzando –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.

Possiamo trovare ulteriori informazioni a riguardo semplicemente utilizzando senza alcun parametro --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

C'è uno script per automatizzare il processo di enumerazione di base del subnet disponibile su iscsiadm

Shodan

  • port:3260 AuthMethod

Riferimenti

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated