Skip to content

Instantly share code, notes, and snippets.

@Arno0x
Last active October 12, 2023 23:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Arno0x/0d50c07424738b07f8b52c1a7e9da161 to your computer and use it in GitHub Desktop.
Save Arno0x/0d50c07424738b07f8b52c1a7e9da161 to your computer and use it in GitHub Desktop.
' Sometimes, after generating a metasploit payload with vba output format, you get a payload which is too long
' for the vba line continuation limit (24 line continuation max)
' So you have to split the payload in two arrays, then merge them again.
'
' This snippet shows the simple trick
Dim PayloadPart1, PayloadPart2, Final As Variant
PayloadPart1 = Array ( whatever metasploit first part payload with line _
continuation _
and again _
and again _
until you close it)
PayloadPart2 = Array ( whatever metasploit second part payload with line _
continuation _
and again _
and again _
until you close it)
' Now merge both arrays into one containing the whole payload
ReDim Final(UBound(PayloadPart1) + UBound(PayloadPart2) + 1)
Dim i As Integer
For i = 0 To Ubound(PayloadPart1)
Final(i) = PayloadPart1(i)
Next i
For i = 0 To Ubound(PayloadPart2)
Final(UBound(PayloadPart1) + 1 + i) = PayloadPart2(i)
Next i
' There you go. Now VirtualAlloc, RtlMoveMemory, CreateThread and so on...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment