Skip to content
Snippets Groups Projects
Commit 95e1dd07 authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

Secure Code Seperation

parent ffd35987
No related branches found
No related tags found
No related merge requests found
stars 0 → 100755
File added
stars.c 0 → 100644
#include<stdio.h>
#include<stdlib.h>
/*
Input: ./a.out 5
Output:
*
**
***
****
*****
*/
int main(int argc, char *argv[]){
int count = atoi(argv[1]);
for(int i=0; i<=count; i++){
for(int j=0; j<i; j++){
printf("*");
}
printf("\n");
}
printf("\n");
return 0;
}
\ No newline at end of file
<pre>
<?
//secure code
// if(isset($_GET['count'])){
// $count = $_GET['count'];
// $re = "/^[0-9]+$/";
// $matches = preg_match($re, $count);
// print_r($matches);
// if($matches){
// $cmd = "./stars $count";
// print($cmd);
// system($cmd);
// } else {
// print("Don't try to hack me :D");
// }
// } else {
// echo "Something is wrong";
// }
//insecure code
if(isset($_GET['count'])){
$count = $_GET['count'];
$re = "/^[0-9]+$/";
$cmd = "./stars $count";
print($cmd);
system($cmd);
} else {
echo "Something is wrong";
}
?></pre>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment