Skip to content

Commit 683ce10

Browse files
committed
Add URL option
1 parent 6a29b87 commit 683ce10

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

modules/auxiliary/gather/http_pdf_authors.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ def initialize(info = {})
1111
super(update_info(info,
1212
'Name' => 'Gather PDF Authors',
1313
'Description' => %q{
14-
This module takes a list of PDF URLs, downloads the PDFs,
15-
and extracts the author's name from the document metadata.
14+
This module downloads PDF files and extracts the author's
15+
name from the document metadata.
1616
},
1717
'License' => MSF_LICENSE,
1818
'Author' => 'Brendan Coles <bcoles[at]gmail.com>'))
1919
register_options(
2020
[
21-
OptPath.new('URL_LIST', [ true, 'File containing a list of PDF URLs to analyze', '' ]),
21+
OptString.new('URL', [ false, 'The URL of a PDF to analyse', '' ]),
22+
OptString.new('URL_LIST', [ false, 'File containing a list of PDF URLs to analyze', '' ]),
2223
OptString.new('OUTFILE', [ false, 'File to store output', '' ])
2324
])
2425
register_advanced_options(
@@ -37,6 +38,16 @@ def progress(current, total)
3738
end
3839

3940
def load_urls
41+
return [ datastore['URL'] ] unless datastore['URL'].to_s.eql? ''
42+
43+
if datastore['URL_LIST'].to_s.eql? ''
44+
fail_with Failure::BadConfig, 'No URL(s) specified'
45+
end
46+
47+
unless File.file? datastore['URL_LIST'].to_s
48+
fail_with Failure::BadConfig, "File '#{datastore['URL_LIST']}' does not exit"
49+
end
50+
4051
File.open(datastore['URL_LIST'], 'rb') {|f| f.read}.split(/\r?\n/)
4152
end
4253

@@ -77,6 +88,8 @@ def download(url)
7788

7889
begin
7990
target = URI.parse url
91+
raise 'Invalid URL' unless target.scheme =~ %r{https?}
92+
raise 'Invalid URL' if target.host.to_s.eql? ''
8093
rescue => e
8194
print_error "Could not parse URL: #{e}"
8295
return
@@ -128,10 +141,6 @@ def write_output(data)
128141
end
129142

130143
def run
131-
unless File.file? datastore['URL_LIST']
132-
fail_with Failure::BadConfig, "File '#{datastore['URL_LIST']}' does not exit"
133-
end
134-
135144
if datastore['PROXY']
136145
@proxysrv, @proxyport = datastore['PROXY'].split(':')
137146
@proxyuser = datastore['PROXY_USER']

0 commit comments

Comments
 (0)