Commit 2cc7a60c authored by Ines Kramer's avatar Ines Kramer

added resources of buffer overflow

parent 59b8ef9b
Pipeline #258 failed with stages
// compile with -no-pie -fno-stack-protector
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
using namespace std;
void spawn_shell() {
char* args[] = {(char*)"/bin/bash", NULL};
execve("/bin/bash", args, NULL);
}
int main() {
char buf[1024];
cout << "Which environment variable do you want to read? ";
cin >> buf;
cout << buf << "=" << getenv(buf) << endl;
}
# include < stdio .h >
# include < stdlib .h >
int main ()
{
int var ;
int check = 0 x04030201 ;
char buf [40];
fgets ( buf , 45 , stdin );
printf ( " \ n [ buf ]: % s \ n " , buf );
printf ( " [ check ] % p \ n " , check );
if (( check != 0 x04030201 ) && ( check != 0 xdeadbeef ))
printf ( " \ nYou are on the right way !\ n " );
if ( check == 0 xdeadbeef )
{
printf ( " Yeah dude ! You win !\ n " );
system ( " / bin / dash " );
}
return 0;
}
\ No newline at end of file
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int main (int argc, char *argv[])
{
char buffer[4];
if (argc == 2) {
strcpy(buffer,argv[1]);
printf(buffer);
printf("\n");
}
else{
printf("Enter one command line argument");
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment