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


정의

P0f is a tool that utilizes an array of sophisticated, purely passive traffic fingerprinting mechanisms to identify the players behind any incidental TCP/IP communications (often as little as a single normal SYN) without interfering in any way. Version 3 is a complete rewrite of the original codebase, incorporating a significant number of improvements to network-level fingerprinting, and introducing the ability to reason about application-level payloads (e.g., HTTP).

Some of p0f’s capabilities include:

  • Highly scalable and extremely fast identification of the operating system and software on both endpoints of a vanilla TCP connection – especially in settings where NMap probes are blocked, too slow, unreliable, or would simply set off alarms.
  • Measurement of system uptime and network hookup, distance (including topology behind NAT or packet filters), user language preferences, and so on.
  • Automated detection of connection sharing / NAT, load balancing, and application-level proxying setups.
  • Detection of clients and servers that forge declarative statements such as X-Mailer or User-Agent.

The tool can be operated in the foreground or as a daemon, and offers a simple real-time API for third-party components that wish to obtain additional information about the actors they are talking to.


Common uses for p0f include reconnaissance during penetration tests; routine network monitoring; detection of unauthorized network interconnects in corporate environments; providing signals for abuse-prevention tools; and miscellanous forensics.

  p0f를 간략하게 소개하면 운영하는 서비스에 대한 OS를 확인하거나 어플리케이션의 정보를 확인할 수 있다.
예를 들면 서버의 OS가 리눅스 3.x, 또는 80 아파치 2.x 등을 확인할 수 있다.

해킹을 하기 전 footprint 단계에서 타겟 서비스의 정보를 파악해야 할 일이 생기는데 이럴 때 사용하는 것이 p0f 이다.
(footprint에 대한 설명은 http://kkn1220.tistory.com/61 참고)

25번 nmap에서 -O 옵션을 주어 타겟의 OS를 확인해보았다. (http://kkn1220.tistory.com/103 참고)
그렇다면 nmap과 p0f의 차이점은 무엇일까? 라는 질문을 할 수 있다. p0f는 Passive OS Fingerprinting으로 말 그대로 수동적인 OS 탐지 도구이다. nmap과 같은 Active Fingerprinting과는 수동적이냐 능동적이냐의 차이가 있으며 수동적인 OS 탐지도구의 경우 추가 또는 비정상적 트래픽을 생성하지 않는 것이 특징이다. 즉 정상적인 통신을 하면서 타겟 시스템의 OS를 확인할 수 있다.

 p0f는 4가지 동작모드를 지원한다.

-SYN mode: 연결 시도 측 운영체제 정보 확인

-SYN + ACK mode: 응답하는 측 운영체제 정보 확인

-RST/RST+ ACK mode: 연결 시도 거부 시스템 측 정보 확인

-stray ACK mode: 기존 세션 검토


Usage

사용법은 어렵지 않다. 

옵션으로 인터페이스를 설정하거나 promiscuous 모드 설정, 저장하거나 input file 지정 등 사항에 맞게 지정하면 끝이다.


-i 인터페이스 모드로 eth0을 지정하였고 promiscuous를 지정하였다. 이전에 스니핑 포스트 때 언급하였는데 자신의 주소값을 무시하고 모든 패킷을 받아들이는 상태를 promiscuous 모드라고 한다. (스니핑 http://kkn1220.tistory.com/67 참고)

그림출처: 안랩

kali는 기다리게 된다....


보기 편하도록 ubuntu(192.168.100.5)에서 실행이 아닌 kali에서 ssh로 192.168.100.5로 접속을 한 상태이다.

kkn은 ubuntu(192.168.100.5)이고 ssh로 raspberry pi(192.168.100.9)로 연결을 시도하는 화면의 모습이다.

위의 사진을 보면 192.168.100.5의 OS를 확인할 수 있다. 실제로는 3.19인데 완벽하게 맞추지는 못한다.

또한 9번 raspberry의 경우 라즈비안을 설치하였는데 os에 ??? 로 확인할 수가 없었다..


심심해서 ubuntu에서 apt-get update를 하였다. 

위의 사진에는 표현되지 않았지만 해당 서버의 경우 리눅스 2.4, 3.x로 출력이 되었다. 

또한 80포트 apache의 경우 2.x로 출력이 되었음을 확인할 수 있었다.


뭐 간단한 예제이기에 별거 없어보인다. 하지만 실제 타겟에 대해 할 경우 많은 내용이 출력될 수 있다. 그렇기 때문에 패킷 덤프파일을 이용하여 os를 탐지하는 경우가 더 많은 듯 보인다.

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

[Information-Gathering27]recon-ng  (0) 2016.04.12
[Information-Gathering25]nmap  (0) 2016.04.06
[Information-Gathering24]miranda  (0) 2016.03.29
[Information-Gathering23]masscan  (0) 2016.03.24
[Information-Gathering22]hping3  (0) 2016.03.18

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


정의

Nmap (“Network Mapper”) is a free and open source (license) utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts. Nmap runs on all major computer operating systems, and official binary packages are available for Linux, Windows, and Mac OS X. In addition to the classic command-line Nmap executable, the Nmap suite includes an advanced GUI and results viewer (Zenmap), a flexible data transfer, redirection, and debugging tool (Ncat), a utility for comparing scan results (Ndiff), and a packet generation and response analysis tool (Nping).


Nmap was named “Security Product of the Year” by Linux Journal, Info World, LinuxQuestions.Org, and Codetalker Digest. It was even featured in twelve movies, including The Matrix Reloaded, Die Hard 4, Girl With the Dragon Tattoo, and The Bourne Ultimatum.

 기존과는 다르게 nmap은 간략하게 소개 할 수가 없다. nmap에는 상당히 많은 기능과 옵션이 존재하기 때문이다.

그래도 굳이 정의하자면 포트스캐닝 도구로서 호스트나 네트워크를 스캐닝 할 때 매우 우용한 도구다. 라고 표현하고 싶다.

위의 정의를 보면 nmap은 네트워크 검사나 보안 감사를 위한 무료이자 오픈소스 유틸리티로 표현하고 있다.

nmap은 raw ip 패킷을 이용하여 네트워크상의 호스트 검사, 사용하는 서비스가 무엇인지, 운영하는 OS, 사용 중인 패킷 필터, 방화벽 타입 등을 검사한다.

 원문 페이지를 방문하면 nmap에 대한 장점을 소개하였는데 간략하게 소개하자면

1) 다양한 포트스캐닝 메커니즘(TCP&UDP), os 감지, 버전 감지, ping sweeps 등을 제공하는 유연성

2) huge network 상에서 제공할 수 있는 강력함

3) 윈도우, 리눅스, 솔라리스, 맥 등에서 사용할 수 있음

4) 자세한 다큐먼트 등을 소개하고 있다.


Usage

위에서 볼 수 있듯이 엄청많다....


#nmap [Scan Type(s)] [Options] {target specification}

기본 syntax는 위와 같다.

자주 사용하는 옵션에 대해 소개하고자 한다. 나머지 옵션 및 기능들은 man page 참고!

(분류는 보기좋게(?) 개인적으로 판단하였습니다.)

[Scan Type(s)]

1)Port Scanning

-sT: TCP connect() scan: TCP scanning의 가장 기초적인 형태로 connect()함수를 사용해서 모든 포트에 대해 스캔

-sS: TCP SYN scan: full TCP접속을 하지 않으므로 "half-open" 스캐닝이라 한다. 하나의 SYN 패킷을 보내어 SYN|ACK 응답이 오면 그 포트는 listening 상태임을 나타내며, RST(ReSeT)응답이 오면 non-listener임을 나타냄

이 기술은 하나의 패킷을 보내어 응답을 받으면 그 즉시 RST 패킷을 보내서 접속을 끊어버리기 때문에 로그를 남기지 않는 경우가 대부분임. 즉 추적이 어렵다.

-sF: Stealth FIN: SYN 패킷을 막아놓은 방화벽이나 패킷 필터 또는 Synlogger와 Courtney 같은 스캔을 탐지하는 프로그램들을 무사히 통과할 수 있다. open 포트로 FIN 패킷을 보내면 이 패킷을 무시하고, closed 포트로 보내면 RST 패킷이 온다.

-sX: Xmas Tree: FIN, URG, PUSH 코드 비트를 설정한 채 패킷을 보냄. RESET은 포트가 닫혔다는 것을 말해주며, 반응이 없는 것은 포트가 열려있음을 뜻함

-sN: Null scan: 어떤 코드 비트도 설정하지 않은 패킷을 보냄. RESET은 포트가 닫힌 것을 말하며, 반응이 없는 것은 포트가 열린 것을 뜻함

-sP: Ping scanning: 네트워크의 어느 호스트가 살아있는지를 알고 싶을 때 사용(-sn 과 동일)

-sU; UDP scan, 시간이 상당히 오래 걸림

-sA: ACK scan 

-sW: window scan 

-sR: RPC scan

2)Service And Version Detection

-sV:Version detection

-sR:RPC scan

3)OS Detection

-O: Enable OS detection

리눅스 3.x를 사용한다고 추측하고 있다. 정확한 버전까지는 확인할 수 없으나 대략적으로 판단할 수 있다.


[Options]

1)Port Specification And Scan Order

-p: port ranges(Only scan specified ports): 특정 포트를 지정하는 것으로 예를 들어 -p 80 식으로 지정함, '-' 범위 지정 가능
(Udp:53, 111, 137, Tcp:21-25, 80, 139, 8080)

-F(fast scan)

-r(Don't randomize ports)

2) Timing and Performance

-T:paranoid|sneaky|polite|normar|aggressive|insane

->The first two are for IDS evasion. Polite mode slows down the scan to use less bandwidth and target machine resources. Normal mode is the default and so -T3 does nothing. Aggressive mode speeds scans up by making the assumption that you are on a reasonably fast and reliable network. Finally insane mode. assumes that you are on an extraordinarily fast network or are willing to sacrifice some accuracy for speed.

주로 4번(-T4)을 많이 사용하는 것 같음

3) Verbosity

nmap을 쓰는 사람은 기본적으로 v옵션을 사용

-v: Increase verbosity level: 자세히

Use it twice or more for even greater verbosity: -vv, or give a verbosity level directly, for example -v3


{target specification}

타겟을 지정하는 데 있어 단일 호스트 192.168.100.5, 다중 호스트 192.168.100.3-20 으로 주어지는게 가능하다.

또한 CIDR-style을 지원한다. 예를 들어 192.168.100.0/24는 192.168.100.0번부터 192.168.100.255까지 256의 호스트를 스캔

-iL inputfilename

작성한 파일이 제대로 동작하는지 tab기능과 enter를 통해 작성 결과 모두 정상적으로 출력되는 것을 확인할 수 있었다.

비록 위의 결과는 3개의 호스트에 대해서만 출력하였지만 같은 IP대역이 아닌 다양하고 상당히 많은 수의 호스트 리스트가 필요할 수 있다. 이 때 유용하게 쓰일 것으로 사료된다.


nmap을 모두 설명하기에는 실력의 부족도 있지만 nmap에 대한 기능만 다룬 두꺼운 책 한권이 있을 정도로 다루는 범위가 방대하다. 해당 포스트는 nmap에 대한 소개 정도로 보면 좋을 듯 싶다. 하지만 기능은 매우 강력하다라는 것을 표현하고 싶다.

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

[Information-Gathering27]recon-ng  (0) 2016.04.12
[Information-Gathering26]p0f  (0) 2016.04.07
[Information-Gathering24]miranda  (0) 2016.03.29
[Information-Gathering23]masscan  (0) 2016.03.24
[Information-Gathering22]hping3  (0) 2016.03.18

[원문: 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