Code Monkey home page Code Monkey logo

luject's Introduction

luject

A static injector of dynamic library for application

Introduction (中文)

luject is a static injector of dynamic library for application. It support the following applications:

  • Android APK
  • iPhoneOS IPA
  • Windows Program (does not supported yet)
  • Linux Program
  • MacOS Program

If you want to know more, please refer to:

Prerequisites

XMake installed on the system. Available here.

Build

$ xmake

Installation

$ xmake install

Usage

$ luject -i app.apk lib1.so lib2.so
$ luject -i app.ipa lib1.dylib lib2.dylib
$ luject -i liba.so lib1.so lib2.so
$ luject -i app.exe lib1.dll lib2.dll
$ luject -i a.dll lib1.dll lib2.dll
$ luject -i liba.dylib lib1.dylib lib2.dyib
$ luject -i bin lib1.so lib2.so

Example

Inject libfrida-gadget.so to apk

Use frida tools to dynamically analyze the application. For details, see: frida

$ luject -i app.apk -p libtest /tmp/libfrida-gadget.so

libtest is a so library that requires matching injection in the apk, and supports pattern matching to achieve batch injection, for example: libtest_*.so, if you do not specify the -p parameter, all so are defaulted for batch full injection.

refs: How to use frida on a non-rooted device

Development

Build and run

$ xmake
$ xmake run luject -i [input] liba.so libb.so

Build and run tests

$ xmake build test
$ xmake run test

Contacts

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

luject's People

Contributors

waruqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luject's Issues

windows平台测试注入失败

环境:win10 1909
程序:test.exe,test.dll,均为vs2010编译
使用Actions中编译好的windows版本luject程序,将test.dll注入到test.exe程序,提示成功,生成了test_injected.exe 程序,但是经过测试发现,运行test_injected.exe, test.dll并没有被加载

/lib/armeabi not found!

  1. 错误信息:

luject -i aa.apk ../frida_lx/frida-gadget-15.1.1-android-x86_64.so
extract aa.apk
x86_64 found!
error: /var/folders/69/t_nd3vwx22n0wnrn13qtz4nr0000gn/T/.luject501/210913/aa.tmp/lib/armeabi not found!

  1. 命令行
    luject -i aa.apk ../frida_lx/frida-gadget-15.1.1-android-x86_64.so

  2. 操作系统 macos

  3. apk结构:

/lib/arm64-v8a/.so
/lib/armeabi -v7a/
.so

CentOS7 编译失败

`[username@vmi442840 luject]$ xmake
checking for platform ... linux
checking for architecture ... x86_64
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
-> lief 0.11.5
please input: y (y/n/m)
y
=> install lief 0.11.5 .. failed

/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c: In function ‘mbedtls_aes_crypt_ecb’:
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c:1031:9: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
// If padlock data misaligned, we just fall back to
^
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c:1031:9: warning: (this will be reported only once per input file) [enabled by default]
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c: At top level:
cc1: warning: unrecognized command line option "-Wno-expansion-to-defined" [enabled by default]
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c: In function ‘mbedtls_aesni_crypt_ecb’:
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c:100:43: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
asm( "movdqu (%3), %xmm0 \n\t" // load input
^
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c:100:43: warning: (this will be reported only once per input file) [enabled by default]
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c: At top level:
cc1: warning: unrecognized command line option "-Wno-expansion-to-defined" [enabled by default]
/home/username/.xmake/cache/packages/2307/l/lief/0.11.5/source/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aria.c:205:37: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
ta = *b; // 4567
^
if you want to get more verbose errors, please see:
-> /home/username/.xmake/cache/packages/2307/l/lief/0.11.5/installdir.failed/logs/install.txt
error: install failed!`

error: zip not found

Linux kali 5.7.0-kali1-amd64
Zip 3.0

root@kali:/home/kali# luject -i base.apk -p libcore libfrida-gadget.so
error: zip not found!

xmake时报错

执行xmake时报错。
所使用的的环境是Ubuntu 16.04,以下是报错详情截图:
image

xmake编译工程install lief报错

描述问题

xmake编译工程报错

  • @ #1. ### [期待的结果](###
    请尽量清晰精准地描述你所期待的结果。

错误信息

=> install lief 0.11.5 .. failed

/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c: In function ‘mbedtls_aesni_crypt_ecb’:
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c:100:43: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
asm( "movdqu (%3), %xmm0 \n\t" // load input
^
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c:100:43: warning: (this will be reported only once per input file) [enabled by default]
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c: In function ‘mbedtls_aes_crypt_ecb’:
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c:1031:9: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
// If padlock data misaligned, we just fall back to
^
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aes.c:1031:9: warning: (this will be reported only once per input file) [enabled by default]
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aesni.c: At top level:
cc1: warning: unrecognized command line option "-Wno-expansion-to-defined" [enabled by default]
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aria.c:205:37: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
ta = *b; // 4567
^
/root/.xmake/cache/packages/2206/l/lief/0.11.5/source/LIEF-0.11.5/build_5fd114f4/mbed_tls/src/lief_mbed_tls/library/aria.c:205:37: warning: (this will be reported only once per input file) [enabled by default]
cc1: warning: unrecognized command line option "-Wno-expansion-to-defined" [enabled by default]
if you want to get more verbose errors, please see:
-> /root/.xmake/cache/packages/2206/l/lief/0.11.5/installdir.failed/logs/install.txt
error: install failed!

相关环境

ubuntu3.6.2 x86_64
xmake按照示例安装的2.5.9 xmake-v2.5.9.gz.run
安装完成后
cd ./luject-master 目录进行
xmake 工程编译

win系统也试过,也是执行到lief安装报错

请问是不是我操作有问题

请提供编译和运行环境

图片
信息。

其他信息

请提供其他附加信息帮助我们诊断问题。

编译失败

~/Downloads/luject-1.0.5 xmake
[ 50%]: linking.release luject
error: Undefined symbols for architecture x86_64:
"lua_objlen(lua_State*, int)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_rawget(lua_State*, int)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_settop(lua_State*, int)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_pushnil(lua_State*)", referenced from:
lni_elf_detect_arch(lua_State*) in main.cpp.o
"lua_pushnumber(lua_State*, double)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_pushstring(lua_State*, char const*)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_elf_detect_arch(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_pushboolean(lua_State*, int)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_pushlstring(lua_State*, char const*, unsigned long)", referenced from:
lni_elf_detect_arch(lua_State*) in main.cpp.o
"luaL_checklstring(lua_State*, int, unsigned long*)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_elf_detect_arch(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
"lua_type(lua_State*, int)", referenced from:
lni_pe_add_libraries(lua_State*) in main.cpp.o
lni_elf_add_libraries(lua_State*) in main.cpp.o
lni_macho_add_libraries(lua_State*) in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

luject master xmake failed

xmake version :
xmake v2.7.9+20230515, A cross-platform build utility based on Lua



issue print to terminal

[ 25%]: cache compiling.release src/lni/main.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++14 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -isystem /home/jiachengy/.xmake/packages/l/libxmake/v2.7.1/e20dade54e864035be295e18a062200d/include -isystem /home/jiachengy/.xmake/packages/l/libxmake/v2.7.1/e20dade54e864035be295e18a062200d/include/lua -isystem /home/jiachengy/.xmake/packages/l/lief/0.11.5/5fd114f41ff6445fb276c359a1d679ec/include -DNDEBUG -o build/.objs/luject/linux/x86_64/release/src/lni/main.cpp.o src/lni/main.cpp
error: src/lni/main.cpp: In function ‘tb_int_t lni_pe_add_libraries(lua_State*)’:
src/lni/main.cpp:44:23: error: ‘lua_objlen’ was not declared in this scope; did you mean ‘lua_len’?
   44 |         tb_size_t n = lua_objlen(lua, 3);
      |                       ^~~~~~~~~~
      |                       lua_len
src/lni/main.cpp: In function ‘tb_int_t lni_elf_add_libraries(lua_State*)’:
src/lni/main.cpp:86:23: error: ‘lua_objlen’ was not declared in this scope; did you mean ‘lua_len’?
   86 |         tb_size_t n = lua_objlen(lua, 3);
      |                       ^~~~~~~~~~
      |                       lua_len
src/lni/main.cpp: In function ‘tb_int_t lni_macho_add_libraries(lua_State*)’:
src/lni/main.cpp:161:23: error: ‘lua_objlen’ was not declared in this scope; did you mean ‘lua_len’?
  161 |         tb_size_t n = lua_objlen(lua, 3);
      |                       ^~~~~~~~~~
      |                       lua_len
src/lni/main.cpp: In function ‘tb_int_t main(tb_int_t, tb_char_t**)’:
src/lni/main.cpp:223:30: warning: ISO C++ forbids converting a string constant to ‘tb_char_t*’ {aka ‘char*’} [-Wwrite-strings]
  223 |     tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null};
      |                              ^~~~~
src/lni/main.cpp:223:37: warning: ISO C++ forbids converting a string constant to ‘tb_char_t*’ {aka ‘char*’} [-Wwrite-strings]
  223 |     tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null};
      |                                     ^~~~
src/lni/main.cpp:223:43: warning: ISO C++ forbids converting a string constant to ‘tb_char_t*’ {aka ‘char*’} [-Wwrite-strings]
  223 |     tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null};
      |                                           ^~~~~~~~~~


extract failed!

提取APK时失败。

PS E:\项目\luject> xmake run luject -i .\xxx.apk -p libxlua.so .\frida-gadget-arm64.so
extract xxx.apk
error: extract failed!
error: execv(E:\项目\luject\build\windows\x64\release\luject.exe -i .\xxx.apk -p libxlua.so .\frida-gadget-arm64.so) failed(-1)

master branch xmake

Describe the problem details

Please describe your problem details here.
Clone master branch ,xmake show this issue

[ 5%]: cache compiling.release src/sv/sv/src/semvers.c
[ 5%]: cache compiling.release src/sv/sv/src/comp.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lj_debug.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lib_io.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lj_vmmath.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lj_mcode.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lj_opt_split.c
[ 6%]: cache compiling.release src/luajit/luajit/src/lib_debug.c
if you want to get more verbose errors, please see:
-> /Users/xxxxxx/.xmake/cache/packages/2209/l/libxmake/v2.5.9/installdir.failed/logs/install.txt
error: install failed!

detail logs :

[ 59%]: cache compiling.release src/tbox/tbox/src/tbox/platform/ifaddrs.c
[ 59%]: cache compiling.release src/tbox/tbox/src/tbox/platform/socket.c
[ 59%]: cache compiling.release src/tbox/tbox/src/tbox/platform/poller.c
[ 60%]: cache compiling.release src/tbox/tbox/src/tbox/platform/page.c
[ 60%]: cache compiling.release src/tbox/tbox/src/tbox/platform/addrinfo.c
[ 60%]: cache compiling.release src/tbox/tbox/src/tbox/platform/time.c
[ 60%]: cache compiling.release src/tbox/tbox/src/tbox/platform/semaphore.c
[ 60%]: cache compiling.release src/tbox/tbox/src/tbox/platform/event.c
[ 61%]: cache compiling.release src/tbox/tbox/src/tbox/platform/backtrace.c
[ 61%]: cache compiling.release src/tbox/tbox/src/tbox/platform/path.c
error: src/tbox/tbox/src/tbox/platform/ifaddrs.c:187:17: error: variable 'ipflags' set but not used [-Werror,-Wunused-but-set-variable]
tb_uint32_t ipflags = 0;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.