Don’t Sleep – Mouse

Mouse

Add-Type -AssemblyName System.Windows.Forms

while ($true)
{
  $Pos = [System.Windows.Forms.Cursor]::Position
  $x = ($pos.X % 500) + 1
  $y = ($pos.Y % 500) + 1
  [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
  Start-Sleep -Seconds 10
}

Don’t Sleep – Keyboard

Keyboard

# Time for loop to run
param($minutes = 920)

# Loop
$myshell = New-Object -com "Wscript.Shell"

for ($i = 0; $i -lt $minutes; $i++) {
    $myshell.sendkeys("{SCROLLLOCK}")
    Get-Date -Format "dddd MM/dd/yyyy HH:mm K" | Write-Host
    Write-Host "I'm very sleepy!"
    Write-Host "."
    Write-Host "."
    Write-Host "Don't Sleep!"
    Start-Sleep -Milliseconds 100
    $myshell.sendkeys("{SCROLLLOCK}")
    Echo $i minutes
    Start-Sleep -Seconds 60
}


PowerShell File Maker

Useful when making junk files to test transfer speeds & such.

# Define the size of the file in megabytes
$FileSize = 50

#Convert into bytes for calculation
$FileSize = $FileSize * 1024 * 1024
 
# Define the path and name of the file
$filePath = "C:\path\to\your\file.txt"
 
# Create a file with the specified size
$fs = [System.IO.File]::Create($filePath)
$fs.SetLength($fileSize)
$fs.Close()
 
Write-Output "File created at $filePath with size $fileSize megabytes"

PowerShell File Transfer Calculator

# Function to convert data size to megabits
function Convert-DataSizeToMb {
    param (
        [float]$dataSize,
        [string]$unit
    )
    switch ($unit.ToLower()) {
        "kb" { return $dataSize * 0.008 }
        "mb" { return $dataSize * 8 }
        "gb" { return $dataSize * 8192 }
        "tb" { return $dataSize * 8388608 }
        default { throw "Invalid data size unit" }
    }
}
 
# Function to convert transfer rate to megabits per second
function Convert-TransferRateToMbps {
    param (
        [float]$transferRate,
        [string]$unit
    )
    switch ($unit.ToLower()) {
        "kbps" { return $transferRate * 0.001 }
        "mbps" { return $transferRate }
        "gbps" { return $transferRate * 1000 }
        default { throw "Invalid transfer rate unit" }
    }
}
 
# Prompt for the amount of data and its unit
$dataAmount = Read-Host "Enter the amount of data to transfer"
$dataUnit = Read-Host "Enter the unit of data size (KB, MB, GB, TB)"
 
# Prompt for the transfer rate and its unit
$transferRate = Read-Host "Enter the transfer rate"
$rateUnit = Read-Host "Enter the unit of transfer rate (kbps, mbps, gbps)"
 
# Convert data size and transfer rate to megabits
$dataAmountMb = Convert-DataSizeToMb -dataSize $dataAmount -unit $dataUnit
$transferRateMbps = Convert-TransferRateToMbps -transferRate $transferRate -unit $rateUnit
 
# Calculate transfer time in seconds
$transferTimeSeconds = $dataAmountMb / $transferRateMbps
 
# Convert transfer time to hours, minutes, and seconds
$transferTimeHours = [math]::Floor($transferTimeSeconds / 3600)
$transferTimeMinutes = [math]::Floor(($transferTimeSeconds % 3600) / 60)
$transferTimeSeconds = [math]::Floor($transferTimeSeconds % 60)
 
# Output the transfer time
Write-Output "Transfer time: $transferTimeHours hours, $transferTimeMinutes minutes, $transferTimeSeconds seconds"

Explicit Permission Hunter

# Specify the root folder path
$rootFolderPath = "C:\Temp"
 
# Get all items (files and subfolders) under the root folder
$items = Get-ChildItem -Path $rootFolderPath -Recurse
 
# Iterate through each item
foreach ($item in $items) {
    # Get the ACL for the item
    $acl = Get-Acl -Path $item.FullName
 
    # Check if any explicit permissions exist (not inherited)
    $explicitPermissions = $acl.Access | Where-Object { $_.IsInherited -eq $false }
 
    if ($explicitPermissions.Count -gt 0) {
        Write-Host "Explicit permissions found for $($item.FullName):"
        foreach ($permission in $explicitPermissions) {
            Write-Host "  User: $($permission.IdentityReference)"
            Write-Host "  Permissions: $($permission.FileSystemRights)"
            Write-Host "  Access Control Type: $($permission.AccessControlType)"
            Write-Host "  Inherited: $($permission.IsInherited)"
            Write-Host ""
        }
    }
}

Validate SHA256 Checksums with Python

import tkinter as tk
from tkinter import filedialog, simpledialog, messagebox
import hashlib

def calculate_sha256(file_path):
    sha256_hash = hashlib.sha256()
    with open(file_path, "rb") as f:
        # Read and update hash string value in blocks of 4K
        for byte_block in iter(lambda: f.read(4096), b""):
            sha256_hash.update(byte_block)
    return sha256_hash.hexdigest()

def verify_checksum():
    file_path = filedialog.askopenfilename(title="Select the file to check the SHA256 checksum on", filetypes=[("All Files", "*.*")])

    if file_path:
        # Prompt user for SHA256 checksum
        entered_checksum = simpledialog.askstring("Checksum Verification", "Enter SHA256 checksum:")

        # Calculate the SHA256 checksum of the selected file
        file_checksum = calculate_sha256(file_path)

        # Compare entered checksum with calculated checksum
        if entered_checksum == file_checksum:
            messagebox.showinfo("Verification Result", "Checksum verification successful. The file has not been tampered with.")
        else:
            messagebox.showerror("Verification Result", "Checksum verification failed. The file may have been tampered with.")
    else:
        messagebox.showinfo("File Selection", "File selection cancelled by the user.")

# Create the main application window
root = tk.Tk()
root.withdraw()  # Hide the main window

# Call the verify_checksum function
verify_checksum()

# Start the main loop
root.mainloop()

Don’t Scan Random QR codes

Don’t scan codes from strangers (if you receive a QR code from an unsolicited message — text, social media, email, or physical — be skeptical and don’t use it!) If it’s a physical QR code — take a look to see if it was tampered with.