Changeset 445

Show
Ignore:
Timestamp:
03/28/06 20:09:48 (3 years ago)
Author:
common
Message:

shellcode-signatures
- create sch_namespace_##NAME## by deriving NamespaceShellcodehandler? as definded in sch_namespace.{c,h}pp
- removed sc_shellcode from sch_namespace_*
- adds sch_namespace.{c,h}pp

benefits:
every sch_namespace now relies on NamespaceShellcodeHandler::'s construktor, destructor, Init() and Exit() fn, saves code, and time
copying the needed values (pattern, name, namespace) from the sc_shellcode struct is done in NamespaceShellcodeHandlers? constructor
if we add values to the sc_shellcode struct, its very easy to add them to every sch_namespace_*, just extend the NamespaceShellcodeHandler? class and add the copying to the construktor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nepenthes/trunk/modules/shellcode-signatures/Makefile.am

    r436 r445  
    1515shellcodesignatures_la_SOURCES += y.tab.c lex.yy.c 
    1616shellcodesignatures_la_SOURCES += shellcode-signatures.cpp shellcode-signatures.hpp  
     17shellcodesignatures_la_SOURCES += sch_namespace.cpp sch_namespace.hpp 
    1718shellcodesignatures_la_SOURCES += sch_namespace_xor.cpp sch_namespace_xor.hpp 
    1819shellcodesignatures_la_SOURCES += sch_namespace_bindshell.cpp sch_namespace_bindshell.hpp 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_base64.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include "sch_namespace_base64.hpp" 
    3331 
     
    5149using namespace nepenthes; 
    5250 
    53 NamespaceBase64::NamespaceBase64(sc_shellcode *sc) 
     51NamespaceBase64::NamespaceBase64(sc_shellcode *sc) : NamespaceShellcodeHandler(sc) 
    5452{ 
    55         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    56         m_ShellcodeHandlerName += "::"; 
    57         m_ShellcodeHandlerName += sc->name; 
    58  
    59         m_Shellcode = sc; 
    6053} 
    6154 
     
    6558 
    6659} 
    67  
    68  
    69 bool NamespaceBase64::Init() 
    70 { 
    71         const char * pcreEerror; 
    72         int32_t pcreErrorPos; 
    73         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    74         { 
    75                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    76                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    77                 return false; 
    78         } else 
    79         { 
    80                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    81         } 
    82  
    83 //      printf("%s\n",m_Shellcode->pattern); 
    84 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    85         return true; 
    86 } 
    87  
    88 bool NamespaceBase64::Exit() 
    89 { 
    90         return true; 
    91 } 
    92  
    9360 
    9461sch_result NamespaceBase64::handleShellcode(Message **msg) 
     
    10976        { 
    11077                int32_t i; 
    111                 for ( i=0; i < m_Shellcode->map_items; i++ ) 
     78                for ( i=0; i < m_MapItems; i++ ) 
    11279                { 
    113                         if (m_Shellcode->map[i] == sc_none) 
     80                        if (m_Map[i] == sc_none) 
    11481                                        continue; 
    11582 
    116                         logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     83                        logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    11784                        const char *match = NULL; 
    11885                        pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    11986 
    120                         switch ( m_Shellcode->map[i] ) 
     87                        switch ( m_Map[i] ) 
    12188                        { 
    12289                        case sc_post: 
     
    12794 
    12895                        default: 
    129                                 logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     96                                logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Map[i])); 
    13097                        } 
    13198                } 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_base64.hpp

    r436 r445  
    3232#define HAVE_NAMESPACE_BASE64_HPP 
    3333 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
    3734 
     35#include "sch_namespace.hpp" 
    3836 
    3937namespace nepenthes 
    4038{ 
    41         class NamespaceBase64 : public ShellcodeHandler 
     39        class NamespaceBase64 : public NamespaceShellcodeHandler 
    4240        { 
    4341        public: 
    4442                NamespaceBase64(sc_shellcode *sc); 
    4543                ~NamespaceBase64(); 
    46                 sch_result handleShellcode(Message **msg); 
     44/* 
    4745                bool Init(); 
    4846                bool Exit(); 
    49         private: 
    50                 pcre    *m_Pcre; 
    51                 sc_shellcode *m_Shellcode; 
     47*/ 
     48                sch_result handleShellcode(Message **msg); 
    5249        }; 
    5350} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_bindfiletransfer.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include <sys/types.h> 
    3331#include <sys/socket.h> 
     
    5654using namespace nepenthes; 
    5755 
    58 NamespaceBindFiletransfer::NamespaceBindFiletransfer(sc_shellcode *sc) 
     56NamespaceBindFiletransfer::NamespaceBindFiletransfer(sc_shellcode *sc) : NamespaceShellcodeHandler(sc) 
    5957{ 
    60         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    61         m_ShellcodeHandlerName += "::"; 
    62         m_ShellcodeHandlerName += sc->name; 
    6358 
    64         m_Shellcode = sc; 
    6559} 
    6660 
     
    6862{ 
    6963 
    70 } 
    71  
    72 bool NamespaceBindFiletransfer::Init() 
    73 { 
    74         const char * pcreEerror; 
    75         int32_t pcreErrorPos; 
    76         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    77         { 
    78                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    79                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    80                 return false; 
    81         } else 
    82         { 
    83                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    84         } 
    85  
    86 //      printf("%s\n",m_Shellcode->pattern); 
    87 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    88         return true; 
    89 } 
    90  
    91 bool NamespaceBindFiletransfer::Exit() 
    92 { 
    93         return true; 
    9464} 
    9565 
     
    11787                if ( (matchCount = pcre_exec(m_Pcre, 0, (char *) shellcode, len, 0, 0, (int *)ovec, sizeof(ovec)/sizeof(int32_t))) > 0 ) 
    11888                { 
    119                         logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_Shellcode->map_items); 
     89                        logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_MapItems); 
    12090                        int32_t i; 
    121                         for ( i=0; i < m_Shellcode->map_items; i++ ) 
     91                        for ( i=0; i < m_MapItems; i++ ) 
    12292                        { 
    123                                 if (m_Shellcode->map[i] == sc_none) 
     93                                if (m_Map[i] == sc_none) 
    12494                                continue; 
    12595                                 
    12696 
    127                                 logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     97                                logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    12898                                const char *match = NULL; 
    12999                                pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    130100 
    131                                 switch ( m_Shellcode->map[i] ) 
     101                                switch ( m_Map[i] ) 
    132102                                { 
    133103 
     
    143113 
    144114                                default: 
    145                                         logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     115                                        logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Map[i])); 
    146116                                } 
    147117 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_bindfiletransfer.hpp

    r433 r445  
    3232 
    3333#include <stdint.h> 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
     34#include "sch_namespace.hpp" 
     35 
    3736 
    3837namespace nepenthes 
    3938{ 
    40         class NamespaceBindFiletransfer : public ShellcodeHandler 
     39        class NamespaceBindFiletransfer : public NamespaceShellcodeHandler 
    4140        { 
    4241        public: 
     
    4443                ~NamespaceBindFiletransfer(); 
    4544                sch_result handleShellcode(Message **msg); 
    46                 bool Init(); 
    47                 bool Exit(); 
    48         private: 
    49                 pcre    *m_Pcre; 
    50                 sc_shellcode *m_Shellcode; 
    5145        }; 
    5246} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_bindshell.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include <sys/types.h> 
    3331#include <netinet/in.h> 
     
    5452using namespace nepenthes; 
    5553 
    56 NamespaceBindShell::NamespaceBindShell(sc_shellcode *sc) 
     54NamespaceBindShell::NamespaceBindShell(sc_shellcode *sc) : NamespaceShellcodeHandler(sc) 
    5755{ 
    58         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    59         m_ShellcodeHandlerName += "::"; 
    60         m_ShellcodeHandlerName += sc->name; 
    61  
    62         m_Shellcode = sc; 
    6356} 
    6457 
     
    6659{ 
    6760 
    68 } 
    69  
    70 bool NamespaceBindShell::Init() 
    71 { 
    72         const char * pcreEerror; 
    73         int32_t pcreErrorPos; 
    74         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    75         { 
    76                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    77                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    78                 return false; 
    79         } else 
    80         { 
    81                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    82         } 
    83  
    84 //      printf("%s\n",m_Shellcode->pattern); 
    85 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    86         return true; 
    87 } 
    88  
    89 bool NamespaceBindShell::Exit() 
    90 { 
    91         return true; 
    9261} 
    9362 
     
    11180                 uint16_t port=0; 
    11281 
    113                 for ( int i=0; i < m_Shellcode->map_items; i++ ) 
     82                for ( int i=0; i < m_MapItems; i++ ) 
    11483                { 
    115                         if ( m_Shellcode->map[i] == sc_port ) 
     84                        if ( m_Map[i] == sc_port ) 
    11685                        { 
    11786                                pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, 1, &match); 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_bindshell.hpp

    r428 r445  
    3131#define HAVE_NAMESPACE_BINDSHELL_HPP 
    3232 
    33 #include <stdint.h> 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
     33#include "sch_namespace.hpp" 
    3734 
    3835namespace nepenthes 
    3936{ 
    40         class NamespaceBindShell : public ShellcodeHandler 
     37        class NamespaceBindShell : public NamespaceShellcodeHandler 
    4138        { 
    4239        public: 
     
    4441                ~NamespaceBindShell(); 
    4542                sch_result handleShellcode(Message **msg); 
    46                 bool Init(); 
    47                 bool Exit(); 
    48         private: 
    49                 pcre    *m_Pcre; 
    50                 sc_shellcode *m_Shellcode; 
    5143        }; 
    5244} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_connectbackfiletransfer.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include <sys/types.h> 
    3331#include <sys/socket.h> 
     
    5654using namespace nepenthes; 
    5755 
    58 NamespaceConnectbackFiletransfer::NamespaceConnectbackFiletransfer(sc_shellcode *sc) 
     56NamespaceConnectbackFiletransfer::NamespaceConnectbackFiletransfer(sc_shellcode *sc) : NamespaceShellcodeHandler(sc) 
    5957{ 
    60         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    61         m_ShellcodeHandlerName += "::"; 
    62         m_ShellcodeHandlerName += sc->name; 
    63  
    64         m_Shellcode = sc; 
    6558} 
    6659 
     
    6861{ 
    6962 
    70 } 
    71  
    72 bool NamespaceConnectbackFiletransfer::Init() 
    73 { 
    74         const char * pcreEerror; 
    75         int32_t pcreErrorPos; 
    76         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    77         { 
    78                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    79                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    80                 return false; 
    81         } else 
    82         { 
    83                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    84         } 
    85  
    86 //      printf("%s\n",m_Shellcode->pattern); 
    87 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    88         return true; 
    89 } 
    90  
    91 bool NamespaceConnectbackFiletransfer::Exit() 
    92 { 
    93         return true; 
    9463} 
    9564 
     
    12190                if ( (matchCount = pcre_exec(m_Pcre, 0, (char *) shellcode, len, 0, 0, (int *)ovec, sizeof(ovec)/sizeof(int32_t))) > 0 ) 
    12291                { 
    123                         logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_Shellcode->map_items); 
     92                        logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_MapItems); 
    12493                        int32_t i; 
    125                         for ( i=0; i < m_Shellcode->map_items; i++ ) 
     94                        for ( i=0; i < m_MapItems; i++ ) 
    12695                        { 
    127                                 if (m_Shellcode->map[i] == sc_none) 
     96                                if (m_Map[i] == sc_none) 
    12897                                continue; 
    12998                                 
    13099 
    131                                 logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     100                                logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    132101                                const char *match = NULL; 
    133102                                pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    134103 
    135                                 switch ( m_Shellcode->map[i] ) 
     104                                switch ( m_Map[i] ) 
    136105                                { 
    137106 
     
    152121 
    153122                                default: 
    154                                         logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     123                                        logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Map[i])); 
    155124                                } 
    156125 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_connectbackfiletransfer.hpp

    r432 r445  
    3232#define HAVE_NAMESPACE_CONNECTBACKFILETRANSFER_HPP 
    3333 
    34 #include <stdint.h> 
    35 #include <pcre.h> 
    36 #include "ShellcodeHandler.hpp" 
    37 #include "parser.hpp" 
     34#include "sch_namespace.hpp" 
    3835 
    3936namespace nepenthes 
    4037{ 
    41         class NamespaceConnectbackFiletransfer : public ShellcodeHandler 
     38        class NamespaceConnectbackFiletransfer : public NamespaceShellcodeHandler 
    4239        { 
    4340        public: 
     
    4542                ~NamespaceConnectbackFiletransfer(); 
    4643                sch_result handleShellcode(Message **msg); 
    47                 bool Init(); 
    48                 bool Exit(); 
    49         private: 
    50                 pcre    *m_Pcre; 
    51                 sc_shellcode *m_Shellcode; 
    5244        }; 
    5345} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_connectbackshell.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include <sys/types.h> 
    3331#include <sys/socket.h> 
     
    5654using namespace nepenthes; 
    5755 
    58 NamespaceConnectbackShell::NamespaceConnectbackShell(sc_shellcode *sc) 
     56NamespaceConnectbackShell::NamespaceConnectbackShell(sc_shellcode *sc) : NamespaceShellcodeHandler(sc) 
    5957{ 
    60         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    61         m_ShellcodeHandlerName += "::"; 
    62         m_ShellcodeHandlerName += sc->name; 
    63  
    64         m_Shellcode = sc; 
    6558} 
    6659 
     
    6861{ 
    6962 
    70 } 
    71  
    72 bool NamespaceConnectbackShell::Init() 
    73 { 
    74         const char * pcreEerror; 
    75         int32_t pcreErrorPos; 
    76         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    77         { 
    78                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    79                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    80                 return false; 
    81         } else 
    82         { 
    83                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    84         } 
    85  
    86 //      printf("%s\n",m_Shellcode->pattern); 
    87 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    88         return true; 
    89 } 
    90  
    91 bool NamespaceConnectbackShell::Exit() 
    92 { 
    93         return true; 
    9463} 
    9564 
     
    12594                if ( (matchCount = pcre_exec(m_Pcre, 0, (char *) shellcode, len, 0, 0, (int *)ovec, sizeof(ovec)/sizeof(int32_t))) > 0 ) 
    12695                { 
    127                         logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_Shellcode->map_items); 
     96                        logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_MapItems); 
    12897                        int32_t i; 
    129                         for ( i=0; i < m_Shellcode->map_items; i++ ) 
     98                        for ( i=0; i < m_MapItems; i++ ) 
    13099                        { 
    131                                 if (m_Shellcode->map[i] == sc_none) 
     100                                if (m_Map[i] == sc_none) 
    132101                                continue; 
    133102                                 
    134103 
    135                                 logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     104                                logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    136105                                const char *match = NULL; 
    137106                                pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    138107 
    139                                 switch ( m_Shellcode->map[i] ) 
     108                                switch ( m_Map[i] ) 
    140109                                { 
    141110 
     
    157126 
    158127                                default: 
    159                                         logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     128                                        logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Map[i])); 
    160129                                } 
    161130 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_connectbackshell.hpp

    r428 r445  
    3131#define HAVE_NAMESPACE_CONNECTBACKSHELL_HPP 
    3232 
    33 #include <stdint.h> 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
     33#include "sch_namespace.hpp" 
    3734 
    3835namespace nepenthes 
    3936{ 
    40         class NamespaceConnectbackShell : public ShellcodeHandler 
     37        class NamespaceConnectbackShell : public NamespaceShellcodeHandler 
    4138        { 
    4239        public: 
     
    4441                ~NamespaceConnectbackShell(); 
    4542                sch_result handleShellcode(Message **msg); 
    46                 bool Init(); 
    47                 bool Exit(); 
    48         private: 
    49                 pcre    *m_Pcre; 
    50                 sc_shellcode *m_Shellcode; 
    5143        }; 
    5244} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_execute.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include "sch_namespace_execute.hpp" 
    3331 
     
    5149using namespace nepenthes; 
    5250 
    53 NamespaceExecute::NamespaceExecute(sc_shellcode *sc) 
     51NamespaceExecute::NamespaceExecute(sc_shellcode *sc): NamespaceShellcodeHandler(sc) 
    5452{ 
    55         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    56         m_ShellcodeHandlerName += "::"; 
    57         m_ShellcodeHandlerName += sc->name; 
    58  
    59         m_Shellcode = sc; 
    6053} 
    6154 
     
    6558} 
    6659 
    67 bool NamespaceExecute::Init() 
    68 { 
    69         const char * pcreEerror; 
    70         int32_t pcreErrorPos; 
    71         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    72         { 
    73                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    74                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    75                 return false; 
    76         } else 
    77         { 
    78                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    79         } 
    80  
    81 //      printf("%s\n",m_Shellcode->pattern); 
    82 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    83         return true; 
    84 } 
    85  
    86 bool NamespaceExecute::Exit() 
    87 { 
    88         return true; 
    89 } 
    9060 
    9161sch_result NamespaceExecute::handleShellcode(Message **msg) 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_execute.hpp

    r429 r445  
    3232#define HAVE_NAMESPACE_EXECUTE_HPP 
    3333 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
     34#include "sch_namespace.hpp" 
    3735 
    3836 
    3937namespace nepenthes 
    4038{ 
    41         class NamespaceExecute : public ShellcodeHandler 
     39        class NamespaceExecute : public NamespaceShellcodeHandler 
    4240        { 
    4341        public: 
     
    4543                ~NamespaceExecute(); 
    4644                sch_result handleShellcode(Message **msg); 
    47                 bool Init(); 
    48                 bool Exit(); 
    49         private: 
    50                 pcre    *m_Pcre; 
    51                 sc_shellcode *m_Shellcode; 
    5245        }; 
    5346} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_konstanzxor.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    31  
    3230#include "sch_namespace_konstanzxor.hpp" 
    3331 
     
    4745using namespace nepenthes; 
    4846 
    49 NamespaceKonstanzXOR::NamespaceKonstanzXOR(sc_shellcode *sc) 
     47NamespaceKonstanzXOR::NamespaceKonstanzXOR(sc_shellcode *sc): NamespaceShellcodeHandler(sc) 
    5048{ 
    51         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    52         m_ShellcodeHandlerName += "::"; 
    53         m_ShellcodeHandlerName += sc->name; 
    54  
    55         m_Shellcode = sc; 
    5649 
    5750} 
     
    6053{ 
    6154 
    62 } 
    63  
    64 bool NamespaceKonstanzXOR::Init() 
    65 { 
    66         const char * pcreEerror; 
    67         int32_t pcreErrorPos; 
    68         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    69         { 
    70                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    71                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    72                 return false; 
    73         } else 
    74         { 
    75                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    76         } 
    77  
    78 //      printf("%s\n",m_Shellcode->pattern); 
    79 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    80         return true; 
    81 } 
    82  
    83 bool NamespaceKonstanzXOR::Exit() 
    84 { 
    85         return true; 
    8655} 
    8756 
     
    10776        if ( (matchCount = pcre_exec(m_Pcre, 0, (char *) shellcode, len, 0, 0, (int *)ovec, sizeof(ovec)/sizeof(int32_t))) > 0 ) 
    10877        { 
    109                 logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_Shellcode->map_items); 
     78                logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_MapItems); 
    11079                int32_t i; 
    111                 for ( i=0; i < m_Shellcode->map_items; i++ ) 
     80                for ( i=0; i < m_MapItems; i++ ) 
    11281                { 
    113                         if (m_Shellcode->map[i] == sc_none) 
     82                        if (m_Map[i] == sc_none) 
    11483                                        continue; 
    11584 
    116                         logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     85                        logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    11786                        const char *match = NULL; 
    11887                        int matchSize = pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    11988 
    120                         switch ( m_Shellcode->map[i] ) 
     89                        switch ( m_Map[i] ) 
    12190                        { 
    12291 
     
    135104 
    136105                        default: 
    137                                 logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     106                                logCrit("%s not used mapping %s\n",m_ShellcodeHandlerName.c_str(), sc_get_mapping_by_numeric(m_Map[i])); 
    138107                        } 
    139108                } 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_konstanzxor.hpp

    r436 r445  
    3131#define HAVE_NAMESPACE_KONSTANZXOR_HPP 
    3232 
    33 #include <stdint.h> 
    34 #include <pcre.h> 
    35 #include "ShellcodeHandler.hpp" 
    36 #include "parser.hpp" 
     33#include "sch_namespace.hpp" 
    3734 
    3835namespace nepenthes 
    3936{ 
    40         class NamespaceKonstanzXOR : public ShellcodeHandler 
     37        class NamespaceKonstanzXOR : public NamespaceShellcodeHandler 
    4138        { 
    4239        public: 
     
    4441                ~NamespaceKonstanzXOR(); 
    4542                sch_result handleShellcode(Message **msg); 
    46                 bool Init(); 
    47                 bool Exit(); 
    48         private: 
    49                 pcre    *m_Pcre; 
    50                 sc_shellcode *m_Shellcode; 
    5143        }; 
    5244} 
  • nepenthes/trunk/modules/shellcode-signatures/sch_namespace_linkxor.cpp

    r443 r445  
    2828/* $Id$ */ 
    2929 
    30 #include <stdint.h> 
    3130 
    3231#include "sch_namespace_linkxor.hpp" 
     
    4746using namespace nepenthes; 
    4847 
    49 NamespaceLinkXOR::NamespaceLinkXOR(sc_shellcode *sc) 
     48NamespaceLinkXOR::NamespaceLinkXOR(sc_shellcode *sc):NamespaceShellcodeHandler(sc) 
    5049{ 
    51         m_ShellcodeHandlerName = sc_get_namespace_by_numeric(sc->nspace); 
    52         m_ShellcodeHandlerName += "::"; 
    53         m_ShellcodeHandlerName += sc->name; 
    54  
    55         m_Shellcode = sc; 
    5650 
    5751} 
     
    6256} 
    6357 
    64 bool NamespaceLinkXOR::Init() 
    65 { 
    66         const char * pcreEerror; 
    67         int32_t pcreErrorPos; 
    68         if ( (m_Pcre = pcre_compile(m_Shellcode->pattern, PCRE_DOTALL, &pcreEerror, (int *)&pcreErrorPos, 0)) == NULL ) 
    69         { 
    70                 logCrit("%s could not compile pattern \n\t\"%s\"\n\t Error:\"%s\" at Position %u",  
    71                                 m_ShellcodeHandlerName.c_str(), pcreEerror, pcreErrorPos); 
    72                 return false; 
    73         } else 
    74         { 
    75                 logInfo("%s loaded ...\n",m_ShellcodeHandlerName.c_str()); 
    76         } 
    77  
    78 //      printf("%s\n",m_Shellcode->pattern); 
    79 //      g_Nepenthes->getUtilities()->hexdump((byte *)m_Shellcode->pattern,m_Shellcode->pattern_size); 
    80         return true; 
    81 } 
    82  
    83 bool NamespaceLinkXOR::Exit() 
    84 { 
    85         return true; 
    86 } 
    8758 
    8859sch_result NamespaceLinkXOR::handleShellcode(Message **msg) 
     
    12394        if ( (matchCount = pcre_exec(m_Pcre, 0, (char *) shellcode, len, 0, 0, (int *)ovec, sizeof(ovec)/sizeof(int32_t))) > 0 ) 
    12495        { 
    125                 logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_Shellcode->map_items); 
     96                logCrit("MATCH %s  matchCount %i map_items %i \n",m_ShellcodeHandlerName.c_str(), matchCount, m_MapItems); 
    12697                int32_t i; 
    127                 for ( i=0; i < m_Shellcode->map_items; i++ ) 
     98                for ( i=0; i < m_MapItems; i++ ) 
    12899                { 
    129                         if (m_Shellcode->map[i] == sc_none) 
     100                        if (m_Map[i] == sc_none) 
    130101                                        continue; 
    131102 
    132                         logInfo(" i = %i map_items %i , map = %s\n",i,m_Shellcode->map_items, sc_get_mapping_by_numeric(m_Shellcode->map[i])); 
     103                        logInfo(" i = %i map_items %i , map = %s\n",i,m_MapItems, sc_get_mapping_by_numeric(m_Map[i])); 
    133104                        const char *match = NULL; 
    134105                        int matchSize = pcre_get_substring((char *) shellcode, (int *)ovec, (int)matchCount, i, &match); 
    135106 
    136                         switch ( m_Shellcode->map[i] ) 
     107                        switch ( m_Map[i] ) 
    137108                        { 
    138109 
     
    164135 
    165136                        default: 
    166                                 logCrit("%s not used mapping %s\n",m