origami 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/COPYING.LESSER +165 -0
  2. data/README +77 -0
  3. data/VERSION +1 -0
  4. data/bin/config/pdfcop.conf.yml +237 -0
  5. data/bin/gui/about.rb +46 -0
  6. data/bin/gui/config.rb +132 -0
  7. data/bin/gui/file.rb +385 -0
  8. data/bin/gui/hexdump.rb +74 -0
  9. data/bin/gui/hexview.rb +91 -0
  10. data/bin/gui/imgview.rb +72 -0
  11. data/bin/gui/menu.rb +392 -0
  12. data/bin/gui/properties.rb +132 -0
  13. data/bin/gui/signing.rb +635 -0
  14. data/bin/gui/textview.rb +107 -0
  15. data/bin/gui/treeview.rb +409 -0
  16. data/bin/gui/walker.rb +282 -0
  17. data/bin/gui/xrefs.rb +79 -0
  18. data/bin/pdf2graph +121 -0
  19. data/bin/pdf2ruby +353 -0
  20. data/bin/pdfcocoon +104 -0
  21. data/bin/pdfcop +455 -0
  22. data/bin/pdfdecompress +104 -0
  23. data/bin/pdfdecrypt +95 -0
  24. data/bin/pdfencrypt +112 -0
  25. data/bin/pdfextract +221 -0
  26. data/bin/pdfmetadata +123 -0
  27. data/bin/pdfsh +13 -0
  28. data/bin/pdfwalker +7 -0
  29. data/bin/shell/.irbrc +104 -0
  30. data/bin/shell/console.rb +136 -0
  31. data/bin/shell/hexdump.rb +83 -0
  32. data/origami.rb +36 -0
  33. data/origami/3d.rb +239 -0
  34. data/origami/acroform.rb +321 -0
  35. data/origami/actions.rb +299 -0
  36. data/origami/adobe/fdf.rb +259 -0
  37. data/origami/adobe/ppklite.rb +489 -0
  38. data/origami/annotations.rb +775 -0
  39. data/origami/array.rb +187 -0
  40. data/origami/boolean.rb +101 -0
  41. data/origami/catalog.rb +486 -0
  42. data/origami/destinations.rb +213 -0
  43. data/origami/dictionary.rb +188 -0
  44. data/origami/docmdp.rb +96 -0
  45. data/origami/encryption.rb +1293 -0
  46. data/origami/export.rb +283 -0
  47. data/origami/file.rb +222 -0
  48. data/origami/filters.rb +250 -0
  49. data/origami/filters/ascii.rb +189 -0
  50. data/origami/filters/ccitt.rb +515 -0
  51. data/origami/filters/crypt.rb +47 -0
  52. data/origami/filters/dct.rb +61 -0
  53. data/origami/filters/flate.rb +112 -0
  54. data/origami/filters/jbig2.rb +63 -0
  55. data/origami/filters/jpx.rb +53 -0
  56. data/origami/filters/lzw.rb +195 -0
  57. data/origami/filters/predictors.rb +276 -0
  58. data/origami/filters/runlength.rb +117 -0
  59. data/origami/font.rb +209 -0
  60. data/origami/functions.rb +93 -0
  61. data/origami/graphics.rb +33 -0
  62. data/origami/graphics/colors.rb +191 -0
  63. data/origami/graphics/instruction.rb +126 -0
  64. data/origami/graphics/path.rb +154 -0
  65. data/origami/graphics/patterns.rb +180 -0
  66. data/origami/graphics/state.rb +164 -0
  67. data/origami/graphics/text.rb +224 -0
  68. data/origami/graphics/xobject.rb +493 -0
  69. data/origami/header.rb +90 -0
  70. data/origami/linearization.rb +318 -0
  71. data/origami/metadata.rb +114 -0
  72. data/origami/name.rb +170 -0
  73. data/origami/null.rb +75 -0
  74. data/origami/numeric.rb +188 -0
  75. data/origami/obfuscation.rb +233 -0
  76. data/origami/object.rb +527 -0
  77. data/origami/outline.rb +59 -0
  78. data/origami/page.rb +559 -0
  79. data/origami/parser.rb +268 -0
  80. data/origami/parsers/fdf.rb +45 -0
  81. data/origami/parsers/pdf.rb +27 -0
  82. data/origami/parsers/pdf/linear.rb +113 -0
  83. data/origami/parsers/ppklite.rb +86 -0
  84. data/origami/pdf.rb +1144 -0
  85. data/origami/reference.rb +113 -0
  86. data/origami/signature.rb +474 -0
  87. data/origami/stream.rb +575 -0
  88. data/origami/string.rb +416 -0
  89. data/origami/trailer.rb +173 -0
  90. data/origami/webcapture.rb +87 -0
  91. data/origami/xfa.rb +3027 -0
  92. data/origami/xreftable.rb +447 -0
  93. data/templates/patterns.rb +66 -0
  94. data/templates/widgets.rb +173 -0
  95. data/templates/xdp.rb +92 -0
  96. data/tests/dataset/test.dummycrt +28 -0
  97. data/tests/dataset/test.dummykey +27 -0
  98. data/tests/tc_actions.rb +32 -0
  99. data/tests/tc_annotations.rb +85 -0
  100. data/tests/tc_pages.rb +37 -0
  101. data/tests/tc_pdfattach.rb +24 -0
  102. data/tests/tc_pdfencrypt.rb +110 -0
  103. data/tests/tc_pdfnew.rb +32 -0
  104. data/tests/tc_pdfparse.rb +98 -0
  105. data/tests/tc_pdfsig.rb +37 -0
  106. data/tests/tc_streams.rb +129 -0
  107. data/tests/ts_pdf.rb +45 -0
  108. metadata +193 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README ADDED
@@ -0,0 +1,77 @@
1
+ ################################################################################
2
+ # #
3
+ # Origami - Ruby PDF manipulation framework #
4
+ # #
5
+ ################################################################################
6
+
7
+ :: DESCRIPTION
8
+ ==============
9
+
10
+ Origami is a framework written in Ruby designed to parse, analyze, and forge PDF
11
+ documents.
12
+ This is *NOT* a PDF rendering library, it aims at providing a scripting tool for
13
+ generating and analyzing malicious PDF files. As well, it can be used to create
14
+ on-the-fly customized PDFs, or to inject evil code into already existing
15
+ documents.
16
+
17
+
18
+ :: LICENSE
19
+ ==========
20
+
21
+ This software is distributed under the LGPL license.
22
+ See the COPYING.LESSER file for more details.
23
+
24
+
25
+ :: RELEASE
26
+ ==========
27
+
28
+ - Current : Version 1.0.0 beta3
29
+
30
+
31
+ :: DEPENDENCIES
32
+ ===============
33
+
34
+ - Ruby 1.8 (actually not tested on 1.9)
35
+ - Ruby-GTK2 (only for GUI), http://ruby-gnome2.sourceforge.jp/
36
+
37
+
38
+ :: DIRECTORIES
39
+ ==============
40
+
41
+ ``origami/``
42
+ * Core scripts used to parse a PDF file. All objects and features are
43
+ provided here.
44
+
45
+ ``walker/``
46
+ * An unfinished GTK interface to analyze a PDF.
47
+
48
+ ``samples/``
49
+ * Many samples, mostly sorted to generate specially crafted PDFs.
50
+
51
+ ``tools/``
52
+ * Useful tools based on Origami.
53
+
54
+ ``tests/``
55
+ * Test case units.
56
+
57
+ ``doc/``
58
+ * Automated RubyDoc HTML documentation.
59
+
60
+
61
+ :: CONTRIBUTORS
62
+ ===============
63
+
64
+ Guillaume Delugré <guillaume@security-labs.org> - Author
65
+ Frédéric Raynal <fred@security-labs.org> - Contributor
66
+
67
+
68
+ :: NOTES
69
+ ========
70
+
71
+ This is a beta release. It contains many bugs and many incomplete
72
+ features. If you encounter a problem, feel free to report it by mail at
73
+ <guillaume [at] security-labs [dot] org>, with a short explanation of
74
+ what you did and any necessary PDF documents.
75
+
76
+ Thanks.
77
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0-beta3
@@ -0,0 +1,237 @@
1
+ ---
2
+ POLICY_NONE:
3
+
4
+ #
5
+ # General features.
6
+ #
7
+ allowParserErrors: true
8
+ allowAttachments: true
9
+ allowEncryption: true
10
+ allowFormCalc: true
11
+ allowJSAtOpening: true
12
+ allowJS: true
13
+ allowAcroForms: true
14
+ allowXFAForms: true
15
+
16
+ #
17
+ # Page annotations.
18
+ #
19
+ allowAnnotations: true
20
+ allow3DAnnotation: true
21
+ allowFileAttachmentAnnotation: true
22
+ allowMovieAnnotation: true
23
+ allowRichMediaAnnotation: true
24
+ allowScreenAnnotation: true
25
+ allowSoundAnnotation: true
26
+
27
+ #
28
+ # PDF Actions.
29
+ #
30
+ allowChainedActions: true
31
+ allowOpenAction: true
32
+ allowGoTo3DAction: true
33
+ allowGoToAction: true
34
+ allowGoToEAction: true
35
+ allowGoToRAction: true
36
+ allowImportDataAction: true
37
+ allowJSAction: true
38
+ allowLaunchAction: true
39
+ allowMovieAction: true
40
+ allowNamedAction: true
41
+ allowRenditionAction: true
42
+ allowRichMediaAction: true
43
+ allowSoundAction: true
44
+ allowSubmitFormAction: true
45
+ allowURIAction: true
46
+
47
+ #
48
+ # Stream filters.
49
+ #
50
+ allowASCII85Filter: true
51
+ allowASCIIHexFilter: true
52
+ allowCCITTFaxFilter: true
53
+ allowCryptFilter: true
54
+ allowDCTFilter: true
55
+ allowFlateFilter: true
56
+ allowJBIG2Filter: true
57
+ allowJPXFilter: true
58
+ allowLZWFilter: true
59
+ allowRunLengthFilter: true
60
+
61
+ POLICY_STANDARD:
62
+
63
+ #
64
+ # General features.
65
+ #
66
+ allowParserErrors: false
67
+ allowAttachments: false
68
+ allowAcroForms: true
69
+ allowEncryption: true
70
+ allowFormCalc: true
71
+ allowJS: true
72
+ allowJSAtOpening: false
73
+ allowXFAForms: true
74
+
75
+ #
76
+ # Page annotations.
77
+ #
78
+ allowAnnotations: true
79
+ allow3DAnnotation: false
80
+ allowFileAttachmentAnnotation: false
81
+ allowMovieAnnotation: false
82
+ allowRichMediaAnnotation: false
83
+ allowScreenAnnotation: false
84
+ allowSoundAnnotation: false
85
+
86
+ #
87
+ # PDF Actions.
88
+ #
89
+ allowChainedActions: true
90
+ allowOpenAction: true
91
+ allowGoTo3DAction: false
92
+ allowGoToAction: true
93
+ allowGoToEAction: false
94
+ allowGoToRAction: false
95
+ allowImportDataAction: false
96
+ allowJSAction: true
97
+ allowLaunchAction: false
98
+ allowMovieAction: false
99
+ allowNamedAction: false
100
+ allowRenditionAction: false
101
+ allowRichMediaAction: false
102
+ allowSoundAction: false
103
+ allowSubmitFormAction: true
104
+ allowURIAction: true
105
+
106
+ #
107
+ # Stream filters.
108
+ #
109
+ allowASCII85Filter: false
110
+ allowASCIIHexFilter: false
111
+ allowCCITTFaxFilter: true
112
+ allowCryptFilter: true
113
+ allowDCTFilter: true
114
+ allowFlateFilter: true
115
+ allowJBIG2Filter: false
116
+ allowJPXFilter: false
117
+ allowLZWFilter: false
118
+ allowRunLengthFilter: false
119
+
120
+ POLICY_STRONG:
121
+
122
+ #
123
+ # General features.
124
+ #
125
+ allowParserErrors: false
126
+ allowAttachments: false
127
+ allowAcroForms: false
128
+ allowEncryption: true
129
+ allowFormCalc: true
130
+ allowJS: false
131
+ allowJSAtOpening: false
132
+ allowXFAForms: false
133
+
134
+ #
135
+ # Page annotations.
136
+ #
137
+ allowAnnotations: true
138
+ allow3DAnnotation: false
139
+ allowFileAttachmentAnnotation: false
140
+ allowMovieAnnotation: false
141
+ allowRichMediaAnnotation: false
142
+ allowScreenAnnotation: false
143
+ allowSoundAnnotation: false
144
+
145
+ #
146
+ # PDF Actions.
147
+ #
148
+ allowChainedActions: false
149
+ allowOpenAction: true
150
+ allowGoTo3DAction: false
151
+ allowGoToAction: true
152
+ allowGoToEAction: false
153
+ allowGoToRAction: false
154
+ allowImportDataAction: false
155
+ allowJSAction: false
156
+ allowLaunchAction: false
157
+ allowMovieAction: false
158
+ allowNamedAction: false
159
+ allowRenditionAction: false
160
+ allowRichMediaAction: false
161
+ allowSoundAction: false
162
+ allowSubmitFormAction: false
163
+ allowURIAction: true
164
+
165
+ #
166
+ # Stream filters.
167
+ #
168
+ allowASCII85Filter: false
169
+ allowASCIIHexFilter: false
170
+ allowCCITTFaxFilter: false
171
+ allowCryptFilter: true
172
+ allowDCTFilter: true
173
+ allowFlateFilter: true
174
+ allowJBIG2Filter: false
175
+ allowJPXFilter: false
176
+ allowLZWFilter: false
177
+ allowRunLengthFilter: false
178
+
179
+ POLICY_PARANOID:
180
+
181
+ #
182
+ # General features.
183
+ #
184
+ allowParserErrors: false
185
+ allowAttachments: false
186
+ allowAcroForms: false
187
+ allowEncryption: false
188
+ allowFormCalc: false
189
+ allowJS: false
190
+ allowJSAtOpening: false
191
+ allowXFAForms: false
192
+
193
+ #
194
+ # Page annotations.
195
+ #
196
+ allowAnnotations: true
197
+ allow3DAnnotation: false
198
+ allowFileAttachmentAnnotation: false
199
+ allowMovieAnnotation: false
200
+ allowRichMediaAnnotation: false
201
+ allowScreenAnnotation: false
202
+ allowSoundAnnotation: false
203
+
204
+ #
205
+ # PDF Actions.
206
+ #
207
+ allowChainedActions: false
208
+ allowOpenAction: false
209
+ allowGoTo3DAction: false
210
+ allowGoToAction: true
211
+ allowGoToEAction: false
212
+ allowGoToRAction: false
213
+ allowImportDataAction: false
214
+ allowJSAction: false
215
+ allowLaunchAction: false
216
+ allowMovieAction: false
217
+ allowNamedAction: false
218
+ allowRenditionAction: false
219
+ allowRichMediaAction: false
220
+ allowSoundAction: false
221
+ allowSubmitFormAction: false
222
+ allowURIAction: false
223
+
224
+ #
225
+ # Stream filters.
226
+ #
227
+ allowASCII85Filter: false
228
+ allowASCIIHexFilter: false
229
+ allowCCITTFaxFilter: false
230
+ allowCryptFilter: false
231
+ allowDCTFilter: true
232
+ allowFlateFilter: true
233
+ allowJBIG2Filter: false
234
+ allowJPXFilter: false
235
+ allowLZWFilter: false
236
+ allowRunLengthFilter: false
237
+