forked from AlessandroZ/LaZagne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d90002f
commit e4af3e1
Showing
40 changed files
with
1,127 additions
and
2,119 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import _subprocess as sub | ||
import subprocess | ||
import base64 | ||
import re | ||
|
||
def powershell_execute(script, function): | ||
|
||
script = re.sub("Write-Verbose ","Write-Output ", script, flags=re.I) | ||
script = re.sub("Write-Error ","Write-Output ", script, flags=re.I) | ||
script = re.sub("Write-Warning ","Write-Output ", script, flags=re.I) | ||
|
||
fullargs = ["powershell.exe", "-C", "-"] | ||
|
||
info = subprocess.STARTUPINFO() | ||
info.dwFlags = sub.STARTF_USESHOWWINDOW | sub.CREATE_NEW_PROCESS_GROUP | ||
info.wShowWindow = sub.SW_HIDE | ||
p = subprocess.Popen(fullargs, startupinfo=info, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True, shell=True) | ||
|
||
p.stdin.write("$base64=\"\""+"\n") | ||
n = 25000 | ||
b64_script = base64.b64encode(script) | ||
tab = [b64_script[i:i+n] for i in range(0, len(b64_script), n)] | ||
for t in tab: | ||
p.stdin.write("$base64+=\"%s\"\n" % t) | ||
p.stdin.flush() | ||
|
||
p.stdin.write("$d=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64))\n") | ||
p.stdin.write("Invoke-Expression $d\n") | ||
|
||
p.stdin.write("\n$a=Invoke-Expression \"%s\" | Out-String\n" % function) | ||
p.stdin.write("$b=[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(\"$a\"))\n") | ||
p.stdin.write("Write-Host $b\n") | ||
|
||
# Get the result in base64 | ||
output = "" | ||
for i in p.stdout.readline(): | ||
output += i | ||
output = base64.b64decode(output) | ||
|
||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.