Skip to content

Instantly share code, notes, and snippets.

@nullbind
Last active February 19, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nullbind/f0bfea6c0121ee537fc3104b71e0a356 to your computer and use it in GitHub Desktop.
Save nullbind/f0bfea6c0121ee537fc3104b71e0a356 to your computer and use it in GitHub Desktop.
PowerUpSQL_GUI2
# --------------------------------------------
# Create Form
# --------------------------------------------
# Create primary form
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$Form.Text = ""
#$Form.Opacity = 0.98 # 1.0 is fully opaque; 0.0 is invisible
$image_Form = [system.drawing.image]::FromFile("C:\Users\ssutherland\Pictures\monkey5.png")
$Form.Width = 1000
$Form.Height = 500
#$icon_Form = New-Object system.drawing.icon ("C:\Users\ssutherland\Pictures\nullbind.ico")
#$Form.Icon = $icon_Form
$form.ShowIcon = $false
$pageBackgroundColor = "#929191"
$pageystart = 50
$Form.Add_Resize($Form_Resize)
#$Form.FormBorderStyle = "None"
# --------------------------------------------
# Create Form Objects
# --------------------------------------------
#region Top panel
# MAIN FORM: Left Top Panel
$topMenuleft = New-Object System.Windows.Forms.FlowLayoutPanel
$topMenuleft.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 0
$topMenuleft.Location = $System_Drawing_Point
$topMenuleft.Name = "leftopmenu"
$topMenuleft.BackColor ="#333333"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 50
$System_Drawing_Size.Width = $leftMenu.Width
$topMenuleft.Size = $System_Drawing_Size
$topMenuleft.Margin = "0,0,0,0"
$Form.Controls.Add($topMenuleft)
# MAIN FORM: Left Top Panel - Label
$labelTop = New-Object System.Windows.Forms.Label
$labelTop.Text = "PowerUpSQL"
$labelTop.TextAlign = "MiddleCenter"
$labelTop.BackColor = "#CE112D"
$labelTop.ForeColor = "white" #"#3d3935"
$labelTop.Margin = "0,0,0,0"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 50
$System_Drawing_Size.Width = $leftMenu.Width
$labelTop.Size = $System_Drawing_Size
$menuFont = New-Object System.Drawing.Font("Ariel",10,[System.Drawing.FontStyle]::Bold)
$labelTop.Font = $menuFont # Font styles are: Regular, Bold, Italic, Underline, Strikeout
$topMenuleft.Controls.Add($labelTop)
# MAIN FORM: Right Top Panel
# https://stackoverflow.com/questions/1592876/make-a-borderless-form-movable
$topMenuright = New-Object System.Windows.Forms.FlowLayoutPanel
$topMenuright.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = $leftMenu.Width
$System_Drawing_Point.Y = 0
$topMenuright.Location = $System_Drawing_Point
$topMenuright.Name = "righttopmenu"
$topMenuright.BackColor = "#3d3935" #"#CE112D"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 50
$System_Drawing_Size.Width = $Form.Width - 50
$topMenuright.Size = $System_Drawing_Size
$topMenuright.Margin = "0,0,0,0"
$menuFont = New-Object System.Drawing.Font("Ariel",12,[System.Drawing.FontStyle]::Bold)
$topMenuright.Font = "white" # Font styles are: Regular, Bold, Italic, Underline, Strikeout
$Form.Controls.Add($topMenuright)
# MAIN FORM: Right Top Panel - Label
$labelTop2 = New-Object System.Windows.Forms.Label
$labelTop2.Text = " DashBoard"
$labelTop2.TextAlign = "MiddleRight"
$labelTop2.BackColor = "Transparent"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = $topMenuright.Height
$System_Drawing_Size.Width = $topMenuright.Width - 150
$labelTop2.Size = $System_Drawing_Size
$menuFont = New-Object System.Drawing.Font("Ariel",10,[System.Drawing.FontStyle]::Bold)
$labelTop2.Font = $menuFont # Font styles are: Regular, Bold, Italic, Underline, Strikeout
$labelTop2.ForeColor = "white"
$labelTop2.Margin = "0,0,0,0"
$topMenuright.Controls.Add($labelTop2)
#endregion Top Panel
#region Left Menu
# MAIN FORM: Left Menu Panel
$leftMenu = New-Object System.Windows.Forms.FlowLayoutPanel
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = $pageystart
$leftMenu.Location = $System_Drawing_Point
$leftMenu.Name = "leftmenu"
$leftMenu.BackColor ="#333333"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 150
$leftMenu.Margin = "0,0,0,0"
$leftMenu.Size = $System_Drawing_Size
$menuFont = New-Object System.Drawing.Font("Ariel",10,[System.Drawing.FontStyle]::Bold)
$leftMenu.Font = $menuFont # Font styles are: Regular, Bold, Italic, Underline, Strikeout
$Form.Controls.Add($leftMenu)
# Button Styles
$leftMenuButtonWidth = 150
$leftMenuButtonHeight = 30
$leftMenuButtonColor = "#929191"
$leftMenuButtonColorDown = "#CE112D"
$leftMenuButtonForeColorDown = "white"
$leftMenuButtonForeGround = "#3d3935"
$leftMenuButtonMargin = "0,0,0,0"
$leftMenuButtonAlign = "MiddleLeft"
$leftMenuButtonBorderStyle = "Flat"
$leftMenuButtonBorderSize = 0
$leftMenuButtonFont = New-Object System.Drawing.Font("Ariel",10,[System.Drawing.FontStyle]::Bold)
# LEFT MENU: DashBoard Button
$buttonDashBoard = New-Object System.Windows.Forms.Button
$buttonDashBoard.TabIndex = 4
$buttonDashBoard.Name = "DashBoard"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = 40
$buttonDashBoard.Size = $System_Drawing_Size
$buttonDashBoard.BackColor = "#333333"
$buttonDashBoard.ForeColor = "#929191" #"White"
$buttonDashBoard.Text = "DashBoard"
$buttonDashBoard.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonDashBoard.add_Click($view_form_DashBoard)
$buttonDashBoard.Margin = $leftMenuButtonMargin
$buttonDashBoard.TextAlign = $leftMenuButtonAlign
$buttonDashBoard.FlatStyle = $leftMenuButtonBorderStyle
$buttonDashBoard.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$leftMenu.Controls.Add($buttonDashBoard)
# LEFT MENU: Discover Button
$buttonDiscover = New-Object System.Windows.Forms.Button
$buttonDiscover.TabIndex = 4
$buttonDiscover.Name = "Discover"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonDiscover.Size = $System_Drawing_Size
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonDiscover.Text = "Discover"
$buttonDiscover.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonDiscover.add_Click($view_form_discover)
$buttonDiscover.ForeColor = $leftMenuButtonForeGround
$buttonDiscover.Margin = $leftMenuButtonMargin
$buttonDiscover.TextAlign = $leftMenuButtonAlign
$buttonDiscover.FlatStyle = $leftMenuButtonBorderStyle
$buttonDiscover.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonDiscover.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonDiscover)
# LEFT MENU: Inventory Button
$buttonInventory = New-Object System.Windows.Forms.Button
$buttonInventory.TabIndex = 4
$buttonInventory.Name = "Inventory"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonInventory.Size = $System_Drawing_Size
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonInventory.Text = "Inventory"
$buttonInventory.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonInventory.add_Click($view_form_inventory)
$buttonInventory.ForeColor = $leftMenuButtonForeGround
$buttonInventory.Margin = $leftMenuButtonMargin
$buttonInventory.TextAlign = $leftMenuButtonAlign
$buttonInventory.FlatStyle = $leftMenuButtonBorderStyle
$buttonInventory.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonInventory.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonInventory)
# LEFT MENU: Audit Button
$buttonAudit = New-Object System.Windows.Forms.Button
$buttonAudit.TabIndex = 4
$buttonAudit.Name = "Audit"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonAudit.Size = $System_Drawing_Size
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAudit.Text = "Audit"
$buttonAudit.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonAudit.add_Click($view_form_audit)
$buttonAudit.ForeColor = $leftMenuButtonForeGround
$buttonAudit.Margin = $leftMenuButtonMargin
$buttonAudit.TextAlign = $leftMenuButtonAlign
$buttonAudit.FlatStyle = $leftMenuButtonBorderStyle
$buttonAudit.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonAudit.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonAudit)
# LEFT MENU: Attack Button
$buttonAttack = New-Object System.Windows.Forms.Button
$buttonAttack.TabIndex = 4
$buttonAttack.Name = "Attack"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonAttack.Size = $System_Drawing_Size
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonAttack.Text = "Attack"
$buttonAttack.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonAttack.add_Click($view_form_attack)
$buttonAttack.ForeColor = $leftMenuButtonForeGround
$buttonAttack.Margin = $leftMenuButtonMargin
$buttonAttack.TextAlign = $leftMenuButtonAlign
$buttonAttack.FlatStyle = $leftMenuButtonBorderStyle
$buttonAttack.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonAttack.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonAttack)
# LEFT MENU: Execute Button
$buttonExecute = New-Object System.Windows.Forms.Button
$buttonExecute.TabIndex = 4
$buttonExecute.Name = "Execute"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonExecute.Size = $System_Drawing_Size
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonExecute.Text = "Execute"
$buttonExecute.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonExecute.add_Click($view_form_execute)
$buttonExecute.ForeColor = $leftMenuButtonForeGround
$buttonExecute.Margin = $leftMenuButtonMargin
$buttonExecute.TextAlign = $leftMenuButtonAlign
$buttonExecute.FlatStyle = $leftMenuButtonBorderStyle
$buttonExecute.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonExecute.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonExecute)
# LEFT MENU: Hunt Button
$buttonHunt = New-Object System.Windows.Forms.Button
$buttonHunt.TabIndex = 4
$buttonHunt.Name = "Hunt"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonHunt.Size = $System_Drawing_Size
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonHunt.Text = "Hunt"
$buttonHunt.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonHunt.add_Click($view_form_hunt)
$buttonHunt.ForeColor = $leftMenuButtonForeGround
$buttonHunt.Margin = $leftMenuButtonMargin
$buttonHunt.TextAlign = $leftMenuButtonAlign
$buttonHunt.FlatStyle = $leftMenuButtonBorderStyle
$buttonHunt.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonHunt.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonHunt)
# LEFT MENU: Report Button
$buttonReport = New-Object System.Windows.Forms.Button
$buttonReport.TabIndex = 4
$buttonReport.Name = "Report"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonReport.Size = $System_Drawing_Size
$buttonReport.BackColor = "$leftMenuButtonColor"
$buttonReport.Text = "Report"
$buttonReport.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonReport.add_Click($view_form_report)
$buttonReport.ForeColor = $leftMenuButtonForeGround
$buttonReport.Margin = $leftMenuButtonMargin
$buttonReport.TextAlign = $leftMenuButtonAlign
$buttonReport.FlatStyle = $leftMenuButtonBorderStyle
$buttonReport.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$buttonReport.Font = $leftMenuButtonFont
$leftMenu.Controls.Add($buttonReport)
# LEFT MENU: Close Button
$buttonClose = New-Object System.Windows.Forms.Button
$buttonClose.TabIndex = 4
$buttonClose.Name = "Close"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $leftMenuButtonWidth
$System_Drawing_Size.Height = $leftMenuButtonHeight
$buttonClose.Size = $System_Drawing_Size
$buttonClose.BackColor = "#333333"
$buttonClose.ForeColor = "#929191" #"White"
$buttonClose.Text = "Close"
$buttonClose.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonClose.add_Click({$Form.Close()})
$buttonClose.Margin = $leftMenuButtonMargin
$buttonClose.TextAlign = $leftMenuButtonAlign
$buttonClose.FlatStyle = $leftMenuButtonBorderStyle
$buttonClose.FlatAppearance.BorderSize = $leftMenuButtonBorderSize
$leftMenu.Controls.Add($buttonClose)
#endregion Left Menu
#region Asset Tree
# MAIN FORM: Asset Tree Page
# https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/treeview-control-windows-forms
$treeMenu = New-Object System.Windows.Forms.FlowLayoutPanel
$treeMenu.DataBindings.DefaultDataSourceUpdateMode = 0
$treeMenu.Margin = "0,0,0,0"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 150
$System_Drawing_Point.Y = $pageystart
$treeMenu.Location = $System_Drawing_Point
$treeMenu.Name = "treeMenu"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = $form.Height - 88
$System_Drawing_Size.Width = 200
$treeMenu.Size = $System_Drawing_Size
$Form.Controls.Add($treeMenu)
# MAIN FORM: Function to create tree nodes
function Add-Node {
param (
$selectedNode,
$name,
$tag
)
$newNode = new-object System.Windows.Forms.TreeNode
$newNode.Name = $name
$newNode.Text = $name
$newNode.Tag = $tag
$selectedNode.Nodes.Add($newNode) | Out-Null
return $newNode
}
# MAIN FORM: Asset Tree - for all
$treeView1 = New-Object System.Windows.Forms.TreeView
$treeView1.BackColor = "#e6e6e6"
$treeView1.Margin = "0,0,0,0"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = $form.Height - 88
$System_Drawing_Size.Width = 200
$treeView1.Size = $System_Drawing_Size
$treeMenu.Controls.add($treeView1)
$nodeSQLInstanceAll = New-Object System.Windows.Forms.TreeNode
$nodeSQLInstanceAll.Name = "All SQL Instances"
$nodeSQLInstanceAll.text = "All Instances (0)"
$nodeSQLInstancePing = New-Object System.Windows.Forms.TreeNode
$nodeSQLInstancePing.Name = "Pingable"
$nodeSQLInstancePing.text = "Ping Response (0)"
$nodeSQLInstancePort = New-Object System.Windows.Forms.TreeNode
$nodeSQLInstancePort.Name = "Port"
$nodeSQLInstancePort.text = "Port Accessible (0)"
$nodeSQLInstanceUser = New-Object System.Windows.Forms.TreeNode
$nodeSQLInstanceUser.Name = "User"
$nodeSQLInstanceUser.text = "User Access (0)"
$nodeSQLInstanceSysadmin = New-Object System.Windows.Forms.TreeNode
$nodeSQLInstanceSysadmin.Name = "Sysadmin"
$nodeSQLInstanceSysadmin.text = "Sysadmin Access (0)"
$treeView1.Nodes.Add($nodeSQLInstanceAll) | Out-Null
$treeView1.Nodes.Add($nodeSQLInstancePing) | Out-Null
$treeView1.Nodes.Add($nodeSQLInstancePort) | Out-Null
$treeView1.Nodes.Add($nodeSQLInstanceUser) | Out-Null
$treeView1.Nodes.Add($nodeSQLInstanceSysadmin) | Out-Null
#endregion Asset Tree
#region DashBoard Page
# DashBoard page: layout
$formDashBoard = New-Object System.Windows.Forms.FlowLayoutPanel
$formDashBoard.forecolor = "White"
$formDashBoard.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formDashBoard.Location = $System_Drawing_Point
$formDashBoard.Name = "formDashBoard"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formDashBoard.Size = $System_Drawing_Size
$Form.Controls.Add($formDashBoard)
# Dashboard label
$label_DashBoard2 = New-Object System.Windows.Forms.Label
$label_DashBoard2.Text = "DashBoard Page"
$label_DashBoard2.BackColor = "Transparent"
$label_DashBoard2.forecolor = "gray"
$label_DashBoard2.Margin = "50,50,50,50"
$label_DashBoard2.Height = 219
$label_DashBoard2.Width = 337
#$imageDashboard = [system.drawing.image]::FromFile("C:\Users\ssutherland\Pictures\powerupsql-large.png")
#$label_DashBoard2.BackgroundImage = $imageDashboard
#$label_DashBoard2.BackgroundImageLayout = "Center" # None, Tile, Center, Stretch, Zoom
$formDashBoard.Controls.Add($label_DashBoard2)
#endregion DashBoard Page
#region Discover Page
# DISCOVER page: layout
$formDiscover = New-Object System.Windows.Forms.FlowLayoutPanel
$formDiscover.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formDiscover.Location = $System_Drawing_Point
$formDiscover.Name = "formDiscover"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formDiscover.Size = $System_Drawing_Size
$Form.Controls.Add($formDiscover)
# DISCOVER page: page label
$labelDiscover = New-Object System.Windows.Forms.Label
$labelDiscover.Text = "Discover instances from files, local computer, active directory domain, udp broadcast, udp scan, tcp scan."
$labelDiscover.BackColor = "Transparent"
$labelDiscover.forecolor = "gray"
$labelDiscover.Margin = "50,50,50,50"
$labelDiscover.Height = 219
$labelDiscover.Width = 337
$formDiscover.Controls.Add($labelDiscover)
# DISCOVER page: instance selected label
$labelDiscoverInstance = New-Object System.Windows.Forms.Label
$labelDiscoverInstance.Text = "No instance selected."
$labelDiscoverInstance.BackColor = "Transparent"
#$label_Test.AutoSize = $True
$formDiscover.Controls.Add($labelDiscoverInstance)
# DISCOVER page: Discover Button
$buttonDiscoverScan = New-Object System.Windows.Forms.Button
$buttonDiscoverScan.TabIndex = 4
$buttonDiscoverScan.Name = "Discover"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 80
$System_Drawing_Size.Height = 25
$buttonDiscoverScan.Size = $System_Drawing_Size
$buttonDiscoverScan.BackColor = "#929191"
$buttonDiscoverScan.Text = "Browse"
$buttonDiscoverScan.Location = $System_Drawing_Point
$buttonDiscoverScan.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonDiscoverScan.add_Click($discover_localfile)
$formDiscover.Controls.Add($buttonDiscoverScan)
#endregion Discover Page
#region Inventory Page
# INVENTORY page: layout
$formInventory = New-Object System.Windows.Forms.FlowLayoutPanel
$formInventory.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formInventory.Location = $System_Drawing_Point
$formInventory.Name = "formInventory"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formInventory.Size = $System_Drawing_Size
$Form.Controls.Add($formInventory)
# INVENTORY page: test label
$label_INVENTORY = New-Object System.Windows.Forms.Label
$label_INVENTORY.Text = "Inventory Page, pull inventory from instances and review info."
$label_INVENTORY.BackColor = "Transparent"
$label_INVENTORY.forecolor = "gray"
$label_INVENTORY.Margin = "50,50,50,50"
$label_INVENTORY.Height = 219
$label_INVENTORY.Width = 337
#$label_Test.AutoSize = $True
$formINVENTORY.Controls.Add($label_INVENTORY)
#endregion Inventory Page
#region Audit Page
# Audit page: layout
$formAudit = New-Object System.Windows.Forms.FlowLayoutPanel
$formAudit.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formAudit.Location = $System_Drawing_Point
$formAudit.Name = "formAudit"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formAudit.Size = $System_Drawing_Size
$Form.Controls.Add($formAudit)
# Audit page: test label
$label_Audit = New-Object System.Windows.Forms.Label
$label_Audit.Text = "Audit Page, perform the invoke-sqlaudit function against targets and review/export the results."
$label_Audit.BackColor = "Transparent"
$label_Audit.forecolor = "gray"
$label_Audit.Margin = "50,50,50,50"
$label_Audit.Height = 219
$label_Audit.Width = 337
$formAudit.Controls.Add($label_Audit)
#endregion Audit Page
#region Attack Page
# Attack page: layout
$formAttack = New-Object System.Windows.Forms.FlowLayoutPanel
$formAttack.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formAttack.Location = $System_Drawing_Point
$formAttack.Name = "formAttack"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formAttack.Size = $System_Drawing_Size
$Form.Controls.Add($formAttack)
# Attack page: test label
$label_Attack = New-Object System.Windows.Forms.Label
$label_Attack.Text = "Attack Page, escalate, dump passwords, persistence. "
$label_Attack.BackColor = "Transparent"
$label_Attack.forecolor = "gray"
$label_Attack.Margin = "50,50,50,50"
$label_Attack.Height = 219
$label_Attack.Width = 337
$formAttack.Controls.Add($label_Attack)
#endregion Attack Page
#region Execute Page
# Execute page: layout
$formExecute = New-Object System.Windows.Forms.FlowLayoutPanel
$formExecute.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formExecute.Location = $System_Drawing_Point
$formExecute.Name = "formExecute"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formExecute.Size = $System_Drawing_Size
$Form.Controls.Add($formExecute)
# Execute page: test label
$label_Execute = New-Object System.Windows.Forms.Label
$label_Execute.Text = "Execute Page, execute os command via various methods, and execute sql queries."
$label_Execute.BackColor = "Transparent"
$label_Execute.forecolor = "gray"
$label_Execute.Margin = "50,50,50,50"
$label_Execute.Height = 219
$label_Execute.Width = 337
$formExecute.Controls.Add($label_Execute)
#endregion Execute Page
#region Hunt Page
# Hunt page: layout
$formHunt = New-Object System.Windows.Forms.FlowLayoutPanel
$formHunt.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formHunt.Location = $System_Drawing_Point
$formHunt.Name = "formHunt"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formHunt.Size = $System_Drawing_Size
$Form.Controls.Add($formHunt)
# Hunt page: test label
$label_Hunt = New-Object System.Windows.Forms.Label
$label_Hunt.Text = "Hunt Page, hunt for preset attack sigs/weak configurations, and custom query results. Include shared accounts, sensitive data"
$label_Hunt.BackColor = "Transparent"
$label_Hunt.forecolor = "gray"
$label_Hunt.Margin = "50,50,50,50"
$label_Hunt.Height = 219
$label_Hunt.Width = 337
$formHunt.Controls.Add($label_Hunt)
#endregion Hunt Page
#region Report Page
# Report page: layout
$formReport = New-Object System.Windows.Forms.FlowLayoutPanel
$formReport.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 350
$System_Drawing_Point.Y = $pageystart
$formReport.Location = $System_Drawing_Point
$formReport.Name = "formReport"
$treeMenu.BackColor ="$pageBackgroundColor"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 1000
$formReport.Size = $System_Drawing_Size
$Form.Controls.Add($formReport)
# Report page: test label
$label_Report = New-Object System.Windows.Forms.Label
$label_Report.Text = "Report Page, role up diagrams and charts"
$label_Report.BackColor = "Transparent"
$label_Report.forecolor = "gray"
$label_Report.Margin = "50,50,50,50"
$label_Report.Height = 219
$label_Report.Width = 337
$formReport.Controls.Add($label_Report)
#endregion Report Page
# --------------------------------------------
#region Events and Actions
# --------------------------------------------
# Resize form objects when form scales
$Form_Resize =
{
# Scale left menu
$leftMenu.Height = $Form.Height
# Scale tree
$treeMenu.Height = $form.Height - 88
$treeView1.Height = $form.Height - 88
# Scale height of pages
$formDiscover.Height = $Form.Height
$formInventory.Height = $Form.Height
$formAudit.Height = $Form.Height
$formAttack.Height = $Form.Height
$formExecute.Height = $Form.Height
$formHunt.Height = $Form.Height
$formReport.Height = $Form.Height
$formDashBoard.Height = $Form.Height
# Scale width of pages
$labelTop2.Width = $topMenuright.Width - 150
$topMenuright.Width = $Form.Width - 50
$formDiscover.Width = $Form.Width
$formInventory.Width = $Form.Width
$formAudit.Width = $Form.Width
$formAttack.Width = $Form.Width
$formExecute.Width = $Form.Width
$formHunt.Width = $Form.Width
$formReport.Width = $Form.Width
$formDashBoard.Width = $Form.Width
}
#region form button actions
# View dashboard Form
$view_form_DashBoard =
{
# Show the dashboard form
$formDashBoard.Visible = $true
$labelTop2.Text = "DashBoard"
# Hide the other forms
$formInventory.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
# Change button color
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Discover Form
$view_form_discover =
{
# Show the discover form
$formDiscover.Visible = $true
$buttonDiscover.BackColor = "$leftMenuButtonColorDown"
$buttonDiscover.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Discover"
# Hide the other forms
$formInventory.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Inventory Form
$view_form_inventory =
{
# Show the inventory form
$formInventory.Visible = $true
$buttonInventory.BackColor = "$leftMenuButtonColorDown"
$buttonInventory.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Inventory"
# Hide the other forms
$formDiscover.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Audit Form
$view_form_audit =
{
# Show the inventory form
$formAudit.Visible = $true
$buttonAudit.BackColor = "$leftMenuButtonColorDown"
$buttonAudit.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Audit"
# Hide the other forms
$formDiscover.Visible = $false
$formInventory.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# Change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Attack Form
$view_form_Attack =
{
# Show the attack form
$formAttack.Visible = $true
$buttonAttack.BackColor = "$leftMenuButtonColorDown"
$buttonAttack.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Attack"
# Hide the other forms
$formDiscover.Visible = $false
$formInventory.Visible = $false
$formAudit.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Execute Form
$view_form_execute =
{
# Show the execute form
$formExecute.Visible = $true
$buttonExecute.BackColor = "$leftMenuButtonColorDown"
$buttonExecute.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Execute"
# Hide the other forms
$formDiscover.Visible = $false
$formInventory.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formHunt.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# Change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Hunt Form
$view_form_hunt =
{
# Show the hunt form
$formHunt.Visible = $true
$buttonHunt.BackColor = "$leftMenuButtonColorDown"
$buttonHunt.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Hunt"
# Hide the other forms
$formDiscover.Visible = $false
$formInventory.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formReport.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonReport.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
$buttonReport.ForeColor = "$leftMenuButtonForeGround"
}
# View Report Form
$view_form_report =
{
# Show the report form
$formReport.Visible = $true
$buttonReport.BackColor = "$leftMenuButtonColorDown"
$buttonReport.ForeColor = "$leftMenuButtonForeColorDown"
$labelTop2.Text = "Report"
# Hide the other forms
$formDiscover.Visible = $false
$formInventory.Visible = $false
$formAudit.Visible = $false
$formAttack.Visible = $false
$formExecute.Visible = $false
$formHunt.Visible = $false
$formDashBoard.Visible = $false
# Change button color back
$buttonDiscover.BackColor = "$leftMenuButtonColor"
$buttonInventory.BackColor = "$leftMenuButtonColor"
$buttonAudit.BackColor = "$leftMenuButtonColor"
$buttonAttack.BackColor = "$leftMenuButtonColor"
$buttonExecute.BackColor = "$leftMenuButtonColor"
$buttonHunt.BackColor = "$leftMenuButtonColor"
# change button forecolor
$buttonDiscover.ForeColor = "$leftMenuButtonForeGround"
$buttonInventory.ForeColor = "$leftMenuButtonForeGround"
$buttonAudit.ForeColor = "$leftMenuButtonForeGround"
$buttonAttack.ForeColor = "$leftMenuButtonForeGround"
$buttonHunt.ForeColor = "$leftMenuButtonForeGround"
$buttonExecute.ForeColor = "$leftMenuButtonForeGround"
}
#endregion form button actions
#region discover page actions
# Import targets from a local file
$discover_localfile =
{
<#
# clear existing records in tree
if ($nodeSQLInstanceAll)
{
$treeview1.Nodes.remove($nodeSQLInstanceAll)
$Form.Refresh()
}
#>
#Get file path from browser
$sqlfilepath = Read-OpenFileDialog
#Generate Module nodes for tree one
$SQLServers = Get-SQLInstanceFile -Verbose -FilePath $sqlfilepath
$SQLServersCount = $SQLServers.row.count
$SQLServers | % {
$parentNode = Add-Node $nodeSQLInstanceAll $_.Instance
}
$countAllNodes = $nodeSQLInstanceAll.GetNodeCount($false)
$nodeSQLInstanceAll.text = "All Instances ($countAllNodes)"
#$nodeSQLInstanceAll.Expand()
# for tree one
# After item is selected take an action
$treeView1.add_AfterSelect({
$instancename = $this.SelectedNode.Name
$labelDiscoverInstance.Text ="Select Instance: $instancename"
})
}
#endregion discover page actions
#endregion Events and Actions
# --------------------------------------------
#region General Use Funcations
# --------------------------------------------
function Read-OpenFileDialog([string]$InitialDirectory, [switch]$AllowMultiSelect)
{
Add-Type -AssemblyName System.Windows.Forms
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.initialDirectory = $InitialDirectory
$openFileDialog.filter = "All files (*.*)| *.*"
if ($AllowMultiSelect) { $openFileDialog.MultiSelect = $true }
$openFileDialog.ShowDialog() > $null
if ($allowMultiSelect) { return $openFileDialog.Filenames } else { return $openFileDialog.Filename }
}
#endregion General Use Funcations
# Show the form
$Form.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment