您如何查看嵌入在 PDF 中的 JavaScript?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15706730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 01:48:11  来源:igfitidea点击:

How do you view the JavaScript embedded in a PDF?

javascriptpdf

提问by user833970

I have a PDF, which I think has JavaScript embedded in it. Is it possible to see what that JavaScript is? And if so, how would I see it?

我有一个 PDF,我认为其中嵌入了 JavaScript。是否有可能看到 JavaScript 是什么?如果是这样,我将如何看待它?

It's probably possible to hack something together with iText, but I would prefer something faster.

可能有可能与 iText 一起破解一些东西,但我更喜欢更快的东西。

采纳答案by Bruno Lowagie

Download iText RUPS: https://github.com/itext/rups/releases

下载 iText RUPS:https: //github.com/itext/rups/releases

Open the PDF using RUPS and you'll be able to look at all the PDF objects. iText RUPS isn't a PDF viewer, it's a PDF syntax browser.

使用 RUPS 打开 PDF,您将能够查看所有 PDF 对象。iText RUPS 不是 PDF 查看器,而是 PDF 语法浏览器。

回答by Roland

If you prefer a fast method, just open the PDF with a text editor, e.g. NotePad++, and search on JavaScript.

如果您更喜欢快速的方法,只需使用文本编辑器(例如 NotePad++)打开 PDF,然后搜索 JavaScript。

In my case, I ran into a pdf that insisted on being printed instead of viewed. With NP++ I found this script:

就我而言,我遇到了坚持打印而不是查看的pdf。使用 NP++ 我找到了这个脚本:

<</S/JavaScript/JS(this.print\({bUI: true,bSilent: false,bShrinkToFit: true}\);this.closeDoc\(\);)>>

The notation is a little weird, but obviously it has a Print command, followed by a Close command.

符号有点奇怪,但显然它有一个打印命令,后跟一个关闭命令。

You can even replace the Close command with spaces, which is easy in Overwrite mode (press the Insert key to toggle to and from Overwrite mode). You need to keep the total nr of characters the same, to preserve the offset pointers in the PDF. Then, the document can be viewed after cancelling the print command.

您甚至可以用空格替换关闭命令,这在覆盖模式下很容易(按插入键在覆盖模式之间切换)。您需要保持字符的总 nr 相同,以保留 PDF 中的偏移指针。然后,取消打印命令后可以查看文档。

As it was a digitally signed document, of course the signature showed "invalid" :-)

因为它是一个数字签名的文件,当然签名显示“无效”:-)