通过xp_cmdshell获取文件内容 [英] Get file contents via xp_cmdshell

查看:715
本文介绍了通过xp_cmdshell获取文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有从Windows xp命令提示符获取文件的方法吗?我试图运行 xp_cmdshell'类型[文件路径]'但然后当我将其他文件,并将其重命名为file.exe(即可执行)不行。

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?

推荐答案

您可以对文件使用BULK INSERT,将该文件视为具有一行和一列的表。这应该允许你直接读取文件到一个VARBINARY字段

像这样:

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]

这需要SQL Server访问您尝试读取的文件。听起来你正在试图从你无法访问的服务器获取可执行文件? : - )

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? :-)

这篇关于通过xp_cmdshell获取文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆