Skip to content
Permalink
Browse files
32Bit ALSR version added
  • Loading branch information
aa9863 committed Jan 23, 2023
1 parent 3ffc722 commit 2bc89c8ff57d33d57ff962eba8a1b9824b20a751
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
@@ -1 +1,2 @@
*~
*~
solve
@@ -0,0 +1,14 @@
FROM 6048_builder as ClientBuilder

ADD ./ret2winOne.c /opt/target.c

WORKDIR /opt
RUN gcc -m32 /opt/target.c -o /opt/target


FROM 6048_server
COPY --from=ClientBuilder /opt/target /home/cueh/target

CMD ["/tmp/runscript.sh", "/home/cueh/target"]


@@ -0,0 +1,14 @@
version: "3.7"

services:
server:
build:
context: .
ports:
- "1337:1337"
- "22:22"
#cap_add:
# - CAP_SYS_ADMIN
privileged: true
environment:
- RUN_ALSR
@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int INPUT=300; //Give enough to overflow
int BUFFER=150;

void win(void){
/*Win Condition
We Want to jump here
*/
printf("\n ===== Win ===== \n\n");
system("/bin/sh"); //Tradition to get a shell
}

void lose(void){
/* Lose Condition */
printf("Lose :(\n");
}

int main(int argc, char* argv[]){
/* Main Function*/
char buffer[BUFFER];
char readBuffer[INPUT];

setvbuf(stdout, NULL, _IONBF, 0);
//Pointer to the lose function
void (*fp)(void) = lose;

printf("--- Overflow the Buffer ---\n");
printf("Current Memory Address is %p\n",lose);
printf("Aim for %p\n", win);

printf("What is your input >");
//fflush(stdout);
fgets(readBuffer, INPUT, stdin);
//Strip newline
readBuffer[strcspn(readBuffer, "\n")] = 0;
printf("You entered >%s<\n", readBuffer);

memcpy(buffer, readBuffer, strlen(readBuffer));
printf("Off to %p\n",fp);
fp();

return 0;
}

0 comments on commit 2bc89c8

Please sign in to comment.