PluginProbe
WebTotem Security / 2.2.2
WebTotem Security v2.2.2
3.0.2 3.0.1 3.0.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.1 2.2.2 2.2.3 All 110 releases
← All changes | library/WT.php +12 -17 2.1.92.2.2 View file →
@@ -2,14 +2,14 @@
2 2
3 3
4 4 class WTSEC_LIBRARY_WT
5 5 {
6 +
6 7 const URL = "https://api.wtotem.com/graphql";
7 -// const URL = "https://api-1.2ke2xgwx4.wtotem.com/graphql";
8 8
9 9 public static function auth($key)
10 10 {
11 - $payload = '{"query":"mutation{\n guest{\n apiKeys{\n auth(apiKey:\"' . $key . '\"),{\n token{\n value,refreshToken,expiresIn\n }\n }\n }\n }\n}"}';
11 + $payload = '{"query":"mutation{ guest{ apiKeys{ auth(apiKey:\"' . $key . '\"),{ token{ value,refreshToken,expiresIn } } } } }"}';
12 12 return self::requestApi($payload);
13 13 }
14 14
15 15 protected static function requestApi($payload, $token = false, $repeat = false)
@@ -18,9 +18,9 @@
18 18 $token = WTSEC_LIBRARY_App::getToken();
19 19 }
20 20 $args = [
21 21 'body' => $payload,
22 - 'timeout' => '30',
22 + 'timeout' => '60',
23 23 'sslverify' => false,
24 24 'headers' => ['Content-Type:application/json', 'Content-Type' => 'application/json', 'source:WORDPRESS', 'Accept: application/json'],
25 25 ];
26 26 if (!is_null($token) && $token) {
@@ -30,9 +30,9 @@
30 30 $response = wp_remote_post(self::URL, $args);
31 31 $httpcode = wp_remote_retrieve_response_code($response);
32 32
33 33 if ($httpcode < 200) {
34 - WTSEC_LIBRARY_Session::setNotification("error", WTSEC_LIBRARY_Localization::lmsg('could_not_connect_to_the_server')." requestApi");
34 + WTSEC_LIBRARY_Session::setNotification("error", WTSEC_LIBRARY_Localization::lmsg('could_not_connect_to_the_server'));
35 35 }
36 36 $response = wp_remote_retrieve_body($response);
37 37 $result = json_decode($response, true);
38 38 if (isset($result['errors'][0]['message'])) {
@@ -100,10 +100,11 @@
100 100 return $response;
101 101 }
102 102
103 103
104 - public static function getFileByUrl($url)
104 + public static function getFileByUrl($url, $fileName)
105 105 {
106 + $url = $url.'/'.$fileName;
106 107 $args = [
107 108 'timeout' => '30',
108 109 'sslverify' => false,
109 110 ];
@@ -111,17 +112,11 @@
111 112 $httpcode = wp_remote_retrieve_response_code($response);
112 113 if ($httpcode < 200) {
113 114 WTSEC_LIBRARY_Session::setNotification("error", WTSEC_LIBRARY_Localization::lmsg('could_not_connect_to_the_server')." getFileByUrl");
114 115 }
115 - $filename = null;
116 - $metas = explode(";",$response['headers']["content-disposition"]);
117 - foreach ($metas as $meta){
118 - if(stripos($meta,"filename") !== false){
119 - $filename = trim(str_replace(["filename=","=","\""],"",$meta));
120 - }
121 - }
116 +
122 117 $response = wp_remote_retrieve_body($response);
123 - return ["body" => $response, "filename" => $filename];
118 + return ["body" => $response, "filename" => $fileName];
124 119 }
125 120
126 121 public static function getOwnSite($attempt = false)
127 122 {
@@ -167,9 +162,9 @@
167 162 public static function getAllChecks($host_id)
168 163 {
169 164 $from = time() - (60 * 60 * 24);
170 165 $to = time();
171 - $from_waf = time() - (60 * 60 * 24 * 7);
166 + $from_waf = time() - (60 * 60 * 24 * 30);
172 167 $payload = '{"query":"query($id: ID!, $dateRange: DateRangeInput!) { auth { viewer { sites { one(id: $id) { ports { status ip tcp lastTest { time } } availability { status lastTest { time } responseTime downTime(dateRange: $dateRange) percent(dateRange: $dateRange) } deface { status lastTest { time } words count } domain { status registrar owner email createdDate expiredDate } ports { status lastTest { time } ip tcp country } ssl { status daysLeft expiryDate issueDate } reputation { status lastTest { time } virusList { virus{ type path } antiVirus } } firewall { lastTest { time } status chart(dateRange: $dateRange) { time attacks blocked } report(dateRange: $dateRange) { time attacks ip } } maliciousScript { lastTest { time } status } antivirus { status stats { changed deleted scaned infected error } lastTest { time } isFirstCheck } } } } } }","variables":{"id":"' . $host_id . '","dateRange":{"to":' . $to . ',"from":' . $from_waf . '}}}';
173 168 // $payload = '{"query":"query($id: ID!, $dateRange:DateRangeInput!) {\n auth {\n viewer {\n sites {\n one(id: $id) {\n ports{\n status\n ip\n tcp\n lastTest{\n time\n }\n }\n availability {\n status\n lastTest {\n time\n }\n responseTime\n downTime(dateRange: $dateRange)\n percent(dateRange: $dateRange)\n }\n deface {\n status\n lastTest {\n time\n }\n words\n count\n }\n domain {\n status\n registrar\n owner\n email\n createdDate\n expiredDate\n }\n ports {\n status\n lastTest {\n time\n }\n ip\n tcp\n country\n }\n ssl {\n status\n daysLeft\n expiryDate\n issueDate\n }\n reputation {\n status\n lastTest {\n time\n }\n virusList {\n viruses\n antiVirus\n }\n }\n firewall {\n lastTest { \n time\n } \n status\n logs{\n edges\n{\n node{\n status\n country\n type\n}\n}\n}\n chart(dateRange: $dateRange) {\n time\n attacks\n blocked\n }\n report(dateRange: $dateRange) {\n time\n attacks\n ip\n }\n }\n maliciousScript{\n lastTest{\n time\n }\n status\n }\n antivirus{\n status \n stats { \n changed\n deleted\n scaned\n infected\n error\n } \n lastTest { \n time\n } \n isFirstCheck\n }\n }\n }\n }\n }\n}","variables":{"id":"' . $host_id . '","dateRange":{"to":' . $to . ',"from":' . $from_waf . '}}}';
174 169 $response = self::requestApi($payload, true);
175 170 if (isset($response['data']['auth']['viewer']['sites']['one'])) {
@@ -197,9 +192,9 @@
197 192 }
198 193
199 194 public static function generateAmFile($id)
200 195 {
201 - $payload = '{"operationName":null,"variables":{},"query":"mutation {\n auth {\n am {\n install(siteId: \"'.$id.'\")\n }\n }\n}\n"}';
196 + $payload = '{ "operationName":null, "variables":{}, "query":"mutation { auth { am { install(siteId: \"'.$id.'\"){ downloadLink, amFilename, wafFilename, avFilename } } } }"}';
202 197 return self::requestApi($payload, true);
203 198 }
204 199
205 200 public static function checkStatus($id, $service)
@@ -207,9 +202,8 @@
207 202 $payload = '{"operationName":null,"variables":{"id":"' . $id . '"},"query":"query ($id: ID!) {\n auth {\n viewer {\n sites {\n one(id: $id) {\n ... on Site {\n configs {\n ... on ' . $service . 'Config {\n isActive\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"}';
208 203 return self::requestApi($payload, true);
209 204 }
210 205
211 -
212 206 public static function getAntivirus($host_id, $limit = 10, $cursor = null, $days = 365, $event = 'infected')
213 207 {
214 208 $from = (is_array($days)) ? $days['begin'] : time() - (60 * 60 * 24 * $days);
215 209 $to = (is_array($days)) ? $days['end'] : time();
@@ -388,5 +382,6 @@
388 382 public static function getScore(){
389 383 return self::requestURL("https://api.wtotem.com/site/score?url=".WTSEC_SITE_URL);
390 384 }
391 385
392 -}
386 +}
387 +