|
| 1 | +#include <Windows.h> |
| 2 | +#include <stdio.h> |
| 3 | +#include <iostream> |
| 4 | + |
| 5 | +#include "Common.h" |
| 6 | +#include "ipv4fuscation.h" |
| 7 | +#include "ipv6fuscation.h" |
| 8 | +#include "MacFuscation.h" |
| 9 | + |
| 10 | + |
| 11 | +#define IPv4Fuscation 1000 |
| 12 | +#define MacFuscation 2000 |
| 13 | +#define IPv6Fuscation 3000 |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +int printUsage(char * MeLocation) { |
| 18 | + printf("[!] Usage: %s <payload file path> [Option*]\n", MeLocation); |
| 19 | + printf("[i] Option Can Be : \n"); |
| 20 | + printf("\t[1] \"MacFuscation\" || \"mac\" ::: Output The Shellcode As A Array Of Mac Addresses [FC-48-83-E4-F0-E8]\n"); |
| 21 | + printf("\t[2] \"Ipv4Fuscation\" || \"ipv4\" ::: Output The Shellcode As A Array Of ipv4 Addresses [252.72.131.228]\n"); |
| 22 | + printf("\t[3] \"Ipv6Fuscation\" || \"ipv6\" ::: Output The Shellcode As A Array Of ipv6 Addresses [FC48:83E4:F0E8:C000:0000:4151:4150:5251]\n"); |
| 23 | + printf("[i] "); |
| 24 | + system("PAUSE"); |
| 25 | + return -1; |
| 26 | +} |
| 27 | + |
| 28 | +void Logo() { |
| 29 | + |
| 30 | + // it probably wont be printed like that but ehh |
| 31 | + std::cout << R"( |
| 32 | +
|
| 33 | + ▄█ █▄ ▄████████ ▄█ ▄█ ▄████████ ▄█ █▄ ▄████████ ▄█ ▄█ |
| 34 | + ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ |
| 35 | + ███ ███ ███ █▀ ███ ███ ███ █▀ ███ ███ ███ █▀ ███ ███ |
| 36 | + ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ███ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ |
| 37 | +▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ███ ███ ▀███████████ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ███ ███ |
| 38 | + ███ ███ ███ █▄ ███ ███ ███ ███ ███ ███ █▄ ███ ███ |
| 39 | + ███ ███ ███ ███ ███▌ ▄ ███▌ ▄ ▄█ ███ ███ ███ ███ ███ ███▌ ▄ ███▌ ▄ |
| 40 | + ███ █▀ ██████████ █████▄▄██ █████▄▄██ ▄████████▀ ███ █▀ ██████████ █████▄▄██ █████▄▄██ |
| 41 | + ▀ ▀ ▀ ▀ |
| 42 | + )" << "\t\t\t\t\t\t\t\t\t\t\t\tBY ORCA10K \n"; |
| 43 | +} |
| 44 | + |
| 45 | + |
| 46 | +int main(int argc, char* argv[]) { |
| 47 | + int Type = 0; |
| 48 | + BOOL Success = FALSE; |
| 49 | + char OutputShellFileName[32]; |
| 50 | + Logo(); |
| 51 | + |
| 52 | + // args check: |
| 53 | + if (argc != 3) { |
| 54 | + return printUsage(argv[0]); |
| 55 | + } |
| 56 | + |
| 57 | + // checking if we can read the payload |
| 58 | + if ((!ReadBinFile(argv[1])) || PayloadData.pShell == NULL || PayloadData.BytesNumber == NULL) { |
| 59 | + system("PAUSE"); |
| 60 | + return -1; |
| 61 | + } |
| 62 | + printf("[i] Size Of Shellcode: %ld \n", (unsigned int) PayloadData.BytesNumber); |
| 63 | + |
| 64 | + // checking the format of the shellcode to output |
| 65 | + |
| 66 | + if (strcmp(argv[2], "MacFuscation") == 0 || strcmp(argv[2], "macfuscation") == 0 || strcmp(argv[2], "mac") == 0 || strcmp(argv[2], "MAC") == 0){ |
| 67 | + if (PayloadData.BytesNumber % 6 == 0) { |
| 68 | + printf("[i] The Shellcode is Already multiple of 6, No Need To Append Nops ... \n"); |
| 69 | + PayloadData.pNewShell = malloc((SIZE_T)PayloadData.BytesNumber); |
| 70 | + memcpy(PayloadData.pNewShell, PayloadData.pShell, PayloadData.BytesNumber); |
| 71 | + PayloadData.FinalSize = PayloadData.BytesNumber; |
| 72 | + } |
| 73 | + else { |
| 74 | + printf("[i] The Shellcode is Not multiple of 6\n"); |
| 75 | + AppendShellcode(6); |
| 76 | + } |
| 77 | + Type = MacFuscation; |
| 78 | + } |
| 79 | + |
| 80 | + else if (strcmp(argv[2], "Ipv4Fuscation") == 0 || strcmp(argv[2], "ipv4fuscation") == 0 || strcmp(argv[2], "ipv4") == 0 || strcmp(argv[2], "IPV4") == 0) { |
| 81 | + if (PayloadData.BytesNumber % 4 == 0) { |
| 82 | + printf("[i] The Shellcode is Already multiple of 4, No Need To Append Nops ... \n"); |
| 83 | + PayloadData.pNewShell = malloc((SIZE_T)PayloadData.BytesNumber); |
| 84 | + memcpy(PayloadData.pNewShell, PayloadData.pShell, PayloadData.BytesNumber); |
| 85 | + PayloadData.FinalSize = PayloadData.BytesNumber; |
| 86 | + } |
| 87 | + else { |
| 88 | + printf("[i] The Shellcode is Not multiple of 4\n"); |
| 89 | + AppendShellcode(4); |
| 90 | + } |
| 91 | + Type = IPv4Fuscation; |
| 92 | + } |
| 93 | + |
| 94 | + else if (strcmp(argv[2], "Ipv6Fuscation") == 0 || strcmp(argv[2], "ipv6fuscation") == 0 || strcmp(argv[2], "ipv6") == 0 || strcmp(argv[2], "IPV6") == 0) { |
| 95 | + if (PayloadData.BytesNumber % 16 == 0) { |
| 96 | + printf("[i] The Shellcode is Already multiple of 16, No Need To Append Nops ... \n"); |
| 97 | + PayloadData.pNewShell = malloc((SIZE_T)PayloadData.BytesNumber); |
| 98 | + memcpy(PayloadData.pNewShell, PayloadData.pShell, PayloadData.BytesNumber); |
| 99 | + PayloadData.FinalSize = PayloadData.BytesNumber; |
| 100 | + } |
| 101 | + else { |
| 102 | + printf("[i] The Shellcode is Not multiple of 16\n"); |
| 103 | + AppendShellcode(16); |
| 104 | + } |
| 105 | + Type = IPv6Fuscation; |
| 106 | + } |
| 107 | + |
| 108 | + else { |
| 109 | + printf("[!] Unkown Input : %s \n", argv[2]); |
| 110 | + return printUsage(argv[0]); |
| 111 | + } |
| 112 | + |
| 113 | + printf("[i] Final Shellcode Size : %ld\n", (unsigned int)PayloadData.FinalSize); |
| 114 | + unsigned char* FinallShell = (unsigned char*)malloc(PayloadData.FinalSize); |
| 115 | + memcpy(FinallShell, PayloadData.pNewShell, (SIZE_T)PayloadData.FinalSize); |
| 116 | + |
| 117 | + // writing the decoder functions and the shellcode |
| 118 | + switch (Type){ |
| 119 | + case IPv4Fuscation: |
| 120 | + strcpy(OutputShellFileName, "IPv4Fuscation.cpp"); |
| 121 | + WriteShellCodeFile(OutputShellFileName, &Success); |
| 122 | + Generateipv4Output(PayloadData.FinalSize, FinallShell, &Success); |
| 123 | + break; |
| 124 | + case MacFuscation: |
| 125 | + strcpy(OutputShellFileName, "MacFuscation.cpp"); |
| 126 | + WriteShellCodeFile(OutputShellFileName , &Success); |
| 127 | + GenerateMacOutput(PayloadData.FinalSize, FinallShell, &Success); |
| 128 | + break; |
| 129 | + case IPv6Fuscation: |
| 130 | + strcpy(OutputShellFileName, "IPv6Fuscation.cpp"); |
| 131 | + WriteShellCodeFile(OutputShellFileName, &Success); |
| 132 | + Generateipv6Output(PayloadData.FinalSize, FinallShell, &Success); |
| 133 | + break; |
| 134 | + default: |
| 135 | + printf("[!] Unkown Error Occured %d \n", GetLastError()); |
| 136 | + break; |
| 137 | + } |
| 138 | + |
| 139 | + if (Success){ |
| 140 | + printf("[+] Wrote The Shellcode And The Decoder To : %s \n", OutputShellFileName); |
| 141 | + } |
| 142 | + else{ |
| 143 | + printf("[!] Failed To Write The Shellcode; Returned Error : %d \n", GetLastError()); |
| 144 | + } |
| 145 | + |
| 146 | + free(PayloadData.pNewShell); |
| 147 | + free(FinallShell); |
| 148 | + //printf("[#] Hit Enter To Exit ... \n"); |
| 149 | + //getchar(); |
| 150 | + return 0; |
| 151 | +} |
0 commit comments