From e5371d5ee381008c9a5e344eac28da499437dcdb Mon Sep 17 00:00:00 2001 From: Chaniel Date: Sun, 22 Jun 2014 13:13:33 +0800 Subject: [PATCH 1/5] Create guard_log.c --- chapter9/guard_log.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 chapter9/guard_log.c diff --git a/chapter9/guard_log.c b/chapter9/guard_log.c new file mode 100644 index 0000000..eba3e0b --- /dev/null +++ b/chapter9/guard_log.c @@ -0,0 +1,19 @@ +/* this have code injection security problem, such you input: ' && ls / && echo ' */ +#include +#include +#include + +char * now(){ + time_t t; + time(&t); + return asctime(localtime(&t)); +} + +int main(){ + char comment[80]; + char cmd[120]; + fgets(comment, 80, stdin); + sprintf(cmd, "echo '%s %s' >> reports.log", comment, now()); + system(cmd); + return 0; +} From 9f5a89fc591da8d6b55be71b8485a55221ff8099 Mon Sep 17 00:00:00 2001 From: Chaniel Date: Tue, 24 Jun 2014 16:44:48 +0800 Subject: [PATCH 2/5] Create system_test.c --- chapter9/system_test.c | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 chapter9/system_test.c diff --git a/chapter9/system_test.c b/chapter9/system_test.c new file mode 100644 index 0000000..4ec9d42 --- /dev/null +++ b/chapter9/system_test.c @@ -0,0 +1,5 @@ +#include +int +main() { + system("ls -l"); +} From 891ecab585dd5950f79f8ab7873fbdbf976f726e Mon Sep 17 00:00:00 2001 From: Chaniel Date: Sat, 28 Jun 2014 15:44:32 +0800 Subject: [PATCH 3/5] Create newshound.c --- chapter9/newshound.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 chapter9/newshound.c diff --git a/chapter9/newshound.c b/chapter9/newshound.c new file mode 100644 index 0000000..c2552bb --- /dev/null +++ b/chapter9/newshound.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char *feeds[] = {"http://www.cnn.com/rss/celebs.xml", + "http://www.rolling.stone.com/rock.xml", + "http://eonline.com/gossip.xml" + }; + + int times = 3; + char *phrase = argv[1]; + int i; + for (i = 0; i < times; i++){ + char var[255]; + sprintf(var, "RSS_FEED=%s", feeds[i]); + //char *vars = {var, NULL}; + char *vars = {var}; + pid_t pid = fork(); + if(pid == -1){ + fprintf(stderr,"can't fork process: %s\n", strerror(errno)); + return 1; + } + if(!pid) { + if(execle("/usr/bin/python", "/usr/bin/python", "./rssgossip.py", phrase, NULL, vars) == -1) + fprintf(stderr,"can't run script: %s\n", strerror(errno)); + return 1; + } + } + return 0; +} From 0ffcd087c988e4a59b5027a6822ecfe7be251360 Mon Sep 17 00:00:00 2001 From: Chaniel Date: Sun, 29 Jun 2014 18:05:01 +0800 Subject: [PATCH 4/5] Create tools --- tools | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tools diff --git a/tools b/tools new file mode 100644 index 0000000..8148e14 --- /dev/null +++ b/tools @@ -0,0 +1,3 @@ +gdb 调试器 +gprof 性能分析 +gcov 性能分析 From d01fca89adc7dd37118099a132624106254af6a6 Mon Sep 17 00:00:00 2001 From: Chaniel Date: Sun, 29 Jun 2014 18:06:20 +0800 Subject: [PATCH 5/5] Rename tools to dev-tools --- tools => dev-tools | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools => dev-tools (100%) diff --git a/tools b/dev-tools similarity index 100% rename from tools rename to dev-tools