@@ -47,7 +47,8 @@ def run
47
47
shells . each do |shell |
48
48
get_shell_history ( users , user , shell )
49
49
end
50
- get_sql_history ( users , user )
50
+ get_mysql_history ( users , user )
51
+ get_psql_history ( users , user )
51
52
get_vim_history ( users , user )
52
53
last = execute ( "/usr/bin/last && /usr/bin/lastlog" )
53
54
sudoers = cat_file ( "/etc/sudoers" )
@@ -109,25 +110,45 @@ def get_shell_history(users, user, shell)
109
110
end
110
111
end
111
112
112
- def get_sql_history ( users , user )
113
+ def get_mysql_history ( users , user )
113
114
if user == "root" and users != nil
114
115
users = users . chomp . split ( )
115
116
users . each do |u |
116
117
if u == "root"
117
- vprint_status ( "Extracting SQL history for #{ u } " )
118
+ vprint_status ( "Extracting MySQL history for #{ u } " )
118
119
sql_hist = cat_file ( "/root/.mysql_history" )
119
120
else
120
- vprint_status ( "Extracting SQL history for #{ u } " )
121
+ vprint_status ( "Extracting MySQL history for #{ u } " )
121
122
sql_hist = cat_file ( "/home/#{ u } /.mysql_history" )
122
123
end
123
-
124
- save ( "History for #{ u } " , sql_hist ) unless sql_hist . nil? || sql_hist =~ /No such file or directory/
124
+ save ( "MySQL History for #{ u } " , sql_hist ) unless sql_hist . nil? || sql_hist =~ /No such file or directory/
125
125
end
126
126
else
127
- vprint_status ( "Extracting SQL history for #{ user } " )
127
+ vprint_status ( "Extracting MySQL history for #{ user } " )
128
128
sql_hist = cat_file ( "/home/#{ user } /.mysql_history" )
129
129
vprint_status ( sql_hist ) if sql_hist
130
- save ( "SQL History for #{ user } " , sql_hist ) unless sql_hist . nil? || sql_hist =~ /No such file or directory/
130
+ save ( "MySQL History for #{ user } " , sql_hist ) unless sql_hist . nil? || sql_hist =~ /No such file or directory/
131
+ end
132
+ end
133
+
134
+ def get_psql_history ( users , user )
135
+ if user == "root" and users != nil
136
+ users = users . chomp . split ( )
137
+ users . each do |u |
138
+ if u == "root"
139
+ vprint_status ( "Extracting PostgreSQL history for #{ u } " )
140
+ sql_hist = cat_file ( "/root/.psql_history" )
141
+ else
142
+ vprint_status ( "Extracting PostgreSQL history for #{ u } " )
143
+ sql_hist = cat_file ( "/home/#{ u } /.psql_history" )
144
+ end
145
+ save ( "PostgreSQL History for #{ u } " , sql_hist ) unless sql_hist . blank? || sql_hist =~ /No such file or directory/
146
+ end
147
+ else
148
+ vprint_status ( "Extracting PostgreSQL history for #{ user } " )
149
+ sql_hist = cat_file ( "/home/#{ user } /.psql_history" )
150
+ vprint_status ( sql_hist ) if sql_hist
151
+ save ( "PostgreSQL History for #{ user } " , sql_hist ) unless sql_hist . blank? || sql_hist =~ /No such file or directory/
131
152
end
132
153
end
133
154
0 commit comments