While this file may seem simple, there is actually a lot of going on behind the scenes. Lets break down this file and
look at the different sections. Specifically we are calling from the mssql.rb in the lib/msf/core/exploits area.
One of the first things that is done in this file is the importation of the Remote class, and inclusion
of the MSSQL module.

The platform section indicates the target's platform and version. The following part is the 'Targets' object,
which is where different versions would be enumerated. These lines give the user the ability to select
a target prior to an attack. The 'DefaultTarget' value is used when no target is specified when setting up the attack.

The 'def exploit' line indicates the beginning of our exploit code. The next declaration is for debugging purposes. Considering there is a lot of information going back and forth, it's a good idea having this set to 'false' until it's needed.

debug = false # enable to see the output

Moving on to the next line, this is the most complex portion of the entire attack. This one liner here is really multiple lines of code being pulled from mssql.rb.

mssql_upload_exec (function defined in mssql.rb for uploading an executable through SQL to the underlying operating system)

Msf::Util::EXE.to_win32pe(framework,payload.encoded) = create a metasploit payload based off of what you specified, make it an executable and encode it with default encoding

debug = call the debug function is it on or off?

Lastly the handler will handle the connections from the payload in the background so we can accept a metasploit payload. The disconnect portion of the code ceases the connection from the MSSQL server.
Now that we have walked through this portion, we will break down the next section in the mssql.rb to find out exactly what this attack was doing.