马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
js逆向常用代码
加载
- const loadingStyle = `
- #loadingDiv {
- position: fixed;
- z-index: 9999;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(255, 255, 255, 0.8);
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- }
- .loader {
- border: 16px solid #f3f3f3;
- border-radius: 50%;
- border-top: 16px solid #3498db;
- width: 120px;
- height: 120px;
- animation: spin 2s linear infinite;
- }
- .loading-text {
- margin-top: 20px;
- font-size: 20px;
- color: #333;
- }
- @keyframes spin {
- 0% { transform: rotate(0deg); }
- 100% { transform: rotate(360deg); }
- }
- `;
- const loadingHTML = `
- <div id="loadingDiv">
- <div class="loader"></div>
- <div class="loading-text">正在生成</div>
- </div>
- `;
- // 显示加载页面的方法
- function showLoadingScreen() {
- // 创建样式元素并插入到head中
- const style = document.createElement("style");
- style.type = "text/css";
- style.id = "loadingStyle";
- style.innerHTML = loadingStyle;
- document.head.appendChild(style);
- // 创建加载层元素并插入到body中
- const loadingDiv = document.createElement("div");
- loadingDiv.innerHTML = loadingHTML;
- document.body.appendChild(loadingDiv);
- }
- // 隐藏加载页面的方法
- function hideLoadingScreen() {
- const loadingDiv = document.getElementById("loadingDiv");
- if (loadingDiv) {
- loadingDiv.style.display = "none";
- }
- const style = document.getElementById("loadingStyle");
- if (style) {
- style.remove();
- }
- }
复制代码 拦截图片天生
- var originalCreateObjectURL = URL.createObjectURL;
- // 重写createObjectURL方法
- URL.createObjectURL = function (blob) {
- // 调用原始的createObjectURL方法,并返回其结果
- var originalResult = originalCreateObjectURL(blob);
- // 返回重写后的结果
- return originalResult;
- };
复制代码- // 保存原始的 Image 构造函数
- const OriginalImage = window.Image;
- // 创建一个自定义的 Image 构造函数
- function CustomImage() {
- const img = new OriginalImage();
- // 定义一个 setter 拦截 src 属性
- Object.defineProperty(img, "src", {
- set: function (url) {
- // 继续设置 src 属性
- img.setAttribute("src", url);
- },
- });
- return img;
- }
- window.Image = CustomImage;
复制代码- const originalCreateElement = document.createElement;
- // 重写 createElement 方法
- document.createElement = function (tagName) {
- const element = originalCreateElement.call(document, tagName);
- if (tagName.toLowerCase() === "img") {
- // 定义一个 setter 拦截 src 属性
- Object.defineProperty(element, "src", {
- set: function (url) {
-
- element.setAttribute("src", url);
- },
- get: function () {
- return element.getAttribute("src");
- },
- });
- }
- return element;
- };
复制代码 拦截apply函数
- const originalApply = Function.prototype.apply;
- Object.defineProperty(Function.prototype, "apply", {
- value: function (target, thisArg, argArray) {
-
- // 调用原始的 apply 方法
- return originalApply.call(this, target, thisArg, argArray);;
- },
- });
复制代码 拦截Function的构建函数
- Function.prototype.constructor_ = Function.prototype.constructor;
- Function.prototype.constructor=function Function(){
- console.log(arguments)
- return this.constructor_(...arguments)
- }
复制代码 拦截Vue加载
- // 创建一个 MutationObserver 实例
- const observer = new MutationObserver((mutationsList) => {
- for (const mutation of mutationsList) {
- if (mutation.type === "childList") {
- // 遍历新增的节点
- for (const addedNode of mutation.addedNodes) {
- if (addedNode.tagName === "SCRIPT") {
- const scriptSrc = addedNode.src;
- // 检查是否为 Vue.js 文件
- if (scriptSrc && scriptSrc.includes("vue")) {
- // 监听 script 标签的 load 事件
- addedNode.addEventListener("load", () => {
- console.log("Vue.js 文件加载成功");
- // 在这里可以执行你需要的操作
- // 例如检查 Vue 是否可用
- if (typeof Vue !== "undefined") {
- const originalBeforeCreate = Vue.options.beforeCreate || [];
- Vue.options.beforeCreate = [
- function () {
- console.log(
- "Vue instance is about to be created.",
- this
- );
- debugger
- // 在这里添加自定义代码
- },
- ...originalBeforeCreate,
- ];
- }
- });
- }
- }
- }
- }
- }
- });
- // 配置观察选项
- const config = { childList: true, subtree: true };
- // 开始观察 document.body
- observer.observe(document.head, config);
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
|