Autojs Dex加密混淆 (魔改Rhino)

QQ: 1659809758

內容發佈日期 ↓ 2020.06.06

GitHub

魔改 Rhino 源碼 ,
使用IDEA 運行 java 進行 js 轉 dex
https://github.com/xxxxue/Autojs_Rhino_Dex_Self




內容發佈日期 ↓ 2020.05.06

GitHub

家(203118908) 大佬開源的地址
https://github.com/snailuncle/batchJs2Dex

倉庫應該已經更新了 , 點擊進入 這篇博文中使用的分支,

1. JS混淆

JS 混淆 網址 :

http://jshaman.com/protect.html

混淆 配置

  1. 混淆之前 將 UI 剪切 出來

  2. 勾選 下圖的 變量和函數名 混淆
    在這裏插入圖片描述

  3. 混淆成功後 將 JS 代碼 粘貼到 VSCode 中 並將 UI代碼 粘貼到 對應的 位置

  4. 手動批量 將 {{ 綁定值 }} 格式的 UI 綁定 .修改爲 混淆後的變量名

  5. 使用 VSCode運行 … 確定 無誤後 將 JS 代碼 放入 aaa.js

2. JS轉class

自己新建一個 bat 文件, 雙擊 運行

aaa.js 文件 地址 改爲你自己電腦上的路徑

-nosource 編譯後的class 去掉 js 源碼
-encoding 設置 編碼格式. 默認的 是 GBK 會 中文亂碼


@echo off
Setlocal enabledelayedexpansion
echo org.mozilla.javascript.tools.jsc.Main.main(["-nosource","-encoding", "UTF-8","E:/Work/GitHub/batchJs2Dex/other/aaa.js"]) | java -jar rhino1712.jar 
pause && exit


3. class 轉 dex

使用之前,請確保 自己的 android dx 配置了 環境變量

在這裏插入圖片描述

自己新建一個 bat 文件, 雙擊 運行

start cmd /k "dx --dex --output =aaa.dex aaa.class"

4. 最終目錄結構圖

最終目錄結構

Dex 熱更新 例子

Autojs 版本

免費版 4.1.1
其他版本 出錯的話,自己改一改

如果調試 Dex 依然是 亂碼的話,
就試一試 打包後的apk,
打包的apk 執行Dex 不亂碼 就可以了

DexVersion 內容 格式:

在這裏插入圖片描述

代碼



"ui";

var DexName = "aaa.dex";
var DexVersionName = "DexVersion.js";
//本地文件
var LocalDirPath = "/sdcard/代碼俠輔助/";
var LocalDexPath = LocalDirPath + DexName;
var LocalVersionFilePath = LocalDirPath + DexVersionName;

//網絡文件
var RemoteHost = "http://自己的地址/";
var RemoteDexFilePath = RemoteHost + DexName;
var RemoteVersionFilePath = RemoteHost + DexVersionName;


var Header = {
  headers: {
    "User-Agent":
      "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3754.400 QQBrowser/10.5.4034.400 ",
  },
};
/**
 * 開始運行
 */
function Run() {
  try {
    var checkState = false;

    //更新
    threads
      .start(function () {
        checkState = CheckVersion();
      })
      .join();

    if (checkState) {
      //加載dex並運行
      runtime.loadDex(LocalDexPath);
      new Packages["aaa"]()();
    }
  } catch (error) {
    toast("檢查更新狀態失敗\n" + error);
    console.warn("Run Error: " + error);
  }
}

/**
 * 檢查版本
 */
function CheckVersion() {
  var res = true;
  try {
    if (!files.exists(LocalVersionFilePath)) {
      console.log("創建版本文件");
      files.createWithDirs(LocalVersionFilePath);
      /** 默認值 */
      files.write(LocalVersionFilePath, "0.0.0");
    }

    var localVersion = files.read(LocalVersionFilePath);
    var remoteVersion = http.get(RemoteVersionFilePath,Header).body.string();

    if (localVersion != remoteVersion || !files.exists(LocalDexPath)) {
      console.warn("本地版本: " + localVersion);
      console.warn("遠程版本: " + remoteVersion);
      if (DownloadDex()) {
        files.write(LocalVersionFilePath, remoteVersion);
      } else {
        //res = false;
      }
    } else {
      toast("最新版,無需更新");
    }
  } catch (error) {
    console.warn("CheckVersion Error: " + error);
    toast("檢查版本發生異常\n" + error);
    //OpenLog();
  }
  return res;
}

/**
 * 下載Dex
 */
function DownloadDex() {
  var res = false;
  try {
    console.warn("dex開始更新");
    var res = http.get(RemoteDexFilePath,Header);
    if (Http200(res)) {
      files.writeBytes(LocalDexPath, res.body.bytes());
      if (files.exists(LocalDexPath)) {
        console.warn("dex更新成功");
        toast("更新成功");
        res = true;
      }
    } else {
      console.warn("DownloadDex 下載失敗:  " + res);
      toast("DownloadDex 下載失敗:  " + res);
      OpenLog();
      threads.shutDownAll();
      sleep(99999);
    }   
  } catch (error) {
    console.warn("DownloadDex Error: " + error);
    toast("下載新的dex 異常.\n" + error);
   // OpenLog();
  }

  return res;
}

/**
 * 判斷是否 不是 空
 * @param {any}} content 內容
 */
function IsNotNullOrEmpty(content) {
  return content != null && content != undefined && Trim(content).length > 0;
}

/**
 * http200驗證
 * @param {object} content http返回的json
 */
function Http200(content) {
  return (
    IsNotNullOrEmpty(content) &&
    (content.statusCode == 200 || content.statusCode == "200")
  );
}

/**
 * 去除左右空格
 * @param {string} content
 */
function Trim(content) {
  return (content + "").replace(/(^\s*)|(\s*$)/g, "");
}

function OpenLog() {
  ui.run(function () {
    // app.startActivity("console");
   
  });
}

Run();



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章