Agent communications - Gargravarr2112/vFense GitHub Wiki

Agent to server communication.

The agent communicates over https (443) to the vFense server. In order for the agent to successfully speak to the server, the agent will require a valid token, that the server will generate during the initialize_vFense.py.

Token

You can retrieve the token in the admin panel or in python.

$bpython
>>> from vFense.core.view.manager import ViewManager
>>> view = ViewManager('global')
>>> view.get_token()
u'2HKF20x7ovFe3jBytRocNZXCh0Gg4swGjkN8Qq6akPA'

Headers needed for agent communication.

When communicating to the server for the 1st time, you must pass the headers like this.

$bpython
>>> import requests
>>> auth_headers = (
    {
        'Authentication': (
            {
                'token': '2HKF20x7ovFe3jBytRocNZXCh0Gg4swGjkN8Qq6akPA'
            }
        )
    }
)
>>> data = requests.post(
    'https://localhost/rvl/v2/core/newagent', verify=False, headers=auth_headers, data={all the agent data}
)

When communicating to the server after the 1st time the headers will look like this..

$bpython
>>> import requests
>>> auth_headers = (
    {
        'Authentication': (
            {
                'token': '2HKF20x7ovFe3jBytRocNZXCh0Gg4swGjkN8Qq6akPA',
                'agent_id': '84b2343f-cf13-4af7-9509-52751293f5ac'
            }
        )
    }
)
>>> data = requests.get(
    'https://localhost/rvl/v2/core/checkin', verify=False, headers=auth_headers
)

Agent v1 Communication URIS

{
    "count": 1, 
    "vfense_status_code": 1001, 
    "generic_status_code": 1001, 
    "message": "get_result_uris - response uris retrieved successfully.", 
    "db_status_code": 0, 
    "data": {
        "reboot": {
            "response_uri": "rvl/v1/core/results/reboot", 
            "request_method": "PUT"
        }, 
        "check_in": {
            "response_uri": "rvl/v1/core/checkin", 
            "request_method": "GET"
        }, 
        "uninstall_agent": {
            "response_uri": "rvl/v1/rv/results/uninstall", 
            "request_method": "PUT"
        }, 
        "startup": {
            "response_uri": "rvl/v1/core/results/startup", 
            "request_method": "PUT"
        }, 
        "available_agent_update": {
            "response_uri": "rvl/rv/available_agent_update", 
            "request_method": "PUT"
        }, 
        "updatesapplications": {
            "response_uri": "rvl/v1/rv/updatesapplications", 
            "request_method": "PUT"
        }, 
        "install_os_apps": {
            "response_uri": "rvl/v1/rv/results/install/apps/", 
            "request_method": "PUT"
        }, 
        "install_supported_apps": {
            "response_uri": "rvl/v1/rv/results/install/apps/supported", 
            "request_method": "PUT"
        }, 
        "refresh_response_uris": {
            "response_uri": "rvl/core/uris/response", 
            "request_method": "GET"
        }, 
        "install_agent_update": {
            "response_uri": "rvl/v1/rv/results/install/apps/agent", 
            "request_method": "PUT"
        }, 
        "logout": {
            "response_uri": "rvl/logout", 
            "request_method": "GET"
        }, 
        "shutdown": {
            "response_uri": "rvl/v1/core/results/shutdown", 
            "request_method": "PUT"
        }, 
        "new_agent": {
            "response_uri": "rvl/core/newagent", 
            "request_method": "POST"
        }, 
        "login": {
            "response_uri": "rvl/login", 
            "request_method": "POST"
        }, 
        "install_custom_apps": {
            "response_uri": "rvl/v1/rv/results/install/apps/custom", 
            "request_method": "PUT"
        }, 
        "monitor_data": {
            "response_uri": "rvl/v1/monitoring/monitordata", 
            "request_method": "POST"
        }, 
        "uninstall": {
            "response_uri": "rvl/v1/rv/results/uninstall", 
            "request_method": "PUT"
        }
    }
}

Agent v2 Communication URIS

 {
    "count": 1, 
    "vfense_status_code": 1001, 
    "generic_status_code": 1001, 
    "message": "get_result_uris - response uris retrieved successfully.", 
    "db_status_code": 0, 
    "data": {
        "refresh_apps": {
            "response_uri": "rvl/v2/{0}/apps/refresh_apps", 
            "request_method": "PUT"
        }, 
        "reboot": {
            "response_uri": "rvl/v2/{0}/core/results/reboot", 
            "request_method": "PUT"
        }, 
        "check_in": {
            "response_uri": "rvl/v2/{0}/core/checkin", 
            "request_method": "GET"
        }, 
        "uninstall_agent": {
            "response_uri": "rvl/v2/{0}/apps/results/uninstall", 
            "request_method": "PUT"
        }, 
        "available_agent_update": {
            "response_uri": "rvl/v2/apps/available_agent_update", 
            "request_method": "PUT"
        }, 
        "startup": {
            "response_uri": "rvl/v2/{0}/core/results/startup", 
            "request_method": "PUT"
        }, 
        "install_os_apps": {
            "response_uri": "rvl/v2/{0}/results/apps/os/install", 
            "request_method": "PUT"
        }, 
        "install_supported_apps": {
            "response_uri": "rvl/v2/{0}/results/apps/install/supported", 
            "request_method": "PUT"
        }, 
        "refresh_response_uris": {
            "response_uri": "rvl/v2/core/uris/response", 
            "request_method": "GET"
        }, 
        "install_agent_update": {
            "response_uri": "rvl/v2/{0}/apps/results/apps/agent", 
            "request_method": "PUT"
        }, 
        "shutdown": {
            "response_uri": "rvl/v2/{0}/core/results/shutdown", 
            "request_method": "PUT"
        }, 
        "new_token": {
            "response_uri": "rvl/v2/{0}/core/results/newtoken", 
            "request_method": "PUT"
        }, 
        "new_agent": {
            "response_uri": "rvl/v2/core/newagent", 
            "request_method": "POST"
        }, 
        "install_custom_apps": {
            "response_uri": "rvl/v2/{0}/results/apps/install/custom", 
            "request_method": "PUT"
        }, 
        "monitor_data": {
            "response_uri": "rvl/v2/{0}/monitoring/monitordata", 
            "request_method": "POST"
        }, 
        "uninstall": {
            "response_uri": "rvl/v2/{0}/apps/results/uninstall", 
            "request_method": "PUT"
        }
    }
}