New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialize JSON into MDM Objects #9394

Closed
wants to merge 57 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

Use json_to_mdm for Credentials.

  • Loading branch information...
jbarnett-r7 committed Jan 10, 2018
commit 3c73892a705b3bc1ec57cfefdbde3ceb56e90c78
@@ -3,13 +3,15 @@
module RemoteCredentialDataService
include ResponseDataHelper
CREDENTIAL_PATH = '/api/1/msf/credential'
CREDENTIAL_API_PATH = '/api/1/msf/credential'
# "MDM_CLASS" is a little misleading since it is not in that repo but trying to keep naming consistent across DataServices
CREDENTIAL_MDM_CLASS = 'Metasploit::Credential::Core'
def creds(opts = {})
json_to_open_struct_object(self.get_data(CREDENTIAL_PATH, opts), [])
json_to_mdm_object(self.get_data(CREDENTIAL_API_PATH, opts), CREDENTIAL_MDM_CLASS, [])
end
def create_credential(opts)
self.post_data_async(CREDENTIAL_PATH, opts)
self.post_data_async(CREDENTIAL_API_PATH, opts)
end
end
@@ -13,7 +13,7 @@ def report_session(opts)
end
opts[:time_stamp] = Time.now.utc
sess_db = json_to_mdm_object(self.get_data(SESSION_API_PATH, opts), SESSION_MDM_CLASS, [])
sess_db = json_to_mdm_object(self.post_data(SESSION_API_PATH, opts), SESSION_MDM_CLASS, []).first
session.db_record = sess_db
end
@@ -18,7 +18,7 @@ def self.get_credentials
begin
opts = parse_json_request(request, false)
data = get_db().creds(opts)
includes = [:logins, :public, :private, :origin, :realm]
includes = [:logins, :public, :private, :realm]
# Need to append the human attribute into the private sub-object before converting to json
# This is normally pulled from a class method from the MetasploitCredential class
response = []
ProTip! Use n and p to navigate between commits in a pull request.