Get file contents via xp_cmdshell

倾然丶 夕夏残阳落幕 提交于 2019-12-21 22:09:50

问题


Is there way to get file from windows xp command prompt? I tried to run xp_cmdshell 'type [path to file]' but then when i insert theese data into other file and renaming it to file.exe (that is executable) it does not work. Any suggestions how to get file contents in such way that i can use it?


回答1:


You could use BULK INSERT on the file and treat the file as a table with one row and one column. This should allow you to read the file directly into a VARBINARY field

Like this:

CREATE TABLE FileRead
(
  content VARBINARY(MAX)
)

BULK INSERT FileRead FROM [FilePath]

This requires SQL Server to have access to the file you are trying to read. It sounds like you are trying to "acquire" executables from a server you do not have access to? :-)



来源:https://stackoverflow.com/questions/10674987/get-file-contents-via-xp-cmdshell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!