Code
Httpmodule automatically converts aspx to simplified and traditional Chinese characters
Asp is implemented using httpmodule.. Net ( * . aspx) automatic conversion of Simplified Chinese and Traditional Chinese !
simple thinking !
global. the event processing function of the codebehind application_beginrequest of asax should also be implemented !
httphandler cannot be implemented because it is " interception " !
Good results!Attackers can process arbitrary ASP. NET sites and virtual directories.!You do not need to modify any of the originalCode!
The Code is as follows:
Strconvhttpmodule. CS
/**//*
Csc.exe/T: Library strconvhttpmodule. CS/R: C: \ WINDOWS \ Microsoft. NET \ framework \ v1.1.4322 \ Microsoft. VisualBasic. dll
*/
Code
[Copy to clipboard]
Code:
NamespaceMicroshaoft. httpmodules
{
UsingSystem;
UsingSystem. Web;
UsingSystem. collections;
UsingMicroshaoft. IO;
Public Class Strconvhttpmodule: ihttpmodule
{
Public String Modulename
{
Get
{
Return " Strconvhttpmodule " ;
}
}
Public Void Init (httpapplication Application)
{
Application. beginrequest + = ( New Eventhandler ( This . Application_beginrequest ));
}
Private Void Application_beginrequest ( Object Sender, eventargs E)
{
Httpapplication = (Httpapplication) sender;
Httpcontext Context = Application. context;
Context. response. Filter = New Strconvfilterstream (context. response. Filter );
}
Public void dispose ()
{< BR >}
NamespaceMicroshaoft. Io
{
UsingSystem;
UsingSystem. IO;
UsingSystem. Web;
UsingSystem. text;
UsingSystem. Globalization;
UsingMicrosoft. VisualBasic;
Public class strconvfilterstream: stream
{< br> private stream _ sink;
private long _ position;
Public strconvfilterstream (Stream sink)
{< br> This . _ sink = sink;
}
Public override bool Canread
{< br> Get
{< br> return true ;
}< BR >}
Public override bool canseek
{< br> Get
{< br> return true ;
}< BR >}
Public override bool canwrite
{< br> Get
{< br> return true ;
}< BR >}
Public override long length
{< br> Get
{< br> return 0 ;
}< BR >}
Public Override Long Position
{
Get
{
Return This . _ Position;
}
Set
{
This . _ Position = Value;
}
}
Public override long seek ( long offset, seekorigin direction)
{< br> return This . _ sink. seek (offset, direction);
}
Public override void setlength ( long length)
{< br> This . _ sink. setlength (length);
}
Public override void close ()
{< br> This . _ sink. close ();
}
Public override void flush ()
{< br> This . _ sink. flush ();
}
Public override int Read ( byte [] buffer, int offset, int count)
{< br> return This . _ sink. read (buffer, offset, count);
}
Public Override Void Write ( Byte [] Buffer, Int Offset, Int Count)
{
If (Httpcontext. Current. response. contenttype = " Text/html " )
{
Encoding E = Encoding. getencoding (httpcontext. Current. response. charset );
String S = E. getstring (buffer, offset, count );
S = Strings. strconv (S, vbstrconv. traditionalchinese, cultureinfo. currentculture. lcid );
This . _ Sink. Write (E. getbytes (s ), 0 , E. getbytecount (s ));
}
Else
{
This . _ Sink. Write (buffer, offset, count );
}
}
}
}
set strconvhttpmodule. CS is compiled into strconvhttpmodule. DLL:
csc.exe / T: Library strconvhttpmodule. CS / r: C: \ windows \ Microsoft. net \ framework \ V1. 1.4322 \ Microsoft. visualBasic. DLL
Take the Quickstart tutorial site that comes with the Microsoft. NET Framework SDK as an example.
HTTP://Localhost/Quickstart/
Modify web. config In the Quickstart virtual directory<System. Web></System. Web>Add the following configuration section to the region:
Code
[Copy to clipboard]
Code:
< Httpmodules >
< Add name = " Strconvhttpmodule " Type = " Microshaoft. httpmodules. strconvhttpmodule, strconvhttpmodule " />
</ Httpmodules >
Copy strconvhttpmodule. DLL to the bin \ directory of the virtual directory.
And sub-virtual directories under the virtual directory at all levels under the bin \ directory
Merit acquisition!