src/network/nKrawall.cpp File Reference

#include "nKrawall.h"
#include "nNetwork.h"
#include "nServerInfo.h"
#include "nNetObject.h"
#include "tString.h"
#include "tArray.h"
#include "tConsole.h"
#include "tSysTime.h"
#include "tMemManager.h"
#include "tRandom.h"
#include <stdlib.h>
#include <string>
#include <vector>
#include <string.h>

Include dependency graph for nKrawall.cpp:

Go to the source code of this file.

Functions

static void sn_GetSupportedMethods (std::vector< tString > &toFill)
static bool sn_IsSupportedMethod (tString const &method)
static bool sn_BothHave (tString const &a, tString const &b, tString const &m)
static tString sn_Replace (nKrawall::nScrambleInfo const &info, tString const &original)
static void sn_WriteHexByte (std::ostream &s, int c)

Variables

static tString sn_methodBlacklist ("bmd5")
static tConfItemLine sn_methodBlacklistConf ("HASH_METHOD_BLACKLIST", sn_methodBlacklist)


Function Documentation

static bool sn_BothHave ( tString const &  a,
tString const &  b,
tString const &  m 
) [static]

Definition at line 120 of file nKrawall.cpp.

References tIsInList().

Referenced by nKrawall::nMethod::BestMethod().

00122 {
00123     return tIsInList( a, m ) && tIsInList( b, m );

Here is the call graph for this function:

Here is the caller graph for this function:

static void sn_GetSupportedMethods ( std::vector< tString > &  toFill  )  [static]

Definition at line 59 of file nKrawall.cpp.

References sn_methodBlacklist, and tIsInList().

Referenced by nKrawall::nMethod::BestMethod(), sn_IsSupportedMethod(), and nKrawall::nMethod::SupportedMethods().

00061 {
00062     char const * protocols[] = { 
00063         "md5",
00064         "bmd5",
00065         0
00066     };
00067 
00068     // iterate through methods, starting from best, and return the first that fits
00069     char const * const * run = protocols;
00070     while ( *run )
00071     {
00072         tString method( *run );
00073         if ( !tIsInList( sn_methodBlacklist, method ) )
00074         {
00075             toFill.push_back( method );
00076         }
00077         ++run;
00078     }

Here is the call graph for this function:

Here is the caller graph for this function:

static bool sn_IsSupportedMethod ( tString const &  method  )  [static]

Definition at line 80 of file nKrawall.cpp.

References sn_GetSupportedMethods().

Referenced by nKrawall::nMethod::ScrambleWithSalt().

00082 {
00083     std::vector< tString > methods;
00084     sn_GetSupportedMethods( methods);
00085     
00086     for( std::vector< tString >::iterator iter = methods.begin(); iter != methods.end(); ++iter )
00087     {
00088         if ( method == *iter )
00089         {
00090             return true;
00091         }
00092     }
00093 
00094     return false;

Here is the call graph for this function:

Here is the caller graph for this function:

static tString sn_Replace ( nKrawall::nScrambleInfo const &  info,
tString const &  original 
) [static]

Definition at line 170 of file nKrawall.cpp.

References in, and nKrawall::nScrambleInfo::username.

Referenced by nKrawall::nMethod::ScramblePassword().

00172 {
00173     std::istringstream in( static_cast< char const * >( original ) );
00174     std::ostringstream out;
00175 
00176     char s = in.get();
00177     while ( !in.eof() )
00178     {
00179         if ( s != '%' || in.eof() )
00180         {
00181             out.put(s);
00182         }
00183         else
00184         {
00185             s = in.get();
00186             if ( s == 'u' )
00187             {
00188                 out << info.username;
00189             }
00190             else
00191             {
00192                 out << '%' << s;
00193             }
00194         }
00195 
00196         s = in.get();
00197     }
00198 
00199     return tString( out.str().c_str() );

Here is the caller graph for this function:

static void sn_WriteHexByte ( std::ostream &  s,
int  c 
) [static]

Definition at line 310 of file nKrawall.cpp.

Referenced by nKrawall::EncodeScrambledPassword(), and nKrawall::EncodeString().

00312 {
00313     // don't want to rely on filling type iomanip things, never learned how to use them reliably
00314     s << std::hex <<  std::setfill('0') << std::setw(2) << c;
00315     // s << ( val & 0xF0 ) / 0x10;
00316     // s << ( val & 0x0F );

Here is the caller graph for this function:


Variable Documentation

tString sn_methodBlacklist("bmd5") [static]

Referenced by sn_GetSupportedMethods().

tConfItemLine sn_methodBlacklistConf("HASH_METHOD_BLACKLIST", sn_methodBlacklist) [static]


Generated on Sat Mar 15 23:00:37 2008 for Armagetron Advanced by  doxygen 1.5.4