Chargeur de shellcode

Outil open source pour tester les shellcodes.

Chargeur de shellcode est un utilitaire en ligne de commande pour tester les shellcodes.
Ce petit utilitaire open source injecte un shellcode personnalisé dans la mémoire de son propre processus.

Shellcode Loader est écrit en C et fourni en open source.
Fonctionne sur n'importe quel Windows de WinXP jusqu'à Win11.

Shellcode Loader fournit 3 méthodes différentes de chargement de shellcode :

  • ASM en ligne
  • Fonction C
  • AppelFenêtreProc
Usage:
  1. Ouvrez cmd.exe ou Windows Powershell
  2. Tapez ShellLoad + le chemin de votre fichier shellcode.
    Exemple : ShellLoad "C:\Shellcode.file"
  3. Appuyez sur Entrée. Le shellcode sera chargé et exécuté.
    Des informations et des messages d'erreur seront affichés sur la console.
  4. Si vous souhaitez afficher l'aide à l'utilisation et les paramètres avancés (tels que la méthode d'exécution du shellcode),
    exécutez ShellLoad.exe sans aucun paramètre.
Chargeur de shellcode

Télécharger "Shellcode Loader" ShellcodeLoader.zip – Téléchargé 863 fois – 55 Ko


Le paquet contient:
ShellLoad.exe (compilé)
ShellLoad.c (source C)

Code source:

ShellLoad.c :

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// ________________________________________________
//
// ShellLoad.c
//
// PURPOSE:
// Useful tool to test shellcodes.
// The program will load the shellcode from file and execute it into its own process memory.
// 3 different shellcode loading methods are provided as option.
//
// USAGE:
// Execute the program passing the shellcode file path as parameter.
// 2° parameter is optional and lets you define the preferred shellcode loading method:
// 1 = Inline ASM (Default)
// 2 = C Function
// 3 = CallWindowProc
//
//
// RELEASE NOTES:
// v1.0.0
// 27 Jul 2021
//
// AUTHOR:
// © BreakingSecurity.net 
// https://BreakingSecurity.net
// ________________________________________________

#include <Windows.h>
#include <stdio.h>
// Shellcode Entrypoint function prototype
// TIP: We can edit this function to support different return types and parameters
typedef INT(*ShellEntry)();
#define METHOD_INLINEASM 1
#define METHOD_CFUNCTION 2
#define METHOD_CALLWINDOWPROC 3

int main(int argc, char *argv[])
{
	int ret = 0;
	int mtd = 1;
	int err = 0;
	DWORD fsize = 0;
	printf("\n");
	printf("-------------------------\n");
	printf(" Shellcode Loader v1.0.0\n");
	printf(" BreakingSecurity.net\n");
	printf("-------------------------\n");
	printf("\n");
	if (argc < 2)
	{
		printf("USAGE MODE:\n");
		printf("ShellLoad.exe path\n");
		printf("ShellLoad.exe path method\n");
		printf("\n");
		printf("METHODS:\n");
		printf("1 = Inline ASM (default)\n");
		printf("2 = C Function\n");
		printf("3 = CallWindowProc\n\n");
		printf("EXAMPLE (default method): ShellLoad.exe \"C:\\shellcode.file\" \n");
		printf("EXAMPLE (select method): ShellLoad.exe \"C:\\shellcode.file\" 1\n");
		printf("------------------------\n");
		printf("\n[-] ERROR: No parameter passed. Path to shellcode is required.\n\n");
		_getch();
		return 0;
	}
	if (argc > 2)
	{
		mtd = atoi(argv[2]);
	}
	printf("[+] Opening file: %s\n", argv[1]);
	HANDLE hFile = CreateFileA(argv[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE) 
	{
		err = GetLastError();
		printf("[-] ERROR: Unable to open file. Error %i\n", err);
		return 0;
	}
	fsize = GetFileSize(hFile, NULL);
	if (fsize == INVALID_FILE_SIZE) 
	{
		err = GetLastError();
		printf("[-] ERROR: GetFileSize error %i\n", err);
		CloseHandle(hFile);
		return 0;
	}
	printf("[+] File Size: %i bytes\n", fsize);
	printf("[+] Allocating memory buffer...\n");
	void* pShellcode = VirtualAlloc(NULL, fsize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	if (pShellcode == NULL) 
	{
		err = GetLastError();
		printf("[-] ERROR: VirtualAlloc error %i\n", err);
		CloseHandle(hFile);
		return 0;
	}
	printf("[+] Reading file...\n");
	DWORD nBytesRead = 0;
	ReadFile(hFile, pShellcode, fsize, &nBytesRead, NULL);
	CloseHandle(hFile);
	switch (mtd)
	{
		case METHOD_INLINEASM:
		{
			printf("[+] Executing shellcode (method: Inline ASM)\n");
			__asm
			{
				call pShellcode	// Execute shellcode entrypoint
				mov ret, eax	// Retrieve return value
			}
			break;
		}
		case METHOD_CFUNCTION:
		{
			printf("[+] Executing shellcode (method: C Function)\n");
			ShellEntry fShellcode = (ShellEntry)pShellcode;
			ret = fShellcode();
			break;
		}
		case METHOD_CALLWINDOWPROC:
		{
			printf("[+] Executing shellcode (method: CallWindowProc)\n");
			// TIP: we can use CallWindowProc parameters to pass arguments to our function
			ret = CallWindowProcA((WNDPROC)pShellcode, 0, 0, 0, 0);
			break;
		}
	}
	printf("[+] Shellcode executed!\n");
	_getch(); // Keep shellcode running
	return ret;
}
Menu