apache2에 관련된 원데이 분석을 하기 위해서 취약한 서버를 올리고자 했다.
apr, apr-util, pcre 설치를 선행하고 원하는 버전의 apache2를 설치하는 방법에 대해 정리한다.
apr 설치
Index of /dist/apr
archive.apache.org
$ sudo apt-get install libapr1 libapr1-dev
$ cd /usr/local
$ wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
$ tar xvfz apr-1.7.0.tar.gz
$ cd apr-1.7.0.tar.gz
$ ./configure --prefix=/usr/local/apr
$ make && make install
위 명령어 수행시 다음과 같은 에러가 뜬다면, configure 파일에서 해당 부분을 찾아 수정해준다.
rm: cannot remove 'libtoolT': No such file or directory
$ vi configure
$RM "$cfgfile" -> $RM -f "$cfgfile"
apr-util 설치
Index of /dist/apr
archive.apache.org
$ wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
$ tar xvfz apr-util-1.6.3.tar.gz
$ ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util
$ make && make install
pcre 설치
PCRE - Browse /pcre/8.45 at SourceForge.net
Centralized Workload Automation and Job Scheduling Orchestrate your entire tech stack with our no-code connectors and low-code REST API adapter
sourceforge.net
$ apt-get install libpcre3 libpcre3-dev
$ cd /usr/local
$ wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz
$ tar xvfz pcre-8.45.tar.gz
$ cd /usr/local/pcre-8.45
$ ./configure --prefix=/usr/local/pcre
$ make && make install
apache2 설치
Index of /dist/httpd
archive.apache.org
CVE-2021-41773 에 해당하는 취약한 서버 버전인 apache2.4.49를 설치할 것이다. 위 링크에서 버전 별 아파치 서버를 다운 받을 수 있다.
$ sudo apt-get install libexpat1-dev
$ wget https://archive.apache.org/dist/httpd/httpd-2.4.49.tar.gz
$ tar xvfz httpd-2.4.49.tar.gz
$ ./configure --prefix=/usr/local/apache2.4 \
--enable-module=so --enable-rewrite --enable-so \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
--enable-mods-shared=all
$ make && make install
앞서 설치해놓은 apr, apr-util, pcre 경로를 지정하고 설치를 진행한다.
apache2 실행
$ sudo vim /usr/local/apache/conf/httpd.conf
-> listen port set
$ sudo /usr/local/apache/bin/httpd -k start
$ ps -ef | grep httpd | grep -v grep
$ sudo netstat -anp | grep httpd
httpd.conf 파일에서 httpd 서비스가 올라갈 포트를 설정해줄 수 있다. 기존 서버에 80번 포트를 사용하는 서비스가 있어서 1127 포트로 설정해주었다.

ps 명령어와 netstat 명령어로잘 실행된 것을 확인할 수 있다.

해당 서버 ip로 앞서 설정한 1127포트로 접속하면, index.html 파일이 뜨는 것을 확인할 수 있다.