tags: RPCCLient SMB_Enumeration SMB


Questo strumento permette di interagire con molti protocolli che fatto riferiemento al protocollo RPC tra cui il protocollo SMB. Per autenticarsi anonimamente tramite RPC possiamo utilizzare la seguente sintassi:

rpcclient -U "" 10.129.14.128
 
Enter WORKGROUP\'s password:
rpcclient $> 

La password è vuota.

Una volta all’interno possiamo utilizzare per esempio i seguenti comandi per ottenere informazioni:

rpcclient $> srvinfo
 
        DEVSMB         Wk Sv PrQ Unx NT SNT DEVSM
        platform_id     :       500
        os version      :       6.1
        server type     :       0x809a03
		
		
rpcclient $> enumdomains
 
name:[DEVSMB] idx:[0x0]
name:[Builtin] idx:[0x1]
 
 
rpcclient $> querydominfo
 
Domain:         DEVOPS
Server:         DEVSMB
Comment:        DEVSM
Total Users:    2
Total Groups:   0
Total Aliases:  0
Sequence No:    1632361158
Force Logoff:   -1
Domain Server State:    0x1
Server Role:    ROLE_DOMAIN_PDC
Unknown 3:      0x1
 
 
rpcclient $> netshareenumall
 
netname: print$
        remark: Printer Drivers
        path:   C:\var\lib\samba\printers
        password:
netname: home
        remark: INFREIGHT Samba
        path:   C:\home\
        password:
netname: dev
        remark: DEVenv
        path:   C:\home\sambauser\dev\
        password:
netname: notes
        remark: CheckIT
        path:   C:\mnt\notes\
        password:
netname: IPC$
        remark: IPC Service (DEVSM)
        path:   C:\tmp
        password:
		
		
rpcclient $> netsharegetinfo notes
 
netname: notes
        remark: CheckIT
        path:   C:\mnt\notes\
        password:
        type:   0x0
        perms:  0
        max_uses:       -1
        num_uses:       1
revision: 1
type: 0x8004: SEC_DESC_DACL_PRESENT SEC_DESC_SELF_RELATIVE 
DACL
        ACL     Num ACEs:       1       revision:       2
        ---
        ACE
                type: ACCESS ALLOWED (0) flags: 0x00 
                Specific bits: 0x1ff
                Permissions: 0x101f01ff: Generic all access SYNCHRONIZE_ACCESS WRITE_OWNER_ACCESS WRITE_DAC_ACCESS READ_CONTROL_ACCESS DELETE_ACCESS 
                SID: S-1-1-0

Enumerazione Utenti

 
rpcclient $> enumdomusers
 
user:[mrb3n] rid:[0x3e8]
user:[cry0l1t3] rid:[0x3e9]
 
 
rpcclient $> queryuser 0x3e9
 
        User Name   :   cry0l1t3
        Full Name   :   cry0l1t3
        Home Drive  :   \\devsmb\cry0l1t3
        Dir Drive   :
        Profile Path:   \\devsmb\cry0l1t3\profile
        Logon Script:
        Description :
        Workstations:
        Comment     :
        Remote Dial :
        Logon Time               :      Do, 01 Jan 1970 01:00:00 CET
        Logoff Time              :      Mi, 06 Feb 2036 16:06:39 CET
        Kickoff Time             :      Mi, 06 Feb 2036 16:06:39 CET
        Password last set Time   :      Mi, 22 Sep 2021 17:50:56 CEST
        Password can change Time :      Mi, 22 Sep 2021 17:50:56 CEST
        Password must change Time:      Do, 14 Sep 30828 04:48:05 CEST
        unknown_2[0..31]...
        user_rid :      0x3e9
        group_rid:      0x201
        acb_info :      0x00000014
        fields_present: 0x00ffffff
        logon_divs:     168
        bad_password_count:     0x00000000
        logon_count:    0x00000000
        padding1[0..7]...
        logon_hrs[0..21]...
 
 
rpcclient $> queryuser 0x3e8
 
        User Name   :   mrb3n
        Full Name   :
        Home Drive  :   \\devsmb\mrb3n
        Dir Drive   :
        Profile Path:   \\devsmb\mrb3n\profile
        Logon Script:
        Description :
        Workstations:
        Comment     :
        Remote Dial :
        Logon Time               :      Do, 01 Jan 1970 01:00:00 CET
        Logoff Time              :      Mi, 06 Feb 2036 16:06:39 CET
        Kickoff Time             :      Mi, 06 Feb 2036 16:06:39 CET
        Password last set Time   :      Mi, 22 Sep 2021 17:47:59 CEST
        Password can change Time :      Mi, 22 Sep 2021 17:47:59 CEST
        Password must change Time:      Do, 14 Sep 30828 04:48:05 CEST
        unknown_2[0..31]...
        user_rid :      0x3e8
        group_rid:      0x201
        acb_info :      0x00000010
        fields_present: 0x00ffffff
        logon_divs:     168
        bad_password_count:     0x00000000
        logon_count:    0x00000000
        padding1[0..7]...
        logon_hrs[0..21]...
        

Possiamo quindi utilizzare i risultati per identificare il RID del gruppo, che possiamo poi utilizzare per recuperare informazioni dall’intero gruppo:

rpcclient $> querygroup 0x201
 
        Group Name:     None
        Description:    Ordinary Users
        Group Attribute:7
        Num Members:2

Tuttavia, può anche accadere che non tutti i comandi siano disponibili e che ci siano alcune restrizioni basate sull’utente. Tuttavia, la query queryuser RID è per lo più consentita in base al RID. Possiamo quindi utilizzare rpcclient per forzare brute force i RID per ottenere informazioni. Poiché potremmo non sapere a chi è stato assegnato quale RID, sappiamo che otterremo informazioni al riguardo non appena interroghiamo un RID assegnato. Esistono diversi metodi e strumenti che possiamo utilizzare per questo scopo. Per rimanere fedeli allo strumento, possiamo creare un ciclo For utilizzando Bash, in cui inviamo un comando al servizio tramite rpcclient e filtriamo i risultati.

for i in $(seq 500 1100);do rpcclient -N -U "" 10.129.14.128 -c "queryuser 0x$(printf '%x\n' $i)" | grep "User Name\|user_rid\|group_rid" && echo "";done
 
        User Name   :   sambauser
        user_rid :      0x1f5
        group_rid:      0x201
		
        User Name   :   mrb3n
        user_rid :      0x3e8
        group_rid:      0x201
		
        User Name   :   cry0l1t3
        user_rid :      0x3e9
        group_rid:      0x201