"use strict";

const Base = require("../base");
const LANG = require("../../language"); // 插件语言库
const LANG_T = antSword["language"]["toastr"]; // 通用通知提示
class ScreenShot extends Base {
  exploit() {
    let self = this;
    self.core = this.top.core;
    let args = this.getArgs();
    let data = this.genPayload(args);
    let cellA = this.layout.cells("a");
    let cellB = this.layout.cells("b");
    self.core
      .request(data)
      .then((_ret) => {
        let res = antSword.unxss(_ret["text"], false);
        if (res === "") {
          res = "output is empty.";
        }
        switch (self.shelltype) {
          case "aspx":
            res = res.replace(/->\|/, "").replace(/\|<-/, ""); // 临时替换一下标签
          case "aspxcsharp":
          case "jspjs":
          case "jsp":
            let image = `<img width="100%" src="data:image/png;base64,${res}">`;
            self.safeHTML(cellA, image);
            break;
          default:
            break;
        }
        toastr.success(LANG["success"], LANG_T["success"]);
      })
      .catch((e) => {
        console.log(e);
        toastr.error(e.constructor === Object ? JSON.stringify(e) : e, "Error");
      });
  }
}
module.exports = ScreenShot;
