cgi-bin 을 이용하여 서버에 루트권한으로 실행 정보
Linux cgi-bin 을 이용하여 서버에 루트권한으로 실행본문
1. g++ 을 이용하여 파일하나를 만든다.
suexec.cpp
#include <stdlib.h>
using namespace std;
int main()
{
system("cd /var/www/html; ./print.py");
return 0;
}
g++ -o setuid.do suexec.cpp
chmod 4755 setuid.do
cgi-bin 디렉토리로 setuid.do 이동시킨다.
print.py
#!/usr/bin/env python
import os
#for html view
print "Content-Type: text/planin\n\n"
os.system("mkdir byoungguk")
print "byoungguk directory create ok"
http://localhost/cgi-bin/setuid.do
서버에 확인하면 정상적으로 디렉토리가 생성이 되어 있다.
추천
0
0
댓글 0개