‘Writing Small Shellcode In Windows’
‘The information has been provided by Dafydd Stuttard.
The original article can be found at: http://www.ngssoftware.com/papers/WritingSmallShellcode.pdf‘
Size is important for shellcode because when exploiting vulnerabilities in compiled software we are often constrained in the amount of data we can work with. Smaller solutions than ours are certainly possible, but at this size the amount of work involved increases exponentially as each additional byte is trimmed from the code.
It is assumed that the reader has some familiarity with x86 assembly language.
The task to be performed by our code is as follows:
1. Bind a shell to port 6666.
2. Allow one connection to the shell.
3. Exit cleanly.
It must work on Windows NT4, 2000, XP and 2003, and will be launched using:
unsigned char sc = ”;
‘shellcode goes here’,
lea eax, sc
Hence, we can observe the following:
* The shellcode cannot contain any null bytes.
* The shellcode must be run from the stack.
* Winsock has not been initialised.
* We may assume that eax points to the start of our code.
Our full solution is in the Appendix to this paper. First, we present some notes on the approach taken and some of the details of the solution.
The full whitepaper can be downloaded from: http://www.ngssoftware.com/papers/WritingSmallShellcode.pdf.’