Analysis of privilege spoofing vulnerability in Sablog-X2.0 background management

Source: Internet
Author: User
Not long ago, 80vul.com announced a vulnerability of sax2.0, and then 4ngel released a patch. However, some code for permission verification still has problems. Let's briefly talk about this vulnerability: Dcp. phpif (! $ Sax_uid |! $ Sax_pw |! $ Sax_logincount |! $ Sax_hash) {if this condition is not met, you can use the background permission verification.

Not long ago, 80vul.com announced a vulnerability of sax2.0, and then 4ngel released a patch. However, some code for permission verification still has problems. Let's briefly talk about this vulnerability: D

Cp.Php

 
 
  1. If(! $ Sax_uId|! $ Sax_pw |! $ Sax_logiNcOunt |! $ Sax_hash ){
  2. // As long as this condition is not met, you can pass the background permission verification.
  3. Loginpage ();
  4. }
  5. ...
  6. If($ Sax_group = 1 ){
  7. // To obtain administrator permissions, you must also ensure that the value of $ sax_group is 1.
  8. ...

Let's take a look at how these variables come from.

Common. inc. php

 
 
  1. List ($ sax_uid, $ sax_pw, $ sax_logincount) = $ _ COOKIE [\ 'sax _ auth \ ']?ExPlode ("t", authcode ($ _ COOKIE [\ 'sax _ auth \ '], \ 'decode \')):Array(\'\',\'\',\'\');
  2. // Authcode () is a simple call of base64_decode
  3. $ Sax_hash = sax_aDdSlashes ($ _ COOKIE [\ 'sax _ hash \ ']);
  4. // These variables are from $ _ COOKIE and can be controlled :)
  5. // However, the subsequent code will pass ex under certain conditionsTrAct ($ _ EVO) to re-register these variables
  6.  
  7. $ Sax_uid = intval ($ sax_uid );
  8. $ Sax_pw = sax_addslashes ($ sax_pw );
  9. $ Sax_logincount = intval ($ sax_logincount );
  10. $ Sax_group = 4;
  11. // The default value is 4, and the value we need is 1.
  12. $ _ EVO =Array();
  13. // Here is the fix variable overwrite vulnerability :)
  14.  
  15. $ Seccode = $ sessionexists = 0;
  16. $ Userfields = \ 'U. userid AS sax_uid, u. username AS sax_user, u. password AS sax_pw, u. groupid AS sax_group, u. logincount AS sax_logincount, u. email as sax_email, u. url as sax_url, u. lastpost, u. lastip, u. lastvisit, u. lastactivity \';
  17. // The fields defined here include sax_user, sax_pw, sax_group, and sax_logincount, which are used for background permission verification.
  18. If($ Sax_hash ){
  19. If($ Sax_uid & $ sax_pw ){
  20. // Process [1]
  21. // Sax_group will be queried here, but if we want to set the value to 1 [that is to say, query the Administrator information], you must know the Administrator's sax_hash, sax_pw, sax_logincount, and other values.
  22. $ Query = $ DB-> query ("SELECT s. hash, s. seccode, $ userfields
  23. FROM {$ db_prefix} users u
  24. Left join {$ db_prefix} sessions s ON (s. uid = u. userid)
  25. WHERE s. hash = \ '$ sax_hash \' AND u. userid = \ '$ sax_uid \' AND CONCAT_WS (\'. \ ', s. ip1, s. ip2, s. ip3, s. ip4) = \ '$ onlineip \'
  26. AND u. password = \ '$ sax_pw \' AND u. logincount = \ '$ sax_logincount \' AND s. auth_key = \ '$ sax_auth_key \'");
  27. }ELsE{
  28. $ Query = $ DB-> query ("SELECT hash, uid as sessionuid, groupid, seccode, lastactivity FROM {$ db_prefix} sessions WHERE hash = \ '$ sax_hash \' AND CONCAT_WS (\'. \ ', ip1, ip2, ip3, ip4) = \' $ onlineip \ 'limit 1 ");
  29. // Process [2]
  30. // If we know the Administrator's sax_hash and onlineip, we can set the following $ _ EVO [\ 'sessionuid \ '] value to the Administrator's id.
  31. }
  32. If($ _ EVO = $ DB-> fetch_array ($ query )){
  33. $ Sessionexists = 1;
  34. If
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.