Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

Linux黑客系列(二)GO GO GO!->扫描

[复制链接]
bestwc 发表于 2007-8-24 10:28:17 | 显示全部楼层 |阅读模式
本教程需要一定的黑客技术和Linux系统基础知识.

先看看我们要用的扫描器的介绍:

NMap,也就是Network Mapper,是linux下的网络扫描和嗅探工具包,其基本功能有三个,一是探测一组主机是否在线;其次是扫描 主机端口,嗅探所提供的网络服务;还可以推断主机所用的操作系统 。Nmap可用于扫描仅有两个节点的LAN,直至500个节点以上的网络。Nmap 还允许用户定制扫描技巧。通常,一个简单的使用ICMP协议的ping操 作可以满足一般需求;也可以深入探测UDP或者TCP端口,直至主机所 使用的操作系统;还可以将所有探测结果记录到各种格式的日志中, 供进一步分析操作。

OK 我们开始 :)

下载地址:http://insecure.org/nmap/download.html
当前版本地址:http://download.insecure.org/nmap/dist/nmap-4.21ALPHA4.tar.bz2

好了,我解压缩好了,直接开始编译.....
[root@NewStar8 nmap]# cd /
[root@NewStar8 /]# cd /hacker
[root@NewStar8 hacker]# cd nmap
[root@NewStar8 nmap]#./configure            第一步:配置(configure)

屏幕会飞快闪动这样的字符:
checking for strsep... yes
checking for Berkeley Packet Filter... no
checking for Linux proc filesystem... yes
checking for Linux PF_PACKET sockets... yes
checking for SNMP MIB2 STREAMS... no
checking for route(7) STREAMS... no
checking for arp(7) ioctls... yes
checking for raw IP sockets ip_{len,off} host byte ordering... no
checking for cooked raw IP sockets... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dnet-config
config.status: creating include/Makefile
config.status: creating include/dnet/Makefile
config.status: creating src/Makefile
config.status: creating include/config.h
config.status: executing depfiles commands
config.status: executing default commands
configure: configuring in nbase


省略部分


完成后会显示这样的字符:
config.status: creating Makefile
  (  )  /\  _                (
    \ |  (  \ ( \.(              )                      _____
  \  \ \  `  `  ) \            (  ___                / _  \
(_`    \+  . x  ( .\            \/  \____-----------/ (o)  \_
- .-              \+  ;          (  O                          \____
                          )        \_____________  `              \  /
(__                +- .( -'.- <. - _  VVVVVVV VV V\                \/
(_____            ._._: <_ - <- _  (--  _AAAAAAA__A_/                |
  .    /./.+-  . .- /  +--  - .    \______________//_              \_______
  (__ ' /x  / x _/ (                                  \___'          \    /
, x / ( '  . / .  /                                      |          \  /
    /  /  _/ /    +                                      /              \/
  '  (__/                                            /                  \
            NMAP IS A POWERFUL TOOL -- USE CAREFULLY AND RESPONSIBLY
              [ Sick of the Nmap dragon? Submit your art and tag ]
              [ lines to nmap-dev@insecure.org for next release! ]
Configuration complete.  Type make (or gmake on some *BSD machines) to compile.

呵呵,我们可以开始MAKE了.
[root@NewStar8 nmap]# make
Makefile:213: makefile.dep: 没有那个文件或目录
g++ -MM -Iliblua -Ilibdnet-stripped/include -Ilibpcre -g -O2 -Wall  -Ilibpcap -Inbase -Insock/include  -DHAVE_CONFIG_H -DNMAP_VERSION=\"4.21ALPHA4\" -DNMAP_NAME=\"Nmap\" -DNMAP_URL=\"http://insecure.org\" -DNMAP_PLATFORM=\"i686-pc-linux-gnu\" -DNMAPDATADIR=\"/usr/local/share/nmap\"  main.cc nmap.cc targets.cc tcpip.cc nmap_error.cc utils.cc idle_scan.cc osscan.cc osscan2.cc output.cc scan_engine.cc timing.cc charpool.cc services.cc protocols.cc nmap_rpc.cc portlist.cc NmapOps.cc TargetGroup.cc Target.cc FingerPrintResults.cc service_scan.cc NmapOutputTable.cc MACLookup.cc nmap_tty.cc nmap_dns.cc nse_main.cc nse_auxiliar.cc nse_nsock.cc nse_init.cc nse_nmaplib.cc nse_debug.cc nse_bitlib.cc nse_pcrelib.cc nse_string.cc traceroute.cc  > makefile.dep

INUX=1 -DPCAP_TIMEOUT_IGNORED=1  -DVERSION=\"4.21ALPHA4\" -DHAVE_CONFIG_H=1 -I.    -c nmapfe.c
nmapfe.c:114:2: #error "Your system does not appear to have GTK (www.gtk.org) installed.  Thus the Nmap X Front End will not compile.  You should still be able to use Nmap the normal way (via text console).  GUIs are for wimps anyway :)"
make[1]: *** [nmapfe.o] 错误 1
make[1]: Leaving directory `/hacker/nmap/nmapfe'
make: *** [nmapfe/nmapfe] 错误 2                        

忽略这些错误.我们开始安装.
[root@NewStar8 nmap]# make install
Compiling liblua
make[1]: Entering directory `/hacker/nmap/liblua'
make all MYCFLAGS=-DLUA_USE_POSIX
make[2]: Entering directory `/hacker/nmap/liblua'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/hacker/nmap/liblua'
make[1]: Leaving directory `/hacker/nmap/liblua'
Compiling libpcap
make[1]: Entering directory `/hacker/nmap/libpcap'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/hacker/nmap/libpcap'
Compiling libpcre

中间省略
nmapfe.c:114:2: #error "Your system does not appear to have GTK (www.gtk.org) installed.  Thus the Nmap X Front End will not compile.  You should still be able to use Nmap the normal way (via text console).  GUIs are for wimps anyway :)"
make[1]: *** [nmapfe.o] 错误 1
make[1]: Leaving directory `/hacker/nmap/nmapfe'
make: *** [nmapfe/nmapfe] 错误 2

我们把临时文件清理掉:
[root@NewStar8 nmap]# make clean
cd liblua && make clean
make[1]: Entering directory `/hacker/nmap/liblua'
rm -f liblua.a lua luac lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua.o luac.o print.o
make[1]: Leaving directory `/hacker/nmap/liblua'
cd libpcap && make clean


好 了,基本到这里扫描工具就可以开始使用了:)
ls 一下,果然看到nmap绿色的可执行文件.看看能不能用,扫描我这里的网关192.168.1.1

[root@NewStar8 nmap]# nmap -sT 192.168.1.1

Starting Nmap 4.21ALPHA4 ( http://insecure.org ) at 2007-05-19 05:17 CST
Warning: File ./nmap-services exists, but Nmap is using /usr/local/share/nmap/nmap-services for security and consistency reasons.  set NMAPDIR=. to give priority to files in your local directory (may affect the other data files too).
Interesting ports on 192.168.1.1:
Not shown: 1702 filtered ports
PORT    STATE  SERVICE
80/tcp  open  http
1900/tcp closed UPnP
MAC Address: 00:0A:EB3:C3:92 (Shenzhen Tp-Link Technology Co;)

Nmap finished: 1 IP address (1 host up) scanned in 33.235 seconds
看来一切正常,扫描到了80端口,而且还从MAC地址上判断出生产商是Shenzhen Tp-Link Technology Co
深圳制造,呵呵 好了,等等我开始和大家一起研究nmap的使用方法^_^
 楼主| bestwc 发表于 2007-8-24 10:29:06 | 显示全部楼层
OK,我们开始一起学习nmap的使用方法.

首先你需要输入要探测的主机的IP地址作为参数。这个是最基本的,不可以省略.我们实验一下除了IP不带任何参数.

[root@NewStar8 nmap]# nmap 192.168.1.1

Starting Nmap 4.21ALPHA4 ( http://insecure.org ) at 2007-05-19 05:32 CST
Warning: File ./nmap-services exists, but Nmap is using /usr/local/share/nmap/nmap-services for security and consistency reasons.  set NMAPDIR=. to give priority to files in your local directory (may affect the other data files too).
Interesting ports on 192.168.1.1:
Not shown: 1702 filtered ports
PORT    STATE  SERVICE
80/tcp  open  http
1900/tcp closed UPnP
MAC Address: 00:0A:EB:D3:C3:92 (Shenzhen Tp-Link Technology Co;)

Nmap finished: 1 IP address (1 host up) scanned in 28.165 seconds

上面是对目标主机的进行全面TCP扫描后的结果。显示了监听端口的服务情况。这一基本操作不需要任何参数,缺点是运行了日志服务的 主机可以很容易地监测到这类扫描。该命令是参数开关-sT的缺省, 即监听TCP,结果完全一样。
也就事说,使用nmap ip 和 nmap -sT ip效果是一样的.

-sS选项可以进行更加隐蔽的扫描,并防止被目标主机检测到。 但此方式需要用户拥有root权限-sF -sX -sN则可以进行一些超常的 扫描。假如目标主机安装了过滤和日志软件来检测同步空闲字符SYN, 那么-sS的隐蔽作用就失效了,此时可以采用-sF(隐蔽FIN), -sX(Xmas Tree)以及-sN(Null)方式的扫描。这里需要注意的是由于微软的坚 持和独特,对于运行Windows 95/98或者NT的机器FIN,Xmas或者Null 的扫描结果将都是端口关闭,由此也是推断目标主机可能运行Windows 操作系统的一种方法。以上命令都需要有root权限。  

注意:一起用是会报错的
[root@NewStar8 nmap]# nmap -sS -sF -sX -sN 192.168.1.1
You specified more than one type of TCP scan.  Please choose only one of -sA, -b, -sT, -sF, -sI, -sM, -sN, -sS, -sW, and -sX
QUITTING!

我们继续:
-sU选项是监听目标主机的UDP而不是默认的TCP端口。尽管在linux 机器上有时慢一些,但比Window系统快得多。比如,我们输入上面的 例子:
[root@NewStar8 nmap]# nmap -sU 192.168.1.1

Starting Nmap 4.21ALPHA4 ( http://insecure.org ) at 2007-05-19 05:37 CST
Warning: File ./nmap-services exists, but Nmap is using /usr/local/share/nmap/nmap-services for security and consistency reasons.  set NMAPDIR=. to give priority to files in your local directory (may affect the other data files too).
Interesting ports on 192.168.1.1:
Not shown: 1485 open|filtered ports
PORT      STATE  SERVICE
1017/udp  closed unknown
1900/udp  closed UPnP
17185/udp closed wdbrpc
MAC Address: 00:0A:EB:D3:C3:92 (Shenzhen Tp-Link Technology Co;)

Nmap finished: 1 IP address (1 host up) scanned in 26.120 seconds


下一个:
-O选项用来推断目标主机的操作系统,可以与上述的命令参数联 合使用或者单独调用。Nmap利用TCP/IP“指纹”技术来推测目标主机 的操作系统。
我去探测一下黑吧是什么系统 ^_^
结果显示:
Running (JUST GUESSING) : Netscreen ScreenOS (87%)
Aggressive OS guesses: Netscreen 5XP firewall+vpn (os 4.0.3r2.0) (87%)
No exact OS matches for host (test conditions non-ideal).

因为对MS主机用-O探测 会产生错误报告,所以应该是什么系统各位自己猜....




除了一次只扫描一个目标主机,你也可以同时扫描一个主机群,比如
下例:
nmap -sT -O 202.96.1.1-50就可以同时扫描并探测IP地址在192.168.1.1 到192.168.1.50之间的每一台主机。当然这需要更多的时间,耗费更多的系统资源和网络带宽。输出结果也可能很长。所以,可以使用下面命令将结果重定向输送到一个文件中:
nmap -sT -O -oN test.txt 192.168.1.1-50
另外的一些命令参数选项包括:
-I 进行TCP反向用户认证扫描,可以透露扫描用户信息
-iR 进行随机主机扫描
-p 扫描特定的端口范围
-v 长数据显示,-v -v 是最长数据显示

当然还有非常非常多的参数可以用,功能非常强大,而且从我还上小学的时候就听说过nmap了,经过这么长时间的磨炼,此工具不可小看:)

你可以使用nmap -h来查看帮助资料,使用多了就会习惯^_^



考试:说出此命令的含义
nmap -sS -p 23,80 -oN ftphttpscan.txt 209.212.53.50-100

QQ78975150 Thx for Watching!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-4-26 20:47 , Processed in 0.117552 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表