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 Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Message\ManagerInterface;
use MiniOrange\IDPSaml\Helper\IDPMessages;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use MiniOrange\IDPSaml\Helper\IDPUtility;
use DOMDocument;
use Magento\Customer\Model\Session;
use MiniOrange\IDPSaml\Controller\Actions\ProcessResponseAction;
use Magento\Framework\Session\SessionManagerInterface;
use MiniOrange\IDPSaml\Helper\Data;
use MiniOrange\IDPSaml\Helper\Saml2\SAML2Utilities;
use MiniOrange\IDPSaml\Helper\Saml2\SAML2Response;
use Magento\Framework\Controller\ResultFactory;
class IdpObserver extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
{
    private $requestParams = ["SAMLRequest", "SAMLResponse", "option"];
    protected $messageManager;
    protected $idpUtility;
    protected $request;
    protected $formkey;
    protected $acsUrl;
    protected $customerSession;
    protected $session;
    protected $data;
    protected $urlInterface;
    protected $utilities;
    protected $redirect;
    protected $eventManager;
    protected $context;
    private $testAction;
    protected $resultFactory;
    public function __construct(ManagerInterface $Hr, Context $FF, IDPUtility $Ng, RequestInterface $De, FormKey $vC, Session $d9, SessionManagerInterface $Cw, Data $Ti, \Magento\Framework\Event\ManagerInterface $HA, \Magento\Framework\UrlInterface $L8, SAML2Utilities $wa, ShowTestResultsAction $bu, \Magento\Framework\Controller\ResultFactory $Fb)
    {
        $this->messageManager = $Hr;
        $this->idpUtility = $Ng;
        $this->request = $De;
        $this->customerSession = $d9;
        $this->session = $Cw;
        $this->data = $Ti;
        $this->eventManager = $HA;
        $this->urlInterface = $L8;
        $this->utilities = $wa;
        $this->testAction = $bu;
        parent::__construct($FF);
        $this->context = $FF;
        $this->resultFactory = $Fb;
        $this->formkey = $vC;
        $this->getRequest()->setParam("form_key", $this->formkey->getFormKey());
    }
    public function createCsrfValidationException(RequestInterface $De) : ?InvalidRequestException
    {
        return null;
    }
    public function validateForCsrf(RequestInterface $De) : ?bool
    {
        return true;
    }
    public function execute()
    {
        if ($this->idpUtility->check_plan(2)) {
            goto Ha;
        }
        $this->idpUtility->checkIfValidLicense();
        goto vp;
        Ha:
        $this->idpUtility->checkTrialExpiry();
        vp:
        if ($this->idpUtility->check_plan(2)) {
            goto jM;
        }
        $AV = $this->idpUtility->getStoreConfig(IDPConstants::REG_STATUS);
        $TU = isset($AV) ? true : false;
        $gJ = $TU && $AV != '' && $AV == "MO_VERIFIED" ? true : false;
        $AG = null;
        if ($gJ) {
            goto dg;
        }
        return $this->getResponse()->setBody("Please activate the plugin from Magento dashboard in order to perform the SSO.");
        dg:
        jM:
        $this->idpUtility->log_debug("Inside IDP Observer exceute");
        $lw = $this->request->getParams();
        if (is_array($_POST) && !empty($_POST)) {
            goto Ag;
        }
        $ae = IDPConstants::HTTP_Redirect_Binding;
        goto O5;
        Ag:
        $ae = IDPConstants::HTTP_POST_Binding;
        O5:
        if (!(isset($lw["RelayState"]) && isset($lw["SAMLResponse"]))) {
            goto MV;
        }
        $C9 = $lw["SAMLResponse"];
        $C9 = base64_decode((string) $C9);
        $this->idpUtility->log_debug("samlResponse", print_r($C9, true));
        if (!empty($lw["SAMLResponse"])) {
            goto D1;
        }
        $C9 = gzinflate($C9);
        D1:
        $uC = new \DOMDocument();
        $uC->loadXML($C9);
        $hN = $uC->firstChild;
        if (!($hN->localName == "LogoutResponse")) {
            goto J1;
        }
        $this->logout->setRequestParam($this->REQUEST)->setPostParam($this->POST)->execute();
        J1:
        $C9 = new SAML2Response($hN, $this->idpUtility);
        $x1 = current($C9->getAssertions())->getAttributes();
        $Wl = current(current($C9->getAssertions())->getNameId());
        $x1["NameID"] = array($Wl);
        $this->testAction->setAttrs($x1)->setNameId($x1["NameID"][0])->execute();
        exit;
        MV:
        if (isset($lw["RelayState"])) {
            goto f1;
        }
        $u2 = "/";
        goto hm;
        f1:
        $u2 = $lw["RelayState"];
        $this->idpUtility->log_debug("After RelayState ");
        hm:
        $this->idpUtility->setSessionData("RelayState", $u2);
        if (isset($lw["SAMLRequest"])) {
            goto iu;
        }
        if ($this->customerSession->authenticate()) {
            goto vc;
        }
        $this->idpUtility->log_debug("Redirect login page");
        $e1 = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
        $e1->setPath("customer/account/login");
        return $e1;
        goto Sw;
        vc:
        $this->idpUtility->log_debug("In IDP initiated");
        $XE = new ProcessResponseAction($this->customerSession, $this->idpUtility, $this->data, $this->session, $this->messageManager, $this->eventManager, $this->urlInterface, $this->utilities, $this->context);
        if (isset($lw["app_name"])) {
            goto wJ;
        }
        goto dl;
        wJ:
        $AG = null;
        $U1 = null;
        $lQ = null;
        $jK = trim($lw["app_name"]);
        $AG = $this->idpUtility->fetchspallDetails("miniorange_sp_table", $jK);
        dl:
        if (isset($AG[0]["issuer"])) {
            goto a0;
        }
        goto Vy;
        a0:
        $U1 = $AG[0]["issuer"];
        Vy:
        if (isset($AG[0]["acs_url"])) {
            goto Jy;
        }
        goto CN;
        Jy:
        $lQ = $AG[0]["acs_url"];
        CN:
        $this->idpUtility->log_debug("In IDP initiated call to mo_idp_authorize_user function");
        $XE->mo_idp_authorize_user($lQ, $U1, $u2);
        Sw:
        goto rC;
        iu:
        $XE = new ProcessResponseAction($this->customerSession, $this->idpUtility, $this->data, $this->session, $this->messageManager, $this->eventManager, $this->urlInterface, $this->utilities, $this->context);
        if ($XE->_read_saml_request($lw, $lw["SAMLRequest"], $ae)) {
            goto XH;
        }
        print_r("Bad Request(Your request resulted in an error. Unknown Issuer)");
        exit;
        XH:
        $this->idpUtility->log_debug("After SAMLRequest ");
        if ($this->customerSession->authenticate()) {
            goto T0;
        }
        $this->idpUtility->log_debug("user not authenticated");
        $this->idpUtility->setSessionData("flag", true);
        $e1 = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
        $e1->setPath("customer/account/login");
        return $e1;
        goto DG;
        T0:
        $this->idpUtility->log_debug("user already authenticated");
        $XE = new ProcessResponseAction($this->customerSession, $this->idpUtility, $this->data, $this->session, $this->messageManager, $this->eventManager, $this->urlInterface, $this->utilities, $this->context);
        $U1 = $this->idpUtility->getStoreConfig(IDPConstants::ISSUER);
        $lQ = $this->idpUtility->getAcsUrl();
        $eE = $XE->_read_saml_request($lw, $lw["SAMLRequest"], $ae);
        if (!isset($eE)) {
            goto gD;
        }
        $U1 = $eE;
        gD:
        if (!isset($this->idpUtility->getacs("miniorange_sp_table", $eE)[0]["acs_url"])) {
            goto Ps;
        }
        $lQ = $this->idpUtility->getacs("miniorange_sp_table", $eE)[0]["acs_url"];
        Ps:
        $lD = $this->idpUtility->getSessionData("inResponseTo");
        $this->idpUtility->unsetSessionData("inResponseTo");
        $this->idpUtility->log_debug("call to mo_idp_authorize_user function");
        $XE->mo_idp_authorize_user($lQ, $U1, $u2, $lD);
        DG:
        rC:
    }
}



© 2023 Quttera Ltd. All rights reserved.