maskedeken/trojan-gfw

大哥,这玩意怎么编译出来的?

Closed this issue · 9 comments

求教程

同求教程

同求教程

听说使用lede lean那个编出来的

不想写详细过程了,这里简单说一下。
首先用openwrt的toolchain静态编译出来openssl和boost,就是.a那种库。
假设你已经编译好boost和openssl,所在目录为/opt/boost和/opt/ssl,这时就可以修改trojan的CMakeLists.txt,把find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)这一行注释掉,下面的两行改成
include_directories(/opt/boost)
target_link_libraries(trojan /opt/boost/stage/lib/libboost_program_options.a /opt/boost/stage/lib/libboost_system.a)

同理找到openssl依赖的地方做类似的改动,然后就可以编译了

Lins commented

哥哥,把你的cmakeLISTS 贴一份出来好不好

Lins commented

不想写详细过程了,这里简单说一下。
首先用openwrt的toolchain静态编译出来openssl和boost,就是.a那种库。
假设你已经编译好boost和openssl,所在目录为/opt/boost和/opt/ssl,这时就可以修改trojan的CMakeLists.txt,把find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)这一行注释掉,下面的两行改成
include_directories(/opt/boost)
target_link_libraries(trojan /opt/boost/stage/lib/libboost_program_options.a /opt/boost/stage/lib/libboost_system.a)

同理找到openssl依赖的地方做类似的改动,然后就可以编译了

include_directories(/opt/openssl/)
target_link_libraries(trojan /opt/openssl/lib/libssl.a /opt/openssl/lib/libcrypto.a)

openssl 编译过了 目录都存在,cmake .. 也没报错,
但是编译最后报:

/usr/bin/ld: /opt/openssl/lib/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/trojan.dir/build.make:515: recipe for target 'trojan' failed
make[2]: *** [trojan] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/trojan.dir/all' failed
make[1]: *** [CMakeFiles/trojan.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

boost 按照您说的方法ok 没问题。这个怎么弄求教

不想写详细过程了,这里简单说一下。
首先用openwrt的toolchain静态编译出来openssl和boost,就是.a那种库。
假设你已经编译好boost和openssl,所在目录为/opt/boost和/opt/ssl,这时就可以修改trojan的CMakeLists.txt,把find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)这一行注释掉,下面的两行改成
include_directories(/opt/boost)
target_link_libraries(trojan /opt/boost/stage/lib/libboost_program_options.a /opt/boost/stage/lib/libboost_system.a)
同理找到openssl依赖的地方做类似的改动,然后就可以编译了

include_directories(/opt/openssl/)
target_link_libraries(trojan /opt/openssl/lib/libssl.a /opt/openssl/lib/libcrypto.a)

openssl 编译过了 目录都存在,cmake .. 也没报错,
但是编译最后报:

/usr/bin/ld: /opt/openssl/lib/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/trojan.dir/build.make:515: recipe for target 'trojan' failed
make[2]: *** [trojan] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/trojan.dir/all' failed
make[1]: *** [CMakeFiles/trojan.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

boost 按照您说的方法ok 没问题。这个怎么弄求教

你的编译器都用错了,用了系统自带的编译器
你应该在cmake的时候指定CC和CXX指向openwrt的编译器

Lins commented

不想写详细过程了,这里简单说一下。
首先用openwrt的toolchain静态编译出来openssl和boost,就是.a那种库。
假设你已经编译好boost和openssl,所在目录为/opt/boost和/opt/ssl,这时就可以修改trojan的CMakeLists.txt,把find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)这一行注释掉,下面的两行改成
include_directories(/opt/boost)
target_link_libraries(trojan /opt/boost/stage/lib/libboost_program_options.a /opt/boost/stage/lib/libboost_system.a)
同理找到openssl依赖的地方做类似的改动,然后就可以编译了

include_directories(/opt/openssl/)
target_link_libraries(trojan /opt/openssl/lib/libssl.a /opt/openssl/lib/libcrypto.a)
openssl 编译过了 目录都存在,cmake .. 也没报错,
但是编译最后报:

/usr/bin/ld: /opt/openssl/lib/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/trojan.dir/build.make:515: recipe for target 'trojan' failed
make[2]: *** [trojan] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/trojan.dir/all' failed
make[1]: *** [CMakeFiles/trojan.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

boost 按照您说的方法ok 没问题。这个怎么弄求教

你的编译器都用错了,用了系统自带的编译器
你应该在cmake的时候指定CC和CXX指向openwrt的编译器

其实我是想在ubuntu18 里面把trojan 实现静态编译的。就是看了你的静态编译思路。但是没成功,想学习下。google 老师都学习了,就是不成功。

Golang实现的Trojan代理,支持多个平台,无依赖
https://github.com.cnpmjs.org/p4gefau1t/trojan-go