|
|
|
|
|
|
|
|
FilterChain(FilterChain* S) { |
|
|
FilterChain(FilterChain* S) { |
|
|
if(NULL==S) throw BadSource("FilterChain: NULL source not valid"); |
|
|
if(NULL==S) throw BadSource("FilterChain: NULL source not valid"); |
|
|
else Source = S; |
|
|
else Source = S; |
|
|
} |
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~FilterChain() {} // Stop Warns about no virt dtor |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// FilterChainInput |
|
|
// FilterChainInput |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
|
|
|
|
|
|
unsigned char* InputBuffer; |
|
|
unsigned char* InputBuffer; |
|
|
int BufferIndex; |
|
|
|
|
|
int BufferLength; |
|
|
|
|
|
|
|
|
unsigned int BufferLength; |
|
|
|
|
|
unsigned int BufferIndex;
|
|
|
|
|
|
|
|
|
stringstream& PrependedHeaders; |
|
|
stringstream& PrependedHeaders; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECODING // Delivering filtered data. |
|
|
DECODING // Delivering filtered data. |
|
|
} State; |
|
|
} State; |
|
|
|
|
|
|
|
|
int ScanIx; // Scanning Index. |
|
|
|
|
|
int DequeIx; // Dequeing Index. |
|
|
|
|
|
|
|
|
unsigned int ScanIx; // Scanning Index. |
|
|
|
|
|
unsigned int DequeIx; // Dequeing Index. |
|
|
unsigned char Buffer; // Define a buffer. |
|
|
unsigned char Buffer; // Define a buffer. |
|
|
|
|
|
|
|
|
bool ValidByte(unsigned char y); // True if y can be decoded. |
|
|
bool ValidByte(unsigned char y); // True if y can be decoded. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FilterChainDefunker(FilterChain* S) // Sourced constructor... |
|
|
FilterChainDefunker(FilterChain* S) // Sourced constructor... |
|
|
:FilterChain(S), // Call the base constructor. |
|
|
:FilterChain(S), // Call the base constructor. |
|
|
|
|
|
InputPosition(0), // Reset both position pointers.
|
|
|
|
|
|
OutputPosition(0),
|
|
|
|
|
|
LastRawByte(0),
|
|
|
|
|
|
LastReadOut(0),
|
|
|
|
|
|
LastGetStore(0),
|
|
|
Master(&FilterChainDefunker::SkipHeaders), // Set the initial external and |
|
|
Master(&FilterChainDefunker::SkipHeaders), // Set the initial external and |
|
|
Internal(&FilterChainDefunker::Preamble), // internal states. |
|
|
|
|
|
InputPosition(0), // Reset both position pointers. |
|
|
|
|
|
OutputPosition(0), |
|
|
|
|
|
LastReadOut(0), |
|
|
|
|
|
LastGetStore(0), |
|
|
|
|
|
LastRawByte(0) { |
|
|
|
|
|
|
|
|
Internal(&FilterChainDefunker::Preamble) { // internal states. |
|
|
|
|
|
|
|
|
ClearQueue(); // Clear the queue; |
|
|
ClearQueue(); // Clear the queue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
|
|
|
|
|
|
unsigned char DecodeBfr[UrlDecodeBfrSize]; // Decoded anchor buffer. |
|
|
unsigned char DecodeBfr[UrlDecodeBfrSize]; // Decoded anchor buffer. |
|
|
int DecodeLength; // Decoded anchor length. |
|
|
|
|
|
int DecodePosition; // Read (Inject) Position. |
|
|
|
|
|
|
|
|
unsigned int DecodeLength; // Decoded anchor length. |
|
|
|
|
|
unsigned int DecodePosition; // Read (Inject) Position. |
|
|
bool DecodeFlag; // True if the URL was decoded. |
|
|
bool DecodeFlag; // True if the URL was decoded. |
|
|
|
|
|
|
|
|
void Clear() { // Function to clear the bfr. |
|
|
void Clear() { // Function to clear the bfr. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FilterChainHeaderAnalysis(FilterChain* S, FilterChainIPTester& T) : // Construct with the chain and a tester. |
|
|
FilterChainHeaderAnalysis(FilterChain* S, FilterChainIPTester& T) : // Construct with the chain and a tester. |
|
|
FilterChain(S), // Capture the chain. |
|
|
FilterChain(S), // Capture the chain. |
|
|
|
|
|
Mode(&FilterChainHeaderAnalysis::doSeekDispatch), // Start in SeekDispatch() mode
|
|
|
IPTester(T), // Capture the tester. |
|
|
IPTester(T), // Capture the tester. |
|
|
IPToTest(""), // IPToTest and |
|
|
IPToTest(""), // IPToTest and |
|
|
IPTestResult(""), // IPTestResult are both empty to start. |
|
|
IPTestResult(""), // IPTestResult are both empty to start. |
|
|
|
|
|
|
|
|
FoundMessageID(false), |
|
|
FoundMessageID(false), |
|
|
FoundDate(false), |
|
|
FoundDate(false), |
|
|
FoundSubject(false), |
|
|
FoundSubject(false), |
|
|
FoundHighBitCharacters(false), |
|
|
|
|
|
Mode(&FilterChainHeaderAnalysis::doSeekDispatch) { // Start in SeekDispatch() mode |
|
|
|
|
|
|
|
|
FoundHighBitCharacters(false) { |
|
|
} // -- first byte of a new line ;-) |
|
|
} // -- first byte of a new line ;-) |
|
|
|
|
|
|
|
|
bool MissingFrom() { return (!FoundFrom); } // True if missing From header. |
|
|
bool MissingFrom() { return (!FoundFrom); } // True if missing From header. |