'options'에 해당되는 글 1건

  1. 2016.05.16 Tomcat Method 제한..
Java2016. 5. 16. 21:29

Http Request에 GET과 POST는 아주 많이 사용하니 다들 알고 있을것이다.

그 외에 HEAD, OPTIONS, PUT등 여러 Method 들이 여럿 존재한다.

Tomcat을 설치하고 따로 설정을 해주지 않으면 모든 Method들을 사용 할 수 있다(맞나?)

이것을 제한하지 않으면 Method들을 이용하여 서버에 파일을 생성하는 공격이 들어 올수 있다고 한다.

Tomcat의 설정 하나로 원하는 Method만을 접근 가능하도록 할 수 있다.


<security-constraint>

    <web-resource-collection>

    <web-resource-name></web-resource-name>

    <url-pattern>/*</url-pattern>

    <http-method>HEAD</http-method>

    <http-method>OPTIONS</http-method>

    <http-method>PUT</http-method>

    <http-method>DELETE</http-method>

    <http-method>TRACE</http-method>

    <http-method>CONNECT</http-method>

    </web-resource-collection>

    <auth-constraint>

    <role-name></role-name>

    </auth-constraint>

  </security-constraint>


위의 코드를 현재 돌아가고 있는 서비스의 web.xml 제일 마지막 쯤에 적어주고 Tomcat을 재가동 시켜주면 된다.

http-method가 사용하지 않을 Method명을 적어주면 된다.


재가동 한뒤 제대로 설정이 됐는지 확인 하는 방법은..


$ telnet 200.100.70.50 80

Trying 200.100.70.50...

Connected to 200.100.70.50

Escape character is '^]'.

MOVE

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html><head>

<title>403 Forbidden</title>

</head><body>

<h1>Forbidden</h1>

<p>You don't have permission to access /

on this server.</p>

<hr>

<address>Apache Server at <a href="mailto:webmaster@dummy-host2.example.com">kcacontents.kr</a> Port 80</address>

</body></html>

Connection closed by foreign host.


telnet 명령어로 설정한 서버 IP와 포트번호이 80을 입력하고..

Escape Character is라는 문구가 나오고 커서가 껌벅껌벅 할때..

접근 제한을 한 Method 명을 적어 넣으면 된다.

아마도 막혀 있다면 위와 같은 문구가 나오겠지..아마 맞을거야..

아니면 지적 해주시길..

Posted by Z700zZz