![]() |
About Shell code
About ShellCodeIn this tutorial you'll learn all about shellcode, of course if you'll be reading this article. Let's begin. How could we obtain a ShellCode?What is ShellCodeing? First of all, when we think about ShellCodeing, we think about a Code that will return a remote shell when it's executed. The meaning of ShellCode evolved, now we understand it this way: any byte code which is introduced in an exploit, how'll take an action. CAUTION! A ShellCode cannot contain Null Bytes, and it's even more beautiful if the byte size is small. Another think, important, of course, in this tutorial i'll present only Windows ShellCodeing!Thank's Slick for your help! The tool's you'll need : 1. NASM (The compiling of ASM will make it with NASM) Download : code: Code:
http://nasm.sourceforge.net/Download : Code: Code:
http://alink.sourceforge.net/download.htmlDownload : Code: Code:
http://www.vividmachines.com/shellcode/arwin.c· Displays for Exports, Imports, Menu, Dialog, and Text References · Integrated Debugger for 32 Bit Programs (16 Bit Debug Not Available) · Includes Text Search and Navigation Functions. I recommend v.8.93] 5. WDHEX [A useful tool which copyed the ShellCode from a list to anther .afl saved with W32DASMU]. Download : Code: Code:
http://rapidshare.com/files/46936025/wdhex.exe.htmlLet's consider a little ASM code, which dosen't do much, only a BEEP! CAUTION! A detailed thing . . . i 'll not reach in this tutorial (maybe, the next tutorial) : any kind of application come's loaded with kernel32.dll, so useing other API function's from other dll's (user32.dll, etc.) will need to load the library ( 2 API function's <<very important>> : LoadLibraryA and GetProcAddress).Another thing, when will extract the ShellCode, will extract him only from the zone .. start of the programe made in ASM; declareing the variable's is DENIED!, and importing API function's above this section is the same: incorrect. Let's see an incorrect code: Code: Code:
%include "win32n.inc"Code: Code:
segment .code USE32Code: Code:
;beep.asmCode:
http://msdn2.microsoft.com/en-us/library/ms679277.aspxCAUTION! The API function addresses in dll's can differ from a windows user to another, because the Windows version's, Service Pack version's and the different update's which are made daily. That's why will use ARWIN to find out the function addresses in dll's from our Windows. Will enter the folder were we saved the arwin.exe useing CMD!! After we made it, type the following command: arwin.exe TheDllName FunctionName. For example, we can put: arwin.exe kernel32.dll Beep. Maybe the following image will be helpful: http://www.go4expert.com/images/arti.../arwin2qz4.jpg After your done with the API code above, the fun can start! Copy the code (with your modification) in Notepad and then save it with .ASM extension (File -> Save As -> Filename: beep.asm). So our file will be named like : beep, got it? Ok. It would be better to save all the file's above ( the compiled one's 2 - if it's necessary ) in a folder. Now open CMD to compile the ASM code and to make it .exe ! Enter in CMD in the folder ( were you saved the shit ), then type the following command : nasmw.exe -fobj beep.asm This way were checking for error's, now we can go further. Type in cmd CMD : alink -c -oPE -subsys gui beep If the operation worked you can type beep in CMD to run. Maybe this image will help : http://www.go4expert.com/images/arti...e/alinkzw8.jpg Now we created the exe, let's extract the ShellCode. For this, open .exe with W32DASM. http://www.go4expert.com/images/arti...ode/assfq5.jpg n the above image, you can see : addresses, shellcode and the ASM code ( left -> right ).We can extract this shellcode manual, for example from 31C031DB we obtain : “\x31\xC0\x31\xDB”, or useing wdhex (automatic extractor for the code). For this thing, we need to save all we have seen in W32DASM. How? Easy: File -> Save Disassembly Text File and Create Project File -> FileName: beep.ALF -> Ok. Note: the extension need to be : .ALF, NOT .ELF ( some of you guy's know, i mean, it's for Linux ). Now go to : CMD -> your folder,were you saved the beep.alf -> type : wdhex beep.alf , the app will show the shellcode extracted . http://www.go4expert.com/images/arti...e/wdhexgo3.jpg Conclusion:Our Shellcode is : Code:
char shellcode[]=Code:
/*shellcodetest.c*/here our some good links Code:
http://www.vividmachines.com/shellcode/shellcode.htmlCode:
http://www.bradleybeast.com/content/view/84/Hope you all like my tutorial if you need help dont hesitate to ask me |
| All times are GMT +5.5. The time now is 00:27. |