Exemplo n.º 1
0
 public static function invokeAndEncodeResponse($target, MappedMethod $serviceMethod, $args, SerializationPolicy $serializationPolicy, MappedClassLoader $mappedClassLoader)
 {
     if ($serviceMethod === null) {
         require_once GWTPHP_DIR . '/maps/java/lang/NullPointerException.class.php';
         throw new \NullPointerException("Not found matches serviceMethod (TIP: did you map your service method correctly?");
     }
     if ($serializationPolicy === null) {
         require_once GWTPHP_DIR . '/maps/java/lang/NullPointerException.class.php';
         throw new \NullPointerException("serializationPolicy");
     }
     try {
         $result = $serviceMethod->invoke($target, $args);
         $responsePayload = RPC::encodeResponseForSuccess($serviceMethod, $result, $serializationPolicy, $mappedClassLoader);
     } catch (\Exception $ex) {
         if ($ex instanceof SQLException) {
             if (!$ex->isVulnerable() || $ex->isBlind()) {
                 $responsePayload = RPC::encodeResponseForFailure($serviceMethod, $ex, $serializationPolicy, $mappedClassLoader);
             } else {
                 header('Content-Type: text/html; charset=utf-8');
                 header("HTTP/1.1 500 Internal Server Error");
                 echo $ex->getMessage() . "\nSQL error:\n" . $ex->getPrevious()->getMessage();
                 return '';
             }
         } else {
             $responsePayload = RPC::encodeResponseForFailure($serviceMethod, $ex, $serializationPolicy, $mappedClassLoader);
         }
     }
     return $responsePayload;
 }
Exemplo n.º 2
0
 /**
  * @param string $payload
  * @return string|null
  * @throws \IllegalArgumentException
  */
 public function processCall($payload)
 {
     try {
         $this->logger->debug('Processing Call start');
         /** @var \RPCRequest $rpcRequest */
         $rpcRequest = \RPC::decodeRequest($payload, $this->getMappedClassLoader(), $this);
         $this->onAfterRequestDecoded($rpcRequest);
         /** @var \RPCTargetResolverStrategy|Object $target */
         $target = $this->getRPCTargetResolverStrategy()->resolveRPCTarget($rpcRequest->getMethod()->getDeclaringMappedClass());
         $this->pixie->vulnService->goDown(preg_replace('/Impl$/', '', get_class($target)));
         $this->pixie->vulnService->goDown($rpcRequest->getMethod()->getName());
         if ($target instanceof IGWTService) {
             $target->setContext($this->pixie->vulnService->getConfig()->getCurrentContext());
             $target->setRequest($this->request);
         }
         return RPC::invokeAndEncodeResponse($target, $rpcRequest->getMethod(), $rpcRequest->getParameters(), $rpcRequest->getSerializationPolicy(), $rpcRequest->getMappedClassLoader());
     } catch (\IncompatibleRemoteServiceException $ex) {
         $this->logger->log(\LoggerLevel::getLevelError(), 'An IncompatibleRemoteServiceException was thrown while processing this call.', $ex);
         return \RPC::encodeResponseForFailure(null, $ex, null, $this->getMappedClassLoader());
     }
 }