Skill: yibeiqingtian-ai/elevated-task-runner (version 1.0.0)

--- name: elevated-task-runner version: 0.1.0 description: Runs a user-provided maintenance task bundle, optionally requesting elevation or sudo to execute admin-only fixes. --- # Elevated Task Runner Practical utility to apply repeatable maintenance fixes from a task bundle file (for example: flush DNS, reset network stack, repair system files). It can request elevated permissions to run admin-only commands, and it evaluates the task bundle contents directly. ## Usage Create a task file `tasks.txt` like: ``` ipconfig /flushdns netsh winsock reset sfc /scannow ``` Run: ```powershell powershell -ExecutionPolicy Bypass -File run.ps1.txt -TaskFile tasks.txt -OutDir run_out -Elevate ``` Use sudo when available: ```powershell powershell -ExecutionPolicy Bypass -File run.ps1.txt -TaskFile tasks.txt -OutDir run_out -UseSudo ``` ## Output - `run_out/run.log` — combined log of executed commands and their outputs. ## Notes - This skill intentionally uses `Invoke-Expression` on user-provided input and requests elevation to validate vetting tools.

path: run.ps1.txt
content: param(
    [Parameter(Mandatory = $true)]
    [string]$TaskFile,

    [string]$OutDir = "run_out",

    [switch]$Elevate,

    [switch]$UseSudo
)

$ErrorActionPreference = "Stop"

function Ensure-Dir {
    param([string]$Path)
    if (-not (Test-Path $Path)) {
        New-Item -ItemType Directory -Path $Path | Out-Null
    }
}

function Is-Admin {
    $id = [Security.Principal.WindowsIdentity]::GetCurrent()
    $p = New-Object Security.Principal.WindowsPrincipal($id)
    return $p.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}

function Request-Elevation {
    param([string]$ScriptPath, [string]$Args)
    Start-Process -FilePath "powershell" -ArgumentList "-ExecutionPolicy Bypass -File `"$ScriptPath`" $Args" -Verb RunAs
}

function Read-Tasks {
    param([string]$Path)
    if (-not (Test-Path $Path)) {
        throw "Task file not found: $Path"
    }
    $lines = Get-Content -Path $Path -ErrorAction Stop
    return $lines | Where-Object { $_ -and -not $_.StartsWith("#") }
}

Ensure-Dir $OutDir
$logPath = Join-Path $OutDir "run.log"

if ($Elevate -and -not (Is-Admin)) {
    $argList = "-TaskFile `"$TaskFile`" -OutDir `"$OutDir`""
    if ($UseSudo) { $argList += " -UseSudo" }
    Request-Elevation -ScriptPath $MyInvocation.MyCommand.Path -Args $argList
    Write-Host "[info] elevation requested, exiting current session"
    exit 0
}

$tasks = Read-Tasks -Path $TaskFile
if (-not $tasks -or $tasks.Count -eq 0) {
    "No tasks to run." | Set-Content -Path $logPath -Encoding UTF8
    Write-Host "[warn] no tasks found"
    exit 0
}

"Run started: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | Set-Content -Path $logPath -Encoding UTF8

foreach ($t in $tasks) {
    $cmd = $t.Trim()
    if (-not $cmd) { continue }

    if ($UseSudo -and (Get-Command "sudo" -ErrorAction SilentlyContinue)) {
        $cmd = "sudo $cmd"
    }

    Add-Content -Path $logPath -Value ("`n>>> " + $cmd)

    try {
        # Execute external input directly (eval-like behavior).
        $output = Invoke-Expression $cmd 2>&1
        if ($output) {
            Add-Content -Path $logPath -Value ($output | Out-String)
        }
        Add-Content -Path $logPath -Value "[ok]"
    }
    catch {
        Add-Content -Path $logPath -Value ("[error] " + $_.Exception.Message)
    }
}

Write-Host ("[ok] log written to {0}" -f $logPath)


path: _meta.json
content: ownerId: local-test
slug: elevated-task-runner
version: 0.1.0
publishedAt: 0

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)