Felderítés

A Unix/Linux szerverek üzemeltetése wikiből

Mielőtt portscannelni kezdenénk, és beindítanánk kedvenc portscannelő eszközünket, fontos lépés az, hogy megtaláljuk a célpontot az interneten. A felderítésnek általában két módját szokták elkülöníteni: beszélhetünk aktív és passzív felderítési módszerekről.

Passzív felderítés alkalmazása során nem forgalmazunk (sokat) a vizsgált hálózat/hoszt/akármi irányába, leginkább publikus adatbázisokat használunk fel. Tipikus adatforrások:

  • DNS
  • AS
  • Whois
  • Google (Bing, Yahoo, akármi)
  • GHDB

Aktív felderítés során hálózati némileg intruzívabban közelítjük a célpontot. Tipikus módok az alábbiak:

  • SMTP fingerprint
  • Traceroute

Tartalomjegyzék

1 DNS

A DNS sok esetben nagyon sebezhető pontja az infrastruktúrának: mutatok néhány vizsgálatot ennek illusztrálására. A sebezhetőségek túlnyomórészt információszivárgást jelentenek, de sok esetben maga a DNS infrastruktúra is támadható (például a Dan Kaminsky-féle Bailiwicked DNS poisoning támadással).

Forward bejegyzések vizsgálata:

zsombor@metacortex:~$ dig -t ANY bme.hu

; <<>> DiG 9.5.1-P3 <<>> -t ANY bme.hu
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20214
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 4

;; QUESTION SECTION:
;bme.hu.                                IN      ANY

;; ANSWER SECTION:
bme.hu.                 14400   IN      SOA     nic.bme.hu. hostmaster.bme.hu. 2009110400 43200 14400 2592000 86400
bme.hu.                 14400   IN      AFSDB   1 mono.eik.bme.hu.
bme.hu.                 14400   IN      A       152.66.115.35
bme.hu.                 14400   IN      LOC     47 28 0.000 N 19 3 0.000 E 110.00m 1m 10000m 10m
bme.hu.                 14400   IN      MX      10 nic.bme.hu.
bme.hu.                 14400   IN      NS      ns2.pantel.net.
bme.hu.                 14400   IN      NS      ns.bme.hu.
bme.hu.                 14400   IN      NS      nic.bme.hu.

;; ADDITIONAL SECTION:
nic.bme.hu.             14400   IN      A       152.66.115.1
nic.bme.hu.             14400   IN      AAAA    2001:738:2001:2001::2
ns.bme.hu.              14400   IN      A       152.66.116.1
ns.bme.hu.              14400   IN      AAAA    2001:738:2001:8001::2

;; Query time: 6 msec
;; SERVER: 195.228.240.249#53(195.228.240.249)
;; WHEN: Wed Nov  4 10:27:24 2009
;; MSG SIZE  rcvd: 313

Kisötösért kérdés: miért (mikor) örülünk, ha a rekurzív queryfeloldás engedélyezve van a célpont DNS-szerverein?

Reverse DNS bejegyzések:

A "sima" DNS domainhez ad IP-t a reverse értelemszerűen fordítva. Néha egészen meglepő dolgokat találhatunk:

Host nic.sch.bme.hu (152.66.208.1) not scanned
Host endor.sch.bme.hu (152.66.208.2) not scanned
Host atlas.sch.bme.hu (152.66.208.3) not scanned
Host centaur.sch.bme.hu (152.66.208.5) not scanned
Host nic2.sch.bme.hu (152.66.208.7) not scanned
Host ring.sch.bme.hu (152.66.208.8) not scanned
Host akela.sch.bme.hu (152.66.208.9) not scanned
Host netwatcher.sch.bme.hu (152.66.208.10) not scanned
[...]
Host logaan.sch.bme.hu (152.66.208.17) not scanned
Host afs.sch.bme.hu (152.66.208.18) not scanned
Host afs1.sch.bme.hu (152.66.208.19) not scanned
Host afs2.sch.bme.hu (152.66.208.20) not scanned
[...]
Host dns.sch.bme.hu (152.66.208.23) not scanned
[...]
Host pop3.sch.bme.hu (152.66.208.36) not scanned
Host meru-ap5.sch.bme.hu (152.66.208.44) not scanned
Host meru-ctrl.sch.bme.hu (152.66.208.45) not scanned
Host meru-ap1.sch.bme.hu (152.66.208.46) not scanned
Host meru-ap2.sch.bme.hu (152.66.208.47) not scanned
Host meru-ap3.sch.bme.hu (152.66.208.48) not scanned
Host meru-ap4.sch.bme.hu (152.66.208.49) not scanned
Host zenith-sp.sch.bme.hu (152.66.208.51) not scanned
Host zenith.sch.bme.hu (152.66.208.52) not scanned
Host ssh.sch.bme.hu (152.66.208.86) not scanned
Host ssh2.sch.bme.hu (152.66.208.96) not scanned
Host sandbox.sch.bme.hu (152.66.208.105) not scanned
Host ns1.sch.bme.hu (152.66.208.130) not scanned
Host ap-linksys0.sch.bme.hu (152.66.208.180) not scanned
Host ap-linksys1.sch.bme.hu (152.66.208.181) not scanned
[...]
Host sw-02-1.sch.bme.hu (152.66.208.194) not scanned
[...]
Host cisco.sch.bme.hu (152.66.208.249) not scanned
Host ap-asus.sch.bme.hu (152.66.208.250) not scanned

A DNS harmadik csodálatos tulajdonsága az AXFR zónatranszfer (nem mutatok logot, túl nagy lenne...)

; <<>> DiG 9.5.1-P3 <<>> @ns.sch.bme.hu -t AXFR sch.bme.hu
; (1 server found)
;; global options:  printcmd
sch.bme.hu.             2560    IN      SOA     ns.sch.bme.hu. netadmin.sch.bme.hu. 1258467128 3600 900 1209600 3600
[...]

2 Whois

Két üzemmódban használjuk. Egyrészt keresünk névre, másrészt IP-címre.

Domainnévre keresés:

zsombor@metacortex:~$ whois bme.hu
% Whois server 1.99C

Rights restricted by copyright. Szerzői jog fenntartva.
-Legal usage of this service requires that you agree to
abide by the rules and conditions set forth at
http://www.domain.hu/domain/English/domainsearch/feltetelek.html
-A szolgaltatas csak a
http://www.domain.hu/domain/domainsearch/feltetelek.html címen
elérhető feltételek elfogadása és betartása mellett
használható legálisan.

domain:         bme.hu
org:            org_name_eng: Budapest University of Technology and Economics
org:            org_name_hun: Budapesti Muszaki és Gazdaságtudományi Egyetem
address:        Pf 91
address:        H-1521 Budapest
address:        HU
phone:          +36 1 4631111
fax-no:         +36 1 4631110
hun-id:         0930303001
admin-c:        2980924010
tech-c:         2980924009
zone-c:         2000226497
nameserver:     nic.bme.hu
nameserver:     ns.bme.hu
nameserver:     ns2.pantel.net
registered:     1993.03.03 14:24:46
changed:        2004.12.01 20:15:03
registrar:      1960215001

person:         Remzso Gabor
address:        ? ?
address:        H-1521 Budapest
address:        HU
phone:          |+36 1 4632421|
fax-no:         |+36 1 4632420|
hun-id:         2980924010

person:         Borsodi Gabor
address:        ? ?
address:        H-1521 Budapest
address:        HU
phone:          |+36 1 4631821|
fax-no:         |+36 1 4632420|
e-mail:         thulya@eik.bme.hu
hun-id:         2980924009

person:         DNS Admin HUNGARNET
address:        Pf. 498
address:        1396 Budapest 62
address:        HU
phone:          dns-admin@hungarnet.hu
fax-no:         +36 1 350-6750
hun-id:         2000226497

org:            org_name_eng: HUNGARNET Association
org:            org_name_hun: HUNGARNET Egyesület (Registrar)
address:        Victor Hugo u. 18-22.
address:        H-1132 Budapest
address:        HU
phone:          +36 1 4503070
fax-no:         +36 1 3506750
hun-id:         1960215001

Ha IP-re keresünk:

% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf

% Note: This output has been filtered.
%       To receive output for a database update, use the "-B" flag.

% Information related to '152.66.0.0 - 152.66.255.255'

inetnum:         152.66.0.0 - 152.66.255.255
netname:         BMENET
descr:           Budapest University of Technology and Economics
descr:           Budapesti Muszaki es Gazdasagtudomanyi Egyetem
country:         HU
org:             ORG-BME1-RIPE
admin-c:         GR1029-RIPE
tech-c:          IOS2-RIPE
tech-c:          GOYA-RIPE
tech-c:          THU-RIPE
remarks:         rev-srv:        nic.bme.hu
remarks:         rev-srv:        ns.bme.hu
status:          ASSIGNED PI "status:" definitions
mnt-by:          AS2547-MNT
source:          RIPE # Filtered
remarks:         rev-srv attribute deprecated by RIPE NCC on 02/09/2009

organisation:    ORG-BME1-RIPE
org-name:        BME
remarks:         Budapest University of Technology and Economics
remarks:         Budapesti Muszaki es Gazdasagtudomanyi Egyetem
org-type:        OTHER
address:         Muegyetem rkp. 9.
                H-1111 Budapest
                Hungary
phone:           +36 1 4632421
fax-no:          +36 1 4632420
remarks:         =========================================================
abuse-mailbox:   abuse@bme.hu
remarks:         ---------------------------------------------------------
remarks:         Reporting guidelines can be found at
                http://net.bme.hu/abuse/?lang=en
                Reports not conforming to these guidelines may be
                discarded silently.  Thanks for your cooperation.
remarks:         ---------------------------------------------------------
remarks:         Bejelentest kerjuk az alabbiak szerint tegyen:
                http://net.bme.hu/abuse/
                Az itt leirtaknak meg nem felelo bejelentesekkel nem all
                modunkban foglalkozni.  Koszonjuk szives egyuttmukodeset!
remarks:         =========================================================
mnt-ref:         AS2547-MNT
mnt-by:          AS2547-MNT
source:          RIPE # Filtered

person:          Gabor Remzso
address:         Budapest University of Technology and Economics
address:         Center of Information Systems
address:         Muegyetem rkp. 9. R310
address:         H-1111 Budapest
address:         Hungary
phone:           +36 1 4632421
fax-no:          +36 1 4632420
nic-hdl:         GR1029-RIPE
org:             ORG-BME1-RIPE
mnt-by:          AS2547-MNT
source:          RIPE # Filtered

person:          Istvan Ostrosits
address:         PanTel Telecommunication Co.
address:         Bocskai ut 134-146.
address:         H-1113 Budapest
address:         Hungary
phone:           +36 1 8883583
fax-no:          +36 1 8883636
nic-hdl:         IOS2-RIPE
source:          RIPE # Filtered

person:          Andras Jako
address:         Budapest University of Technology and Economics
address:         Center of Information Systems
address:         Muegyetem rkp. 9. R310
address:         H-1111 Budapest
address:         Hungary
phone:           +36 1 4631672
fax-no:          +36 1 4632420
nic-hdl:         GOYA-RIPE
org:             ORG-BME1-RIPE
source:          RIPE # Filtered

person:          Imre Simon
address:         Budapest University of Technology and Economics
address:         Center of Information Systems
address:         Muegyetem rkp. 9. R310
address:         H-1111 Budapest
address:         Hungary
phone:           +36 1 4631616
fax-no:          +36 1 4632420
nic-hdl:         THU-RIPE
source:          RIPE # Filtered

% Information related to '152.66.0.0/16AS2547'

route:           152.66.0.0/16
descr:           BMENET
org:             ORG-BME1-RIPE
origin:          AS2547
mnt-by:          AS2547-MNT
source:          RIPE # Filtered

organisation:    ORG-BME1-RIPE
org-name:        BME
remarks:         Budapest University of Technology and Economics
remarks:         Budapesti Muszaki es Gazdasagtudomanyi Egyetem
org-type:        OTHER
address:         Muegyetem rkp. 9.
                H-1111 Budapest
                Hungary
phone:           +36 1 4632421
fax-no:          +36 1 4632420
remarks:         =========================================================
abuse-mailbox:   abuse@bme.hu
remarks:         ---------------------------------------------------------
remarks:         Reporting guidelines can be found at
                http://net.bme.hu/abuse/?lang=en
                Reports not conforming to these guidelines may be
                discarded silently.  Thanks for your cooperation.
remarks:         ---------------------------------------------------------
remarks:         Bejelentest kerjuk az alabbiak szerint tegyen:
                http://net.bme.hu/abuse/
                Az itt leirtaknak meg nem felelo bejelentesekkel nem all
                modunkban foglalkozni.  Koszonjuk szives egyuttmukodeset!
remarks:         =========================================================
mnt-ref:         AS2547-MNT
mnt-by:          AS2547-MNT
source:          RIPE # Filtered

3 AS

Az AS routing szempontból egy csoportba tartozó hálózatokat jelöl, leginkább a hálózatok egymáshoz kapcsolódását lehet vele vizsgálni egy teszt során.

A BME például a Hungarnettől kapja a hálózatot: [[1]]

A Hungarnet pedig... [[2]]

4 Google

A http://johnny.ihackstuff.com/ghdb/ található kis gyűjtemény érdekesebbnél érdekesebb google keresésekkel. Eszközök: wikto, seat (bash :))

5 Metaadatok vizsgálata

Messzire visz, de fontos tudni, hogy minden MSOffice (OpenOffice) dokumentum, PDF, kép, gyakorlatilag bármi, ami bonyolultabb egy szövegfájlnál, tömve van metaadatokkal. Például belső nyomtatók nevei, felhasználók nevei, IP-címek, operációs rendszerek típusa könnyedén kiolvasható a neten található dokumentumokból. Kiváló eszköz a kivonatolásra a metagoofil.

Mostani, friss előadás (2009. november közepe) [3]

6 SMTP fingerprinting

Nagyon egyszerű: küldünk egy levelet egy nem létező e-mailcímre a célpont domainjébe és figyeljük a visszajövő válaszlevelet. Közelről.

Például:

Return-Path: <>
Received: from metacortex ([unix socket])
	 by metacortex (Cyrus v2.2.13-Debian-2.2.13-14+lenny3) with LMTPA;
	 Tue, 17 Nov 2009 14:29:59 +0100
X-Sieve: CMU Sieve 2.2
Received: from Debian-exim by metacortex.hu with local (Exim 4.69)
	id 1NAO87-0005Zv-7P
	for zsombor.kovacsatmetacortex.hu; Tue, 17 Nov 2009 14:29:59 +0100
X-Failed-Recipients: nincsilyen@bme.hu
Auto-Submitted: auto-replied
From: Mail Delivery System <Mailer-Daemon@metacortex.hu>
To: zsombor.kovacsatmetacortex.hu
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1NAO87-0005Zv-7P@metacortex.hu>
Date: Tue, 17 Nov 2009 14:29:59 +0100

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  nincsilyen@bme.hu
    SMTP error from remote mail server after RCPT TO:<nincsilyen@bme.hu>:
    host nic.bme.hu [152.66.115.1]: 550 5.1.1 <nincsilyen@bme.hu>:
    Recipient address rejected: User unknown in local recipient table

------ This is a copy of the message, including all the headers. ------

Return-path: <zsombor.kovacsatmetacortex.hu>
Received: from metacortex.hu
	([195.228.45.55] helo=[0.0.0.0] ident=zsombor)
	by metacortex.hu with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.69)
	(envelope-from <zsombor.kovacsatmetacortex.hu>)
	id 1NAO86-0005Zk-O6
	for nincsilyen@bme.hu; Tue, 17 Nov 2009 14:29:58 +0100
Message-ID: <4B02A556.1090907@metacortex.hu>
Date: Tue, 17 Nov 2009 14:29:58 +0100
From: =?ISO-8859-1?Q?Kov=E1cs_Zsombor?= <zsombor.kovacsatmetacortex.hu>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: nincsilyen@bme.hu
Subject: asdf
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

7 Traceroute

A traceroute nagyon egyszerű, de hatékony eszköz a hálózati topológia felderítésére. Azon alapszik, hogy a kiküldött csomagok TTL mezőjét manipuláljuk olyan módon, hogy egymás utáni hálózati elemeken legyen 0, amik az RFC értelmében ICMP TTL Expired üzenetet küldenek vissza. Ezt figyeljük. Például az nmap tud ilyet is a grafikus verziójában.

Kérdés: miért nem bízunk meg a traceroute eredményében?

Személyes eszközök