View Single Post
  #1  
Old 09-29-2026, 20:08
Gladiyator's Avatar
Gladiyator Gladiyator is offline
Family
 
Join Date: Jan 2009
Location: .:: Tehran ::.
Posts: 118
Rept. Given: 79
Rept. Rcvd 66 Times in 22 Posts
Thanks Given: 147
Thanks Rcvd at 151 Times in 42 Posts
Gladiyator Reputation: 66
Lightbulb PS2VM – PowerShell to Bytecode VM

I’d like to share a small open-source project I’ve been working on: PS2VM.

PS2VM is a tool that compiles a subset of Windows PowerShell 5.x scripts into a compact bytecode format (.pbc) and runs them on a simple stack-based virtual machine. The goal is not to replace PowerShell, but to explore an alternate execution path: AST → opcodes → VM, with fallback to the real PowerShell engine on the same runspace when a construct isn’t implemented natively.

What it can do

Compile .ps1 → .pbc

Run bytecode inside the VM

Disassemble .pbc for inspection

Handle common language features (functions, loops, if/switch, arrays, pipelines in a limited form, cmdlet calls, scoped variables, etc.)

Delegate complex features (try/catch, modules, advanced attributes, redirections, and more) to the host PowerShell engine so scripts don’t simply break

What it is not

A full reimplementation of the PowerShell runtime

A guarantee of 100% language coverage

A tool intended for malware, evasion, or unauthorized use

It’s aimed at people interested in compilers, interpreters, PowerShell internals, automation research, and experimentation with custom execution engines — for legitimate and authorized use only.

Feedback, issues, and constructive criticism are welcome.

Thanks for reading.


Github Repo : https://github.com/NIKJOO/PS2VM
Reply With Quote
The Following User Gave Reputation+1 to Gladiyator For This Useful Post:
blue_devil (09-30-2026)
The Following 4 Users Say Thank You to Gladiyator For This Useful Post:
blue_devil (09-30-2026), Kurapica (09-29-2026), MarcElBichon (09-29-2026), niculaita (09-30-2026)