Guest User

Untitled

a guest
Aug 11th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 15.05.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace JetBackup\Core\License;
  15.  
  16. class License
  17. {
  18. const LICENSE_CHECK_URL = 'https://check.jetlicense.com';
  19. const LICENSE_LOCALKEY_DAYS = 259200;
  20. const LICENSE_LOCALKEY_CHECK_INTERVAL = 172800;
  21. const LICENSE_LOCALKEY_FAIL_INTERVAL = 3510;
  22. const LICENSE_NOTIFY_ERROR_INTERVAL = 86400;
  23. const LICENSE_PRODUCT_ID = '58ac64be19a4643cdf582727';
  24. const LICENSE_PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----' . "\n" . 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2F105dMYw8kTC54ANpMt' . "\n" . 'WaVKEFEoRd+D0YDRDB/EGgFbEUdkDvub6FfHcDdgfmRgjUOWap0yX2MpOCy/QA/P' . "\n" . 'SrIuSYe4+jv5J+cW2O6WbnhVdlAQTLOiOgiUYMuFNt6+gx4DaitoxD/p39elThfa' . "\n" . 'KsAawrrxBR0mEdn0JeE1k0l/bbhekzUubR9LReOtveXdMoVygrAQ52mQ0saOSmuB' . "\n" . 'Un2oa4kaWeZfCA/fYW8jMEEjmrftcT3XVi7yA5Fk/xQQ3eNSLIAx2gZf8B2g0zqa' . "\n" . '/QSq9+6BDM/6OdG9o+cMvpSoOojx5ApcQxAwHfSiISfibJ/49kmnP7okCRI7pNvE' . "\n" . '3wIDAQAB' . "\n" . '-----END PUBLIC KEY-----';
  25. const STATUS_ACTIVE = 'Active';
  26. const STATUS_TRIAL = 'Trial';
  27. const STATUS_TRIAL_EXPIRED = 'TrialExpired';
  28. const STATUS_CANCELLED = 'Cancelled';
  29. const STATUS_INVALID = 'Invalid';
  30.  
  31. /**
  32. * @return string
  33. */
  34. static private function _handshake()
  35. {
  36. if (file_exists('/sys/class/dmi/id/product_uuid')) {
  37. $code = \JetBackup\Core\IO\Shell::exec('/bin/cat /sys/class/dmi/id/product_uuid', $response);
  38. if (!$code && isset($response[0])) {
  39. return md5($response[0]);
  40. }
  41. }
  42.  
  43. if (file_exists('/var/lib/dbus/machine-id')) {
  44. $code = \JetBackup\Core\IO\Shell::exec('/bin/cat /var/lib/dbus/machine-id', $response);
  45. if (!$code && isset($response[0])) {
  46. return md5($response[0]);
  47. }
  48. }
  49.  
  50. $code = \JetBackup\Core\IO\Shell::exec('/sbin/ifconfig -a | /bin/grep -i \'hwaddr\' | /bin/awk \' { print $5 } \' | /usr/bin/head -n1', $response);
  51. if (!$code && isset($response[0])) {
  52. return md5($response[0]);
  53. }
  54.  
  55. $code = \JetBackup\Core\IO\Shell::exec('/sbin/ip addr | /bin/grep -i \'ether\' | /bin/awk \' { print $2 } \' | /usr/bin/head -n1', $response);
  56. if (!$code && isset($response[0])) {
  57. return md5($response[0]);
  58. }
  59.  
  60. $code = \JetBackup\Core\IO\Shell::exec('/sbin/ifconfig -a | /bin/grep -i \'ether\' | /bin/awk \' { print $2 } \' | /usr/bin/head -n1', $response);
  61. if (!$code && isset($response[0])) {
  62. return md5($response[0]);
  63. }
  64.  
  65. if (file_exists('/etc/machine-id')) {
  66. $code = \JetBackup\Core\IO\Shell::exec('/bin/cat /etc/machine-id', $response);
  67. if (!$code && isset($response[0])) {
  68. return md5($response[0]);
  69. }
  70. }
  71.  
  72. return '';
  73. }
  74.  
  75. /**
  76. * @param $error
  77. * @param bool $force
  78. *
  79. * @throws JBException
  80. * @throws InvalidArgumentException
  81. * @throws MongoException
  82. */
  83. static private function _checkFailed($error, $force = false)
  84. {
  85. $license = \JetBackup\Core\Factory::getSettingsLicense();
  86. if ($force || ($license->getNotifyDate() < (time() - 21600))) {
  87. $license->setNotifyDate();
  88. $license->save();
  89. \JetBackup\Core\Alert\Alert::add('License check failed', 'There was a failed license check. Error: ' . $error, \JetBackup\Core\Alert\Alert::LEVEL_WARNING);
  90. }
  91. }
  92.  
  93. /**
  94. * @param bool $reset
  95. * @param string $message
  96. * @throws JBException
  97. */
  98. static private function _handleNotify($reset = false, $message = '')
  99. {
  100. $license = \JetBackup\Core\Factory::getSettingsLicense();
  101. $update_time = NULL;
  102.  
  103. if ($reset) {
  104. $update_time = 0;
  105. }
  106. else if (!$license->getNotifyDate()) {
  107. $update_time = time() + self::LICENSE_NOTIFY_ERROR_INTERVAL;
  108. }
  109. else if ($license->getNotifyDate() < time()) {
  110. self::_checkFailed($message, true);
  111. $update_time = 0;
  112. }
  113.  
  114. if ($update_time != NULL) {
  115. $license->setNotifyDate($update_time);
  116. $license->save();
  117. }
  118. }
  119.  
  120. /**
  121. * @throws LicenseException
  122. * @throws JBException
  123. */
  124. static public function retrieveLocalKey()
  125. {
  126. $license = \JetBackup\Core\Factory::getSettingsLicense();
  127. $localkey_details = new LicenseLocalKey();
  128. $handshake = self::_handshake();
  129.  
  130. if (!$handshake) {
  131. $message = 'Unable to get server handshake key';
  132. self::_checkFailed($message);
  133. $license->setLocalKeyInvalid($message, $localkey_details);
  134. $license->save();
  135. return NULL;
  136. }
  137.  
  138. $public_key = openssl_get_publickey(static::LICENSE_PUBLIC_KEY);
  139. $handshake_encrypted = '';
  140.  
  141. if (!openssl_public_encrypt($handshake, $handshake_encrypted, $public_key)) {
  142. $message = 'Unable to prepare handshake key for validation';
  143. self::_checkFailed($message);
  144. $license->setLocalKeyInvalid($message, $localkey_details);
  145. $license->save();
  146. return NULL;
  147. }
  148.  
  149. $panel_info = \JetBackup\Core\Entities\Util::getPanelInfo();
  150. $postfields = [
  151. 'output' => 'json',
  152. 'product_id' => static::LICENSE_PRODUCT_ID,
  153. 'handshake' => base64_encode($handshake_encrypted),
  154. 'info' => ['Hostname' => gethostname(), 'Panel_Name' => trim($panel_info['name']), 'Panel_Version' => trim($panel_info['version']), 'Product_Version' => trim(\JetBackup\Core\Entities\Util::getVersion()), 'Product_Tier' => trim($panel_info['tier']), 'Kernel_Release' => php_uname('r'), 'Kernel_Version' => php_uname('v')]
  155. ];
  156.  
  157. try {
  158. $http = new \GuzzleHttp\Client();
  159. $response = $http->request('POST', self::LICENSE_CHECK_URL, ['form_params' => $postfields]);
  160. .........................................................................
  161. ........................................
  162. ....................
Add Comment
Please, Sign In to add comment