Browse Source

Fixed bug in FilterChainBase64 where an extra character would be returned if the module ran out of data in SCANNING mode. Now if this occurs a flag is set and "No More Data" is thrown instead of returning the extra byte.

Adjusted DEFUNKER preamble in code to indicate spaces in front and back since newlines would be converted to spaces by the outer shell of FilterChainDefunker.

Adjusted engine update number to .15 - now at Version 3.0.15


git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@33 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 14 years ago
parent
commit
49cdc8380a
3 changed files with 24 additions and 18 deletions
  1. 17
    12
      FilterChain.cpp
  2. 2
    1
      FilterChain.hpp
  3. 5
    5
      SNFMulti.cpp

+ 17
- 12
FilterChain.cpp View File



while(true) { // Search for our startup string or get out. while(true) { // Search for our startup string or get out.


try { // Try this...
try { // Try this...
ValidBuffer = false; // No valid buffer yet.
x=FilterChain::GetByte(); // Get the next byte from source. x=FilterChain::GetByte(); // Get the next byte from source.
} // If we get the empty signal } // If we get the empty signal
// here, we've failed to match. // here, we've failed to match.
catch(Empty) { // If so - and we haven't catch(Empty) { // If so - and we haven't
if(0==ScanIx) throw Empty("FilterChainBase64: No more data"); // started then just throw Empty.
x=Base64Start[ScanIx]-1; // If we did start then make
} // sure we won't match below.
if(0==ScanIx) throw Empty("FilterChainBase64: No more data"); // started then just throw Empty.
State=DEQUEING;DequeIx=0; // If we have then we'll dequeue
return GetByte(); // it and throw when that's done
} // because Buffer is not valid.


// It's important that no empty's get beyond this point unless // It's important that no empty's get beyond this point unless
// we've got a match started. Otherwise we'll return corruption. // we've got a match started. Otherwise we'll return corruption.
if(x!=Base64Start[ScanIx]){ // If the byte doesnt match, if(x!=Base64Start[ScanIx]){ // If the byte doesnt match,
// and we've started matching // and we've started matching
if(0!=ScanIx) { // the sequence then save the if(0!=ScanIx) { // the sequence then save the
Buffer=x; // byte for later, change to
Buffer=x; ValidBuffer=true; // byte for later, change to
State=DEQUEING;DequeIx=0; // DEQUING mode, and return State=DEQUEING;DequeIx=0; // DEQUING mode, and return
return GetByte(); // the first Dequeued byte. return GetByte(); // the first Dequeued byte.
} }


} else { // When we're done with that part, } else { // When we're done with that part,
State=SCANNING; // we set our mode back to scanning, State=SCANNING; // we set our mode back to scanning,
ScanIx=DequeIx=0; // reset our indexes to start again,
return Buffer; // and return the unmatching byte that
} // got us to DEQUEING mode.
ScanIx=DequeIx=0; // reset our indexes to start again,
// Here we either have a buffered byte to dequeue, or we ran out
// of data while attempting to match our startup sequence. If we
// have a vaild byte we return it. If not, we throw No More Data!
if(ValidBuffer) return Buffer;
else throw Empty("FilterChainBase64: No more data");
}


break; break;
} }
// FilterChainDefunker // FilterChainDefunker
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
const char* DefunkerPreamble = "\n----[DEFUNKER]----\n";
const char* DefunkerPreamble = " ----[DEFUNKER]---- ";
// Patterns to match // Patterns to match
unsigned char x; // we need a byte. unsigned char x; // we need a byte.


try { try {
if(DefunkerSize-10 < InputPosition) {
cout << "watch this" << endl;
}
if(DefunkerSize <= InputPosition) if(DefunkerSize <= InputPosition)
throw Empty("FilterChainDefunker: No more data"); // Careful about the buffer. throw Empty("FilterChainDefunker: No more data"); // Careful about the buffer.
x = FilterChain::GetByte(); // Try getting the next byte x = FilterChain::GetByte(); // Try getting the next byte

+ 2
- 1
FilterChain.hpp View File



unsigned int ScanIx; // Scanning Index. unsigned int ScanIx; // Scanning Index.
unsigned int DequeIx; // Dequeing Index. unsigned int DequeIx; // Dequeing Index.
unsigned char Buffer; // Define a buffer.
unsigned char Buffer; // Define a buffer.
bool ValidBuffer; // Set if Buffer has data.


bool ValidByte(unsigned char y); // True if y can be decoded. bool ValidByte(unsigned char y); // True if y can be decoded.



+ 5
- 5
SNFMulti.cpp View File



//// Version Info //// Version Info


const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.14 Build: " __DATE__ " " __TIME__;
const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.15 Build: " __DATE__ " " __TIME__;


//// Script Caller Methods //// Script Caller Methods


// data, as well as the ability to output the pre-filtered data for use in // data, as well as the ability to output the pre-filtered data for use in
// rule development and debugging. // rule development and debugging.


DebugInfo = "scanMessage() IZ.GetByte() ==> FilteredData"; // If we panic we are here.
DebugInfo = "scanMessage() IZ.GetByte() ==> FilteredData"; // If we panic we are here.
unsigned char xb=0;
MyScanData.FilteredData.clear(); // Clear the FilteredData buffer. MyScanData.FilteredData.clear(); // Clear the FilteredData buffer.
try { // Watch for exceptions and scan try { // Watch for exceptions and scan
for(int a = 0; a < snf_ScanHorizon; a++) // the message through the filter for(int a = 0; a < snf_ScanHorizon; a++) // the message through the filter
MyScanData.FilteredData.push_back(IZ.GetByte()); // chain into the FilteredData buffer.
MyScanData.FilteredData.push_back(xb=IZ.GetByte()); // chain into the FilteredData buffer.
} // When we run out of data we will } // When we run out of data we will
catch(FilterChain::Empty) {} // get the Empty exception and stop. catch(FilterChain::Empty) {} // get the Empty exception and stop.


// If something goes wrong, an exception will be thrown. // If something goes wrong, an exception will be thrown.


DebugInfo = "scanMessage() EvaluateThis(FilteredData)"; // If we panic, here we are. DebugInfo = "scanMessage() EvaluateThis(FilteredData)"; // If we panic, here we are.
if(false == MyScanData.GBUdbTruncateExecuted) { // If we haven't already truncated: if(false == MyScanData.GBUdbTruncateExecuted) { // If we haven't already truncated:
for(int a = 0, b = MyScanData.FilteredData.size(); a < b; a++) // Scan through the filtered data one for(int a = 0, b = MyScanData.FilteredData.size(); a < b; a++) // Scan through the filtered data one
CurrentMatrix->EvaluateThis(MyScanData.FilteredData[a]); // byte at a time. CurrentMatrix->EvaluateThis(MyScanData.FilteredData[a]); // byte at a time.

Loading…
Cancel
Save