Function Code for detecting image Trojans in ASP

Source: Internet
Author: User

Trojan principle: Intruders use tools such as ASP image Trojan generator to combine a normal image with an ASP Trojan file into an image file (which will soon be harmful to the website)
After the ASP code is inserted into the image encoding, although the image can still be normally displayed, but the file content and size have been changed), and then upload this image using the file upload function provided by the website.
And then the ASP Trojan is uploaded.
'Defense method: Because this Trojan is a combination of pictures and Trojans, you need to check the file content before uploading the image. If the file content is illegal (that is, it contains malicious code ),
'Then the upload is prohibited, blocking the source of the Trojan attack. This is the first level of the Trojan attack and is crucial and must be blocked.
'*************************************** ************************************ Copy codeThe Code is as follows: 'beginners --------------------------------------------------------------------------------------------------------------------------
Function CheckFileContent (FileName)
Dim ClientFile, ClientText, ClientContent, DangerString, DSArray, AttackFlag, k
Set ClientFile = Server. CreateObject ("Scripting. FileSystemObject ")
Set ClientText = ClientFile. OpenTextFile (Server. MapPath (FileName), 1)
ClientContent = LCase (ClientText. ReadAll)
Set ClientText = nothing
Set ClientFile = nothing
AttackFlag = false
DangerString = ". getfolder |. createfolder |. deletefolder |. createdirectory |. deletedirectory |. saveas | wscript. shell | script. encode | server. |. createobject | execute | activexobject | language = | include | filesystemobject | shell. application"
DSArray = split (DangerString, "| ")

For k = 0 to UBound (DSArray)

If InStr (ClientContent, DSArray (k)> 0 then' determines whether the file contains dangerous operation characters. if yes, you must delete the file.
AttackFlag = true
Exit
End if

Next

CheckFileContent = AttackFlag
End function
'End Vertex ----------------------------------------------------------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.