j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
870 stars 100 forks source link

connot resolve webpack bundle like no entry #68

Open AILHC opened 6 months ago

AILHC commented 6 months ago

Describe the bug

connot resolve webpack bundle like no entry

Expected Behaviour

unpack this bundle

Code

(()=>{
var __webpack_modules__ = {...};
var __webpack_module_cache__ = {};
  function __webpack_require__(e) {
    var t = __webpack_module_cache__[e];
    if (t !== undefined) {
      return t.exports;
    }
    var i = __webpack_module_cache__[e] = {
      exports: {}
    };
    __webpack_modules__[e].call(i.exports, i, i.exports, __webpack_require__);
    return i.exports;
  }
  __webpack_require__.d = (e, t) => {
    for (var i in t) {
      if (__webpack_require__.o(t, i) && !__webpack_require__.o(e, i)) {
        Object.defineProperty(e, i, {
          enumerable: true,
          get: t[i]
        });
      }
    }
  };
  __webpack_require__.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
  __webpack_require__.r = e => {
    if (typeof Symbol != "undefined" && Symbol.toStringTag) {
      Object.defineProperty(e, Symbol.toStringTag, {
        value: "Module"
      });
    }
    Object.defineProperty(e, "__esModule", {
      value: true
    });
  };
  var __webpack_exports__ = {};
  (() => {
    "use strict";

    const e = __webpack_require__(9896);
    const t = __webpack_require__(1914);
    const i = __webpack_require__(1441);
    const n = __webpack_require__(4718);
    const s = __webpack_require__(3890);
    const a = __webpack_require__(6324);
    const r = __webpack_require__(5026);
    const o = __webpack_require__(2020);
    const l = __webpack_require__(2966);
    const h = __webpack_require__(2542);
    global.ShaderEditor = (0, e.createEditor)(class {
      constructor() {
        Editor.typeRegistry.addTypes(l.allTypes);
      }
      async onBeginPlay(e) {
        Editor.createAppMenu((0, o.createAppMenuTemplate)());
        Editor.setWindowTitle("Shader Blueprint");
        Editor.createHotkeyManager();
        await Editor.connectAssetDb();
        await Editor.connectShaderDb();
        let i = await gui.UIPackage.createWidget("~/ui/editor/MainView2.widget");
        this._mainView = i;
        i.name = "MainView";
        i.setSize(gui.GRoot.inst.width, gui.GRoot.inst.height);
        i.addRelation(gui.GRoot.inst, gui.RelationType.Size);
        gui.GRoot.inst.addChild(i);
        this._tabBar = new r.FileTabBar(i);
        this._tabBar.onTabSelected = (...e) => this.onTabSelected(...e);
        this._tabBar.onTabWillClose = (...e) => this.onTabWillClose(...e);
        this._tabBar.onTabSave = (...e) => this.onTabSave(...e);
        this.previewFrame = new s.WebIFrame();
        this.previewFrame.port.handle("materialPreviewReady", () => {
          this.previewFrame.ready = true;
          if (t.ScenePanel.ins) {
            t.ScenePanel.ins.autoBuild(0);
          }
        });
        this.previewFrame.load("preview.html");
        let n = i.getChild("panelManager", gui.Shape);
        Editor.createPanelManager({
          filePath: "shaderEditorLayout.json",
          layouts: {
            default: {
              mainPanelId: "ScenePanel"
            }
          }
        }, n);
        await this.setupPanels();
        Editor.panelManager.loadLayout();
        Editor.panelManager.start();
        if (e) {
          await this.onOpenFile(e);
        } else {
          await this.restoreTabs();
        }
      }
      async onBeforeEndPlay() {
        return this._tabBar.queryToCloseAllTabs(true);
      }
      async onEndPlay() {
        Editor.setHistoryDocuments(this._tabBar.getTabs().map(e => e.assetId || ""), this._tabBar.selectedIndex);
      }
      async onOpenFile(e) {
        let t = await Editor.assetDb.getAsset(e);
        if (t) {
          this.openFileInside(t, true);
        }
      }
      async restoreTabs() {
        let {
          files: e,
          active: t
        } = Editor.getHistoryDocuments();
        for (let t of e) {
          try {
            let e = await Editor.assetDb.getAsset(t);
            if (e) {
              await this.openFileInside(e, false);
            }
          } catch (e) {}
        }
        if (t < this._tabBar.tabCount) {
          this._tabBar.selectedTab = this._tabBar.getTabAt(t);
        }
      }
      async openFileInside(e, t) {
        let i;
        if ((i = this._tabBar.findTab(t => t.assetId == e.id)) == null) {
          i = {
            id: (0, h.genShortId2)(),
            assetId: e.id,
            fileType: e.type,
            isModified: false
          };
          this._tabBar.addTab(i, null, t);
        } else if (t) {
          this._tabBar.selectedTab = i;
        }
      }
      async _save(e, i, n) {
        t.ScenePanel.ins.save();
        return true;
      }
      async save(e) {
        return this._save(null, false, e);
      }
      async saveAs() {
        return this._save(null, true);
      }
      async saveAll() {
        for (let e of this._tabBar.getTabs()) {
          if (!(await this._save(e))) {
            break;
          }
        }
      }
      queryToSaveAll() {
        return this._tabBar.queryToSaveAllTabs();
      }
      async setupPanels() {
        let e = Editor.panelManager;
        await Promise.all([e.registerPanel("BlueprintUniformPanel", a.BlueprintUniformPanel, {
          title: "Params",
          icon: "~/ui/type-icons/panel/inspector.svg",
          stretchPriorityX: -1,
          stretchPriorityY: 100,
          location: "left"
        }), e.registerPanel("ScenePanel", t.ScenePanel, {
          title: "",
          icon: "~/ui/type-icons/panel/scene.svg",
          stretchPriorityX: 1,
          stretchPriorityY: 1
        }), e.registerPanel("BlueprintInspectorPanel", i.BlueprintInspectorPanel, {
          title: "Inspector",
          icon: "~/ui/type-icons/panel/inspector.svg",
          stretchPriorityX: -1,
          stretchPriorityY: 100,
          location: "left"
        }), e.registerPanel("BlueprintPreviewPanel", n.BlueprintPreviewPanel, {
          title: "Preview",
          icon: "~/ui/type-icons/panel/preview.svg",
          stretchPriorityX: -1,
          stretchPriorityY: 100,
          location: "left"
        })]);
      }
      async onTabWillClose(e, t) {
        let i = e.length == this._tabBar.tabCount;
        if (t) {
          for (let t of e) {
            if (t.isModified && !(await this._save(t))) {
              return;
            }
          }
        }
        let n = [];
        for (let t of e) {
          this._tabBar.removeTab(t.id);
        }
        if (n.length > 0) {
          await Promise.all(n);
        }
        if (i) {
          Editor.shutdown();
        }
      }
      async onTabSave(e) {
        for (let t of e) {
          t.isModified;
        }
      }
      async onTabSelected(e) {
        t.ScenePanel.ins.openFile(this._tabBar, e, e.assetId);
      }
    });
  })();

})()

Logs

No response

j4k0xb commented 6 months ago

That's being reworked atm in #50

It already detects bundles without an entry id (__webpack_require__.s = <id> or return __webpack_require__(<id>)) But what's left is extracting the entry module in the iife ((() => { ... })() at the bottom) instead of inside __webpack_modules__ image