SQLTeam.com | Weblogs | Forums

Reverse engineer a closed source application that connects to sql server

#1

Hi,
One of my friends have a closed source exe program written using .Net framework, this program connects to an sql server and search for records in multiple databases, unfortunately my friend wiped the computer and all he did was backup the .exe file and the database files (.mdf and .ldf) files.

Now I want to get the program working again by setting up the same environment as before he wiped the hard disk by installing sql server and importing the database

The problem is that sql connection information are hardcoded in the .exe file and I need them to set my sql server, what I did is that I used Strings program from sysinternals and search for any clues about the connection information and I found these:

Provider=SQLOLEDB.1;Password=password@$%#$245;Persist Security Info=True;User ID=sa;Initial Catalog=twist;Data Source=pc
EData Source=pc;Initial Catalog=allinfo;User ID=sa;Password=password@$%#$245

so if I understand correctly the information are as follows:

user=sa
password=password@$%#$245
database=twist and allinfo
instance:pc

so I need to install sql server and set the user name and password as above and the instance name as pc ?

well I tried that and the program is still crashing when trying to connect to the sql server. So I have a couple of questions:

1- can I know the version of sql server that the program used to connect to (in case I installed the wrong version)?

2- Is the password that I got from the strings program encrypted and should not be used directly to setup sql server?

3- is my use of the above information correct ? some sources state that "Data Source" refers to the hostname not the instance!

How can I setup sql server to exactly accept connections from the program using the information above?

This is what I came up with

The errors I get are as follows

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The sercer was not found or was not accessible. Verify that the instanc ename is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider,error:40 - Could not open a connection to SQL Server)

and

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at censored.Module1.insertincombo2013(String sql, String table, DataGridView dgv)
   at censored.2013.Button1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8800 (QFE.050727-8800)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
censored
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/mohammad/Desktop/betaqa/id.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.5483 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8791 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5491 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5495 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5483 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8773 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8771 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8762 (QFE.050727-8700)
    CodeBase: file:///C:/Windows/assembly/GAC_64/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5483 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_64/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

PS:I'm a linux superuser and not a windows user that's why I know very little about Microsoft sql server and windows in general,I have experience in mysql but never used MS sql server before but I wanted to help my friend and I got blocked by my little knowledge.

Regards

0 Likes

#2

pc will be the name of the server and the instance will be the default.
You can create an alias for the server (haven't done it for a while).

0 Likes

#3

I would look to see if there is some sort of config file or ini file (not sure how old the application is. I can't imagine they would hardcode all that in an exe

0 Likes

#4

I have made an alias and the program still doesn't connect

0 Likes

#5

There is not configuration files, I'm sure of that,only one single exe file.

0 Likes

#6

one thing that caught my attention in the connection string is this
Provider=SQLOLEDB.1

what does the number signify?maybe it can help identify the server version ?

Regards

0 Likes

#7

a version of SQLOLEDB

https://docs.microsoft.com/en-us/sql/connect/connect-history?view=sql-server-2017#ole-db

which leads me to believe you might be missing some MDAC/WDAC installations for SQLOLEDB.1. Are you running this on a personal pc or server?

0 Likes

#8

Hi, sorry for the late reply
I'm running this inside a windows 7 virtual machine, do I need to setup a windows server machine ? if so which version do you recommend?

0 Likes

#9

Just install the mac stuff and try

0 Likes

#10

I installed every driver I can find, I couldn't find a link for "SQLOLEDB" since Microsoft docs site says it deprecated.
Thanks

0 Likes