Ejemplo n.º 1
0
 def add_host(self, hostname, checkclass, checktype, status):
     if hostname == None or len(hostname) == 0:
         raise search.SLIBException('invalid hostname')
     if checkclass != 'vuln':
         raise search.SLIBException('check class must be vuln')
     self._indicators.append({
         'host': hostname,
         'class': checkclass,
         'checktype': checktype,
         'status': status
     })
Ejemplo n.º 2
0
def get_vulnauto():
    u = cfg.config.apiurl() + '/legacy/vulnauto'
    r = requests.get(u, verify=cfg.config.sslverify)
    if r.status_code != requests.codes.ok:
        err = 'Request error: response {}'.format(r.status_code)
        raise search.SLIBException(err)
    return json.loads(r.text)
Ejemplo n.º 3
0
def get_sysgroup(groupid):
    u = cfg.config.apiurl() + '/sysgroup/id'
    payload = {'id': groupid}
    r = requests.get(u, params=payload, verify=cfg.config.sslverify)
    if r.status_code != requests.codes.ok:
        err = 'Request error: response {}'.format(r.status_code)
        raise search.SLIBException(err)
    return json.loads(r.text)
Ejemplo n.º 4
0
 def execute(self):
     if len(self._indicators) == 0:
         return
     buf = {'indicators': self._indicators}
     u = self._url + '/indicator'
     payload = {'params': json.dumps(buf)}
     r = requests.post(u, data=payload, verify=self._verify)
     if r.status_code != requests.codes.ok:
         err = 'Indicator request error: response {}, "{}"'.format(
             r.status_code, r.text.strip())
         raise search.SLIBException(err)
Ejemplo n.º 5
0
def get_vulns(targets):
    u = cfg.config.apiurl() + '/vulns/target'
    ret = {'vulns': []}
    for x in targets:
        payload = {'target': x}
        r = requests.get(u, params=payload, verify=cfg.config.sslverify)
        if r.status_code != requests.codes.ok:
            err = 'Request error: response {}'.format(r.status_code)
            raise search.SLIBException(err)
        buf = json.loads(r.text)
        for x in buf['vulnerabilities']:
            ret['vulns'].append(x)
    return ret