origami 1.2.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -0
- data/README.md +112 -0
- data/bin/config/pdfcop.conf.yml +232 -233
- data/bin/gui/about.rb +27 -37
- data/bin/gui/config.rb +108 -117
- data/bin/gui/file.rb +416 -365
- data/bin/gui/gtkhex.rb +1138 -1153
- data/bin/gui/hexview.rb +55 -57
- data/bin/gui/imgview.rb +48 -51
- data/bin/gui/menu.rb +388 -386
- data/bin/gui/properties.rb +114 -130
- data/bin/gui/signing.rb +571 -617
- data/bin/gui/textview.rb +77 -95
- data/bin/gui/treeview.rb +382 -387
- data/bin/gui/walker.rb +227 -232
- data/bin/gui/xrefs.rb +56 -60
- data/bin/pdf2pdfa +53 -57
- data/bin/pdf2ruby +212 -228
- data/bin/pdfcop +338 -348
- data/bin/pdfdecompress +58 -65
- data/bin/pdfdecrypt +56 -60
- data/bin/pdfencrypt +75 -80
- data/bin/pdfexplode +185 -182
- data/bin/pdfextract +201 -218
- data/bin/pdfmetadata +83 -82
- data/bin/pdfsh +4 -5
- data/bin/pdfwalker +1 -2
- data/bin/shell/.irbrc +45 -82
- data/bin/shell/console.rb +105 -130
- data/bin/shell/hexdump.rb +40 -64
- data/examples/README.md +34 -0
- data/examples/attachments/attachment.rb +38 -0
- data/examples/attachments/nested_document.rb +51 -0
- data/examples/encryption/encryption.rb +28 -0
- data/{samples/actions/triggerevents/trigger.rb → examples/events/events.rb} +13 -16
- data/examples/flash/flash.rb +37 -0
- data/{samples → examples}/flash/helloworld.swf +0 -0
- data/examples/forms/javascript.rb +54 -0
- data/examples/forms/xfa.rb +115 -0
- data/examples/javascript/hello_world.rb +22 -0
- data/examples/javascript/js_emulation.rb +54 -0
- data/examples/loop/goto.rb +32 -0
- data/examples/loop/named.rb +33 -0
- data/examples/signature/signature.rb +65 -0
- data/examples/uri/javascript.rb +56 -0
- data/examples/uri/open-uri.rb +21 -0
- data/examples/uri/submitform.rb +47 -0
- data/lib/origami.rb +29 -42
- data/lib/origami/3d.rb +350 -225
- data/lib/origami/acroform.rb +262 -288
- data/lib/origami/actions.rb +268 -288
- data/lib/origami/annotations.rb +697 -722
- data/lib/origami/array.rb +258 -184
- data/lib/origami/boolean.rb +74 -84
- data/lib/origami/catalog.rb +397 -434
- data/lib/origami/collections.rb +144 -0
- data/lib/origami/destinations.rb +233 -194
- data/lib/origami/dictionary.rb +253 -232
- data/lib/origami/encryption.rb +1274 -1243
- data/lib/origami/export.rb +232 -268
- data/lib/origami/extensions/fdf.rb +307 -220
- data/lib/origami/extensions/ppklite.rb +368 -435
- data/lib/origami/filespec.rb +197 -0
- data/lib/origami/filters.rb +301 -295
- data/lib/origami/filters/ascii.rb +177 -180
- data/lib/origami/filters/ccitt.rb +528 -535
- data/lib/origami/filters/crypt.rb +26 -35
- data/lib/origami/filters/dct.rb +46 -52
- data/lib/origami/filters/flate.rb +95 -94
- data/lib/origami/filters/jbig2.rb +49 -55
- data/lib/origami/filters/jpx.rb +38 -44
- data/lib/origami/filters/lzw.rb +189 -183
- data/lib/origami/filters/predictors.rb +221 -235
- data/lib/origami/filters/runlength.rb +103 -104
- data/lib/origami/font.rb +173 -186
- data/lib/origami/functions.rb +67 -81
- data/lib/origami/graphics.rb +25 -21
- data/lib/origami/graphics/colors.rb +178 -187
- data/lib/origami/graphics/instruction.rb +79 -85
- data/lib/origami/graphics/path.rb +142 -148
- data/lib/origami/graphics/patterns.rb +160 -167
- data/lib/origami/graphics/render.rb +43 -50
- data/lib/origami/graphics/state.rb +138 -153
- data/lib/origami/graphics/text.rb +188 -205
- data/lib/origami/graphics/xobject.rb +819 -815
- data/lib/origami/header.rb +63 -78
- data/lib/origami/javascript.rb +596 -597
- data/lib/origami/linearization.rb +285 -290
- data/lib/origami/metadata.rb +139 -148
- data/lib/origami/name.rb +112 -148
- data/lib/origami/null.rb +53 -62
- data/lib/origami/numeric.rb +162 -175
- data/lib/origami/obfuscation.rb +186 -174
- data/lib/origami/object.rb +593 -573
- data/lib/origami/outline.rb +42 -47
- data/lib/origami/outputintents.rb +73 -82
- data/lib/origami/page.rb +703 -592
- data/lib/origami/parser.rb +238 -290
- data/lib/origami/parsers/fdf.rb +41 -33
- data/lib/origami/parsers/pdf.rb +75 -95
- data/lib/origami/parsers/pdf/lazy.rb +137 -0
- data/lib/origami/parsers/pdf/linear.rb +64 -66
- data/lib/origami/parsers/ppklite.rb +34 -70
- data/lib/origami/pdf.rb +1030 -1005
- data/lib/origami/reference.rb +102 -102
- data/lib/origami/signature.rb +591 -609
- data/lib/origami/stream.rb +668 -551
- data/lib/origami/string.rb +397 -373
- data/lib/origami/template/patterns.rb +56 -0
- data/lib/origami/template/widgets.rb +151 -0
- data/lib/origami/trailer.rb +144 -158
- data/lib/origami/tree.rb +62 -0
- data/lib/origami/version.rb +23 -0
- data/lib/origami/webcapture.rb +88 -79
- data/lib/origami/xfa.rb +2863 -2882
- data/lib/origami/xreftable.rb +472 -384
- data/test/dataset/calc.pdf +85 -0
- data/test/dataset/crypto.pdf +82 -0
- data/test/dataset/empty.pdf +49 -0
- data/test/test_actions.rb +27 -0
- data/test/test_annotations.rb +90 -0
- data/test/test_pages.rb +31 -0
- data/test/test_pdf.rb +16 -0
- data/test/test_pdf_attachment.rb +34 -0
- data/test/test_pdf_create.rb +24 -0
- data/test/test_pdf_encrypt.rb +95 -0
- data/test/test_pdf_parse.rb +96 -0
- data/test/test_pdf_sign.rb +58 -0
- data/test/test_streams.rb +182 -0
- data/test/test_xrefs.rb +67 -0
- metadata +88 -58
- data/README +0 -67
- data/bin/pdf2graph +0 -121
- data/bin/pdfcocoon +0 -104
- data/lib/origami/file.rb +0 -233
- data/samples/README.txt +0 -45
- data/samples/actions/launch/calc.rb +0 -87
- data/samples/actions/launch/winparams.rb +0 -22
- data/samples/actions/loop/loopgoto.rb +0 -24
- data/samples/actions/loop/loopnamed.rb +0 -21
- data/samples/actions/named/named.rb +0 -31
- data/samples/actions/samba/smbrelay.rb +0 -26
- data/samples/actions/webbug/submitform.js +0 -26
- data/samples/actions/webbug/webbug-browser.rb +0 -68
- data/samples/actions/webbug/webbug-js.rb +0 -67
- data/samples/actions/webbug/webbug-reader.rb +0 -90
- data/samples/attachments/attach.rb +0 -40
- data/samples/attachments/attached.txt +0 -1
- data/samples/crypto/crypto.rb +0 -28
- data/samples/digsig/signed.rb +0 -46
- data/samples/exploits/cve-2008-2992-utilprintf.rb +0 -87
- data/samples/exploits/cve-2009-0927-geticon.rb +0 -65
- data/samples/exploits/exploit_customdictopen.rb +0 -55
- data/samples/exploits/getannots.rb +0 -69
- data/samples/flash/flash.rb +0 -31
- data/samples/javascript/attached.txt +0 -1
- data/samples/javascript/js.rb +0 -52
- data/templates/patterns.rb +0 -66
- data/templates/widgets.rb +0 -173
- data/templates/xdp.rb +0 -92
- data/test/ts_pdf.rb +0 -50
metadata
CHANGED
|
@@ -1,39 +1,63 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: origami
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Guillaume
|
|
7
|
+
- Guillaume Delugré
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: colorize
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.7'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: minitest
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '5.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '5.0'
|
|
41
|
+
description: Origami is a pure Ruby library to parse, modify and generate PDF documents.
|
|
42
|
+
email: gdelugre@security-labs.org
|
|
18
43
|
executables:
|
|
19
|
-
- pdfdecompress
|
|
20
|
-
- pdfdecrypt
|
|
21
|
-
- pdfencrypt
|
|
22
|
-
- pdfmetadata
|
|
23
|
-
- pdf2graph
|
|
24
|
-
- pdf2ruby
|
|
25
|
-
- pdfextract
|
|
26
|
-
- pdfcop
|
|
27
|
-
- pdfcocoon
|
|
28
44
|
- pdfsh
|
|
29
45
|
- pdfwalker
|
|
30
46
|
- pdf2pdfa
|
|
47
|
+
- pdf2ruby
|
|
48
|
+
- pdfcop
|
|
49
|
+
- pdfmetadata
|
|
50
|
+
- pdfdecompress
|
|
51
|
+
- pdfdecrypt
|
|
52
|
+
- pdfencrypt
|
|
31
53
|
- pdfexplode
|
|
54
|
+
- pdfextract
|
|
32
55
|
extensions: []
|
|
33
56
|
extra_rdoc_files: []
|
|
34
57
|
files:
|
|
58
|
+
- CHANGELOG.md
|
|
35
59
|
- COPYING.LESSER
|
|
36
|
-
- README
|
|
60
|
+
- README.md
|
|
37
61
|
- bin/config/pdfcop.conf.yml
|
|
38
62
|
- bin/gui/COPYING
|
|
39
63
|
- bin/gui/about.rb
|
|
@@ -49,10 +73,8 @@ files:
|
|
|
49
73
|
- bin/gui/treeview.rb
|
|
50
74
|
- bin/gui/walker.rb
|
|
51
75
|
- bin/gui/xrefs.rb
|
|
52
|
-
- bin/pdf2graph
|
|
53
76
|
- bin/pdf2pdfa
|
|
54
77
|
- bin/pdf2ruby
|
|
55
|
-
- bin/pdfcocoon
|
|
56
78
|
- bin/pdfcop
|
|
57
79
|
- bin/pdfdecompress
|
|
58
80
|
- bin/pdfdecrypt
|
|
@@ -65,6 +87,23 @@ files:
|
|
|
65
87
|
- bin/shell/.irbrc
|
|
66
88
|
- bin/shell/console.rb
|
|
67
89
|
- bin/shell/hexdump.rb
|
|
90
|
+
- examples/README.md
|
|
91
|
+
- examples/attachments/attachment.rb
|
|
92
|
+
- examples/attachments/nested_document.rb
|
|
93
|
+
- examples/encryption/encryption.rb
|
|
94
|
+
- examples/events/events.rb
|
|
95
|
+
- examples/flash/flash.rb
|
|
96
|
+
- examples/flash/helloworld.swf
|
|
97
|
+
- examples/forms/javascript.rb
|
|
98
|
+
- examples/forms/xfa.rb
|
|
99
|
+
- examples/javascript/hello_world.rb
|
|
100
|
+
- examples/javascript/js_emulation.rb
|
|
101
|
+
- examples/loop/goto.rb
|
|
102
|
+
- examples/loop/named.rb
|
|
103
|
+
- examples/signature/signature.rb
|
|
104
|
+
- examples/uri/javascript.rb
|
|
105
|
+
- examples/uri/open-uri.rb
|
|
106
|
+
- examples/uri/submitform.rb
|
|
68
107
|
- lib/origami.rb
|
|
69
108
|
- lib/origami/3d.rb
|
|
70
109
|
- lib/origami/acroform.rb
|
|
@@ -73,13 +112,14 @@ files:
|
|
|
73
112
|
- lib/origami/array.rb
|
|
74
113
|
- lib/origami/boolean.rb
|
|
75
114
|
- lib/origami/catalog.rb
|
|
115
|
+
- lib/origami/collections.rb
|
|
76
116
|
- lib/origami/destinations.rb
|
|
77
117
|
- lib/origami/dictionary.rb
|
|
78
118
|
- lib/origami/encryption.rb
|
|
79
119
|
- lib/origami/export.rb
|
|
80
120
|
- lib/origami/extensions/fdf.rb
|
|
81
121
|
- lib/origami/extensions/ppklite.rb
|
|
82
|
-
- lib/origami/
|
|
122
|
+
- lib/origami/filespec.rb
|
|
83
123
|
- lib/origami/filters.rb
|
|
84
124
|
- lib/origami/filters/ascii.rb
|
|
85
125
|
- lib/origami/filters/ccitt.rb
|
|
@@ -117,6 +157,7 @@ files:
|
|
|
117
157
|
- lib/origami/parser.rb
|
|
118
158
|
- lib/origami/parsers/fdf.rb
|
|
119
159
|
- lib/origami/parsers/pdf.rb
|
|
160
|
+
- lib/origami/parsers/pdf/lazy.rb
|
|
120
161
|
- lib/origami/parsers/pdf/linear.rb
|
|
121
162
|
- lib/origami/parsers/ppklite.rb
|
|
122
163
|
- lib/origami/pdf.rb
|
|
@@ -124,41 +165,31 @@ files:
|
|
|
124
165
|
- lib/origami/signature.rb
|
|
125
166
|
- lib/origami/stream.rb
|
|
126
167
|
- lib/origami/string.rb
|
|
168
|
+
- lib/origami/template/patterns.rb
|
|
169
|
+
- lib/origami/template/widgets.rb
|
|
127
170
|
- lib/origami/trailer.rb
|
|
171
|
+
- lib/origami/tree.rb
|
|
172
|
+
- lib/origami/version.rb
|
|
128
173
|
- lib/origami/webcapture.rb
|
|
129
174
|
- lib/origami/xfa.rb
|
|
130
175
|
- lib/origami/xreftable.rb
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
|
|
146
|
-
- samples/digsig/signed.rb
|
|
147
|
-
- samples/exploits/cve-2008-2992-utilprintf.rb
|
|
148
|
-
- samples/exploits/cve-2009-0927-geticon.rb
|
|
149
|
-
- samples/exploits/exploit_customdictopen.rb
|
|
150
|
-
- samples/exploits/getannots.rb
|
|
151
|
-
- samples/flash/flash.rb
|
|
152
|
-
- samples/flash/helloworld.swf
|
|
153
|
-
- samples/javascript/attached.txt
|
|
154
|
-
- samples/javascript/js.rb
|
|
155
|
-
- templates/patterns.rb
|
|
156
|
-
- templates/widgets.rb
|
|
157
|
-
- templates/xdp.rb
|
|
158
|
-
- test/ts_pdf.rb
|
|
159
|
-
homepage: http://code.google.com/p/origami-pdf
|
|
176
|
+
- test/dataset/calc.pdf
|
|
177
|
+
- test/dataset/crypto.pdf
|
|
178
|
+
- test/dataset/empty.pdf
|
|
179
|
+
- test/test_actions.rb
|
|
180
|
+
- test/test_annotations.rb
|
|
181
|
+
- test/test_pages.rb
|
|
182
|
+
- test/test_pdf.rb
|
|
183
|
+
- test/test_pdf_attachment.rb
|
|
184
|
+
- test/test_pdf_create.rb
|
|
185
|
+
- test/test_pdf_encrypt.rb
|
|
186
|
+
- test/test_pdf_parse.rb
|
|
187
|
+
- test/test_pdf_sign.rb
|
|
188
|
+
- test/test_streams.rb
|
|
189
|
+
- test/test_xrefs.rb
|
|
190
|
+
homepage: http://github.com/gdelugre/origami
|
|
160
191
|
licenses:
|
|
161
|
-
- LGPL-3
|
|
192
|
+
- LGPL-3.0+
|
|
162
193
|
metadata: {}
|
|
163
194
|
post_install_message:
|
|
164
195
|
rdoc_options: []
|
|
@@ -168,19 +199,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
168
199
|
requirements:
|
|
169
200
|
- - ">="
|
|
170
201
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '
|
|
202
|
+
version: '2.1'
|
|
172
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
204
|
requirements:
|
|
174
205
|
- - ">="
|
|
175
206
|
- !ruby/object:Gem::Version
|
|
176
207
|
version: '0'
|
|
177
208
|
requirements:
|
|
178
|
-
-
|
|
209
|
+
- gtk2 to run the graphical interface
|
|
179
210
|
rubyforge_project:
|
|
180
|
-
rubygems_version: 2.
|
|
211
|
+
rubygems_version: 2.5.1
|
|
181
212
|
signing_key:
|
|
182
213
|
specification_version: 4
|
|
183
|
-
summary:
|
|
184
|
-
PDF files.
|
|
214
|
+
summary: Ruby framework to manipulate PDF documents
|
|
185
215
|
test_files:
|
|
186
|
-
- test/
|
|
216
|
+
- test/test_pdf.rb
|
data/README
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
NAME
|
|
2
|
-
|
|
3
|
-
origami
|
|
4
|
-
|
|
5
|
-
DESCRIPTION
|
|
6
|
-
|
|
7
|
-
Origami is a framework written in Ruby designed to parse, analyze, and forge
|
|
8
|
-
PDF documents. This is not a PDF rendering library, it aims at providing a
|
|
9
|
-
scripting tool for generating and analyzing malicious PDF files. As well, it
|
|
10
|
-
can be used to create on-the-fly customized PDFs, or to inject evil code into
|
|
11
|
-
already existing documents.
|
|
12
|
-
|
|
13
|
-
VERSION
|
|
14
|
-
|
|
15
|
-
1.2
|
|
16
|
-
|
|
17
|
-
OPTIONAL DEPENDENCIES
|
|
18
|
-
|
|
19
|
-
- Ruby-GTK2 (only for GUI), http://ruby-gnome2.sourceforge.jp/
|
|
20
|
-
- Ruby with OpenSSL support
|
|
21
|
-
- TheRubyRacer gem (only for JavaScript support)
|
|
22
|
-
|
|
23
|
-
INSTALL
|
|
24
|
-
|
|
25
|
-
Stable: gem install origami
|
|
26
|
-
Devel: hg clone https://origami-pdf.googlecode.com/hg/ origami
|
|
27
|
-
|
|
28
|
-
DIRECTORIES
|
|
29
|
-
|
|
30
|
-
``lib/``
|
|
31
|
-
Core scripts used to parse a PDF file. All objects and features are
|
|
32
|
-
provided here.
|
|
33
|
-
|
|
34
|
-
``samples/``
|
|
35
|
-
Many samples, mostly sorted to generate specially crafted PDFs.
|
|
36
|
-
|
|
37
|
-
``bin/``
|
|
38
|
-
Useful tools based on Origami.
|
|
39
|
-
|
|
40
|
-
``test/``
|
|
41
|
-
Test case units.
|
|
42
|
-
|
|
43
|
-
HOMEPAGE
|
|
44
|
-
|
|
45
|
-
http://aslr.fr/pages/Origami
|
|
46
|
-
|
|
47
|
-
CONTRIBUTORS
|
|
48
|
-
|
|
49
|
-
Guillaume Delugré <guillaume (at) security-labs.org> - Author
|
|
50
|
-
Frédéric Raynal <fred (at) security-labs.org> - Contributor
|
|
51
|
-
|
|
52
|
-
LICENSE
|
|
53
|
-
|
|
54
|
-
This software is distributed under the LGPL license.
|
|
55
|
-
See the COPYING.LESSER file for more details.
|
|
56
|
-
|
|
57
|
-
Exception is for the PDF Walker graphical interface located in subdirectory
|
|
58
|
-
bin/gui, which is distributed under the GPL license.
|
|
59
|
-
See bin/gui/COPYING file for more details.
|
|
60
|
-
|
|
61
|
-
NOTES
|
|
62
|
-
|
|
63
|
-
It contains many bugs and many incomplete features. If you encounter a
|
|
64
|
-
problem, feel free to report it by mail at <guillaume [at] security-labs
|
|
65
|
-
[dot] org>, with a short explanation of what you did and any necessary PDF
|
|
66
|
-
documents. Thanks.
|
|
67
|
-
|
data/bin/pdf2graph
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
= Author:
|
|
6
|
-
Guillaume Delugré <guillaume/at/security-labs.org>
|
|
7
|
-
|
|
8
|
-
= Info:
|
|
9
|
-
Generates a Graphviz DOT or GraphML file out of a PDF document.
|
|
10
|
-
|
|
11
|
-
= License:
|
|
12
|
-
Origami is free software: you can redistribute it and/or modify
|
|
13
|
-
it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
15
|
-
(at your option) any later version.
|
|
16
|
-
|
|
17
|
-
Origami is distributed in the hope that it will be useful,
|
|
18
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
GNU Lesser General Public License for more details.
|
|
21
|
-
|
|
22
|
-
You should have received a copy of the GNU Lesser General Public License
|
|
23
|
-
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
|
|
25
|
-
=end
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
require 'origami'
|
|
29
|
-
rescue LoadError
|
|
30
|
-
ORIGAMIDIR = "#{File.dirname(__FILE__)}/../lib"
|
|
31
|
-
$: << ORIGAMIDIR
|
|
32
|
-
require 'origami'
|
|
33
|
-
end
|
|
34
|
-
include Origami
|
|
35
|
-
|
|
36
|
-
require 'optparse'
|
|
37
|
-
|
|
38
|
-
class OptParser
|
|
39
|
-
BANNER = <<USAGE
|
|
40
|
-
Usage: #{$0} <PDF-file> [-f <format>] [-o <output-file>]
|
|
41
|
-
Generates a Graphviz DOT file out of a PDF document.
|
|
42
|
-
Bug reports or feature requests at: http://origami-pdf.googlecode.com/
|
|
43
|
-
|
|
44
|
-
Options:
|
|
45
|
-
USAGE
|
|
46
|
-
|
|
47
|
-
def self.parser(options)
|
|
48
|
-
OptionParser.new do |opts|
|
|
49
|
-
opts.banner = BANNER
|
|
50
|
-
|
|
51
|
-
opts.on("-o", "--output FILE", "Output PDF file") do |o|
|
|
52
|
-
options[:output] = o
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
opts.on("-f", "--format FORMAT", "File format for the generated graph, dot or graphml (Default: dot).") do |f|
|
|
56
|
-
options[:format] = f
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
|
60
|
-
puts opts
|
|
61
|
-
exit
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def self.parse(args)
|
|
67
|
-
options =
|
|
68
|
-
{
|
|
69
|
-
:format => 'DOT'
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
self.parser(options).parse!(args)
|
|
73
|
-
|
|
74
|
-
options
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
begin
|
|
79
|
-
@options = OptParser.parse(ARGV)
|
|
80
|
-
|
|
81
|
-
if ARGV.empty?
|
|
82
|
-
STDERR.puts "Error: No filename was specified. #{$0} --help for details."
|
|
83
|
-
exit 1
|
|
84
|
-
else
|
|
85
|
-
target = ARGV.shift
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
unless ['DOT', 'GRAPHML'].include? @options[:format].upcase
|
|
89
|
-
STDERR.puts "Error: Invalid format `#{format}'. #{0} --help for details."
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
if @options[:outfile].nil?
|
|
93
|
-
@options[:outfile] = File.basename(target, '.pdf') +
|
|
94
|
-
case @options[:format].upcase
|
|
95
|
-
when 'DOT' then
|
|
96
|
-
'.dot'
|
|
97
|
-
when 'GRAPHML' then
|
|
98
|
-
'.graphml'
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
params =
|
|
103
|
-
{
|
|
104
|
-
:verbosity => Parser::VERBOSE_QUIET,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
pdf = PDF.read(target, params)
|
|
108
|
-
case @options[:format].upcase
|
|
109
|
-
when 'DOT' then
|
|
110
|
-
pdf.export_to_graph(@options[:outfile])
|
|
111
|
-
|
|
112
|
-
when 'GRAPHML' then
|
|
113
|
-
pdf.export_to_graphml(@options[:outfile])
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
rescue SystemExit
|
|
117
|
-
rescue Exception => e
|
|
118
|
-
STDERR.puts "#{e.class}: #{e.message}"
|
|
119
|
-
exit 1
|
|
120
|
-
end
|
|
121
|
-
|
data/bin/pdfcocoon
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
= Author:
|
|
6
|
-
Guillaume Delugré <guillaume/at/security-labs.org>
|
|
7
|
-
|
|
8
|
-
= Info:
|
|
9
|
-
Embeds and PDF document into a trojan PDF document.
|
|
10
|
-
|
|
11
|
-
= License:
|
|
12
|
-
Origami is free software: you can redistribute it and/or modify
|
|
13
|
-
it under the terms of the GNU Lesser General Public License as published by
|
|
14
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
15
|
-
(at your option) any later version.
|
|
16
|
-
|
|
17
|
-
Origami is distributed in the hope that it will be useful,
|
|
18
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
GNU Lesser General Public License for more details.
|
|
21
|
-
|
|
22
|
-
You should have received a copy of the GNU Lesser General Public License
|
|
23
|
-
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
|
|
25
|
-
=end
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
require 'origami'
|
|
29
|
-
rescue LoadError
|
|
30
|
-
ORIGAMIDIR = "#{File.dirname(__FILE__)}/../lib"
|
|
31
|
-
$: << ORIGAMIDIR
|
|
32
|
-
require 'origami'
|
|
33
|
-
end
|
|
34
|
-
include Origami
|
|
35
|
-
|
|
36
|
-
require 'optparse'
|
|
37
|
-
|
|
38
|
-
class OptParser
|
|
39
|
-
BANNER = <<USAGE
|
|
40
|
-
Usage: #{$0} [<PDF-file>] [-o <output-file>]
|
|
41
|
-
Embeds and PDF document into a trojan PDF document.
|
|
42
|
-
Bug reports or feature requests at: http://origami-pdf.googlecode.com/
|
|
43
|
-
|
|
44
|
-
Options:
|
|
45
|
-
USAGE
|
|
46
|
-
|
|
47
|
-
def self.parser(options)
|
|
48
|
-
OptionParser.new do |opts|
|
|
49
|
-
opts.banner = BANNER
|
|
50
|
-
|
|
51
|
-
opts.on("-o", "--output FILE", "Output PDF file (stdout by default)") do |o|
|
|
52
|
-
options[:output] = o
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
|
56
|
-
puts opts
|
|
57
|
-
exit
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def self.parse(args)
|
|
63
|
-
options =
|
|
64
|
-
{
|
|
65
|
-
:output => STDOUT,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
self.parser(options).parse!(args)
|
|
69
|
-
|
|
70
|
-
options
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
begin
|
|
75
|
-
@options = OptParser.parse(ARGV)
|
|
76
|
-
|
|
77
|
-
target = (ARGV.empty?) ? STDIN : ARGV.shift
|
|
78
|
-
|
|
79
|
-
EMBEDDEDNAME = "#{::Array.new(5){ rand(26) + 97}}.pdf"
|
|
80
|
-
|
|
81
|
-
pdf = PDF.new
|
|
82
|
-
|
|
83
|
-
objstm = ObjectStream.new.setFilter(:FlateDecode)
|
|
84
|
-
pdf.insert(objstm)
|
|
85
|
-
|
|
86
|
-
pagetree = PageTreeNode.new.insert_page(0, page = Page.new)
|
|
87
|
-
pdf.Catalog.Pages = objstm.insert(pagetree)
|
|
88
|
-
objstm.insert(page)
|
|
89
|
-
|
|
90
|
-
file = objstm.insert(pdf.attach_file(target, :Register => false))
|
|
91
|
-
pdf.Catalog.Names = objstm.insert(
|
|
92
|
-
Names.new.setEmbeddedFiles(NameTreeNode.new.setNames([ EMBEDDEDNAME, file ]))
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
page.onOpen Action::GoToE.new(EMBEDDEDNAME, Destination::GlobalFit.new(0))
|
|
96
|
-
|
|
97
|
-
pdf.save(@options[:output], :noindent => true)
|
|
98
|
-
|
|
99
|
-
rescue SystemExit
|
|
100
|
-
rescue Exception => e
|
|
101
|
-
STDERR.puts "#{e.class}: #{e.message}"
|
|
102
|
-
exit 1
|
|
103
|
-
end
|
|
104
|
-
|