openwrt中的lua脚本和传统的luajit编译后的有点不一样,需要打几个补丁才能正常使用luadec进行反编译,在研究过程中走了很多弯路,把安装过程大概的记录了一下,命令如下


  47  cd ..
  48  mkdir luadec
  49  cd luadec/
  50  git clone https://github.com/viruscamp/luadec
  51  cd luadec/
  52  git submodule update --init lua-5.1
  53  cd lua-5.1
  54  make linux
  55  make clean
  56  mkdir patch
  57  cd patch/
  58  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch
  61  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/030-archindependent-bytecode.patch
  62  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/011-lnum-use-double.patch
  63  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/015-lnum-ppc-compat.patch
  64  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/020-shared_liblua.patch
  67  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/040-use-symbolic-functions.patch
  68  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/050-honor-cflags.patch
  69  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/100-no_readline.patch
  70  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/200-lua-path.patch
  71  wget https://dev.openwrt.org/export/HEAD/trunk/package/utils/lua/patches/300-opcode_performance.patch
  72  ls -lh|wc
  73  ls -lh
  74  cd ..
  75  mv patch/ patches
  76  for i in ../patches/*.patch; do patch -p1 <$i ; done
  77  for i in ./patches/*.patch; do patch -p1 <$i ; done
  78  make linux

修改 lua-5.1/src/MakeFile


  # USE_READLINE=1
  +PKG_VERSION = 5.1.5
  -CFLAGS= -O2 -Wall $(MYCFLAGS)
  +CFLAGS= -fPIC -O2 -Wall $(MYCFLAGS)
  - $(CC) -o [email protected] -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
  + $(CC) -o [email protected] $(LUA_O) $(MYLDFLAGS) -L. -llua $(LIBS)
  - $(CC) -o [email protected] -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
  + $(CC) -o [email protected] $(LUAC_O) $(MYLDFLAGS) -L. -llua $(LIBS)

执行


  make linux
  ldconfig
  cd ../luadec
  make LUAVER=5.1
  sudo cp luadec /usr/local/bin/

参考来源

http://storypku.com/2015/07/how-to-decompile-bytecoded-openwrt-lua-files/

  • 暂无评论

    添加新评论

  • Top