Skip to content

Commit 321fff1

Browse files
committed
Merge branch 'master' of https://github.com/averagesecurityguy/metasploit-framework into averagesecurityguy-master
2 parents 3036f77 + b6d64b7 commit 321fff1

File tree

12 files changed

+241
-97
lines changed

12 files changed

+241
-97
lines changed

lib/msf/core/post/common.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def cmd_exec(cmd, args=nil, time_out=15)
8080
return o
8181
end
8282

83+
#
84+
# Reports to the database that the host is a virtual machine and reports
85+
# the type of virtual machine it is (e.g VirtualBox, VMware, Xen)
86+
#
8387
def report_vm(vm)
8488
return unless session
8589
return unless vm

lib/msf/core/post/file.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
module Msf::Post::File
44

5+
#
6+
# Change directory in the remote session to +path+
7+
#
58
def cd(path)
69
if session.type == "meterpreter"
710
e_path = session.fs.file.expand_path(path) rescue path
@@ -11,6 +14,9 @@ def cd(path)
1114
end
1215
end
1316

17+
#
18+
# Returns the current working directory in the remote session
19+
#
1420
def pwd
1521
if session.type == "meterpreter"
1622
return session.fs.dir.getwd
@@ -110,7 +116,7 @@ def file_rm(file)
110116
end
111117

112118
#
113-
# Writes a given string to a file specified
119+
# Writes a given string to a given local file
114120
#
115121
def file_local_write(file2wrt, data2wrt)
116122
if not ::File.exists?(file2wrt)
@@ -141,7 +147,6 @@ def file_local_digestmd5(file2md5)
141147
#
142148
# Returns a MD5 checksum of a given remote file
143149
#
144-
145150
def file_remote_digestmd5(file2md5)
146151
data = read_file(file2md5)
147152
chksum = nil
@@ -266,7 +271,8 @@ def append_file(file_name, data)
266271
end
267272

268273
#
269-
# Read a local file and write it to the remote file system
274+
# Read a local file +local+ and write it as +remote+ on the remote file
275+
# system
270276
#
271277
def upload_file(remote, local)
272278
write_file(remote, ::File.read(local))

lib/msf/core/post/linux/priv.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ module Linux
77
module Priv
88
include ::Msf::Post::Common
99

10+
#
1011
# Returns true if running as root, false if not.
12+
#
1113
def is_root?
1214
root_priv = false
1315
user_id = cmd_exec("id -u")

lib/msf/core/post/linux/system.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ module Linux
99
module System
1010
include ::Msf::Post::Common
1111
include ::Msf::Post::File
12-
1312
include ::Msf::Post::Unix
1413

14+
#
1515
# Returns a Hash containing Distribution Name, Version and Kernel Information
16+
#
1617
def get_sysinfo
1718
system_data = {}
1819
etc_files = cmd_exec("ls /etc").split()
@@ -97,6 +98,6 @@ def get_sysinfo
9798

9899

99100
end # System
100-
end #Linux
101+
end # Linux
101102
end # Post
102103
end # Msf

lib/msf/core/post/osx/system.rb

Lines changed: 85 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,97 +7,107 @@ class Post
77
module OSX
88
module System
99
include ::Msf::Post::Common
10-
include ::Msf::Post::File
10+
include ::Msf::Post::File
1111

12-
# Return a hash with system Information
13-
def get_sysinfo
14-
system_info = {}
15-
cmd_output = cmd_exec("/usr/bin/sw_vers").split("\n")
16-
cmd_output.each do |l|
17-
field,val = l.chomp.split(":")
18-
system_info[field] = val.strip
19-
end
20-
system_info["Kernel"] = cmd_exec("uname -a")
21-
system_info["Hostname"] = system_info["Kernel"].split(" ")[1]
22-
23-
return system_info
12+
#
13+
# Return a hash with system Information
14+
#
15+
def get_sysinfo
16+
system_info = {}
17+
cmd_output = cmd_exec("/usr/bin/sw_vers").split("\n")
18+
cmd_output.each do |l|
19+
field,val = l.chomp.split(":")
20+
system_info[field] = val.strip
2421
end
22+
system_info["Kernel"] = cmd_exec("uname -a")
23+
system_info["Hostname"] = system_info["Kernel"].split(" ")[1]
24+
25+
return system_info
26+
end
2527

26-
# Returns an array of hashes each representing a user on the system
27-
# Keys are name, gid, uid, dir and shell
28-
def get_users
29-
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
30-
users = []
31-
users_arry = cmd_output.split("\n\n")
32-
users_arry.each do |u|
33-
entry = Hash.new
34-
u.each_line do |l|
35-
field,val = l.chomp.split(": ")
36-
next if field == "password"
37-
entry[field] = val.chomp
28+
#
29+
# Returns an array of hashes each representing a user on the system
30+
# Keys are name, gid, uid, dir and shell
31+
#
32+
def get_users
33+
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
34+
users = []
35+
users_arry = cmd_output.split("\n\n")
36+
users_arry.each do |u|
37+
entry = Hash.new
38+
u.each_line do |l|
39+
field,val = l.chomp.split(": ")
40+
next if field == "password"
41+
entry[field] = val.chomp
3842

39-
end
40-
users << entry
4143
end
42-
return users
44+
users << entry
4345
end
46+
return users
47+
end
4448

45-
# Returns an array of hashes each representing a system accounts on the system
46-
# Keys are name, gid, uid, dir and shell
47-
def get_system_accounts
48-
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
49-
users = []
50-
users_arry = cmd_output.split("\n\n")
51-
users_arry.each do |u|
52-
entry = {}
53-
u.each_line do |l|
54-
field,val = l.chomp.split(": ")
55-
next if field == "password"
56-
entry[field] = val.chomp
57-
end
58-
next if entry["name"] !~ /^_/
59-
users << entry
49+
#
50+
# Returns an array of hashes each representing a system accounts on the system
51+
# Keys are name, gid, uid, dir and shell
52+
#
53+
def get_system_accounts
54+
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
55+
users = []
56+
users_arry = cmd_output.split("\n\n")
57+
users_arry.each do |u|
58+
entry = {}
59+
u.each_line do |l|
60+
field,val = l.chomp.split(": ")
61+
next if field == "password"
62+
entry[field] = val.chomp
6063
end
61-
return users
64+
next if entry["name"] !~ /^_/
65+
users << entry
6266
end
67+
return users
68+
end
6369

64-
# Returns an array of hashes each representing non system accounts on the system
65-
# Keys are name, gid, uid, dir and shell
66-
def get_nonsystem_accounts
67-
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
68-
users = []
69-
users_arry = cmd_output.split("\n\n")
70-
users_arry.each do |u|
71-
entry = {}
72-
u.each_line do |l|
73-
field,val = l.chomp.split(": ")
74-
next if field == "password"
75-
entry[field] = val.chomp
76-
end
77-
next if entry["name"] =~ /^_/
78-
users << entry
70+
#
71+
# Returns an array of hashes each representing non system accounts on the system
72+
# Keys are name, gid, uid, dir and shell
73+
#
74+
def get_nonsystem_accounts
75+
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
76+
users = []
77+
users_arry = cmd_output.split("\n\n")
78+
users_arry.each do |u|
79+
entry = {}
80+
u.each_line do |l|
81+
field,val = l.chomp.split(": ")
82+
next if field == "password"
83+
entry[field] = val.chomp
7984
end
80-
return users
85+
next if entry["name"] =~ /^_/
86+
users << entry
8187
end
88+
return users
89+
end
8290

83-
# Returns an array of hashes each representing user group on the system
84-
# Keys are name, guid and users
85-
def get_groups
86-
cmd_output = cmd_exec("/usr/bin/dscacheutil -q group")
87-
groups = []
88-
groups_arry = cmd_output.split("\n\n")
89-
groups_arry.each do |u|
90-
entry = Hash.new
91-
u.each_line do |l|
92-
field,val = l.chomp.split(": ")
93-
next if field == "password"
94-
entry[field] = val.chomp
91+
#
92+
# Returns an array of hashes each representing user group on the system
93+
# Keys are name, guid and users
94+
#
95+
def get_groups
96+
cmd_output = cmd_exec("/usr/bin/dscacheutil -q group")
97+
groups = []
98+
groups_arry = cmd_output.split("\n\n")
99+
groups_arry.each do |u|
100+
entry = Hash.new
101+
u.each_line do |l|
102+
field,val = l.chomp.split(": ")
103+
next if field == "password"
104+
entry[field] = val.chomp
95105

96-
end
97-
groups << entry
98106
end
99-
return groups
107+
groups << entry
100108
end
109+
return groups
110+
end
101111
end # System
102112
end # OSX
103113
end # Post

lib/msf/core/post/solaris/priv.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ module Solaris
77
module Priv
88
include ::Msf::Post::Common
99

10-
# Returns true if running as root, false if not.
11-
def is_root?
12-
root_priv = false
13-
user_id = cmd_exec("/usr/xpg4/bin/id -u")
14-
if user_id.to_i == 0
15-
root_priv = true
16-
end
17-
return root_priv
10+
#
11+
# Returns true if running as root, false if not.
12+
#
13+
def is_root?
14+
root_priv = false
15+
user_id = cmd_exec("/usr/xpg4/bin/id -u")
16+
if user_id.to_i == 0
17+
root_priv = true
1818
end
19+
return root_priv
20+
end
1921

2022
end # Priv
2123
end # Solaris

lib/msf/core/post/solaris/system.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module Solaris
99
module System
1010
include ::Msf::Post::Common
1111
include ::Msf::Post::File
12-
1312
include ::Msf::Post::Unix
1413

1514
#

lib/msf/core/post/unix.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ module Msf
44
class Post
55
module Unix
66

7+
#
78
# Returns an array of hashes each representing a user
89
# Keys are name, uid, gid, info, dir and shell
10+
#
911
def get_users
1012
users = []
1113
etc_passwd = nil
@@ -34,8 +36,10 @@ def get_users
3436
return users
3537
end
3638

39+
#
3740
# Returns an array of hashes each hash representing a user group
3841
# Keys are name, gid and users
42+
#
3943
def get_groups
4044
groups = []
4145
cmd_out = read_file("/etc/group").split("\n")
@@ -50,7 +54,9 @@ def get_groups
5054
return groups
5155
end
5256

53-
# returns all user directories found
57+
#
58+
# Enumerates the user directories in /Users or /home
59+
#
5460
def enum_user_directories
5561
user_dirs = []
5662

lib/msf/core/post/windows/eventlog.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ class Post
44
module Windows
55

66
module Eventlog
7-
#enumerate eventlogs
7+
8+
#
9+
# Enumerate eventlogs
10+
#
811
def eventlog_list
912
key = "HKLM\\SYSTEM\\CurrentControlSet\\Services\\"
1013
if session.sys.config.sysinfo['OS'] =~ /Windows 2003|.Net|XP|2000/
@@ -16,7 +19,10 @@ def eventlog_list
1619
return eventlogs
1720
end
1821

19-
#clears a given eventlog or all eventlogs if none is given. Returns an array of eventlogs that where cleared.
22+
#
23+
# Clears a given eventlog or all eventlogs if none is given. Returns an array of eventlogs
24+
# that where cleared.
25+
#
2026
def eventlog_clear(evt = "")
2127
evntlog = []
2228
if evt.empty?

0 commit comments

Comments
 (0)