diff --git a/Resource.h b/Resource.h new file mode 100644 index 0000000..ed3ba1e --- /dev/null +++ b/Resource.h @@ -0,0 +1,11 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by fcltisapi.rc +// + +#define IDS_FILTER 101 + +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_CONTROL_VALUE 103 +#define _APS_NEXT_SYMED_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 32768 diff --git a/StdAfx.cpp b/StdAfx.cpp new file mode 100644 index 0000000..c2a780f --- /dev/null +++ b/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// fcltisapi.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/StdAfx.h b/StdAfx.h new file mode 100644 index 0000000..0786b23 --- /dev/null +++ b/StdAfx.h @@ -0,0 +1,20 @@ +#if !defined(AFX_STDAFX_H__EA40DC04_0ADB_426A_825F_A47390C63E5C__INCLUDED_) +#define AFX_STDAFX_H__EA40DC04_0ADB_426A_825F_A47390C63E5C__INCLUDED_ + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +//#include +//#include +//#include // for synchronization objects +//#include +//#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#include + +#endif // !defined(AFX_STDAFX_H__EA40DC04_0ADB_426A_825F_A47390C63E5C__INCLUDED) diff --git a/fcltisapi.cpp b/fcltisapi.cpp new file mode 100644 index 0000000..767ae86 --- /dev/null +++ b/fcltisapi.cpp @@ -0,0 +1,67 @@ +#include "stdafx.h" + +#include +#include "tchar.h" +#include "strsafe.h" + +BOOL WINAPI GetFilterVersion( + PHTTP_FILTER_VERSION pVer +) +{ + pVer->dwFilterVersion = HTTP_FILTER_REVISION; + strncpy_s( pVer->lpszFilterDesc, "HTTPOnlyFilter", SF_MAX_FILTER_DESC_LEN ); + + /* Notify me when headers have been processed */ + pVer->dwFlags = SF_NOTIFY_ORDER_DEFAULT | + SF_NOTIFY_PREPROC_HEADERS | + SF_NOTIFY_SEND_RESPONSE ; + + return TRUE; +}; +// Portion of HttpOnly +DWORD WINAPI HttpFilterProc( + PHTTP_FILTER_CONTEXT pfc, + DWORD dwNotificationType, + LPVOID pvNotification) { + + if (dwNotificationType == SF_NOTIFY_SEND_RESPONSE) + { + // Hard coded cookie length (2k bytes) + CHAR szCookie[2048]; + DWORD cbCookieOriginal = sizeof(szCookie) / sizeof(szCookie[0]); + DWORD cbCookie = cbCookieOriginal; + + HTTP_FILTER_SEND_RESPONSE *pResponse = + (HTTP_FILTER_SEND_RESPONSE*)pvNotification; + + CHAR *szHeader = "Set-Cookie:"; + CHAR *szHttpOnly = "; HttpOnly"; + if (pResponse->GetHeader(pfc,szHeader,szCookie,&cbCookie)) + { + if (SUCCEEDED(StringCchCat(szCookie, + cbCookieOriginal, + szHttpOnly))) + { + if (!pResponse->SetHeader(pfc, + szHeader, + szCookie)) + { // Fail securely - send no cookie! + pResponse->SetHeader(pfc,szHeader,""); + } + } + else + { + pResponse->SetHeader(pfc,szHeader,""); + } + } + // Altijd Server: Microsoft-IIS/6.0 verwijderen + pResponse->SetHeader(pfc, "Server:", "FACILITOR"); + + // Altijd X-Powered-By: ASP.NET verwijderen + // Kan ook gewoon in de interface van IIS Admin maar we hebben + // deze DLL nu toch + pResponse->SetHeader(pfc, "X-Powered-By:", '\0'); + } + + return SF_STATUS_REQ_NEXT_NOTIFICATION; +} \ No newline at end of file diff --git a/fcltisapi.def b/fcltisapi.def new file mode 100644 index 0000000..494119e --- /dev/null +++ b/fcltisapi.def @@ -0,0 +1,7 @@ +; REDIRECTOR.def : declares the module parameters for the DLL. + +LIBRARY "FCLTISAPI" + +EXPORTS + HttpFilterProc + GetFilterVersion diff --git a/fcltisapi.h b/fcltisapi.h new file mode 100644 index 0000000..25aeddc --- /dev/null +++ b/fcltisapi.h @@ -0,0 +1,13 @@ +#if !defined(AFX_FCLTISAPI_H__02C344E8_9F41_46A5_987A_8DA9C14FFDA6__INCLUDED_) +#define AFX_FCLTISAPI_H__02C344E8_9F41_46A5_987A_8DA9C14FFDA6__INCLUDED_ + +// FCLTISAPI.H - Header file for your Internet Server +// fcltisapi Filter + +#include "resource.h" + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_FCLTISAPI_H__02C344E8_9F41_46A5_987A_8DA9C14FFDA6__INCLUDED) diff --git a/fcltisapi.rc b/fcltisapi.rc new file mode 100644 index 0000000..7d3d11f --- /dev/null +++ b/fcltisapi.rc @@ -0,0 +1,126 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// + +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#include ""afxisapi.rc"" // Internet Support resources\r\n" + "#endif\r\n" + "\0" +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "SG|facilitor\0" + VALUE "FileDescription", "fcltisapi Internet Server Extension Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "FCLTISAPI\0" + VALUE "LegalCopyright", "Copyright (C) 2013 FACILITOR\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "FCLTISAPI.DLL\0" + VALUE "ProductName", "fcltisapi Internet Server Extension\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_FILTER "fcltisapi Filter" +END + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "afxres.rc" // Standard components +#include "afxisapi.rc" // Internet Support resources +#endif + +#endif // not APSTUDIO_INVOKED + + diff --git a/fcltisapi.sln b/fcltisapi.sln new file mode 100644 index 0000000..e51df1e --- /dev/null +++ b/fcltisapi.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPonly", "fcltisapi.vcproj", "{E01673B8-BD25-48E4-993A-EF3C7F7BA4B8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E01673B8-BD25-48E4-993A-EF3C7F7BA4B8}.Debug|Win32.ActiveCfg = Debug|Win32 + {E01673B8-BD25-48E4-993A-EF3C7F7BA4B8}.Debug|Win32.Build.0 = Debug|Win32 + {E01673B8-BD25-48E4-993A-EF3C7F7BA4B8}.Release|Win32.ActiveCfg = Release|Win32 + {E01673B8-BD25-48E4-993A-EF3C7F7BA4B8}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/fcltisapi.vcproj b/fcltisapi.vcproj new file mode 100644 index 0000000..c2dae4d --- /dev/null +++ b/fcltisapi.vcproj @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +