MaxLaumeister / PageCrypt

Client-side password-protection for HTML
https://pagecrypt.maxlaumeister.com/
MIT License
513 stars 102 forks source link

Powershell Error #13

Closed Ry3yr closed 4 years ago

Ry3yr commented 4 years ago

It seems, using the powershell-implementation gives some error when using:


######Before enabling script execution########

PS C:\Users\Desktop> .\Encrypt-StaticHTML.psl -File test..htm1 -Password �-
File C:\Users\Q782\Desktop\Encrypt-StaticHTML.p91 cannot be loaded because the execution of scripts is disabled on this system. 
Please see "get-help about_signing" for more details.
Line:1 Character:25
+ .\Encrypt-StaticHTML.psl <<<< -File test..html -Password �--1234�-�
         + Categorylnfo : NotSpecified: (:) [], PSSecurityException
         + FullyQualifiedErrorId : RuntimeException

#####After enabling script execution#######

PS C:\Users\Q?02\Desktop> .\Encrypt�StaticHTML.psi -File test.htm1 -Password �-�
Unexpected token "octicon" in Expression or Instruction.
IN C:\Users\Q702\Desktop\Encrypt-StaticHTML.p31:320 Character:28
+ <svg class="octicon <<<< octicon-sign-out u-align-middle" viewBox="0
 0 16 17" version="1.1" width="16" height="17" aria-hidden="true"><path fill-ru
le="evenodd" d="M12 9V7H8V5h4V3l4 3-4 3zm-2 3H6V3L2 1h8v3h1Vc0-.55-.45-1-1-1H1
C.45 0 0 .45 8 1v11.38c0 .39.22.73.55.91L6 16.01V13h4c.55 0 1-.45 1-1V8h-1v4z">
</path></svg>
+ Categorylnfo : ParserError: (octicon:String) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
MaxLaumeister commented 4 years ago

I see that what you copied from PowerShell is kind of garbled. There are a lot of unknown characters including question marks and stuff, like this was typed by hand or OCR'd, or there was some sort of bad encoding. Do you know why that is, and is there any chance PageCrypt's scripts could have gotten corrupted in a similar way?

I also noticed C:\Users\Desktop in the first powershell script, which is an invalid directory.

Ry3yr commented 4 years ago

Yep, it was OCR'd then corrected by hand

That is a typo: The correct directory is C:\Users\Q702\Desktop

EDIT: Here is the actual output (Screencap'd). As I'm using a german OS, the top notification is obviously in german.

Screenshot_2020-05-05-01-18-16

Make sure to let me know if I've got something wrong with the command.

MaxLaumeister commented 4 years ago

It seems like you originally ran it in PowerShell, but your screenshot is running in Command Prompt, which will not work.

Can I see the screenshot of the PowerShell output?

Ry3yr commented 4 years ago

Like this ?:

Screenshot_2020-05-05-11-46-21

EDIT: Ignore the second one. Hah.

MaxLaumeister commented 4 years ago

Please open up your Encrypt-StaticHTML.psl file in a text editor, and make sure it matches the official script.

The output you're getting only makes any sense to me if you somehow downloaded an HTML page from the GitHub website and renamed it to a .ps1 file.

Ry3yr commented 4 years ago

Made sure to get the file directly this time. Now Powershell is complaining about some "unsigned file" (?) -Roughly this translates to "the file is not digitally signed" Screenshot_2020-05-05-20-53-28

MaxLaumeister commented 4 years ago

These may help:

https://medium.com/@caiomsouza/fix-for-powershell-script-not-digitally-signed-69f0ed518715

https://stackoverflow.com/questions/9742775/why-is-my-locally-created-script-not-allowed-to-run-under-the-remotesigned-execu

I just googled "ps1 not digitally signed".

Ry3yr commented 4 years ago

Ran "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass" Retried the script afterwards.

And wow. That is one hell of an ouput.

Attached: file.html file.enc.html (inside zip) *output.txt

(The encoded file is not working it seems, which hardly surprises - as there are quite some errors)

output.txt htmls.zip

I'm just gonna ask in case this cuts things short: I'm only utilizing the files: -Encrypt-StaticHTML.ps1 -file.hml

I'm not missing something crucial here ?

MaxLaumeister commented 4 years ago

According to the readme, you also need decryptTemplate.html in the same directory.

MaxLaumeister commented 4 years ago

If that doesn't work, then what version of PowerShell are you using? On second look at the readme, it says it's written for v5.

Here's how to check your powershell version:
https://stackoverflow.com/questions/1825585/determine-installed-powershell-version

Ry3yr commented 4 years ago

According to Get-Host: Version 2.0 => Gotta update that I guess...

About that decryptTemplate.html: Is that a file inside the github repo of yours, or just an empty html file ?

MaxLaumeister commented 4 years ago

It's a file in the repo.

Ry3yr commented 4 years ago

Sweet, so:

=> Made it work.

Perfect :) !