powershell - Convert code to .EXE using -noexit parameter -
i want convert powershell .exe in order obfuscate code bit, couldn't achieve goal far. tried different tools such ps2exe, powergui, steroids, … , none of them let me add parameters powershell command.
powershell.exe -noexit -windowstyle hidden -file c:\temp\myscript.ps1
anybody give me tip of how achieve this? or maybe other way obfuscate code?
here how did trick. embed code! :) scriptblock key.
$sb = { $query = 'select * __instanceoperationevent within 5 targetinstance isa ''win32_logicaldisk'' , targetinstance.drivetype=2' register-wmievent -query $query -sourceidentifier removablediskdetection -action { $class = $eventargs.newevent.__class $device = $eventargs.newevent.targetinstance.deviceid $wshell = new-object -comobject wscript.shell switch ($class) { __instancecreationevent { $path = $device + '\stamp.kiosk\' write-host '*** checking existence of file $path' if (test-path -path $path) { $wshell.popup('inserted, device id: $device stamp.kiosk', 0, 'done', 0x1) } else { $wshell.popup('inserted, device id: $device without stamp.kiosk', 0, 'done', 0x1) } } __instancedeletionevent { $wshell.popup('removed, device id: $device ', 0, 'done', 0x1) } } } } start-process powershell.exe -argument "-noexit -nologo -noprofile -windowstyle hidden -command $sb"
once jsut manage embed parameters , normal ps1 file result, used ps2exe tool compile it.
.\ps2exe.ps1 -noconsole -inputfile .\magic.ps1 -outputfile magic.exe
Comments
Post a Comment