12???????C??????????
???????????? ???????[ 2012/9/7 9:56:58 ] ????????????
????????12??C???????????漰???????????????塢????????棬??????????????????
????1??gets()????
??????????????????????????
#include<stdio.h>
int main(void)
{
char buff[10];
memset(buff??0??sizeof(buff));
gets(buff);
printf(" The buffer entered is [%s] "??buff);
return 0;
}
???????????????????????????gets()???????????????stdin?????????????????????????????????????????????????????????????????????fgets()???檔
????2??strcpy()????
???????????????????????????????????????????????????????????
#include<stdio.h>
int main(int argc?? char *argv[])
{
int flag = 0;
char passwd[10];
memset(passwd??0??sizeof(passwd));
strcpy(passwd?? argv[1]);
if(0 == strcmp("LinuxGeek"?? passwd))
{
flag = 1;
}
if(flag)
{
printf("
Password cracked
");
}
else
{
printf("
Incorrect passwd
");
}
return 0;
}
???????????????????????????ù???strcpy()??????????????????????“passwd”????????????????????????????“passwd”????????????????????????????????????????????????д“flag”??????????????λ????????“????”???????????????????????flag???λ?????????????????????????????????磺
$ ./psswd aaaaaaaaaaaaa
Password cracked
????????????????????????????????????????????????????????????
?????????????????????????? strncpy()??????
?????????????????????????????????????????????????????洢??????????????????????gcc?????????????????????ò???????????‘-fno-stack-protector’???????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11