cgi-bin 을 이용하여 서버에 루트권한으로 실행 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

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개

© SIRSOFT
현재 페이지 제일 처음으로