'Launch the exploit and write messages to the TextDialog.
:param dlg: The TextDialog.'

def _launch_exploit(self, dlg, expl, vuln):

    dlg.add_message('Checking    if    this    attack    plugin    can    exploit    this    vulnerability...\n')
    vuln_id_list = vuln.get_id()
    (yield True)
    can_exploit = False
    try:
        can_exploit = expl.can_exploit(vuln_id_list)
    except BaseFrameworkException as e:
        dlg.add_message(_('\nERROR:    '))
        dlg.add_message((str(e) + '\n'))
        dlg.done()
        dlg.dialog_run()
        (yield False)
    if (not can_exploit):
        dlg.add_message(_('Sorry,    this    attack    plugin    can    not    exploit    this    vulnerability\n'))
        dlg.done()
        dlg.dialog_run()
        (yield False)
    dlg.add_message(_('Starting    exploitation    process...\n'))
    (yield True)
    try:
        expl.exploit(vuln_id_list)
        (yield True)
    except NoVulnerabilityFoundException as e:
        dlg.add_message((str(e) + '\n'))
    except ExploitFailedException as e:
        dlg.add_message((str(e) + '\n'))
    else:
        dlg.add_message(_('Done\n'))
        (yield True)
    dlg.done()
    dlg.dialog_run()
    (yield False)
