PluginProbe
WebTotem Security / 2.3.7
WebTotem Security v2.3.7
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 +78 -15 2.2.22.3.7 View file →
@@ -3,9 +3,9 @@
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.wtotem.com/graphql";
8 8
9 9 public static function auth($key)
10 10 {
11 11 $payload = '{"query":"mutation{ guest{ apiKeys{ auth(apiKey:\"' . $key . '\"),{ token{ value,refreshToken,expiresIn } } } } }"}';
@@ -117,8 +117,16 @@
117 117 $response = wp_remote_retrieve_body($response);
118 118 return ["body" => $response, "filename" => $fileName];
119 119 }
120 120
121 +
122 + public static function getEmail(){
123 + $payload = '{"query":"query { auth { viewer { email __typename } __typename } }"}';
124 + $result = self::requestApi($payload, true);
125 +
126 + return $result['data']['auth']['viewer']['email'];
127 + }
128 +
121 129 public static function getOwnSite($attempt = false)
122 130 {
123 131 $payload = '{"query":"query getSites { auth { viewer { sites { ...sites __typename } __typename } __typename }}fragment sites on SiteQueries { list(filter: {}) { edges { node { id hostname title ssl { status __typename } availability { status __typename } reputation { status __typename } ports { status __typename } deface { status __typename } domain { status __typename } antivirus { status __typename } firewall { status __typename } maliciousScript { stack { name __typename } __typename } __typename } __typename } __typename } __typename}"}';
124 132
@@ -127,11 +135,9 @@
127 135 //mutator
128 136 foreach ($result['data']['auth']['viewer']['sites']['list']['edges'] as &$m) {
129 137 if (isset($m['node']['hostname'])) {
130 138 $m['node']['hostname'] = WTSEC_LIBRARY_Idn::idn_to_utf8($m['node']['hostname']);
131 -// if ($m['node']['id'] == "c2l0ZV8yNTg=") {
132 -// return $m['node'];
133 -// }
139 +
134 140 if (self::isSiteUrl($m['node']['hostname'])) {
135 141 return $m['node'];
136 142 }
137 143 }
@@ -160,13 +166,13 @@
160 166 }
161 167
162 168 public static function getAllChecks($host_id)
163 169 {
164 - $from = time() - (60 * 60 * 24);
170 + $from = time() - (60 * 60 * 24 * 7);
165 171 $to = time();
166 172 $from_waf = time() - (60 * 60 * 24 * 30);
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 . '}}}';
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 . '}}}';
173 + $language = WTSEC_LANGUAGE;
174 + $payload = '{"query":"query($id: ID!, $dateRange: DateRangeInput!, $language: Language!, $dateRangeWeek: 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 } } serverStatus { info { phpVersion phpServerUser phpServerSoftware phpGatewayInterface phpServerProtocol osInfo cpuCount cpuModel CpuFreq cpuFamily lsCpu maxExecTime mathLibraries } ramChart(dateRange: $dateRangeWeek){ total value time } cpuChart(dateRange: $dateRangeWeek){ value time } discUsage{ total free } status } maliciousScript { lastTest { time } status } scoring( language: $language ){ score lastTest{ time } result{ ip country isHigherThan }} agentManager{ statuses{ am{ time } } } antivirus { status stats { changed deleted scaned infected error } lastTest { time } isFirstCheck } } } } } }","variables":{"id":"' . $host_id . '","dateRange":{"to":' . $to . ',"from":' . $from_waf . '}, "dateRangeWeek":{"to":' . $to . ',"from":' . $from . '}, "language":"'.$language.'"}}';
169 175 $response = self::requestApi($payload, true);
170 176 if (isset($response['data']['auth']['viewer']['sites']['one'])) {
171 177 return $response['data']['auth']['viewer']['sites']['one'];
172 178 }
@@ -204,25 +210,71 @@
204 210 }
205 211
206 212 public static function getAntivirus($host_id, $limit = 10, $cursor = null, $days = 365, $event = 'infected')
207 213 {
208 - $from = (is_array($days)) ? $days['begin'] : time() - (60 * 60 * 24 * $days);
209 - $to = (is_array($days)) ? $days['end'] : time();
214 + $from = (is_array($days)) ? $days['from'] : time() - (60 * 60 * 24 * $days);
215 + $to = (is_array($days)) ? $days['to'] : time();
210 216 $cursor = ($cursor == null) ? 'null' : '"' . $cursor . '"';
211 - $payload = '{"operationName":null,"variables":{"id":"' . $host_id . '","avLogFilter":{"event":"'.$event.'","dateRange":{"to":'.$to.',"from":'.$from.'},"order":{"direction":"DESC","field":"time"},"pagination":{"first":' . $limit . ',"cursor":' . $cursor . '}}},"query":"query ($id: ID!, $avLogFilter: AvLogFilter!) { auth { viewer { sites { one(id: $id) { id ... on Site { configs { ... on AvConfig { isActive id } } } antivirus { status log(avLogFilter: $avLogFilter) { edges { node { filePath matches event signatures time } } pageInfo { endCursor hasNextPage __typename } } lastTest { time } stats { changed deleted scaned infected } } } } } } }"}';
217 + $payload = '{"operationName":null,"variables":{"id":"' . $host_id . '","avLogFilter":{"event":"'.$event.'","dateRange":{"to":'.$to.',"from":'.$from.'},"order":{"direction":"DESC","field":"time"},"pagination":{"first":' . $limit . ',"cursor":' . $cursor . '}}},"query":"query ($id: ID!, $avLogFilter: AvLogFilter!) { auth { viewer { sites { one(id: $id) { id ... on Site { configs { ... on AvConfig { isActive id } } } antivirus { status log(avLogFilter: $avLogFilter) { edges { node { filePath matches event signatures time permissions permissionsChanged } } pageInfo { endCursor hasNextPage __typename } } lastTest { time } stats { changed deleted scaned infected } } } } } } }"}';
212 218 return self::requestApi($payload, true);
213 219 }
214 220
215 - public static function getOptions($host_id)
221 + public static function getQuarantineList($host_id)
216 222 {
217 - $payload = '{"query":"query{\nuserHost(id:' . $host_id . '){\n id\n title\n hostname\n stack\n createdAt\n services {\n id\n name\n configs {\n id\n \tdata\n isActive\n }\n }\n }\n}"}';
223 + $payload = '{"query":"query{ auth{ viewer{ sites{ one(id:\"'.$host_id.'\"){ antivirus{ quarantine{ id path date } } } } } } } "}';
218 224 return self::requestApi($payload, true);
219 225 }
220 226
227 + public static function moveToQuarantine($host_id, $path)
228 + {
229 + $payload = '{"query":"mutation{ auth{ sites{ av{ moveToQuarantine(input:{ siteId:\"'.$host_id.'\", path:\"'.$path.'\" }) } } } } "}';
230 + return self::requestApi($payload, true);
231 + }
232 +
233 + public static function moveFromQuarantine($id)
234 + {
235 + $payload = '{"query":"mutation{ auth{ sites{ av{ moveFromQuarantine(id: \"'.$id.'\") } } } } "}';
236 + return self::requestApi($payload, true);
237 + }
238 +
239 + public static function reportsList($host_id, $limit = 10, $cursor = null)
240 + {
241 + $cursor = ($cursor == null) ? 'null' : '"' . $cursor . '"';
242 + $payload = '{"variables":{ "filter": { "order": { "direction": "DESC", "field": "created_at"}, "siteId":"'.$host_id.'", "pagination":{"first":' . $limit . ', "cursor":' . $cursor . '} } },"query":"query ReportsQuery($filter: ReportListFilter!) { auth { viewer { reports { list(filter: $filter) { edges { node { id site { hostname } createdAt wa dc ps rc sc av waf } cursor } pageInfo { endCursor hasNextPage } } } } } }"}';
243 + return self::requestApi($payload, true);
244 + }
245 +
246 + public static function reportGenerate($host_id, $period, $services, $language = "en")
247 + {
248 + $from = (is_array($period)) ? $period['from'] : time() - (60 * 60 * 24 * $period);
249 + $to = (is_array($period)) ? $period['to'] : time();
250 + $payload = '{"query":"query ($input: GenerateReportInput) { auth { viewer { reports { generate(input: $input) } } } }", "variables":{ "input": { "siteId": "' . $host_id . '", "from": ' . $from . ', "to": ' . $to . ', "wa": '.$services['wa'].', "dc": '.$services['dc'].', "ps": '.$services['ps'].', "rc": '.$services['rc'].', "sc": '.$services['sc'].', "av": '.$services['av'].', "waf": '.$services['waf'].', "language": "'.$language.'" } } }';
251 +
252 + return self::requestApi($payload, true);
253 + }
254 +
255 + public static function reportDownload($id)
256 + {
257 + $payload = '{"query": "query { auth { viewer { reports { download(id: \"' . $id . '\") } } } }"}';
258 + return self::requestApi($payload, true);
259 + }
260 +
261 + public static function getConfigs($host_id)
262 + {
263 + $payload = '{"query":"query{ auth{ viewer{ sites{ one(id:\"'.$host_id.'\"){ configs{ ... on WaConfig { id service isActive } ... on AvConfig { id service isActive } ... on DcConfig { id service isActive } ... on DecConfig { id service isActive } ... on RcConfig { id service isActive } ... on CmsConfig { id service isActive } ... on PsConfig { id service isActive } ... on WafConfig { id service isActive } } } } } } } "}';
264 + return self::requestApi($payload, true);
265 + }
266 +
267 + public static function toggleConfigs($service_id)
268 + {
269 + $payload = '{"query":"mutation{ auth{ configs{ toggle(id: \"'.$service_id.'\"){ ... on WaConfig { service isActive } ... on AvConfig { service isActive } ... on DcConfig { service isActive } ... on DecConfig { service isActive } ... on RcConfig { service isActive } ... on CmsConfig { service isActive } ... on PsConfig { service isActive } ... on WafConfig { service isActive } } } } } "}';
270 + return self::requestApi($payload, true);
271 + }
272 +
221 273 public static function getFirewall($host_id, $limit = 20, $cursor = null, $days = 365)
222 274 {
223 - $from = (is_array($days)) ? $days['begin'] : time() - (60 * 60 * 24 * $days);
224 - $to = (is_array($days)) ? $days['end'] : time();
275 + $from = (is_array($days)) ? $days['from'] : time() - (60 * 60 * 24 * $days);
276 + $to = (is_array($days)) ? $days['to'] : time();
225 277 $cursor = ($cursor == null) ? 'null' : '"'.$cursor.'"';
226 278
227 279 $payload = '{"operationName":"FirewallAttackLog","variables":{"dateRange":{"to":'.$to.',"from":'.$from.'},"id":"'.$host_id.'","wafLogFilter":{"dateRange":{"to":'.$to.',"from":'.$from.'},"order":{"direction":"DESC","field":"time"},"pagination":{"first":'.$limit.',"cursor":' . $cursor . '}}},"query":"query FirewallAttackLog($id: ID!, $wafLogFilter: WafLogFilter!, $dateRange: DateRangeInput!) { auth { viewer { sites { one(id: $id) { firewall { lastTest { time } status... FirewallLogFragment map(dateRange: $dateRange) { attacks, country } __typename } __typename } __typename } __typename } __typename } } fragment FirewallLogFragment on Waf { logs(wafLogFilter: $wafLogFilter) { edges { cursor node { type blocked payload ip location { country { nameEn __typename } __typename } time request status country category __typename } __typename } pageInfo { endCursor hasNextPage __typename } __typename } __typename }"}';
228 280 $res = self::requestApi($payload, true);
@@ -235,10 +287,21 @@
235 287 $to = time();
236 288 $from_waf = ($days <= 1) ? strtotime(date('Y-m-d 00:00:01')) : time() - (60 * 60 * 24 * $days);
237 289
238 290 $payload = '{ "query":"query($id: ID!, $dateRange: DateRangeInput!, $wafLogFilter: WafLogFilter!) { auth { viewer { sites { one(id: $id) { firewall { lastTest { time } status logs(wafLogFilter: $wafLogFilter) { edges { node { status country type userAgent } } } chart(dateRange: $dateRange) { time attacks blocked } report(dateRange: $dateRange) { time attacks ip } } } } } } }", "operationName":null,"variables":{"id":"' . $host_id . '","dateRange":{"to":' . $to . ',"from":' . $from_waf . '}, "wafLogFilter": { "dateRange": { "from": ' .$from_waf. ', "to": ' .$to. ' }, "pagination": { "cursor": null }, "order": { "direction": "DESC", "field": "time" } } } }';
291 + $response = self::requestApi($payload, true);
292 + return $response['data']['auth']['viewer']['sites']['one']['firewall']['chart'];
293 + }
239 294
240 - return self::requestApi($payload, true);
295 + public static function getServerStatusChart($host_id, $days = 7)
296 + {
297 + $to = time();
298 + $from = ($days <= 1) ? strtotime(date('Y-m-d 00:00:01')) : time() - (60 * 60 * 24 * $days);
299 +
300 + $payload = '{ "query":"query($id: ID!, $dateRange: DateRangeInput!) { auth { viewer { sites { one(id: $id) { serverStatus { ramChart(dateRange: $dateRange){ total value time } cpuChart(dateRange: $dateRange){ value time } } } } } } }", "variables":{"id":"' . $host_id . '","dateRange":{"to":' . $to . ',"from":' . $from . '} } }';
301 +
302 + $response = self::requestApi($payload, true);
303 + return $response['data']['auth']['viewer']['sites']['one']['serverStatus'];
241 304 }
242 305
243 306 public static function getStatusIcon($status)
244 307 {