MCPcopy
hub / github.com/sleventyeleven/linuxprivchecker / execute_cmd

Function execute_cmd

linuxprivchecker.py:38–59  ·  view source on GitHub ↗

Execute Command (execute_cmd) loop through dictionary, execute the commands, store the results, return updated dict :param cmddict: Dictionary of commands to execute and results :return: The command Dictionary with the commands results included

(cmddict)

Source from the content-addressed store, hash-verified

36
37
38def execute_cmd(cmddict):
39 """
40 Execute Command (execute_cmd)
41 loop through dictionary, execute the commands, store the results, return updated dict
42
43 :param cmddict: Dictionary of commands to execute and results
44 :return: The command Dictionary with the commands results included
45 """
46
47 for item in cmddict:
48 cmd = cmddict[item]["cmd"]
49 if compatmode == 0: # newer version of python, use preferred subprocess
50 out, error = sub.Popen([cmd], stdout=sub.PIPE, stderr=sub.PIPE, shell=True).communicate()
51 results = out.split('\n')
52 else: # older version of python, use os.popen
53 echo_stdout = os.popen(cmd, 'r')
54 results = echo_stdout.read().split('\n')
55
56 # write the results to the command Dictionary for each command run
57 cmddict[item]["results"] = results
58
59 return cmddict
60
61
62def print_results(cmddict):

Callers 11

enum_system_infoFunction · 0.70
enum_network_infoFunction · 0.70
enum_filesystem_infoFunction · 0.70
enum_cron_jobsFunction · 0.70
enum_user_infoFunction · 0.70
enum_user_history_filesFunction · 0.70
enum_rc_filesFunction · 0.70
search_file_permsFunction · 0.70
search_file_passwordsFunction · 0.70
enum_procs_pkgsFunction · 0.70
enum_dev_toolsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected