简体   繁体   English

SQL EXEC xp_cmdshell

[英]SQL EXEC xp_cmdshell

I am venturing into SQL injection over the past few days. 在过去的几天里,我正在尝试SQL注入。 I am able to leverage a SQL injection vulnerability to bypass login and ping back to my attacking machine from the same injection point using exec xp_cmdshell 我能够利用exec xp_cmdshell利用SQL注入漏洞绕过登录并从同一注入点ping回攻击机器

My question is how can I get some remote reverse shell kind of connection back to my host machine. 我的问题是如何使远程反向外壳类型的连接返回到主机。 What all can I achieve using the xp_cmdshell with whatever default tools installed on the vulnerable server? 使用xp_cmdshell和易受攻击的服务器上安装的任何默认工具,我可以实现什么?

Any help regarding xp_cmdshell perhaps any links to the resources would be really helpful. 关于xp_cmdshell的任何帮助,也许到资源的任何链接都将非常有帮助。

Thanks 谢谢

Here's a couple of things that might help; 这可能会有所帮助。

Its probably worth pointing out that whatever you are using to connect to SQL Server will need to be given the sysadmin server role to use the xp_cmdshell procedure. 可能值得指出的是,无论使用什么方法连接到SQL Server,都必须被赋予sysadmin服务器角色才能使用xp_cmdshell过程。 Also the functionality is not enabled by default. 此外,默认情况下未启用该功能。 An existing sysadmin would have to change the advanced configuration options first to allow xp_cmdshell use. 现有的系统管理员必须首先更改高级配置选项,才能使用xp_cmdshell。

Here's how to do that: https://msdn.microsoft.com/en-us/library/ms190693.aspx 这样做的方法如下: https : //msdn.microsoft.com/en-us/library/ms190693.aspx

Next any commands you pass to the OS will execute as the SQL Server database engine service account, not the SQL user, which may have restricted access. 接下来,您传递给操作系统的所有命令都将作为SQL Server数据库引擎服务帐户(而不是SQL用户)执行,该帐户可能具有受限的访问权限。 Plus even if the service account is a local admin in Windows you won't be able to force cmd style permissions elevation from SQL Server alone. 另外,即使服务帐户是Windows中的本地管理员,您也无法单独从SQL Server强制执行cmd样式权限提升。 You'll need the service account password too, assuming this is a domain service account. 假设这是一个域服务帐户,您也将需要服务帐户密码。

Here's the MSDN article about the procedure: 这是有关该过程的MSDN文章:

https://msdn.microsoft.com/en-us/library/ms175046.aspx https://msdn.microsoft.com/zh-CN/library/ms175046.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM