Created
November 20, 2012 09:44
-
-
Save mdeous/4117011 to your computer and use it in GitHub Desktop.
Zenk-Security Wargame - Easy1 ASLR OFF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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