PS:决定下学期搬过去和成电的兄弟一起住,May God bless us.....
成都电锯在线的兄弟们:
Just keep your mind open and suck in the experience.And if it hurts,it's probably worth it.God is Love!
StackOverrun.c
#include
#include
void foo(const char* input)
{
char buf[10];
//小心这可是stack骗局哦
//我们可以看到参数的漏洞
printf("My stack looks like:\n%p\n%p\n%p\n%p\n%p\n% p\n\n");
//头号公敌:stack overrun
strcpy(buf, input);
printf("%s\n", buf);
printf("Now the stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n\n");
}
void bar(void)
{
printf("Augh! I've been hacked!\n");
}
int main(int argc, char* argv[])
{
printf("Address of foo = %p\n", foo);
printf("Address of bar = %p\n", bar); //打印函数的地址
if (argc != 2)
{
printf("Please supply a string as an argument!\n");
return -1;
}
foo(argv[1]);
return 0;
}
After the complied,you can try about his:
>StackOverrun.exe shawntherockisanewbie
Address of foo = 00401000
Address of bar = 00401060
My stack looks like:
00000000
00000000
00000000
7FFDA000
00401091
004010BB
shawntherockisanewbie
Now the stack looks like:
00000000
00000000
77616873
6568746E
6B636F72
6E617369
Now,Windows will pop-up a error-warnning window "The instruction at"0x6e617369" referenced memory at "0x6e617369" .The memory could not be "read"".
Whis is "0x6e617369"?Because the letter "n"'s ASCII is 6e.
How to improve this problem in this case?It's too easy to figure it out.
#include
#include
void foo(const char* in)
{
char buf[64]; //Win32程序可不能接受超过64的字符串命令
strncpy(buf, in, sizeof(buf));
buf[sizeof(buf)] = '\0'; //胜利!
printf("%s\n", buf);
}
void bar(const char* in)
{
printf("Augh! I've been hacked!\n");
}
int main(int argc, char* argv[])
{
if(argc != 2)
{
printf("Usage is %s [string]\n", argv[0]); //提示用法
return -1;
}
printf("Address of foo is %p, address of bar is %p\n", foo, bar); //显示出当前的函数地址
foo(argv[1]); //把接受到的字符传到foo()函数
return 0;
}
The console program of Windows that cant accept more than 64 char.
PS:Secure code tech is not specify to any programming language.
You can get used to it to any programming language what you like in your project.
Most of the algorithms we discuss have great practical utility. We therefore address implementation concerns and other engineering issues. We often provide practical alternatives to the few algorithms that are primarily of theoretical interest.
If you wish to implement any of the algorithms, you will find the translation of our pseudocode into your favorite programming language a fairly straightforward task. The pseudocode is designed to present each algorithm clearly and succinctly. Consequently, we do not address error-handling and other software-engineering issues that require specific assumptions about your programming environment. We attempt to present each algorithm simply and directly without allowing the idiosyncrasies of a particular programming language to obscure its essence.
偶然间在某XX的blog上看到了David Chappell在TechEd-Boston(2006)上的话:
If you are a developer, and you don’t like change, you should get out of this business as early as possible.
If you are a Developer, you should always reset yourself, reset what you learn and do thing before, fundamentally.



Nov 25th 2006, a bore afternoon,I went to the Chengdu Microsoft .NET Usergroup party.DP department of Microsoft's employee give a speech about the How to development of Windows Vista in the future.Here is some picture that you can enjoy it.If you wanna join us to next party,give me a mail.


