找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

linux上NC的应用--蜜罐技术

2009-12-20 13:45| 发布者: admin| 查看: 92| 评论: 0|原作者: 夙玉

在写这篇日志之前,曾经接触过网络安全产品:UTM、网闸、vpn设备;但是一直都在想,这些安全设备上面的一个很有意思的功能如何用很小很小的linux来实现虚拟服务功能,引诱黑客来攻击--这个就是所谓的蜜罐。实际上,实现蜜罐并不难,说破了,网络安全其实也不怎么安全!!哈哈哈

下面先介绍一个号称瑞士军刀的工具--NC。NC在linux实际应用上很少见,一般服务器上面也没开设NC的,而且在网络架构中一般都是有其他的网络安全产品做过滤作用,所以,服务器还是比较安全的。废话少说,先把NC介绍清楚先。

HttpClient中反复提到用
NetCAt
进行调试,下载NetCat一看,确实如其所述的小巧而功能强大,如瑞士军刀。
  NetCat是一个非常简单的Unix工具,可以读、写TCP或UDP网络连接(network connection)。它被设计成一个可靠的后端(back-end)工具,能被其它的程序程序或脚本直接地或容易地驱动。同时,它又是一个功能丰富的网络调试和开发工具,因为它可以建立你可能用到的几乎任何类型的连接,以及一些非常有意思的内建功能。NetCat,它的实际可运行的名字叫nc,应该早很就被提供,就象另一个没有公开但是标准的Unix工具。
  GNU也有一个
netcat
项目,但此处学习的不是GNU的那个。
  最简单的使用方法,”nc host port”,能建立一个TCP连接,连向指定的主机和端口。接下来,你的从标准输入中输入的任何内容都会被发送到指定的主机,任何通过连接返回来的信息都被显示在你的标准输出上。这个连接会一直持续下去,至到连接两端的程序关闭连接。注意,这种行为不同于大多数网络程序,它们会在从标准输入读到一个文件结束符后退出。
  NetCat还可以当服务器使用,监听任意指定端口的连接请求(inbound connection),并可做同样的读写操作。除了较小限制外,它实际并不关心自己以“客户端”模式还是“服务器”模式运行,它都会来回运送全部数据。在任何一种模式下,都可以设置一个非活动时间来强行关闭连接。
  它还可以通过UDP来完成这些功能,因此它就象一个telnet那样的UDP程序,用来测试你的UDP服务器。正如它的“U”所指的,UDP跟TCP相比是一种不可靠的数据传输,一些系统在使用UDP传送大量数据时会遇到麻烦,但它还有一些用途。
  你可能会问“为什么不用telnet来连接任意的端口”?问题提得好(valid),这儿有一些理由。Telnet有“标准输入文件结束符(standard input EOF)”问题,所以需要在脚本中延迟计算以便等待网络输出结束。这就是netcat持续运行直到连接被关闭的主要原因。Telnet也不能传输任意的二进制数据,因为一些特定的字符会被解释为Telnet的参数而被从数据流中去除。Telnet还将它的一些诊断信息显示到标准输出上,而NetCat会将这信息与它的输出分开以不改变真实数据的传输,除非你要求它这么做。当然了,Telnet也不能监听端口,也不能使用UDP。NetCat没有这些限制,比Telnet更小巧和快捷,而且还有一些其它的功能。
  NetCat的一些主要功能:

支持连出和连入(outbound and inbound connection),TCP和UDP,任意源和目的端口

全部DNS正向/反向检查,给出恰当的警告

使用任何源端口

使用任何本地设置的网络资源地址

内建端口扫描功能,带有随机数发生器

内建loose source-routing功能

可能标准输入读取命令行参数

慢发送模式,每N秒发送一行

以16进制显示传送或接收的数据

允许其它程序服务建立连接,可选

对Telnet应答,可选
那如何利用NC来实现蜜罐的功能呢?首先:在linux上面安全NC,因为这边选择的是redflag linux AX3.0的版本,自带有nc;再下载一个扫描工具,随便一个能够对网络端口进行扫描就可以,比如:sniffer等。这里我就以天锐局域网扫描工具来做实验。
实验过程:
1,首先,查看要使用的机器的IP地址信息
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095014.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
2,用天锐局域网扫描工具对192.168.228.90的机器进行端口扫描
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095126.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
3,查看NC的帮助,看做蜜罐合适的一些参数,当然,不同版本的NC参数使用不同。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095109.jpg');}" onmousewheel="return imgzoom(this);" alt="" />

5,使用-l参数来对端口进行监听
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095217.jpg');}" onmousewheel="return imgzoom(this);" alt="" />

6,用扫描工具对90机器进行一次扫描,发现原来没有开启的80端口现在已经启动起来了。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095230.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
7,扫描之后,会发现机器上的监听已经停止,
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095241.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
这里,nc的监听已经结束了,如果再进行扫描的话,是没有80端口的存在,可以再做一次扫描,
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095307.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
看到的结果跟预测的结果一样。

那,如何实现长实践监听呢?怎么记录黑客的行为呢?根据帮助中可以得知,-k参数是用来长时间监听的,
现在,执行一下加-k参数的命令,试试效果:

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095333.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095343.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
发现结果监听还在继续。。

从日志中,可以看出攻击方的IP地址:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095322.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blog.chinaunix.net/photo/82278_081219095353.jpg');}" onmousewheel="return imgzoom(this);" alt="" />

信息已经被记录下来。

当然,要实现蜜罐技术,并不是现在这么简单,还需要加些其他东西进去,比如:如何去做判断,如何去跟踪等。







最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 05:28 , Processed in 0.148319 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部