|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |