Online PHP and Javascript Decoder decode hidden script to uncover its real functionality


namespace MiniOrange\IDPSaml\Controller\Actions;

use Magento\Framework\App\Action\Context;
use MiniOrange\IDPSaml\Helper\IDPUtility;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use MiniOrange\IDPSaml\Helper\Data;
use MiniOrange\IDPSaml\Controller\Actions\PasswordGrant;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Customer\Model\CustomerFactory;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\Framework\App\Bootstrap;
use Magento\Customer\Model\Customer;
use Magento\Framework\App\Response\Http;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Model\Session;
use Magento\Framework\Controller\ResultFactory;
use Magento\Customer\Model\AddressFactory;
class Userinfo extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
{
    private $REQUEST;
    private $POST;
    private $passwordGrant;
    protected $resultFactory;
    private $customerSession;
    private $customerFactory;
    private $customerRepository;
    protected $response;
    protected $idpUtility;
    protected $customerCollectionFactory;
    protected $_addressFactory;
    public function __construct(Context $FF, IDPUtility $Ng, ResultFactory $Fb, Session $d9, CustomerFactory $o2, CustomerRepositoryInterface $ql, Http $WG, CollectionFactory $Fn, AddressFactory $uw)
    {
        $this->resultFactory = $Fb;
        $this->customerSession = $d9;
        $this->idpUtility = $Ng;
        $this->customerFactory = $o2;
        $this->customerRepository = $ql;
        $this->response = $WG;
        $this->customerCollectionFactory = $Fn;
        $this->_addressFactory = $uw;
        parent::__construct($FF);
    }
    public function execute()
    {
        $this->idpUtility->log_debug("UserInfo: started");
        foreach (getallheaders() as $uM => $TC) {
            $this->idpUtility->log_debug("UserInfo: attribute name: " . $uM . " attribute value: " . $TC);
            if (!($uM == "Authorization" && !empty($TC))) {
                goto Xy;
            }
            $TC = ltrim(substr($TC, 6));
            $Ii = explode("client", $TC);
            $Wm = $Ii[1];
            $this->idpUtility->log_debug("received client id in userinfo: ", $Wm);
            Xy:
            dB:
        }
        Ge:
        $Kb = $this->idpUtility->getMiniOrangeOAuthClients();
        foreach ($Kb as $av) {
            if (!($av->getData()[IDPConstants::CLIENT_ID] === $Wm)) {
                goto b2;
            }
            $AG = $av->getData();
            b2:
            Hc:
        }
        ER:
        if (isset($AG)) {
            goto NQ;
        }
        foreach ($Kb as $av) {
            $AG = $av->getData();
            goto t6;
            T6:
        }
        t6:
        NQ:
        $this->idpUtility->log_debug("UserInfo: client selected for attribute mapping in userinfo: ", $AG[IDPConstants::CLIENT_NAME]);
        $sg = $AG[IDPConstants::CLIENT_ID];
        $lw = $this->getRequest()->getParams();
        $U0 = [];
        foreach (getallheaders() as $uM => $TC) {
            $U0[$uM] = $TC;
            Kk:
        }
        xj:
        $Lk = $U0["Authorization"];
        $VV = trim(substr($Lk, 6));
        $this->idpUtility->log_debug("UserInfo: access token received: ", $VV);
        $Ug = $this->idpUtility->getUserDataFromToken($VV);
        if (!empty($Ug)) {
            goto C9;
        }
        $rd = json_encode(["error" => "invalid_grant", "error_description" => "Access token not found"]);
        $this->response->setBody($rd);
        $this->response->setStatusCode(200);
        $this->response->setHeader("Content-Type", "application/json", true);
        $this->response->setHeader("Content-Length", strlen($rd));
        $this->response->send();
        return;
        C9:
        $Rd = $Ug["user_id"];
        $oq = $Ug["access_token_expiry_time"];
        $this->idpUtility->log_debug("UserInfo: User Id: ", $Rd);
        if (!empty($Rd)) {
            goto E9;
        }
        $rd = json_encode(["error" => "invalid_grant", "error_description" => "Access Token could not be retreived. Please try again or contact your administrator"]);
        $this->response->setBody($rd);
        $this->response->setStatusCode(200);
        $this->response->setHeader("Content-Type", "application/json", true);
        $this->response->setHeader("Content-Length", strlen($rd));
        $this->response->send();
        return;
        goto U5;
        E9:
        $Es = $this->idpUtility->ValidateAccessToken($oq);
        $this->idpUtility->log_debug("UserInfo: accessTokenValidationResult: ", $Es);
        if (!$Es) {
            goto gZ;
        }
        $rd = json_encode(["error" => "invalid_grant", "error_description" => "Access token has expired"]);
        $this->response->setBody($rd);
        $this->response->setStatusCode(200);
        $this->response->setHeader("Content-Type", "application/json", true);
        $this->response->setHeader("Content-Length", strlen($rd));
        $this->response->send();
        return;
        gZ:
        U5:
        if (!$AG[IDPConstants::IS_BACKEND_SSO_ENABLED]) {
            goto to;
        }
        $Zf = $this->idpUtility->getAdminUserById($Rd);
        $this->idpUtility->log_debug("UserInfo: started email", $Zf->getEmail());
        $this->idpUtility->log_debug("UserInfo: started getUsername", $Zf->getUsername());
        $EF = (object) ["NameId" => $Zf->getEmail(), "firstName" => $Zf->getFirstName(), "lastName" => $Zf->getLastName(), "role_id" => $Zf->getRole()->getId()];
        $this->idpUtility->log_debug("Final userinfo object for backend user: ", $EF);
        $rd = json_encode($EF);
        $this->response->setBody($rd);
        $this->response->setStatusCode(200);
        $this->response->setHeader("Content-Type", "application/json", true);
        $this->response->setHeader("Content-Length", strlen($rd));
        $this->response->send();
        return;
        goto cC;
        to:
        $Zf = $this->customerRepository->getById($Rd);
        $Rd = $Zf->getId();
        $GV = $AG[IDPConstants::ATTRIBUTE_MAPPING];
        $rk = $AG[IDPConstants::CUSTOM_ATTRIBUTE_MAPPING];
        $this->idpUtility->log_debug("UserInfo: mapped_attrs: ", $GV);
        $Qq = $this->customerFactory->create()->load($Rd);
        $JM = $Qq->getData();
        $this->idpUtility->log_debug("customer_entity attributes : ", $JM);
        $Eo = $Qq->getDefaultBilling();
        $TO = $Qq->getDefaultShipping();
        $this->idpUtility->log_debug("billing address id : ", $Eo);
        $this->idpUtility->log_debug("shipping address id : ", $TO);
        $qC = $this->_addressFactory->create()->load($Eo);
        $y4 = $this->_addressFactory->create()->load($TO);
        if (!isset($qC)) {
            goto PK;
        }
        $kC = $qC->getData();
        PK:
        if (!isset($y4)) {
            goto wh;
        }
        $mY = $y4->getData();
        wh:
        $EF = (object) ["NameId" => $Zf->getEmail()];
        if (!($GV != null)) {
            goto jj;
        }
        $GV = json_decode((string) $GV);
        foreach ($GV as $hO => $TC) {
            if (isset($JM[$TC])) {
                goto Y8;
            }
            if (isset($kC[$TC])) {
                goto Q6;
            }
            if (!isset($mY[$TC])) {
                goto wD;
            }
            $EF->{$hO} = $mY[$TC];
            wD:
            goto JJ;
            Q6:
            $EF->{$hO} = $kC[$TC];
            JJ:
            goto dx;
            Y8:
            $EF->{$hO} = $JM[$TC];
            dx:
            CF:
        }
        Jn:
        jj:
        if (!($rk != NULL)) {
            goto De;
        }
        $rk = json_decode((string) $rk);
        foreach ($rk as $hO => $TC) {
            $EF->{$hO} = $TC;
            BJ:
        }
        E4:
        De:
        $this->idpUtility->log_debug("UserInfo: genericObject after adding attribute mapping: ", $EF);
        $rd = json_encode($EF);
        $this->idpUtility->log_debug("UserInfo: final json to be sent in response: ", $rd);
        $this->response->setBody($rd);
        $this->response->setStatusCode(200);
        $this->response->setHeader("Content-Type", "application/json", true);
        $this->response->setHeader("Content-Length", strlen($rd));
        $this->response->send();
        return;
        cC:
    }
    public function createCsrfValidationException(RequestInterface $De) : ?InvalidRequestException
    {
        return null;
    }
    public function validateForCsrf(RequestInterface $De) : ?bool
    {
        return true;
    }
}



© 2023 Quttera Ltd. All rights reserved.