'Exploits a vuln that was found and stored in the kb.
:param vuln_to_exploit: The vulnerability id to exploit
:return: A list of shells of proxies generated by the exploitation phase'

def exploit(self, vuln_to_exploit=None):

    if (not self.can_exploit()):
        fmt = 'No    %s    vulnerabilities    have    been    found.'
        msg = (fmt % '    or    '.join(self.get_kb_location()))
        raise NoVulnerabilityFoundException(msg)
    om.out.information((self.get_name() + '    exploit    plugin    is    starting.'))
    generated_shells = []
    for vuln in self.get_exploitable_vulns():
        if (vuln_to_exploit is not None):
            if (vuln_to_exploit != vuln.get_id()):
                continue
        if (not isinstance(vuln.get_url(), URL)):
            msg = '%s    plugin    can    NOT    exploit    vulnerability    with    id    "%s"    as    it    doesn\'t    have    an    URL.'
            om.out.debug((msg % (self.get_name(), vuln.get_id())))
            continue
        if (not isinstance(vuln.get_method(), basestring)):
            msg = '%s    plugin    can    NOT    exploit    vulnerability    with    id    "%s"    as    it    doesn\'t    have    an    HTTP    method.'
            om.out.debug((msg % (self.get_name(), vuln.get_id())))
            continue
        try:
            s = self._generate_shell(vuln)
        except (HTTPRequestException, ScanMustStopException, ScanMustStopByUnknownReasonExc, ScanMustStopByUserRequest) as e:
            msg = 'The    exploitation    failed    due    to    HTTP    exception:    "%s".'
            raise ExploitFailedException((msg % e))
        if (s is not None):
            kb.kb.append(self.get_name(), 'shell', s)
            generated_shells.append(s)
            om.out.console(('Vulnerability    successfully    exploited.    Generated    shell    object    %s' % s))
            if self._generate_only_one:
                return [s]
            else:
                pass
    return generated_shells
