Get the Whitepaper called Bypassing ASLR/DEP. It discusses techniques to bypass these security mechanisms and how custom shellcodes are developed.
You can download it from the following link: https://packetstormsecurity.com/files/download/105478/ASLR-DEP.pdf
Source: https://packetstormsecurity.com/files/105478/Bypassing-ASLR-DEP.html

