Skip to content

Instantly share code, notes, and snippets.

@mdeous
Created November 20, 2012 09:44
Show Gist options
  • Select an option

  • Save mdeous/4117011 to your computer and use it in GitHub Desktop.

Select an option

Save mdeous/4117011 to your computer and use it in GitHub Desktop.
Zenk-Security Wargame - Easy1 ASLR OFF
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("Usage : prog filename\n");
exit(1);
}
char com[61] = "/bin/touch ";
char com2[60] = "chmod 777 ";
char name[50];
int i;
for (i=0; argv[1][i]!=0; i++)
{
if (argv[1][i] > 'z' || argv[1][i] < 'a')
{
printf("Not allowed char in filename\n");
exit(1);
}
}
strncpy(name,argv[1],50);
name[49] = '\0';
strcat(com,name);
strcat(com2,name);
if (system(com) != 0)
{
printf("Permission denied\n");
exit(1);
}
system(com2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment