[원문: http://tools.kali.org/information-gathering/miranda]


정의

Miranda is a Python-based Universal Plug-N-Play client application designed to discover, query and interact with UPNP devices, particularly Internet Gateway Devices (aka, routers). It can be used to audit UPNP-enabled devices on a network for possible vulnerabilities. Some of its features include:


Interactive shell with tab completion and command history

Passive and active discovery of UPNP devices

Customizable MSEARCH queries (query for specific devices/services)

Full control over application settings such as IP addresses, ports and headers

Simple enumeration of UPNP devices, services, actions and variables

Correlation of input/output state variables with service actions

Ability to send actions to UPNP services/devices

Ability to save data to file for later analysis and collaboration

Command logging

 간략하게 miranda는 Internet Gateway Device(ex.router)같은 UPNP 디바이스를 찾고 상호작용하기 위해 설계 된 파이썬 기반의 Universal PnP 클라이언트 어플리케이션이다. 즉 IGD 타겟에 대해 나열하기 위해 사용 된다고 정의할 수 있다.

Miranda를 실행하기 전에 UPnP에 대한 적절한 지식이 필요하다.

UPnP(https://www.microsoft.com/korea/windowsxp/pro/techinfo/planning/upnp/protocol.mspx 발췌)

UPnP 정의

UPnP는 네트워크 상에 있는 네트워크 장치들이 서로 연동될 수 있도록 하는 범용 표준 프로토콜이다.

UPnP는 표준 IP 프로토콜을 활용함으로 다양한 네트워크 매체를 활용할 수 있는데 즉 장치들을 네트워크로 서로 연결시키는데 활용할 수 있는 모든 매체가 UPnP 기능을 구현할 수 있다.

UPnP가 사용하는 프로토콜

UPnP 프로토콜 스택

    <UPnP 프로토콜 스택>

1)TCP/IP

-TCP/IP 네트워킹 프로토콜 스택은 나머지 모든 UPnP 프로토콜을 구축하는 기반 역할

-TCP/IP 서비스(DHCP, DNS 등) 뿐만 아니라 TCP, UDP, IGMP, ARP , IP 등 TCP/IP 스택에 있는 많은 프로토콜을 사용


2)HTTP, HTTPU, HTTPMU

-HTTP를 기본 프로토콜로하여 유니캐스트, 멀티캐스트를 지원하는 프로토콜

-HTTP는 TCP/IP기반, HTTPU, HTTPMU는 UDP/IP 기반 위에서 동작


3)SSDP

-SDP(Simple Service Discovery Protocol)는 네트워크 서비스를 네트워크 상에서 검색하는 방법을 정의

-SSDP는 HTTPU 및 HTTPMU 기반 위에 구축되며, 제어 포인트가 네트워크 상에서 원하는 리소스를 검색하는 방법 및 장치들이 네트워크상에서 자신들이 가용상태에 있음을 알리는 방법을 정의

-제어 포인트 및 장치 모두가 SSDP를 사용하는데 UPnP 제어 포인트는 부팅이 되자마자 SSDP 검색 요청(HTTPMU을 사용함)을 보내서 네트워크에서 활용 가능한 장치와 서비스를 검색

-UPnP 장치는 멀티캐스트 포트 정보를 수신하고, 검색 요청을 수신하자마자 장치는 일치 여부를 확인하기 위하여 검색 조건을 점검. 만약 일치된 것이 발견되면 유니캐스트 SSDP (HTTPU를 사용) 응답이 제어 포인트로 전송

-이외에도 SSDP는 장치 및 장치 관련 서비스가 네트워크와의 연결을 원활하게 끊는 방법을 포함하고 있으며, 또한 자체적인 문제 해결을 위하여 유해 정보를 정화하는데 사용되는 캐시 타임아웃(cache timeouts)을 포함


4)GENA

-GENA (Generic Event Notification Architecture)는 TCP/IP를 통한 HTTP 및 멀티캐스트 UDP를 사용하여 통보(notifications)를 송수신하는 기능을 제공

-또한 GENA은 이벤트 실행을 위하여 가입자 및 통보 발행자의 개념을 정의

-UPnP는 GENA 포맷을 사용하여 존재 발표 내용을 생성한 후에 SSDP 프로토콜을 통하여 전송하고 UPnP 이벤트 작업의 서비스 상태 변화를 신호로 알려주는 기능 수행


5)SOAP
-SOAP (Simple Object Access Protocol)는 XML 및 HTTP의 용법을 정의하여 원격 프로시저 호출을 실행

-SOAP는 또한 보안용으로 SSL (Secure Sockets Layer)을 활용하고 HTTP의 연결 관리 기능을 활용


6)XML

-XML(Extensible Markup Language)은 웹 상의 구조화된 데이터를 위한 범용 포맷

-XML은 태그와 특성(tags, attributes)을 사용한다는 측면에서 보면 HTML과 유사한 점이 많지만, XML은 그러한 태그와 특성들이 일반적으로 정의된 것이 아니라 사용되는 컨텍스트 내에서 해석된다는 관점에서 보면 상당히 다름

-XML은 장치 및 서비스 설명서, 제어 메시지 및 이벤트에 사용되는 UPnP의 핵심적 부분


(https://www.ethicalhacker.net/columns/heffner/plug-n-play-network-hacking 정리가 참 잘되어 있음)

UPnP 위험성 언급

-UPnP implementations are at more risk than others; several UPnP-enabled IGDs allow the DNS settings to be directly altered via UPnP, which is just begging for a MITM/phishing attack. Still others, particularly those devices that use some form of embedded Linux, actually use the un-sanitized values they receive via UPnP requests as part of executed shell commands, leaving them open to command-injection attacks. A list of some known vulnerable routers can be found here.

UPnP protocol overview

-The UPnP protocol uses a multicast address of 239.255.255.250 and TCP port 1900. 

Devices that offer UPnP services will periodically send out SSDP NOTIFY messages to 239:255:255:250:1900, announcing themselves to any UPnP clients that are listening. 

Likewise, UPnP clients can send SSDP M-SEARCH requests to 239:255:255:250:1900 to see if any UPnP devices respond. Clients can send an M-SEARCH request looking for any UPnP device, or they can specify that they are looking for a particular UPnP device, or they can query only for a device that supports a specific UPnP service. UPnP hosts that match the devices/services requested will respond with a SSDP RESPONSE message, which contains the same information sent in an SSDP NOTIFY message.

-An SSDP NOTIFY message sent by a UPnP host contains a ‘Location’ header which specifies the location of an XML file. This file contains XML data indicating, among other things, the UPnP device type(s) and services supported by the host, 

as well as paths to additional XML documents that describe the various services in detail. In order to discover the full UPnP capabilities of an IGD, you must parse through all the XML files to extract the devices types, services, and actions offered by the IGD.

-UPnP devices support various services that advertise what actions they support. 

A UPnP client can send a UPnP device an action request at any time; this could be a request to open up a port, change the default DNS server, or anything else that the UPnP device supports. 

Input/output data for action requests and responses are sent using SOAP, which uses XML to structure information sent between two parties. 

SOAP requests are essentially HTTP POST requests with some additional SOAP headers included in the HTTP headers.


Usage

usage는 심플하다. 

miranda를 실행하면 upnp 프롬포트의 쉘로 입력할 수 있다. msearch와 pcap으로 명령을 실행할 수 있는데

pcap의 경우 SSDP NOTIFY 메시지를 통한 수동적 실행이고

msearch의 경우 M-SEARCH 메시지를 이용하여 UPnP디바이스에 쿼리를 날린다.

기본적으로 msearch는 모든 UPnP 디바이스를 탐색하지만, 특정 디바이스 타입이나 서비스를 정해서 찾을 수도 있다.

위의 msearch결과는 네트워크상에서 하나의 UPnP가 있다는 것을 확인할 수 있다. 

위의 xml의 경로를 찾아가면 아래와 같이 화면이 출력된다.


위의 host list명령어는 발견된 모든 UPnP 호스트의 리스트를 보여준다.

아래의 host get 0은 위의[0]의 인덱스 번호이며 해당 호스트의 모든 정보를 얻는다.

얻은 정보를 가지고 host info 0 명령어를 실행하면 아래와 같이 해당 호스트에 대한 정보를 수집할 수 있다.

해당 호스트의 요약된 정보를 보고싶으면 host summary 0 명령어를 실행하면 된다.

위의 xml정보와 동일하다. 내용으로는 모든 디바이스 타입과 각각의 디바이스 타입에 관련된 추가 데이터를 확인 할 수 있다.

조금 더 자세한 내용을 확인하고자 한다면 host details 0을 실행하면 된다. 각각 디바이스의 데이터 타입 등이 출력된다.

종종 데이터가 길게 출력될 수 있기 때문에 text로 볼 수 있도록 기능이 제공된다.

save info 0 <file_name>

데이터 저장

summary에서 WANConnectionDevice를 확인했었다.

위에서 보면 알 수 있듯이 AddportMapping과 DeletePortMapping을 확인할 수 있다. 

또한 GetExternalIPAddress 또한 확인할 수 있다.


Let’s try adding a port mapping to open up the administrative interface on port 80 of the IGD (192.168.0.1) by mapping it to port 8080 on the WAN:

add port mapping

upnp> host send 0 WANConnectionDevice WANIPConnection AddPortMapping


Required argument:

     Argument Name:  NewPortMappingDescription

     Data Type:      string

     Allowed Values: []

     Set NewPortMappingDescription value to: All your ports are belong to us


Required argument:

     Argument Name:  NewLeaseDuration

     Data Type:      ui4

     Allowed Values: []

     Set NewLeaseDuration value to: 0


Required argument:

     Argument Name:  NewInternalClient

     Data Type:      string

     Allowed Values: []

     Set NewInternalClient value to: 192.168.0.1


Required argument:

     Argument Name:  NewEnabled

     Data Type:      boolean

     Allowed Values: []

     Set NewEnabled value to: 1


Required argument:

     Argument Name:  NewExternalPort

     Data Type:      ui2

     Allowed Values: []

     Set NewExternalPort value to: 8080


Required argument:

     Argument Name:  NewRemoteHost

     Data Type:      string

     Allowed Values: []

     Set NewRemoteHost value to:


Required argument:

     Argument Name:  NewProtocol

     Data Type:      string

     Allowed Values: [‘TCP’, ‘UDP’]

     Set NewProtocol value to: TCP


Required argument:

     Argument Name:  NewInternalPort

     Data Type:      ui2

     Allowed Values: []

     Set NewInternalPort value to: 80

The AddPortMapping action takes several input values, but there are a few important notes that should be made here:

1) Boolean values are either ‘1’ (true) or ‘0’ (false);

2) The NewProtocol argument only allows for two values, ‘TCP’ or ‘UDP’

3) We did not specify a value for the NewRemoteHost variable, which allows all remote hosts to match this port mapping.


We didn’t get any output from the AddPortMapping action because it has no output variables defined (again, this information is all stored in the data structure if you’re curious). However, we can verify that the action was successful by running the GetSpecificPortMappingEntry action:


get specific port mapping entry

upnp> host send 0 WANConnectionDevice WANIPConnection GetSpecificPortMappingEntry


Required argument:

     Argument Name:  NewExternalPort

     Data Type:      ui2

     Allowed Values: []

      Set NewExternalPort value to: 8080


Required argument:

     Argument Name:  NewRemoteHost

     Data Type:      string

     Allowed Values: []

     Set NewRemoteHost value to:


Required argument:

     Argument Name:  NewProtocol

     Data Type:      string

     Allowed Values: [‘TCP’, ‘UDP’]

     Set NewProtocol value to: TCP


NewPortMappingDescription : All your ports are belong to us

NewLeaseDuration : 0

NewInternalClient : 192.168.0.1

NewEnabled : 1

NewInternalPort : 80


delete port mapping

upnp> host send 0 WANConnectionDevice WANIPConnection DeletePortMapping


Required argument:

     Argument Name:  NewProtocol

     Data Type:      string

     Allowed Values: [‘TCP’, ‘UDP’]

     Set NewProtocol value to: TCP


Required argument:

     Argument Name:  NewExternalPort

     Data Type:      ui2

     Allowed Values: []

     Set NewExternalPort value to: 8080


Required argument:

     Argument Name:  NewRemoteHost

     Data Type:      string

     Allowed Values: []

     Set NewRemoteHost value to:


'해킹 > kali tools' 카테고리의 다른 글

[Information-Gathering26]p0f  (0) 2016.04.07
[Information-Gathering25]nmap  (0) 2016.04.06
[Information-Gathering23]masscan  (0) 2016.03.24
[Information-Gathering22]hping3  (0) 2016.03.18
[Information-Gathering21]goofile  (0) 2016.03.18

+ Recent posts