Created
November 6, 2018 16:43
-
-
Save twilight-sparkle-irl/61f7531d4b6dc368f575c5101adbcbc1 to your computer and use it in GitHub Desktop.
make a fake smartscreen/update-like popup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Title = "Windows needs your help" | |
| $Content = @" | |
| All we need is your credit card number, the three digits on the back, and the expiration month and day! But be quick! | |
| Sphinx of black quartz, judge my brown fox over this lazy dog! | |
| Testing testing testing | |
| "@ | |
| $ButtonText = "Accept" | |
| # -- code begins below, scroll down till you see "ACCEPT CODE" to edit what happens when you accept | |
| Add-Type -AssemblyName PresentationCore | |
| Add-Type -AssemblyName WindowsBase | |
| $AccentColor = (new-object System.Windows.Media.BrushConverter).ConvertFromString('#FF'+(([Convert]::ToString((Get-ItemProperty -Path HKCU:\Software\Microsoft\Windows\DWM).AccentColor,16).Substring(2)-split '(..)'|? { $_ })[2..0])-join '' -split ' ' -join '') | |
| $Dimmer = New-Object system.windows.window | |
| $Dimmer.AllowsTransparency = $true | |
| $Dimmer.WindowStyle = "None" | |
| $Dimmer.WindowStartupLocation = "CenterScreen" | |
| $Dimmer.ResizeMode = "NoResize" | |
| $Dimmer.WindowState = "Maximized" | |
| $Dimmer.Opacity = 0.5 | |
| $Dimmer.Background = [System.Windows.Media.Brushes]::Black | |
| $Window = New-Object system.windows.window | |
| $Window.Background = $AccentColor | |
| $Window.Foreground = [System.Windows.Media.Brushes]::White | |
| $Window.WindowStyle = "None" | |
| $Window.WindowStartupLocation = "CenterScreen" | |
| $Window.ResizeMode = "NoResize" | |
| $Window.SizeToContent = "WidthAndHeight" | |
| $Window.MinHeight = 400 | |
| $Grid = New-Object System.Windows.Controls.Grid | |
| $Grid.VerticalAlignment=0 | |
| $Row1 = new-object system.windows.controls.rowdefinition | |
| $Row2 = new-object system.windows.controls.rowdefinition | |
| $Row3 = new-object system.windows.controls.rowdefinition | |
| $Grid.RowDefinitions.add($Row1) | |
| $Grid.RowDefinitions.add($Row2) | |
| $Grid.RowDefinitions.add($Row3) | |
| $Grid.Margin = 16 | |
| $TitleLabel = New-Object System.Windows.Controls.Label | |
| $TitleLabel.Content = $Title | |
| $TitleLabel.FontFamily = "Segoe UI" | |
| $TitleLabel.FontSize = 42 | |
| $TitleLabel.Foreground = [System.Windows.Media.Brushes]::White | |
| $ContentText = New-Object System.Windows.Controls.AccessText | |
| $ContentText.TextWrapping = "WrapWithOverflow" | |
| $ContentText.Text = $Content | |
| $ContentLabel = New-Object System.Windows.Controls.Label | |
| $ContentLabel.Content = $ContentText | |
| $ContentLabel.FontFamily = "Segoe UI" | |
| $ContentLabel.FontSize = 18 | |
| $ContentLabel.Foreground = [System.Windows.Media.Brushes]::White | |
| $ContentLabel.MaxWidth = 800 | |
| $ContentMargin = New-object System.Windows.Thickness | |
| $ContentMargin.Top = 13 | |
| $ContentLabel.Margin = $ContentMargin | |
| [system.windows.controls.grid]::SetRow($ContentLabel,1) | |
| $Button = New-Object System.Windows.Controls.Button | |
| $Button.Content = $ButtonText | |
| $Button.FontSize = 18 | |
| $Button.FontFamily = "Segoe UI" | |
| $ButtonPadding = New-object System.Windows.Thickness | |
| $ButtonPadding.Top = $ButtonPadding.Bottom = 3 | |
| $ButtonPadding.Right = $ButtonPadding.Left = 20 | |
| $Button.Padding = $ButtonPadding | |
| $Button.BorderThickness = 2 | |
| $Button.BorderBrush = [System.Windows.Media.Brushes]::White | |
| $Button.Foreground = [System.Windows.Media.Brushes]::White | |
| $Button.Background = [System.Windows.Media.Brushes]::Transparent | |
| $Button.HorizontalAlignment = "Right" | |
| [system.windows.controls.grid]::SetRow($Button,2) | |
| $Button.Add_Click({Start-Sleep -m 120;$Dimmer.Close();$Window.Close(); | |
| #-- EXAMPLE ACCEPT CODE -- | |
| Start-Sleep -m 650;Start-Process "https://twitter.com/intent/tweet?text=@NO_BOOT_DEVICE%20Here%27s%20my%20credit%20card%20info%21%3A%0a" | |
| #-- END EXAMPLE ACCEPT CODE -- | |
| }) | |
| $Grid.Children.add($TitleLabel) | |
| $Grid.Children.add($ContentLabel) | |
| $ButtonMargin = New-object System.Windows.Thickness | |
| $ButtonMargin.Top = (400- 221) #TODO this should be $window.actualheight - $grid.actualheight but that returns NaN at this point fsr | |
| $Button.Margin = $ButtonMargin | |
| $Grid.Children.add($Button) | |
| $Window.Content = $Grid | |
| $Dimmer.Show();$Window.ShowDialog() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment