Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 10.14.5 Ddlopen Error #1

Open
jeremyforan opened this issue Jun 29, 2019 · 2 comments
Open

macOS 10.14.5 Ddlopen Error #1

jeremyforan opened this issue Jun 29, 2019 · 2 comments

Comments

@jeremyforan
Copy link

I was able to compile and flash but I am getting the following error when trying to run the script.

`client $ ./proxmark3 /dev/cu.usbmodem14401
Prox/RFID mark3 RFID instrument
bootrom: /-suspect 2019-06-29 01:41:14
os: /-suspect 2019-06-29 01:41:15
LF FPGA image built for 2s30vq100 on 2015/03/06 at 07:38:04
HF FPGA image built for 2s30vq100 on 2015/11/ 2 at 9: 8: 8

uC: AT91SAM7S512 Rev B
Embedded Processor: ARM7TDMI
Nonvolatile Program Memory Size: 512K bytes. Used: 192397 bytes (37). Free: 331891 bytes (63).
Second Nonvolatile Program Memory Size: None
Internal SRAM Size: 64K bytes
Architecture Identifier: AT91SAM7Sxx Series
Nonvolatile Program Memory Type: Embedded Flash Memory
proxmark3> script run amiibo help
--- Executing: amiibo.lua, args 'help'
dlopen(./libluamiibo.so, 6): no suitable image found. Did find:
./libluamiibo.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/jeremyforan/Downloads/proxmark3-amiimicyou-master/client/libluamiibo.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
dlopen(./libluamiibo.so, 6): no suitable image found. Did find:
./libluamiibo.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/jeremyforan/Downloads/proxmark3-amiimicyou-master/client/libluamiibo.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00

-----Finished
proxmark3> `

@hacklu
Copy link

hacklu commented Jul 21, 2019

seems have to build the libamiibo under OSX.
and you should modify this line in "CMakeLists.txt"

-target_link_libraries(luamiibo crypto)
+target_link_libraries(luamiibo crypto lua)

@jamchamb
Copy link
Collaborator

jamchamb commented Nov 2, 2019

Sorry for the late response, the included libluamiibo.so is built for Linux. I was able to build the library on Mac OS X Catalina with these steps:

  1. Clone this repo
  2. Clone https://github.com/jamchamb/amiitool.git
  3. Get cmake and openssl so you can build amiitool: brew install cmake openssl
  4. Go to the amiitool directory and git checkout lua-lib
  5. Open CMakeLists.txt and set the PROXMARK_LIBLUA path setting to the liblua directory in the proxmark3 repo. For example I changed it to: set(PROXMARK_LIBLUA "~/git/proxmark3-amiimicyou/liblua/")
  6. At this point I had some issues building with the openssl libraries installed from homebrew and getting dynamic linking to Lua to work. Here's a patch I made for the CMakeLists.txt file:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa43c3f..b75b0fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 2.8.4)
 project(nfc3d C)
 
+find_package(OpenSSL REQUIRED)
 include_directories(include)
 
 if(CMAKE_COMPILER_IS_GNUCC)
@@ -31,7 +32,7 @@ set(ZEROTEST_FILES
 	src/zerotest.c
 )
 add_executable(zerotest ${ZEROTEST_FILES})
-target_link_libraries(zerotest crypto)
+target_link_libraries(zerotest OpenSSL::Crypto)
 
 #[[ TODO: fix this
 #set(NINTEST_FILES
@@ -39,7 +40,7 @@ target_link_libraries(zerotest crypto)
 #	src/nintest.c
 #)
 #add_executable(nintest ${NINTEST_FILES})
-#target_link_libraries(nintest crypto)
+#target_link_libraries(nintest OpenSSL::Crypto)
 #]]
 
 set(AMIITOOL_FILES
@@ -47,7 +48,7 @@ set(AMIITOOL_FILES
 	src/amiitool.c
 )
 add_executable(amiitool ${AMIITOOL_FILES})
-target_link_libraries(amiitool crypto)
+target_link_libraries(amiitool OpenSSL::Crypto)
 
 # Lua library
 
@@ -57,12 +58,12 @@ set (LUAMIIBO_FILES
   src/amiibo_lua.c
 )
 
+add_link_options(-undefined dynamic_lookup)
 add_library(luamiibo SHARED ${LUAMIIBO_FILES})
 
 # Location of Proxmark's lua library
-set(PROXMARK_LIBLUA "~/Documents/proxmark3/liblua")
+set(PROXMARK_LIBLUA "/Users/jchambers/git/proxmark3-amiimicyou/liblua")
 
 set_property(TARGET luamiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
-# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup")
 target_include_directories(luamiibo PRIVATE ${PROXMARK_LIBLUA})
-target_link_libraries(luamiibo crypto)
+target_link_libraries(luamiibo OpenSSL::Crypto)

Make sure to fix your PROXMARK_LIBLUA path again after applying this patch.

Then instead of running build.sh I go to the amiitool directory and run:

$ rm -rf build && mkdir build && cd build
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make

It should finish successfully and generate libluamiibo.dylib. Copy this to the proxmark3-amiimicyou/client directory and then update the Lua scripts to use this instead of the .so file.

diff --git a/client/lualibs/amiibolib.lua b/client/lualibs/amiibolib.lua
index a91091a..66aa53c 100644
--- a/client/lualibs/amiibolib.lua
+++ b/client/lualibs/amiibolib.lua
@@ -1,4 +1,4 @@
-local luamiibo_open, err = package.loadlib("./libluamiibo.so", "luaopen_luamiibo")
+local luamiibo_open, err = package.loadlib("./libluamiibo.dylib", "luaopen_luamiibo")
 
 if err then
    print(err)
diff --git a/client/scripts/amiibo.lua b/client/scripts/amiibo.lua
index c520ef8..3de40d2 100644
--- a/client/scripts/amiibo.lua
+++ b/client/scripts/amiibo.lua
@@ -4,7 +4,7 @@ local Amiibo = require('amiibolib')
 local reader = require('read14a')
 local bin = require('bin')
 local emu = require('emulator')
-local luamiibo_open, err = package.loadlib("./libluamiibo.so", "luaopen_luamiibo")
+local luamiibo_open, err = package.loadlib("./libluamiibo.dylib", "luaopen_luamiibo")
 
 if err then
    print(err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants