2012年6月5日 星期二

[Shell Script]shell script attack

#! /bin/bash

echo "產生 hello.c file..."
echo
cat <<'EOF' > hello.c
#include <stdio.h>

int main()
{
        printf("hello world!\n");
        return 0;
}
EOF

echo "編譯hello.c ..."
echo
# 編譯hello.c,產生執行檔。
gcc -o hello hello.c

#若編譯成功,就執行
if [ $? -eq 0 ]; then
        echo "exec hello ..."
        echo
        ./hello
else
        echo 'compile error:hello.c'
fi



==================

原理是利用Here Document ,這就是shell script 攜帶攻擊程式的概念模型。

沒有留言:

張貼留言