Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SRCBLOCK.CPP - Implementation file for your Internet Server
- // srcblock Filter
- /* Possible Enhancements:
- look for other strings (i.e., c:\inetpub\, _ids34234, etc.)
- */
- #include "stdafx.h"
- #include "srcblock.h"
- ///////////////////////////////////////////////////////////////////////
- // The one and only CSrcblockFilter object
- CSrcblockFilter theFilter;
- ///////////////////////////////////////////////////////////////////////
- // CSrcblockFilter implementation
- CSrcblockFilter::CSrcblockFilter()
- {
- }
- CSrcblockFilter::~CSrcblockFilter()
- {
- }
- BOOL CSrcblockFilter::GetFilterVersion(PHTTP_FILTER_VERSION pVer)
- {
- // Call default implementation for initialization
- CHttpFilter::GetFilterVersion(pVer);
- // Clear the flags set by base class
- pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK;
- // Set the flags we are interested in
- pVer->dwFlags |= SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT
- | SF_NOTIFY_SEND_RAW_DATA;
- // Load description string
- strcpy( pVer->lpszFilterDesc, "Source Code Blocking Filter, v1.0" );
- return TRUE;
- }
- DWORD CSrcblockFilter::OnSendRawData(CHttpFilterContext* pCtxt,
- PHTTP_FILTER_RAW_DATA pRawData)
- {
- CHAR* pszBuffer;
- pszBuffer=(char *)pRawData->pvInData;
- if (strstr(pszBuffer, "< your private string here>"))
- {
- static char szMessage[] =
- "<HTML>"
- "<HEAD><TITLE>Access Denied</TITLE>"
- "</HEAD>\r\n"
- "<BODY>"
- "<P><p><b><font face=Arial size=2>Access Denied: You are not authorized to "
- "view the requested page.</font></b></p>"
- "<p><font face=Arial size=2>Please note that use of this system is monitored "
- "and all access is logged. Any attempt to circumvent the security of this "
- "server may result in prosecution under state, federal or other applicable laws. If you feel "
- "you received this message in error, please contact the system administrator.</font></p>"
- "</BODY></HTML>\r\n\r\n";
- HSE_SEND_HEADER_EX_INFO HeaderExInfo;
- HeaderExInfo.pszStatus = "200 OK";
- HeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
- HeaderExInfo.cchStatus = strlen( HeaderExInfo.pszStatus );
- HeaderExInfo.cchHeader = strlen( HeaderExInfo.pszHeader );
- HeaderExInfo.fKeepConn = FALSE;
- DWORD dwBytesToWrite = strlen( szMessage );
- pCtxt->WriteClient( szMessage, &dwBytesToWrite, 0 );
- return SF_STATUS_REQ_FINISHED;
- }
- else
- {
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
- }
- }
- // Do not edit the following lines, which are needed by ClassWizard.
- #if 0
- BEGIN_MESSAGE_MAP(CSrcblockFilter, CHttpFilter)
- //{{AFX_MSG_MAP(CSrcblockFilter)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- #endif // 0
Advertisement