Changeset 631

Show
Ignore:
Timestamp:
08/30/06 18:22:07 (2 years ago)
Author:
oxff
Message:

nepenthes-experimental.submit-file: added options to run custom handler programs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nepenthes/branches/nepenthes-experimental/modules/submit-file/submit-file.conf.dist

    r321 r631  
    22{ 
    33    path "var/binaries/"; 
     4     
     5    # uncomment this to run the given program on every new sample, the sensor 
     6    # gets. the path to the sample is provided as argv[1] 
     7    #sample-handler = "/usr/bin/true"; 
     8     
     9    # uncomment this to run the given program on every hit of a new or known 
     10    # sample against the sensor. path again is provided as argv[1] 
     11    #hit-handler = "/usr/bin/true"; 
    412}; 
    513     
  • nepenthes/branches/nepenthes-experimental/modules/submit-file/submit-file.cpp

    r543 r631  
    8686                return false; 
    8787        } 
     88         
     89        try 
     90        { 
     91                m_sampleHandlerPath = m_Config->getValString("submit-file.sample-handler"); 
     92        } catch ( ... ) { } 
     93         
     94        try 
     95        { 
     96                m_hitHandlerPath = m_Config->getValString("submit-file.hit-handler"); 
     97        } catch ( ... ) { } 
    8898 
    8999        m_ModuleManager = m_Nepenthes->getModuleMgr(); 
     
    127137                        logDebug("wrote file %s %i to disk \n",path.c_str(),down->getDownloadBuffer()->getSize()); 
    128138                        fclose(f); 
     139                         
     140                        if(!m_sampleHandlerPath.empty() && !fork()) 
     141                        { 
     142                                execl(m_sampleHandlerPath.c_str(), m_sampleHandlerPath.c_str(), path.c_str(), (char *) 0); 
     143                        } 
     144                         
    129145                        break; 
    130146                } 
     
    132148                logDebug("stat error on file %s (%s) \n",path.c_str(),strerror(errno)); 
    133149        } 
     150         
    134151//      m_Nepenthes->getUtilities()->hexdump((byte *)down->getDownloadBuffer()->getData(),down->getDownloadBuffer()->getSize()); 
    135152} 
     
    138155void FileSubmitHandler::Hit(Download *down) 
    139156{ 
     157        string path = m_FilePath +  down->getMD5Sum(); 
     158         
     159        if(!m_hitHandlerPath.empty() && !fork()) 
     160        { 
     161                execl(m_hitHandlerPath.c_str(), m_hitHandlerPath.c_str(), path.c_str(), (char *) 0); 
     162        } 
     163         
    140164        return; 
    141165} 
  • nepenthes/branches/nepenthes-experimental/modules/submit-file/submit-file.hpp

    r318 r631  
    5252        protected: 
    5353                string m_FilePath; 
     54                string m_sampleHandlerPath, m_hitHandlerPath; 
    5455        }; 
    5556