mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-15 01:23:04 -07:00
SWIG experiments
Squash of the following commits (a full rebase was too hard :( ) *ef309cfdf
N - SWIG: create pm3.c (5 months ago) <Philippe Teuwen> *05ba6a73f
N - swig pm3_device -> pm3 (5 months ago) <Philippe Teuwen> *d59630183
N - swig: move pm3.i (5 months ago) <Philippe Teuwen> *6adcfad75
N - Fix historic make & cmake (5 months ago) <Philippe Teuwen> *bcbef2edf
N - Fix typo with script_embedded (5 months ago) <slurdge> *538ee4dab
N - Better SWIG integration: autogen func & attributes (5 months ago) <slurdge> *756b62466
N - SWIG: few helper scripts (5 months ago) <Philippe Teuwen> *47ba4acd0
N - SWIG %extend (5 months ago) <Philippe Teuwen> *21841cb9d
N - simplify scripts (5 months ago) <Philippe Teuwen> *78c4f7929
N - Revert "SWIG experiments: introduce context" (5 months ago) <Philippe Teuwen> *1562b75fc
N - SWIG experiments: introduce context (5 months ago) <Philippe Teuwen> *a503dfcd9
N - SWIG experiments (5 months ago) <Philippe Teuwen>
This commit is contained in:
parent
e959d0e229
commit
eadacd82f5
42 changed files with 8542 additions and 34 deletions
|
@ -289,6 +289,7 @@ set (TARGET_SOURCES
|
|||
${PM3_ROOT}/client/src/graph.c
|
||||
${PM3_ROOT}/client/src/jansson_path.c
|
||||
${PM3_ROOT}/client/src/preferences.c
|
||||
${PM3_ROOT}/client/src/pm3.c
|
||||
${PM3_ROOT}/client/src/pm3_binlib.c
|
||||
${PM3_ROOT}/client/src/pm3_bitlib.c
|
||||
${PM3_ROOT}/client/src/prng.c
|
||||
|
|
|
@ -289,7 +289,7 @@ endif
|
|||
CFLAGS ?= $(DEFCFLAGS)
|
||||
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
||||
PM3CFLAGS = $(CFLAGS)
|
||||
PM3CFLAGS += -I./src -I../include -I../common -I../common_fpga $(INCLUDES)
|
||||
PM3CFLAGS += -I./src -I./include -I../include -I../common -I../common_fpga $(INCLUDES)
|
||||
# WIP Testing
|
||||
#PM3CFLAGS += -std=c11 -pedantic
|
||||
|
||||
|
@ -318,7 +318,7 @@ endif
|
|||
|
||||
CXXFLAGS ?= -Wall -Werror -O3
|
||||
PM3CXXFLAGS = $(CXXFLAGS)
|
||||
PM3CXXFLAGS += -I../include
|
||||
PM3CXXFLAGS += -I../include -I./include
|
||||
|
||||
ifeq ($(QT_FOUND),1)
|
||||
PM3CFLAGS += -DHAVE_GUI
|
||||
|
@ -540,6 +540,7 @@ SRCS = aiddesfire.c \
|
|||
mifare/mifaredefault.c \
|
||||
mifare/mifarehost.c \
|
||||
mifare/ndef.c \
|
||||
pm3.c \
|
||||
pm3_binlib.c \
|
||||
pm3_bitlib.c \
|
||||
preferences.c \
|
||||
|
|
|
@ -64,7 +64,7 @@ int push_cmdscriptfile(char *path, bool stayafter) { return PM3_SUCCESS; }
|
|||
static bool OpenPm3(void) {
|
||||
if (conn.run) { return true; }
|
||||
// Open with LocalSocket. Not a tcp connection!
|
||||
bool ret = OpenProxmark("socket:"PM3_LOCAL_SOCKET_SERVER, false, 1000, false, 115200);
|
||||
bool ret = OpenProxmark(session.current_device, "socket:"PM3_LOCAL_SOCKET_SERVER, false, 1000, false, 115200);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ set_property(TARGET pm3rrg_rdv4_hardnested PROPERTY POSITION_INDEPENDENT_CODE ON
|
|||
target_include_directories(pm3rrg_rdv4_hardnested PRIVATE
|
||||
../../common
|
||||
../../include
|
||||
../include
|
||||
../src
|
||||
jansson)
|
||||
target_include_directories(pm3rrg_rdv4_hardnested INTERFACE hardnested)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MYSRCPATHS =
|
||||
MYINCLUDES = -I../../../common -I../../../include -I../../src -I../jansson
|
||||
MYINCLUDES = -I../../../common -I../../../include -I../../src -I../../include -I../jansson
|
||||
MYCFLAGS =
|
||||
MYDEFS =
|
||||
MYSRCS = hardnested_bruteforce.c
|
||||
|
|
1
client/experimental_client_with_swig/.gitignore
vendored
Normal file
1
client/experimental_client_with_swig/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
4
client/experimental_client_with_swig/00make_swig.sh
Executable file
4
client/experimental_client_with_swig/00make_swig.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
swig -lua -o ../src/pm3_luawrap.c ../src/pm3.i
|
||||
swig -python -o ../src/pm3_pywrap.c ../src/pm3.i
|
10
client/experimental_client_with_swig/01make_client.sh
Executable file
10
client/experimental_client_with_swig/01make_client.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
(
|
||||
cd build
|
||||
cmake ..
|
||||
make -j
|
||||
)
|
||||
|
6
client/experimental_client_with_swig/01make_client_continue.sh
Executable file
6
client/experimental_client_with_swig/01make_client_continue.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
(
|
||||
cd build
|
||||
make -j
|
||||
)
|
3
client/experimental_client_with_swig/02a_run_test_lua.sh
Executable file
3
client/experimental_client_with_swig/02a_run_test_lua.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
build/proxmark3 /dev/ttyACM0 -c "script run testembedded.lua"
|
7
client/experimental_client_with_swig/02b_run_test_py.sh
Executable file
7
client/experimental_client_with_swig/02b_run_test_py.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#/usr/local/lib/python3/dist-packages/pm3.py
|
||||
#/usr/lib/python3/dist-packages/pm3.py
|
||||
|
||||
# need access to pm3.py
|
||||
PYTHONPATH=../src build/proxmark3 /dev/ttyACM0 -c "script run testembedded.py"
|
573
client/experimental_client_with_swig/CMakeLists.txt
Normal file
573
client/experimental_client_with_swig/CMakeLists.txt
Normal file
|
@ -0,0 +1,573 @@
|
|||
# Usage:
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake .. (see below for options)
|
||||
# make (VERBOSE=1 if needed)
|
||||
#
|
||||
# MINGW:
|
||||
# On ProxSpace 3.4:
|
||||
# cmake -G"MSYS Makefiles" ..
|
||||
# On Proxspace 3.3 or less, you need to install cmake:
|
||||
# pacman -S mingw-w64-x86_64-cmake
|
||||
# /mingw64/bin/cmake -G"MSYS Makefiles" ..
|
||||
#
|
||||
# Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
|
||||
# cmake \
|
||||
# -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
|
||||
# -DANDROID_ABI=armeabi-v7a \
|
||||
# -DANDROID_NATIVE_API_LEVEL=android-19 \
|
||||
# -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
|
||||
|
||||
message(STATUS "CMake ${CMAKE_VERSION}")
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(proxmark3)
|
||||
SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.7.0")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
if (NOT SKIPQT EQUAL 1)
|
||||
if(APPLE AND EXISTS /usr/local/opt/qt5)
|
||||
# Homebrew installs Qt5 (up to at least 5.11.0) in
|
||||
# /usr/local/qt5. Ensure that it can be found by CMake
|
||||
# since it is not in the default /usr/local prefix.
|
||||
# Add it to PATHS so that it doesn't override the
|
||||
# CMAKE_PREFIX_PATH environment variable.
|
||||
# QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
|
||||
# e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
|
||||
list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
|
||||
endif(APPLE AND EXISTS /usr/local/opt/qt5)
|
||||
set(QT_PACKAGELIST
|
||||
Qt5Core
|
||||
Qt5Widgets
|
||||
Qt5Gui
|
||||
)
|
||||
set(Qt5_FOUND ON)
|
||||
foreach(_qt_package IN LISTS QT_PACKAGELIST)
|
||||
find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
|
||||
set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
|
||||
if(NOT ${_qt_package}_FOUND)
|
||||
set(Qt5_FOUND OFF)
|
||||
endif(NOT ${_qt_package}_FOUND)
|
||||
endforeach()
|
||||
endif (NOT SKIPQT EQUAL 1)
|
||||
|
||||
if (NOT SKIPBT EQUAL 1)
|
||||
pkg_search_module(BLUEZ QUIET bluez)
|
||||
endif (NOT SKIPBT EQUAL 1)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
pkg_search_module(PYTHON3 QUIET python3)
|
||||
pkg_search_module(PYTHON3EMBED QUIET python3-embed)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
# If cross-compiled, we need to init source and build.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
|
||||
set(EMBED_READLINE ON)
|
||||
set(EMBED_BZIP2 ON)
|
||||
endif (CMAKE_TOOLCHAIN_FILE)
|
||||
|
||||
if (EMBED_READLINE OR EMBED_BZIP2)
|
||||
include(ExternalProject)
|
||||
endif (EMBED_READLINE OR EMBED_BZIP2)
|
||||
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
if (APPLE)
|
||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
|
||||
find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
|
||||
endif (APPLE)
|
||||
if (EMBED_READLINE)
|
||||
ExternalProject_Add(ncurses
|
||||
URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz
|
||||
PREFIX deps/ncurses
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
|
||||
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --disable-database --with-fallbacks=ansi-generic,ansi-mini,color_xterm,dtterm,dumb,Eterm,Eterm-256color,Eterm-88color,eterm-color,gnome,gnome-256color,guru,hurd,iTerm.app,konsole,konsole-16color,konsole-256color,konsole-base,konsole-linux,konsole-solaris,konsole-vt100,kterm,kterm-color,linux,linux-16color,linux-basic,mac,mlterm,mlterm-256color,mrxvt,mrxvt-256color,mterm,mterm-ansi,mvterm,nsterm,nsterm-16color,nsterm-256color,pty,putty,putty-256color,putty-vt100,rxvt,rxvt-16color,rxvt-256color,rxvt-88color,rxvt-basic,rxvt-color,screen,screen-16color,screen-256color,simpleterm,st-16color,st-256color,st52,st52-color,stv52,tt,tt52,unknown,vt100,vt102,vte,vte-256color,xterm,xterm-16color,xterm-256color,xterm-88color,xterm-basic,xterm-bold,xterm-color,xterm-utf8,xterm-vt220,xterm-vt52,xterm1,xtermc,xtermm --enable-termcap --without-ada --without-debug --without-dlsym --without-gpm --without-develop --without-tests --without-cxx-binding --with-termlib
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make libs
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(ncurses configure build install)
|
||||
|
||||
ExternalProject_Add(readline
|
||||
URL ftp://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz
|
||||
PREFIX deps/readline
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
|
||||
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --enable-static
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(readline configure build install)
|
||||
set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
|
||||
set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
|
||||
else (EMBED_READLINE)
|
||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h)
|
||||
find_library(READLINE_LIBRARIES readline)
|
||||
endif (EMBED_READLINE)
|
||||
if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||
set(READLINE_FOUND ON)
|
||||
endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||
endif (NOT SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||
pkg_check_modules(PC_JANSSON QUIET jansson)
|
||||
find_path(JANSSON_INCLUDE_DIRS
|
||||
NAMES jansson.h
|
||||
HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
|
||||
find_library(JANSSON_LIBRARIES
|
||||
NAMES jansson libjansson
|
||||
HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
|
||||
if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
|
||||
set(JANSSON_FOUND ON)
|
||||
endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
|
||||
endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||
|
||||
if(EMBED_BZIP2)
|
||||
set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||
ExternalProject_Add(bzip2
|
||||
GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
|
||||
GIT_TAG platform-tools-30.0.2
|
||||
PREFIX deps/bzip2
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
|
||||
CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make -C ${BZIP2_BUILD_DIR} -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} libbz2.a
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(bzip2 configure build install)
|
||||
set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||
set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
|
||||
set(BZIP2_FOUND ON)
|
||||
else(EMBED_BZIP2)
|
||||
find_package (BZip2 REQUIRED)
|
||||
endif(EMBED_BZIP2)
|
||||
|
||||
if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
|
||||
find_library(WHEREAMI_LIBRARIES whereami)
|
||||
if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
|
||||
set(WHEREAMI_FOUND ON)
|
||||
endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
|
||||
endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
|
||||
add_subdirectory(${PM3_ROOT}/client/deps deps)
|
||||
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/common/commonutil.c
|
||||
${PM3_ROOT}/common/util_posix.c
|
||||
${PM3_ROOT}/common/parity.c
|
||||
${PM3_ROOT}/common/bucketsort.c
|
||||
${PM3_ROOT}/common/crapto1/crapto1.c
|
||||
${PM3_ROOT}/common/crapto1/crypto1.c
|
||||
${PM3_ROOT}/common/crc.c
|
||||
${PM3_ROOT}/common/crc16.c
|
||||
${PM3_ROOT}/common/crc32.c
|
||||
${PM3_ROOT}/common/crc64.c
|
||||
${PM3_ROOT}/common/lfdemod.c
|
||||
${PM3_ROOT}/common/legic_prng.c
|
||||
${PM3_ROOT}/common/iso15693tools.c
|
||||
${PM3_ROOT}/common/cardhelper.c
|
||||
${PM3_ROOT}/common/generator.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1dump.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1utils.c
|
||||
${PM3_ROOT}/client/src/crypto/libpcrypto.c
|
||||
${PM3_ROOT}/client/src/emv/test/cda_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/crypto_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/cryptotest.c
|
||||
${PM3_ROOT}/client/src/emv/test/dda_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/sda_test.c
|
||||
${PM3_ROOT}/client/src/emv/apduinfo.c
|
||||
${PM3_ROOT}/client/src/emv/cmdemv.c
|
||||
${PM3_ROOT}/client/src/emv/crypto.c
|
||||
${PM3_ROOT}/client/src/emv/crypto_polarssl.c
|
||||
${PM3_ROOT}/client/src/emv/dol.c
|
||||
${PM3_ROOT}/client/src/emv/dump.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pk.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pki.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pki_priv.c
|
||||
${PM3_ROOT}/client/src/emv/emv_roca.c
|
||||
${PM3_ROOT}/client/src/emv/emv_tags.c
|
||||
${PM3_ROOT}/client/src/emv/emvcore.c
|
||||
${PM3_ROOT}/client/src/emv/emvjson.c
|
||||
${PM3_ROOT}/client/src/emv/tlv.c
|
||||
${PM3_ROOT}/client/src/fido/additional_ca.c
|
||||
${PM3_ROOT}/client/src/fido/cbortools.c
|
||||
${PM3_ROOT}/client/src/fido/cose.c
|
||||
${PM3_ROOT}/client/src/fido/fidocore.c
|
||||
${PM3_ROOT}/client/src/loclass/cipher.c
|
||||
${PM3_ROOT}/client/src/loclass/cipherutils.c
|
||||
${PM3_ROOT}/client/src/loclass/elite_crack.c
|
||||
${PM3_ROOT}/client/src/loclass/hash1_brute.c
|
||||
${PM3_ROOT}/client/src/loclass/ikeys.c
|
||||
${PM3_ROOT}/client/src/mifare/mad.c
|
||||
${PM3_ROOT}/client/src/mifare/mfkey.c
|
||||
${PM3_ROOT}/client/src/mifare/mifare4.c
|
||||
${PM3_ROOT}/client/src/mifare/mifaredefault.c
|
||||
${PM3_ROOT}/client/src/mifare/mifarehost.c
|
||||
${PM3_ROOT}/client/src/mifare/ndef.c
|
||||
${PM3_ROOT}/client/src/mifare/desfire_crypto.c
|
||||
${PM3_ROOT}/client/src/uart/uart_posix.c
|
||||
${PM3_ROOT}/client/src/uart/uart_win32.c
|
||||
${PM3_ROOT}/client/src/ui/overlays.ui
|
||||
${PM3_ROOT}/client/src/aiddesfire.c
|
||||
${PM3_ROOT}/client/src/aidsearch.c
|
||||
${PM3_ROOT}/client/src/cmdanalyse.c
|
||||
${PM3_ROOT}/client/src/cmdcrc.c
|
||||
${PM3_ROOT}/client/src/cmddata.c
|
||||
${PM3_ROOT}/client/src/cmdflashmem.c
|
||||
${PM3_ROOT}/client/src/cmdflashmemspiffs.c
|
||||
${PM3_ROOT}/client/src/cmdhf.c
|
||||
${PM3_ROOT}/client/src/cmdhf14a.c
|
||||
${PM3_ROOT}/client/src/cmdhf14b.c
|
||||
${PM3_ROOT}/client/src/cmdhf15.c
|
||||
${PM3_ROOT}/client/src/cmdhfcryptorf.c
|
||||
${PM3_ROOT}/client/src/cmdhfepa.c
|
||||
${PM3_ROOT}/client/src/cmdhffelica.c
|
||||
${PM3_ROOT}/client/src/cmdhffido.c
|
||||
${PM3_ROOT}/client/src/cmdhficlass.c
|
||||
${PM3_ROOT}/client/src/cmdhflegic.c
|
||||
${PM3_ROOT}/client/src/cmdhflist.c
|
||||
${PM3_ROOT}/client/src/cmdhflto.c
|
||||
${PM3_ROOT}/client/src/cmdhfmf.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfdes.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfhard.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfp.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfu.c
|
||||
${PM3_ROOT}/client/src/cmdhfst.c
|
||||
${PM3_ROOT}/client/src/cmdhfthinfilm.c
|
||||
${PM3_ROOT}/client/src/cmdhftopaz.c
|
||||
${PM3_ROOT}/client/src/cmdhfwaveshare.c
|
||||
${PM3_ROOT}/client/src/cmdhw.c
|
||||
${PM3_ROOT}/client/src/cmdlf.c
|
||||
${PM3_ROOT}/client/src/cmdlfawid.c
|
||||
${PM3_ROOT}/client/src/cmdlfcotag.c
|
||||
${PM3_ROOT}/client/src/cmdlfdestron.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x05.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x50.c
|
||||
${PM3_ROOT}/client/src/cmdlffdxb.c
|
||||
${PM3_ROOT}/client/src/cmdlfgallagher.c
|
||||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
${PM3_ROOT}/client/src/cmdlfkeri.c
|
||||
${PM3_ROOT}/client/src/cmdlfmotorola.c
|
||||
${PM3_ROOT}/client/src/cmdlfnedap.c
|
||||
${PM3_ROOT}/client/src/cmdlfnexwatch.c
|
||||
${PM3_ROOT}/client/src/cmdlfnoralsy.c
|
||||
${PM3_ROOT}/client/src/cmdlfpac.c
|
||||
${PM3_ROOT}/client/src/cmdlfparadox.c
|
||||
${PM3_ROOT}/client/src/cmdlfpcf7931.c
|
||||
${PM3_ROOT}/client/src/cmdlfpresco.c
|
||||
${PM3_ROOT}/client/src/cmdlfpyramid.c
|
||||
${PM3_ROOT}/client/src/cmdlfsecurakey.c
|
||||
${PM3_ROOT}/client/src/cmdlft55xx.c
|
||||
${PM3_ROOT}/client/src/cmdlfti.c
|
||||
${PM3_ROOT}/client/src/cmdlfviking.c
|
||||
${PM3_ROOT}/client/src/cmdlfvisa2000.c
|
||||
${PM3_ROOT}/client/src/cmdmain.c
|
||||
${PM3_ROOT}/client/src/cmdparser.c
|
||||
${PM3_ROOT}/client/src/cmdscript.c
|
||||
${PM3_ROOT}/client/src/cmdsmartcard.c
|
||||
${PM3_ROOT}/client/src/cmdtrace.c
|
||||
${PM3_ROOT}/client/src/cmdusart.c
|
||||
${PM3_ROOT}/client/src/cmdwiegand.c
|
||||
${PM3_ROOT}/client/src/comms.c
|
||||
${PM3_ROOT}/client/src/fileutils.c
|
||||
${PM3_ROOT}/client/src/flash.c
|
||||
${PM3_ROOT}/client/src/graph.c
|
||||
${PM3_ROOT}/client/src/jansson_path.c
|
||||
${PM3_ROOT}/client/src/preferences.c
|
||||
${PM3_ROOT}/client/src/pm3.c
|
||||
${PM3_ROOT}/client/src/pm3_binlib.c
|
||||
${PM3_ROOT}/client/src/pm3_bitlib.c
|
||||
${PM3_ROOT}/client/src/prng.c
|
||||
${PM3_ROOT}/client/src/scandir.c
|
||||
${PM3_ROOT}/client/src/scripting.c
|
||||
${PM3_ROOT}/client/src/tea.c
|
||||
${PM3_ROOT}/client/src/ui.c
|
||||
${PM3_ROOT}/client/src/util.c
|
||||
${PM3_ROOT}/client/src/wiegand_formats.c
|
||||
${PM3_ROOT}/client/src/wiegand_formatutils.c
|
||||
${CMAKE_BINARY_DIR}/version.c
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
||||
COMMAND sh ${PM3_ROOT}/tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version.c || perl ${PM3_ROOT}/tools/mkversion.pl > ${CMAKE_BINARY_DIR}/version.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version.c ${CMAKE_BINARY_DIR}/version.c
|
||||
DEPENDS ${PM3_ROOT}/common/default_version.c
|
||||
)
|
||||
|
||||
set(ADDITIONAL_SRC "")
|
||||
set(ADDITIONAL_LNK "")
|
||||
set(ADDITIONAL_DIRS "")
|
||||
set(ADDITIONAL_LNKDIRS "")
|
||||
set(X86_CPUS x86 x86_64 i686)
|
||||
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
if (APPLE)
|
||||
message(STATUS "Apple device detected.")
|
||||
set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
|
||||
set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
|
||||
endif (APPLE)
|
||||
|
||||
if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/proxgui.cpp
|
||||
${PM3_ROOT}/client/src/proxguiqt.cpp
|
||||
${TARGET_SOURCES})
|
||||
|
||||
add_definitions("-DHAVE_GUI")
|
||||
set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
set(TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/guidummy.cpp
|
||||
${TARGET_SOURCES})
|
||||
endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
|
||||
if (NOT SKIPBT EQUAL 1)
|
||||
if (BLUEZ_FOUND)
|
||||
add_definitions("-DHAVE_BLUEZ")
|
||||
set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (BLUEZ_FOUND)
|
||||
endif(NOT SKIPBT EQUAL 1)
|
||||
|
||||
if (JANSSON_FOUND)
|
||||
set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (JANSSON_FOUND)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND)
|
||||
add_definitions(-DHAVE_PYTHON)
|
||||
set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
|
||||
elseif (PYTHON3_FOUND)
|
||||
add_definitions(-DHAVE_PYTHON)
|
||||
set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
|
||||
endif (PYTHON3EMBED_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
if (READLINE_FOUND)
|
||||
add_definitions("-DHAVE_READLINE")
|
||||
set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (READLINE_FOUND)
|
||||
endif(NOT SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (BZIP2_FOUND)
|
||||
set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (BZIP2_FOUND)
|
||||
|
||||
if (WHEREAMI_FOUND)
|
||||
set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (WHEREAMI_FOUND)
|
||||
|
||||
message(STATUS "===================================================================")
|
||||
if (SKIPQT EQUAL 1)
|
||||
message(STATUS "GUI support: skipped")
|
||||
else (SKIPQT EQUAL 1)
|
||||
if (Qt5_FOUND)
|
||||
message(STATUS "GUI support: QT5 found, enabled")
|
||||
else (Qt5_FOUND)
|
||||
message(STATUS "GUI support: QT5 not found, disabled")
|
||||
endif (Qt5_FOUND)
|
||||
endif (SKIPQT EQUAL 1)
|
||||
|
||||
if (SKIPBT EQUAL 1)
|
||||
message(STATUS "native BT support: skipped")
|
||||
else (SKIPBT EQUAL 1)
|
||||
if (BLUEZ_FOUND)
|
||||
message(STATUS "native BT support: Bluez found, enabled")
|
||||
else (BLUEZ_FOUND)
|
||||
message(STATUS "native BT support: Bluez not found, disabled")
|
||||
endif (BLUEZ_FOUND)
|
||||
endif(SKIPBT EQUAL 1)
|
||||
|
||||
if (EMBED_BZIP2)
|
||||
message(STATUS "Bzip2 library: embedded")
|
||||
else (EMBED_BZIP2)
|
||||
message(STATUS "Bzip2 library: system library found")
|
||||
endif (EMBED_BZIP2)
|
||||
|
||||
if (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
message(STATUS "Jansson library: local library forced")
|
||||
else (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
if (JANSSON_FOUND)
|
||||
message(STATUS "Jansson library: system library found")
|
||||
else (JANSSON_FOUND)
|
||||
message(STATUS "Jansson library: system library not found, using local library")
|
||||
endif (JANSSON_FOUND)
|
||||
endif (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
|
||||
if (SKIPPYTHON EQUAL 1)
|
||||
message(STATUS "Python3 library: skipped")
|
||||
else (SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND)
|
||||
message(STATUS "Python3 library: Python3 embed found, enabled")
|
||||
elseif (PYTHON_FOUND)
|
||||
message(STATUS "Python3 library: Python3 found, enabled")
|
||||
else (PYTHON3EMBED_FOUND)
|
||||
message(STATUS "Python3 library: Python3 not found, disabled")
|
||||
endif (PYTHON3EMBED_FOUND)
|
||||
endif(SKIPPYTHON EQUAL 1)
|
||||
|
||||
if (SKIPREADLINE EQUAL 1)
|
||||
message(STATUS "Readline library: skipped")
|
||||
else (SKIPREADLINE EQUAL 1)
|
||||
if (READLINE_FOUND)
|
||||
if (EMBED_READLINE)
|
||||
message(STATUS "Readline library: embedded")
|
||||
else (EMBED_READLINE)
|
||||
message(STATUS "Readline library: system library found")
|
||||
endif (EMBED_READLINE)
|
||||
else (READLINE_FOUND)
|
||||
message(STATUS "Readline library: Readline not found, disabled")
|
||||
endif (READLINE_FOUND)
|
||||
endif(SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
message(STATUS "Whereami library: local library forced")
|
||||
else (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
if (WHEREAMI_FOUND)
|
||||
message(STATUS "Whereami library: system library found")
|
||||
else (WHEREAMI_FOUND)
|
||||
message(STATUS "Whereami library: system library not found, using local library")
|
||||
endif (WHEREAMI_FOUND)
|
||||
endif (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
message(STATUS "===================================================================")
|
||||
|
||||
# Lua SWIG
|
||||
if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/pm3_luawrap.c
|
||||
${TARGET_SOURCES})
|
||||
add_definitions(-DHAVE_LUA_SWIG)
|
||||
message("Lua SWIG wrapper found")
|
||||
endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
|
||||
|
||||
# Python SWIG
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/pm3_pywrap.c
|
||||
${TARGET_SOURCES})
|
||||
add_definitions(-DHAVE_PYTHON_SWIG)
|
||||
message("Python SWIG wrapper found")
|
||||
endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
|
||||
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
add_executable(proxmark3
|
||||
${PM3_ROOT}/client/src/proxmark3.c
|
||||
${TARGET_SOURCES}
|
||||
${ADDITIONAL_SRC}
|
||||
)
|
||||
|
||||
target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
|
||||
if (EMBED_READLINE)
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
add_dependencies(proxmark3 ncurses readline)
|
||||
endif (NOT SKIPREADLINE EQUAL 1)
|
||||
endif (EMBED_READLINE)
|
||||
if (EMBED_BZIP2)
|
||||
add_dependencies(proxmark3 bzip2)
|
||||
endif (EMBED_BZIP2)
|
||||
|
||||
if (MINGW)
|
||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
|
||||
# FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
|
||||
# but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
|
||||
target_compile_definitions(proxmark3 PRIVATE _ISOC99_SOURCE)
|
||||
|
||||
set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
|
||||
endif (MINGW)
|
||||
|
||||
target_include_directories(proxmark3 PRIVATE
|
||||
${PM3_ROOT}/common
|
||||
${PM3_ROOT}/common_fpga
|
||||
${PM3_ROOT}/include
|
||||
${PM3_ROOT}/client/src
|
||||
${PM3_ROOT}/client/include
|
||||
${ADDITIONAL_DIRS}
|
||||
)
|
||||
|
||||
if (NOT APPLE)
|
||||
# required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
|
||||
set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
|
||||
endif (NOT APPLE)
|
||||
|
||||
if (NOT JANSSON_FOUND)
|
||||
set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
|
||||
endif (NOT JANSSON_FOUND)
|
||||
if (NOT WHEREAMI_FOUND)
|
||||
set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
|
||||
endif (NOT WHEREAMI_FOUND)
|
||||
|
||||
target_link_libraries(proxmark3 PRIVATE
|
||||
m
|
||||
pm3rrg_rdv4_mbedtls
|
||||
pm3rrg_rdv4_cliparser
|
||||
pm3rrg_rdv4_lua
|
||||
pm3rrg_rdv4_tinycbor
|
||||
pm3rrg_rdv4_amiibo
|
||||
pm3rrg_rdv4_reveng
|
||||
pm3rrg_rdv4_hardnested
|
||||
${ADDITIONAL_LNK})
|
||||
|
||||
if (NOT SKIPPTHREAD EQUAL 1)
|
||||
target_link_libraries(proxmark3 PRIVATE pthread)
|
||||
endif (NOT SKIPPTHREAD EQUAL 1)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
# OSX have a hard time compiling python3 dependency with older cmake.
|
||||
if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||
target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
|
||||
elseif (APPLE)
|
||||
message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
|
||||
endif (NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
install(TARGETS proxmark3 DESTINATION "bin")
|
||||
install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
|
||||
|
||||
add_custom_command(OUTPUT lualibs/pm3_cmd.lua
|
||||
COMMAND "awk -f pm3_cmd_h2lua.awk ../include/pm3_cmd.h > lualibs/pm3_cmd.lua"
|
||||
COMMENT "Creating lualibs/pm3_cmd.lua"
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT lualibs/mfc_default_keys.lua
|
||||
COMMAND "awk -f default_keys_dic2lua.awk mfc_default_keys.dic > lualibs/mfc_default_keys.lua"
|
||||
COMMENT "Creating lualibs/mfc_default_keys.lua"
|
||||
)
|
||||
|
||||
#"make package" will trigger this
|
||||
SET(CPACK_GENERATOR "DEB")
|
||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Iceman")
|
||||
INCLUDE(CPack)
|
4
client/experimental_client_with_swig/testembedded.lua
Executable file
4
client/experimental_client_with_swig/testembedded.lua
Executable file
|
@ -0,0 +1,4 @@
|
|||
local pm3 = require("pm3")
|
||||
p=pm3.pm3()
|
||||
p:console("hw status")
|
||||
print(p.name)
|
6
client/experimental_client_with_swig/testembedded.py
Executable file
6
client/experimental_client_with_swig/testembedded.py
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pm3
|
||||
p=pm3.pm3()
|
||||
p.console("hw status")
|
||||
print("Device:", p.name)
|
1
client/experimental_lib/.gitignore
vendored
Normal file
1
client/experimental_lib/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
4
client/experimental_lib/00make_swig.sh
Executable file
4
client/experimental_lib/00make_swig.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
swig -lua -o ../src/pm3_luawrap.c ../src/pm3.i
|
||||
swig -python -o ../src/pm3_pywrap.c ../src/pm3.i
|
7
client/experimental_lib/01make_lib_continue.sh
Executable file
7
client/experimental_lib/01make_lib_continue.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
(
|
||||
cd build
|
||||
make -j
|
||||
)
|
||||
|
557
client/experimental_lib/CMakeLists.txt
Normal file
557
client/experimental_lib/CMakeLists.txt
Normal file
|
@ -0,0 +1,557 @@
|
|||
# Usage:
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake .. (see below for options)
|
||||
# make (VERBOSE=1 if needed)
|
||||
#
|
||||
# MINGW:
|
||||
# On ProxSpace 3.4:
|
||||
# cmake -G"MSYS Makefiles" ..
|
||||
# On Proxspace 3.3 or less, you need to install cmake:
|
||||
# pacman -S mingw-w64-x86_64-cmake
|
||||
# /mingw64/bin/cmake -G"MSYS Makefiles" ..
|
||||
#
|
||||
# Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
|
||||
# cmake \
|
||||
# -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
|
||||
# -DANDROID_ABI=armeabi-v7a \
|
||||
# -DANDROID_NATIVE_API_LEVEL=android-19 \
|
||||
# -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
|
||||
|
||||
message(STATUS "CMake ${CMAKE_VERSION}")
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(proxmark3)
|
||||
SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.7.0")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
if (NOT SKIPQT EQUAL 1)
|
||||
if(APPLE AND EXISTS /usr/local/opt/qt5)
|
||||
# Homebrew installs Qt5 (up to at least 5.11.0) in
|
||||
# /usr/local/qt5. Ensure that it can be found by CMake
|
||||
# since it is not in the default /usr/local prefix.
|
||||
# Add it to PATHS so that it doesn't override the
|
||||
# CMAKE_PREFIX_PATH environment variable.
|
||||
# QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
|
||||
# e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
|
||||
list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
|
||||
endif(APPLE AND EXISTS /usr/local/opt/qt5)
|
||||
set(QT_PACKAGELIST
|
||||
Qt5Core
|
||||
Qt5Widgets
|
||||
Qt5Gui
|
||||
)
|
||||
set(Qt5_FOUND ON)
|
||||
foreach(_qt_package IN LISTS QT_PACKAGELIST)
|
||||
find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
|
||||
set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
|
||||
if(NOT ${_qt_package}_FOUND)
|
||||
set(Qt5_FOUND OFF)
|
||||
endif(NOT ${_qt_package}_FOUND)
|
||||
endforeach()
|
||||
endif (NOT SKIPQT EQUAL 1)
|
||||
|
||||
if (NOT SKIPBT EQUAL 1)
|
||||
pkg_search_module(BLUEZ QUIET bluez)
|
||||
endif (NOT SKIPBT EQUAL 1)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
pkg_search_module(PYTHON3 QUIET python3)
|
||||
pkg_search_module(PYTHON3EMBED QUIET python3-embed)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
# If cross-compiled, we need to init source and build.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
|
||||
set(EMBED_READLINE ON)
|
||||
set(EMBED_BZIP2 ON)
|
||||
endif (CMAKE_TOOLCHAIN_FILE)
|
||||
|
||||
if (EMBED_READLINE OR EMBED_BZIP2)
|
||||
include(ExternalProject)
|
||||
endif (EMBED_READLINE OR EMBED_BZIP2)
|
||||
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
if (APPLE)
|
||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
|
||||
find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
|
||||
endif (APPLE)
|
||||
if (EMBED_READLINE)
|
||||
ExternalProject_Add(ncurses
|
||||
URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz
|
||||
PREFIX deps/ncurses
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
|
||||
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --disable-database --with-fallbacks=ansi-generic,ansi-mini,color_xterm,dtterm,dumb,Eterm,Eterm-256color,Eterm-88color,eterm-color,gnome,gnome-256color,guru,hurd,iTerm.app,konsole,konsole-16color,konsole-256color,konsole-base,konsole-linux,konsole-solaris,konsole-vt100,kterm,kterm-color,linux,linux-16color,linux-basic,mac,mlterm,mlterm-256color,mrxvt,mrxvt-256color,mterm,mterm-ansi,mvterm,nsterm,nsterm-16color,nsterm-256color,pty,putty,putty-256color,putty-vt100,rxvt,rxvt-16color,rxvt-256color,rxvt-88color,rxvt-basic,rxvt-color,screen,screen-16color,screen-256color,simpleterm,st-16color,st-256color,st52,st52-color,stv52,tt,tt52,unknown,vt100,vt102,vte,vte-256color,xterm,xterm-16color,xterm-256color,xterm-88color,xterm-basic,xterm-bold,xterm-color,xterm-utf8,xterm-vt220,xterm-vt52,xterm1,xtermc,xtermm --enable-termcap --without-ada --without-debug --without-dlsym --without-gpm --without-develop --without-tests --without-cxx-binding --with-termlib
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make libs
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(ncurses configure build install)
|
||||
|
||||
ExternalProject_Add(readline
|
||||
URL ftp://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz
|
||||
PREFIX deps/readline
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
|
||||
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --enable-static
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(readline configure build install)
|
||||
set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
|
||||
set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
|
||||
else (EMBED_READLINE)
|
||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h)
|
||||
find_library(READLINE_LIBRARIES readline)
|
||||
endif (EMBED_READLINE)
|
||||
if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||
set(READLINE_FOUND ON)
|
||||
endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||
endif (NOT SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||
pkg_check_modules(PC_JANSSON QUIET jansson)
|
||||
find_path(JANSSON_INCLUDE_DIRS
|
||||
NAMES jansson.h
|
||||
HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
|
||||
find_library(JANSSON_LIBRARIES
|
||||
NAMES jansson libjansson
|
||||
HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
|
||||
if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
|
||||
set(JANSSON_FOUND ON)
|
||||
endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
|
||||
endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||
|
||||
if(EMBED_BZIP2)
|
||||
set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||
ExternalProject_Add(bzip2
|
||||
GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
|
||||
GIT_TAG platform-tools-30.0.2
|
||||
PREFIX deps/bzip2
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
|
||||
CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
|
||||
BUILD_IN_SOURCE ON
|
||||
BUILD_COMMAND make -C ${BZIP2_BUILD_DIR} -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} libbz2.a
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
ExternalProject_Add_StepTargets(bzip2 configure build install)
|
||||
set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||
set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
|
||||
set(BZIP2_FOUND ON)
|
||||
else(EMBED_BZIP2)
|
||||
find_package (BZip2 REQUIRED)
|
||||
endif(EMBED_BZIP2)
|
||||
|
||||
if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
|
||||
find_library(WHEREAMI_LIBRARIES whereami)
|
||||
if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
|
||||
set(WHEREAMI_FOUND ON)
|
||||
endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
|
||||
endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
|
||||
add_subdirectory(${PM3_ROOT}/client/deps deps)
|
||||
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/common/commonutil.c
|
||||
${PM3_ROOT}/common/util_posix.c
|
||||
${PM3_ROOT}/common/parity.c
|
||||
${PM3_ROOT}/common/bucketsort.c
|
||||
${PM3_ROOT}/common/crapto1/crapto1.c
|
||||
${PM3_ROOT}/common/crapto1/crypto1.c
|
||||
${PM3_ROOT}/common/crc.c
|
||||
${PM3_ROOT}/common/crc16.c
|
||||
${PM3_ROOT}/common/crc32.c
|
||||
${PM3_ROOT}/common/crc64.c
|
||||
${PM3_ROOT}/common/lfdemod.c
|
||||
${PM3_ROOT}/common/legic_prng.c
|
||||
${PM3_ROOT}/common/iso15693tools.c
|
||||
${PM3_ROOT}/common/cardhelper.c
|
||||
${PM3_ROOT}/common/generator.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1dump.c
|
||||
${PM3_ROOT}/client/src/crypto/asn1utils.c
|
||||
${PM3_ROOT}/client/src/crypto/libpcrypto.c
|
||||
${PM3_ROOT}/client/src/emv/test/cda_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/crypto_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/cryptotest.c
|
||||
${PM3_ROOT}/client/src/emv/test/dda_test.c
|
||||
${PM3_ROOT}/client/src/emv/test/sda_test.c
|
||||
${PM3_ROOT}/client/src/emv/apduinfo.c
|
||||
${PM3_ROOT}/client/src/emv/cmdemv.c
|
||||
${PM3_ROOT}/client/src/emv/crypto.c
|
||||
${PM3_ROOT}/client/src/emv/crypto_polarssl.c
|
||||
${PM3_ROOT}/client/src/emv/dol.c
|
||||
${PM3_ROOT}/client/src/emv/dump.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pk.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pki.c
|
||||
${PM3_ROOT}/client/src/emv/emv_pki_priv.c
|
||||
${PM3_ROOT}/client/src/emv/emv_roca.c
|
||||
${PM3_ROOT}/client/src/emv/emv_tags.c
|
||||
${PM3_ROOT}/client/src/emv/emvcore.c
|
||||
${PM3_ROOT}/client/src/emv/emvjson.c
|
||||
${PM3_ROOT}/client/src/emv/tlv.c
|
||||
${PM3_ROOT}/client/src/fido/additional_ca.c
|
||||
${PM3_ROOT}/client/src/fido/cbortools.c
|
||||
${PM3_ROOT}/client/src/fido/cose.c
|
||||
${PM3_ROOT}/client/src/fido/fidocore.c
|
||||
${PM3_ROOT}/client/src/loclass/cipher.c
|
||||
${PM3_ROOT}/client/src/loclass/cipherutils.c
|
||||
${PM3_ROOT}/client/src/loclass/elite_crack.c
|
||||
${PM3_ROOT}/client/src/loclass/hash1_brute.c
|
||||
${PM3_ROOT}/client/src/loclass/ikeys.c
|
||||
${PM3_ROOT}/client/src/mifare/mad.c
|
||||
${PM3_ROOT}/client/src/mifare/mfkey.c
|
||||
${PM3_ROOT}/client/src/mifare/mifare4.c
|
||||
${PM3_ROOT}/client/src/mifare/mifaredefault.c
|
||||
${PM3_ROOT}/client/src/mifare/mifarehost.c
|
||||
${PM3_ROOT}/client/src/mifare/ndef.c
|
||||
${PM3_ROOT}/client/src/mifare/desfire_crypto.c
|
||||
${PM3_ROOT}/client/src/uart/uart_posix.c
|
||||
${PM3_ROOT}/client/src/uart/uart_win32.c
|
||||
${PM3_ROOT}/client/src/ui/overlays.ui
|
||||
${PM3_ROOT}/client/src/aiddesfire.c
|
||||
${PM3_ROOT}/client/src/aidsearch.c
|
||||
${PM3_ROOT}/client/src/cmdanalyse.c
|
||||
${PM3_ROOT}/client/src/cmdcrc.c
|
||||
${PM3_ROOT}/client/src/cmddata.c
|
||||
${PM3_ROOT}/client/src/cmdflashmem.c
|
||||
${PM3_ROOT}/client/src/cmdflashmemspiffs.c
|
||||
${PM3_ROOT}/client/src/cmdhf.c
|
||||
${PM3_ROOT}/client/src/cmdhf14a.c
|
||||
${PM3_ROOT}/client/src/cmdhf14b.c
|
||||
${PM3_ROOT}/client/src/cmdhf15.c
|
||||
${PM3_ROOT}/client/src/cmdhfcryptorf.c
|
||||
${PM3_ROOT}/client/src/cmdhfepa.c
|
||||
${PM3_ROOT}/client/src/cmdhffelica.c
|
||||
${PM3_ROOT}/client/src/cmdhffido.c
|
||||
${PM3_ROOT}/client/src/cmdhficlass.c
|
||||
${PM3_ROOT}/client/src/cmdhflegic.c
|
||||
${PM3_ROOT}/client/src/cmdhflist.c
|
||||
${PM3_ROOT}/client/src/cmdhflto.c
|
||||
${PM3_ROOT}/client/src/cmdhfmf.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfdes.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfhard.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfp.c
|
||||
${PM3_ROOT}/client/src/cmdhfmfu.c
|
||||
${PM3_ROOT}/client/src/cmdhfst.c
|
||||
${PM3_ROOT}/client/src/cmdhfthinfilm.c
|
||||
${PM3_ROOT}/client/src/cmdhftopaz.c
|
||||
${PM3_ROOT}/client/src/cmdhfwaveshare.c
|
||||
${PM3_ROOT}/client/src/cmdhw.c
|
||||
${PM3_ROOT}/client/src/cmdlf.c
|
||||
${PM3_ROOT}/client/src/cmdlfawid.c
|
||||
${PM3_ROOT}/client/src/cmdlfcotag.c
|
||||
${PM3_ROOT}/client/src/cmdlfdestron.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x05.c
|
||||
${PM3_ROOT}/client/src/cmdlfem4x50.c
|
||||
${PM3_ROOT}/client/src/cmdlffdxb.c
|
||||
${PM3_ROOT}/client/src/cmdlfgallagher.c
|
||||
${PM3_ROOT}/client/src/cmdlfguard.c
|
||||
${PM3_ROOT}/client/src/cmdlfhid.c
|
||||
${PM3_ROOT}/client/src/cmdlfhitag.c
|
||||
${PM3_ROOT}/client/src/cmdlfidteck.c
|
||||
${PM3_ROOT}/client/src/cmdlfindala.c
|
||||
${PM3_ROOT}/client/src/cmdlfio.c
|
||||
${PM3_ROOT}/client/src/cmdlfjablotron.c
|
||||
${PM3_ROOT}/client/src/cmdlfkeri.c
|
||||
${PM3_ROOT}/client/src/cmdlfmotorola.c
|
||||
${PM3_ROOT}/client/src/cmdlfnedap.c
|
||||
${PM3_ROOT}/client/src/cmdlfnexwatch.c
|
||||
${PM3_ROOT}/client/src/cmdlfnoralsy.c
|
||||
${PM3_ROOT}/client/src/cmdlfpac.c
|
||||
${PM3_ROOT}/client/src/cmdlfparadox.c
|
||||
${PM3_ROOT}/client/src/cmdlfpcf7931.c
|
||||
${PM3_ROOT}/client/src/cmdlfpresco.c
|
||||
${PM3_ROOT}/client/src/cmdlfpyramid.c
|
||||
${PM3_ROOT}/client/src/cmdlfsecurakey.c
|
||||
${PM3_ROOT}/client/src/cmdlft55xx.c
|
||||
${PM3_ROOT}/client/src/cmdlfti.c
|
||||
${PM3_ROOT}/client/src/cmdlfviking.c
|
||||
${PM3_ROOT}/client/src/cmdlfvisa2000.c
|
||||
${PM3_ROOT}/client/src/cmdmain.c
|
||||
${PM3_ROOT}/client/src/cmdparser.c
|
||||
${PM3_ROOT}/client/src/cmdscript.c
|
||||
${PM3_ROOT}/client/src/cmdsmartcard.c
|
||||
${PM3_ROOT}/client/src/cmdtrace.c
|
||||
${PM3_ROOT}/client/src/cmdusart.c
|
||||
${PM3_ROOT}/client/src/cmdwiegand.c
|
||||
${PM3_ROOT}/client/src/comms.c
|
||||
${PM3_ROOT}/client/src/fileutils.c
|
||||
${PM3_ROOT}/client/src/flash.c
|
||||
${PM3_ROOT}/client/src/graph.c
|
||||
${PM3_ROOT}/client/src/jansson_path.c
|
||||
${PM3_ROOT}/client/src/preferences.c
|
||||
${PM3_ROOT}/client/src/pm3.c
|
||||
${PM3_ROOT}/client/src/pm3_binlib.c
|
||||
${PM3_ROOT}/client/src/pm3_bitlib.c
|
||||
${PM3_ROOT}/client/src/prng.c
|
||||
${PM3_ROOT}/client/src/scandir.c
|
||||
${PM3_ROOT}/client/src/scripting.c
|
||||
${PM3_ROOT}/client/src/tea.c
|
||||
${PM3_ROOT}/client/src/ui.c
|
||||
${PM3_ROOT}/client/src/util.c
|
||||
${PM3_ROOT}/client/src/wiegand_formats.c
|
||||
${PM3_ROOT}/client/src/wiegand_formatutils.c
|
||||
${CMAKE_BINARY_DIR}/version.c
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
||||
COMMAND sh ${PM3_ROOT}/tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version.c || perl ${PM3_ROOT}/tools/mkversion.pl > ${CMAKE_BINARY_DIR}/version.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version.c ${CMAKE_BINARY_DIR}/version.c
|
||||
DEPENDS ${PM3_ROOT}/common/default_version.c
|
||||
)
|
||||
|
||||
set(ADDITIONAL_SRC "")
|
||||
set(ADDITIONAL_LNK "")
|
||||
set(ADDITIONAL_DIRS "")
|
||||
set(ADDITIONAL_LNKDIRS "")
|
||||
set(X86_CPUS x86 x86_64 i686)
|
||||
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
if (APPLE)
|
||||
message(STATUS "Apple device detected.")
|
||||
set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
|
||||
set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
|
||||
endif (APPLE)
|
||||
|
||||
if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/proxgui.cpp
|
||||
${PM3_ROOT}/client/src/proxguiqt.cpp
|
||||
${TARGET_SOURCES})
|
||||
|
||||
add_definitions("-DHAVE_GUI")
|
||||
set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
set(TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/guidummy.cpp
|
||||
${TARGET_SOURCES})
|
||||
endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
|
||||
|
||||
if (NOT SKIPBT EQUAL 1)
|
||||
if (BLUEZ_FOUND)
|
||||
add_definitions("-DHAVE_BLUEZ")
|
||||
set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (BLUEZ_FOUND)
|
||||
endif(NOT SKIPBT EQUAL 1)
|
||||
|
||||
if (JANSSON_FOUND)
|
||||
set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (JANSSON_FOUND)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND)
|
||||
add_definitions(-DHAVE_PYTHON)
|
||||
set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
|
||||
elseif (PYTHON3_FOUND)
|
||||
add_definitions(-DHAVE_PYTHON)
|
||||
set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
|
||||
endif (PYTHON3EMBED_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
if (READLINE_FOUND)
|
||||
add_definitions("-DHAVE_READLINE")
|
||||
set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (READLINE_FOUND)
|
||||
endif(NOT SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (BZIP2_FOUND)
|
||||
set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (BZIP2_FOUND)
|
||||
|
||||
if (WHEREAMI_FOUND)
|
||||
set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||
set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
|
||||
endif (WHEREAMI_FOUND)
|
||||
|
||||
message(STATUS "===================================================================")
|
||||
if (SKIPQT EQUAL 1)
|
||||
message(STATUS "GUI support: skipped")
|
||||
else (SKIPQT EQUAL 1)
|
||||
if (Qt5_FOUND)
|
||||
message(STATUS "GUI support: QT5 found, enabled")
|
||||
else (Qt5_FOUND)
|
||||
message(STATUS "GUI support: QT5 not found, disabled")
|
||||
endif (Qt5_FOUND)
|
||||
endif (SKIPQT EQUAL 1)
|
||||
|
||||
if (SKIPBT EQUAL 1)
|
||||
message(STATUS "native BT support: skipped")
|
||||
else (SKIPBT EQUAL 1)
|
||||
if (BLUEZ_FOUND)
|
||||
message(STATUS "native BT support: Bluez found, enabled")
|
||||
else (BLUEZ_FOUND)
|
||||
message(STATUS "native BT support: Bluez not found, disabled")
|
||||
endif (BLUEZ_FOUND)
|
||||
endif(SKIPBT EQUAL 1)
|
||||
|
||||
if (EMBED_BZIP2)
|
||||
message(STATUS "Bzip2 library: embedded")
|
||||
else (EMBED_BZIP2)
|
||||
message(STATUS "Bzip2 library: system library found")
|
||||
endif (EMBED_BZIP2)
|
||||
|
||||
if (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
message(STATUS "Jansson library: local library forced")
|
||||
else (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
if (JANSSON_FOUND)
|
||||
message(STATUS "Jansson library: system library found")
|
||||
else (JANSSON_FOUND)
|
||||
message(STATUS "Jansson library: system library not found, using local library")
|
||||
endif (JANSSON_FOUND)
|
||||
endif (SKIPJANSSONSYSTEM EQUAL 1)
|
||||
|
||||
if (SKIPPYTHON EQUAL 1)
|
||||
message(STATUS "Python3 library: skipped")
|
||||
else (SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND)
|
||||
message(STATUS "Python3 library: Python3 embed found, enabled")
|
||||
elseif (PYTHON_FOUND)
|
||||
message(STATUS "Python3 library: Python3 found, enabled")
|
||||
else (PYTHON3EMBED_FOUND)
|
||||
message(STATUS "Python3 library: Python3 not found, disabled")
|
||||
endif (PYTHON3EMBED_FOUND)
|
||||
endif(SKIPPYTHON EQUAL 1)
|
||||
|
||||
if (SKIPREADLINE EQUAL 1)
|
||||
message(STATUS "Readline library: skipped")
|
||||
else (SKIPREADLINE EQUAL 1)
|
||||
if (READLINE_FOUND)
|
||||
if (EMBED_READLINE)
|
||||
message(STATUS "Readline library: embedded")
|
||||
else (EMBED_READLINE)
|
||||
message(STATUS "Readline library: system library found")
|
||||
endif (EMBED_READLINE)
|
||||
else (READLINE_FOUND)
|
||||
message(STATUS "Readline library: Readline not found, disabled")
|
||||
endif (READLINE_FOUND)
|
||||
endif(SKIPREADLINE EQUAL 1)
|
||||
|
||||
if (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
message(STATUS "Whereami library: local library forced")
|
||||
else (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
if (WHEREAMI_FOUND)
|
||||
message(STATUS "Whereami library: system library found")
|
||||
else (WHEREAMI_FOUND)
|
||||
message(STATUS "Whereami library: system library not found, using local library")
|
||||
endif (WHEREAMI_FOUND)
|
||||
endif (SKIPWHEREAMISYSTEM EQUAL 1)
|
||||
message(STATUS "===================================================================")
|
||||
|
||||
# Lua SWIG
|
||||
if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/pm3_luawrap.c
|
||||
${TARGET_SOURCES})
|
||||
add_definitions(-DHAVE_LUA_SWIG)
|
||||
message("Lua SWIG wrapper found")
|
||||
endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
|
||||
|
||||
# Python SWIG
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
|
||||
set (TARGET_SOURCES
|
||||
${PM3_ROOT}/client/src/pm3_pywrap.c
|
||||
${TARGET_SOURCES})
|
||||
add_definitions(-DHAVE_PYTHON_SWIG)
|
||||
message("Python SWIG wrapper found")
|
||||
endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
|
||||
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
||||
|
||||
add_library(pm3rrg_rdv4 SHARED
|
||||
${PM3_ROOT}/client/src/proxmark3.c
|
||||
${TARGET_SOURCES}
|
||||
${ADDITIONAL_SRC}
|
||||
)
|
||||
|
||||
target_compile_definitions(pm3rrg_rdv4 PRIVATE LIBPM3)
|
||||
|
||||
target_compile_options(pm3rrg_rdv4 PUBLIC -Wall -Werror -O3)
|
||||
if (EMBED_READLINE)
|
||||
if (NOT SKIPREADLINE EQUAL 1)
|
||||
add_dependencies(pm3rrg_rdv4 ncurses readline)
|
||||
endif (NOT SKIPREADLINE EQUAL 1)
|
||||
endif (EMBED_READLINE)
|
||||
if (EMBED_BZIP2)
|
||||
add_dependencies(pm3rrg_rdv4 bzip2)
|
||||
endif (EMBED_BZIP2)
|
||||
|
||||
if (MINGW)
|
||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
|
||||
# FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
|
||||
# but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
|
||||
target_compile_definitions(pm3rrg_rdv4 PRIVATE _ISOC99_SOURCE)
|
||||
|
||||
set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
|
||||
endif (MINGW)
|
||||
|
||||
target_include_directories(pm3rrg_rdv4 PRIVATE
|
||||
${PM3_ROOT}/common
|
||||
${PM3_ROOT}/common_fpga
|
||||
${PM3_ROOT}/include
|
||||
${PM3_ROOT}/client/src
|
||||
${PM3_ROOT}/client/include
|
||||
${ADDITIONAL_DIRS}
|
||||
)
|
||||
|
||||
if (NOT APPLE)
|
||||
# required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
|
||||
set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
|
||||
endif (NOT APPLE)
|
||||
|
||||
if (NOT JANSSON_FOUND)
|
||||
set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
|
||||
endif (NOT JANSSON_FOUND)
|
||||
if (NOT WHEREAMI_FOUND)
|
||||
set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
|
||||
endif (NOT WHEREAMI_FOUND)
|
||||
|
||||
target_link_libraries(pm3rrg_rdv4 PRIVATE
|
||||
m
|
||||
pm3rrg_rdv4_mbedtls
|
||||
pm3rrg_rdv4_cliparser
|
||||
pm3rrg_rdv4_lua
|
||||
pm3rrg_rdv4_tinycbor
|
||||
pm3rrg_rdv4_amiibo
|
||||
pm3rrg_rdv4_reveng
|
||||
pm3rrg_rdv4_hardnested
|
||||
${ADDITIONAL_LNK})
|
||||
|
||||
if (NOT SKIPPTHREAD EQUAL 1)
|
||||
target_link_libraries(pm3rrg_rdv4 PRIVATE pthread)
|
||||
endif (NOT SKIPPTHREAD EQUAL 1)
|
||||
|
||||
if (NOT SKIPPYTHON EQUAL 1)
|
||||
# OSX have a hard time compiling python3 dependency with older cmake.
|
||||
if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||
target_link_directories(pm3rrg_rdv4 PRIVATE ${ADDITIONAL_LNKDIRS})
|
||||
elseif (APPLE)
|
||||
message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
|
||||
endif (NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
|
||||
endif (NOT SKIPPYTHON EQUAL 1)
|
3
client/experimental_lib/example_c/01make_test.sh
Executable file
3
client/experimental_lib/example_c/01make_test.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
gcc -o test test.c -I../../include -lpm3rrg_rdv4 -L../build -lpthread
|
3
client/experimental_lib/example_c/02run_test.sh
Executable file
3
client/experimental_lib/example_c/02run_test.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
LD_LIBRARY_PATH=../build ./test
|
8
client/experimental_lib/example_c/test.c
Normal file
8
client/experimental_lib/example_c/test.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include "pm3.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
pm3 *p;
|
||||
p = pm3_open("/dev/ttyACM0");
|
||||
pm3_console(p, "hw status");
|
||||
pm3_close(p);
|
||||
}
|
3
client/experimental_lib/example_lua/01link_lib.sh
Executable file
3
client/experimental_lib/example_lua/01link_lib.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
ln -fs ../build/libpm3rrg_rdv4.so pm3.so
|
8
client/experimental_lib/example_lua/02run_test.sh
Executable file
8
client/experimental_lib/example_lua/02run_test.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# pm3.so somewhere in default LUA_CPATH :
|
||||
# /usr/local/lib/lua/5.2/pm3.so
|
||||
# /usr/lib/lua/5.2/pm3.so
|
||||
# ./pm3.so
|
||||
|
||||
./test.lua
|
6
client/experimental_lib/example_lua/test.lua
Executable file
6
client/experimental_lib/example_lua/test.lua
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env lua
|
||||
|
||||
local pm3 = require("pm3")
|
||||
p=pm3.pm3("/dev/ttyACM0")
|
||||
p:console("hw status")
|
||||
print(p.name)
|
3
client/experimental_lib/example_py/01link_lib.sh
Executable file
3
client/experimental_lib/example_py/01link_lib.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
ln -fs ../build/libpm3rrg_rdv4.so _pm3.so
|
11
client/experimental_lib/example_py/02run_test.sh
Executable file
11
client/experimental_lib/example_py/02run_test.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
#/usr/local/lib/python3/dist-packages/_pm3.cpython-38.so
|
||||
#/usr/local/lib/python3/dist-packages/_pm3.abi3.so
|
||||
#/usr/local/lib/python3/dist-packages/pm3.py
|
||||
#/usr/lib/python3/dist-packages/_pm3.cpython-38.so
|
||||
#/usr/lib/python3/dist-packages/_pm3.abi3.so
|
||||
#/usr/lib/python3/dist-packages/pm3.py
|
||||
|
||||
# need access to pm3.py
|
||||
PYTHONPATH=../../src ./test.py
|
3
client/experimental_lib/example_py/02run_test_interactive.sh
Executable file
3
client/experimental_lib/example_py/02run_test_interactive.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
PYTHONPATH=../../src ipython3 -i ./test.py
|
6
client/experimental_lib/example_py/test.py
Executable file
6
client/experimental_lib/example_py/test.py
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pm3
|
||||
p=pm3.pm3("/dev/ttyACM0")
|
||||
p.console("hw status")
|
||||
print("Device:", p.name)
|
11
client/include/pm3.h
Normal file
11
client/include/pm3.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef LIBPM3_H
|
||||
#define LIBPM3_H
|
||||
|
||||
typedef struct pm3_device pm3;
|
||||
|
||||
pm3 *pm3_open(char *port);
|
||||
int pm3_console(pm3* dev, char *cmd);
|
||||
const char *pm3_name_get(pm3* dev);
|
||||
void pm3_close(pm3* dev);
|
||||
pm3 *pm3_get_current_dev(void);
|
||||
#endif // LIBPM3_H
|
|
@ -666,15 +666,15 @@ static int CmdConnect(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (session.pm3_present) {
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
}
|
||||
|
||||
// 10 second timeout
|
||||
OpenProxmark(port, false, 10, false, baudrate);
|
||||
OpenProxmark(&session.current_device, port, false, 10, false, baudrate);
|
||||
|
||||
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark3\n");
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 2020, added Python support (@iceman1001)
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -32,7 +31,15 @@
|
|||
#include "ui.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#ifdef HAVE_LUA_SWIG
|
||||
extern int luaopen_pm3(lua_State* L);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
#ifdef HAVE_PYTHON_SWIG
|
||||
extern PyObject* PyInit__pm3(void);
|
||||
#endif // HAVE_PYTHON_SWIG
|
||||
|
||||
// Partly ripped from PyRun_SimpleFileExFlags
|
||||
// but does not terminate client on sys.exit
|
||||
// and print exit code only if != 0
|
||||
|
@ -274,7 +281,9 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
|
||||
//Add the 'bit' library
|
||||
set_bit_library(lua_state);
|
||||
|
||||
#ifdef HAVE_LUA_SWIG
|
||||
luaL_requiref(lua_state, "pm3", luaopen_pm3, 1);
|
||||
#endif
|
||||
error = luaL_loadfile(lua_state, script_path);
|
||||
free(script_path);
|
||||
if (!error) {
|
||||
|
@ -355,6 +364,10 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
|
||||
// optional but recommended
|
||||
Py_SetProgramName(program);
|
||||
#ifdef HAVE_PYTHON_SWIG
|
||||
// hook Proxmark3 API
|
||||
PyImport_AppendInittab("_pm3", PyInit__pm3);
|
||||
#endif
|
||||
Py_Initialize();
|
||||
|
||||
//int argc, char ** argv
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "uart/uart.h"
|
||||
#include "ui.h"
|
||||
|
@ -541,7 +542,7 @@ bool IsCommunicationThreadDead(void) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool OpenProxmark(char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||
bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||
|
||||
if (!wait_for_port) {
|
||||
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), port);
|
||||
|
@ -588,15 +589,17 @@ bool OpenProxmark(char *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
|
||||
pthread_create(&communication_thread, NULL, &uart_communication, &conn);
|
||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
session.pm3_present = true;
|
||||
session.pm3_present = true; // TODO support for multiple devices
|
||||
|
||||
fflush(stdout);
|
||||
*dev = malloc(sizeof(pm3_device));
|
||||
(*dev)->conn = &conn; // TODO conn shouldn't be global
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// check if we can communicate with Pm3
|
||||
int TestProxmark(void) {
|
||||
int TestProxmark(pm3_device *dev) {
|
||||
|
||||
PacketResponseNG resp;
|
||||
uint16_t len = 32;
|
||||
|
@ -659,8 +662,8 @@ int TestProxmark(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void CloseProxmark(void) {
|
||||
conn.run = false;
|
||||
void CloseProxmark(pm3_device *dev) {
|
||||
dev->conn->run = false;
|
||||
|
||||
#ifdef __BIONIC__
|
||||
if (communication_thread != 0) {
|
||||
|
|
|
@ -65,6 +65,12 @@ typedef struct {
|
|||
|
||||
extern communication_arg_t conn;
|
||||
|
||||
typedef struct pm3_device pm3_device;
|
||||
struct pm3_device {
|
||||
communication_arg_t *conn;
|
||||
int script_embedded;
|
||||
};
|
||||
|
||||
void *uart_receiver(void *targ);
|
||||
void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
|
@ -74,9 +80,10 @@ void clearCommandBuffer(void);
|
|||
|
||||
#define FLASHMODE_SPEED 460800
|
||||
bool IsCommunicationThreadDead(void);
|
||||
bool OpenProxmark(char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
int TestProxmark(void);
|
||||
void CloseProxmark(void);
|
||||
typedef struct pm3_device pm3_device;
|
||||
bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
int TestProxmark(pm3_device *dev);
|
||||
void CloseProxmark(pm3_device *dev);
|
||||
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool WaitForResponseTimeout(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout);
|
||||
|
|
|
@ -373,11 +373,11 @@ static int enter_bootloader(char *serial_port_name) {
|
|||
PrintAndLogEx(SUCCESS, "Press and hold down button NOW if your bootloader requires it.");
|
||||
}
|
||||
msleep(100);
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
// Let time to OS to make the port disappear
|
||||
msleep(1000);
|
||||
|
||||
if (OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
if (OpenProxmark(&session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_(" found"));
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
|
|
55
client/src/pm3.c
Normal file
55
client/src/pm3.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// User API
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "pm3.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "cmdmain.h"
|
||||
#include "ui.h"
|
||||
#include "usart_defs.h"
|
||||
#include "util_posix.h"
|
||||
#include "comms.h"
|
||||
|
||||
pm3_device* pm3_open(char *port) {
|
||||
pm3_init();
|
||||
OpenProxmark(&session.current_device, port, false, 20, false, USART_BAUD_RATE);
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark\n");
|
||||
CloseProxmark(session.current_device);
|
||||
}
|
||||
|
||||
if ((port != NULL) && (!session.pm3_present))
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (!session.pm3_present)
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode");
|
||||
// For now, there is no real device context:
|
||||
return session.current_device;
|
||||
}
|
||||
|
||||
void pm3_close(pm3_device* dev) {
|
||||
// Clean up the port
|
||||
if (session.pm3_present) {
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_QUIT_SESSION, NULL, 0);
|
||||
msleep(100); // Make sure command is sent before killing client
|
||||
CloseProxmark(dev);
|
||||
}
|
||||
}
|
||||
|
||||
int pm3_console(pm3_device* dev, char *Cmd) {
|
||||
// For now, there is no real device context:
|
||||
(void) dev;
|
||||
return CommandReceived(Cmd);
|
||||
}
|
||||
|
||||
const char *pm3_name_get(pm3_device* dev) {
|
||||
return dev->conn->serial_port_name;
|
||||
}
|
||||
|
||||
pm3_device* pm3_get_current_dev(void) {
|
||||
return session.current_device;
|
||||
}
|
39
client/src/pm3.i
Normal file
39
client/src/pm3.i
Normal file
|
@ -0,0 +1,39 @@
|
|||
%module pm3
|
||||
%{
|
||||
/* Include the header in the wrapper code */
|
||||
#include "pm3.h"
|
||||
#include "comms.h"
|
||||
%}
|
||||
|
||||
/* Strip "pm3_" from API functions for SWIG */
|
||||
%rename("%(strip:[pm3_])s") "";
|
||||
%feature("immutable","1") pm3_current_dev;
|
||||
typedef struct {
|
||||
%extend {
|
||||
pm3() {
|
||||
printf("SWIG pm3 constructor, get current pm3\n");
|
||||
pm3_device * p = pm3_get_current_dev();
|
||||
p->script_embedded = 1;
|
||||
return p;
|
||||
}
|
||||
pm3(char *port) {
|
||||
printf("SWIG pm3 constructor with port, open pm3\n");
|
||||
pm3_device * p = pm3_open(port);
|
||||
p->script_embedded = 0;
|
||||
return p;
|
||||
}
|
||||
~pm3() {
|
||||
if ($self->script_embedded) {
|
||||
printf("SWIG pm3 destructor, nothing to do\n");
|
||||
} else {
|
||||
printf("SWIG pm3 destructor, close pm3\n");
|
||||
pm3_close($self);
|
||||
}
|
||||
}
|
||||
int console(char *cmd);
|
||||
char const * const name;
|
||||
}
|
||||
} pm3;
|
||||
//%nodefaultctor device;
|
||||
//%nodefaultdtor device;
|
||||
/* Parse the header file to generate wrappers */
|
80
client/src/pm3.py
Normal file
80
client/src/pm3.py
Normal file
|
@ -0,0 +1,80 @@
|
|||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 4.0.1
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
from sys import version_info as _swig_python_version_info
|
||||
if _swig_python_version_info < (2, 7, 0):
|
||||
raise RuntimeError("Python 2.7 or later required")
|
||||
|
||||
# Import the low-level C/C++ module
|
||||
if __package__ or "." in __name__:
|
||||
from . import _pm3
|
||||
else:
|
||||
import _pm3
|
||||
|
||||
try:
|
||||
import builtins as __builtin__
|
||||
except ImportError:
|
||||
import __builtin__
|
||||
|
||||
def _swig_repr(self):
|
||||
try:
|
||||
strthis = "proxy of " + self.this.__repr__()
|
||||
except __builtin__.Exception:
|
||||
strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_instance_variable(set):
|
||||
def set_instance_attr(self, name, value):
|
||||
if name == "thisown":
|
||||
self.this.own(value)
|
||||
elif name == "this":
|
||||
set(self, name, value)
|
||||
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
|
||||
set(self, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add instance attributes to %s" % self)
|
||||
return set_instance_attr
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_class_variable(set):
|
||||
def set_class_attr(cls, name, value):
|
||||
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
|
||||
set(cls, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add class attributes to %s" % cls)
|
||||
return set_class_attr
|
||||
|
||||
|
||||
def _swig_add_metaclass(metaclass):
|
||||
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
|
||||
def wrapper(cls):
|
||||
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
|
||||
return wrapper
|
||||
|
||||
|
||||
class _SwigNonDynamicMeta(type):
|
||||
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
|
||||
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
|
||||
|
||||
|
||||
class pm3(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def __init__(self, *args):
|
||||
_pm3.pm3_swiginit(self, _pm3.new_pm3(*args))
|
||||
__swig_destroy__ = _pm3.delete_pm3
|
||||
|
||||
def console(self, cmd):
|
||||
return _pm3.pm3_console(self, cmd)
|
||||
name = property(_pm3.pm3_name_get)
|
||||
|
||||
# Register pm3 in _pm3:
|
||||
_pm3.pm3_swigregister(pm3)
|
||||
|
||||
|
||||
|
3259
client/src/pm3_luawrap.c
Normal file
3259
client/src/pm3_luawrap.c
Normal file
File diff suppressed because it is too large
Load diff
3781
client/src/pm3_pywrap.c
Normal file
3781
client/src/pm3_pywrap.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -34,6 +34,7 @@
|
|||
#include "flash.h"
|
||||
#include "preferences.h"
|
||||
|
||||
#ifndef LIBPM3
|
||||
#define BANNERMSG1 " Iceman :coffee:"
|
||||
#define BANNERMSG2 " :snowflake: bleeding edge"
|
||||
#define BANNERMSG3 " https://github.com/rfidresearchgroup/proxmark3/"
|
||||
|
@ -113,6 +114,7 @@ static void showBanner(void) {
|
|||
fflush(stdout);
|
||||
g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG;
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
||||
static const char *prompt_dev = "";
|
||||
static const char *prompt_ctx = "";
|
||||
|
@ -134,7 +136,7 @@ static int check_comm(void) {
|
|||
rl_set_prompt(prompt_filtered);
|
||||
rl_forced_update_display();
|
||||
#endif
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
}
|
||||
msleep(10);
|
||||
return 0;
|
||||
|
@ -452,6 +454,7 @@ check_script:
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef LIBPM3
|
||||
static void dumpAllHelp(int markdown) {
|
||||
session.help_dump_mode = true;
|
||||
PrintAndLogEx(NORMAL, "\n%sProxmark3 command dump%s\n\n", markdown ? "# " : "", markdown ? "" : "\n======================");
|
||||
|
@ -462,6 +465,7 @@ static void dumpAllHelp(int markdown) {
|
|||
dumpCommandsRecursive(cmds, markdown);
|
||||
session.help_dump_mode = false;
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
||||
static char *my_executable_path = NULL;
|
||||
static char *my_executable_directory = NULL;
|
||||
|
@ -546,6 +550,7 @@ static void set_my_user_directory(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef LIBPM3
|
||||
static void show_help(bool showFullHelp, char *exec_name) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nsyntax: %s [-h|-t|-m]", exec_name);
|
||||
|
@ -631,7 +636,7 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
|||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%s"), filepaths[i]);
|
||||
}
|
||||
|
||||
if (OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
if (OpenProxmark(&session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_(" found"));
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Could not find Proxmark3 on " _RED_("%s") ".\n", serial_port_name);
|
||||
|
@ -669,7 +674,7 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
|||
|
||||
finish:
|
||||
ret = flash_stop_flashing();
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
finish2:
|
||||
for (int i = 0 ; i < num_files; ++i) {
|
||||
if (filepaths[i] != NULL)
|
||||
|
@ -682,6 +687,7 @@ finish2:
|
|||
PrintAndLogEx(NORMAL, "\nHave a nice day!");
|
||||
return ret;
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
||||
#if defined(_WIN32)
|
||||
static bool DetectWindowsAnsiSupport(void) {
|
||||
|
@ -696,14 +702,28 @@ static bool DetectWindowsAnsiSupport(void) {
|
|||
|
||||
return SetConsoleMode(hOut, dwMode) ? true : false;
|
||||
}
|
||||
#endif
|
||||
#endif //_WIN32
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
void pm3_init(void) {
|
||||
srand(time(0));
|
||||
|
||||
session.pm3_present = false;
|
||||
session.help_dump_mode = false;
|
||||
session.incognito = false;
|
||||
session.supports_colors = false;
|
||||
session.emoji_mode = ALTTEXT;
|
||||
session.stdinOnTTY = false;
|
||||
session.stdoutOnTTY = false;
|
||||
|
||||
// set global variables soon enough to get the log path
|
||||
set_my_executable_path();
|
||||
set_my_user_directory();
|
||||
|
||||
}
|
||||
|
||||
#ifndef LIBPM3
|
||||
int main(int argc, char *argv[]) {
|
||||
pm3_init();
|
||||
bool waitCOMPort = false;
|
||||
bool addLuaExec = false;
|
||||
bool stayInCommandLoop = false;
|
||||
|
@ -737,10 +757,6 @@ int main(int argc, char *argv[]) {
|
|||
int flash_num_files = 0;
|
||||
char *flash_filenames[FLASH_MAX_FILES];
|
||||
|
||||
// set global variables soon enough to get the log path
|
||||
set_my_executable_path();
|
||||
set_my_user_directory();
|
||||
|
||||
// color management:
|
||||
// 1. default = no color
|
||||
// 2. enable colors if OS seems to support colors and if stdin/stdout aren't redirected
|
||||
|
@ -999,12 +1015,12 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// try to open USB connection to Proxmark
|
||||
if (port != NULL) {
|
||||
OpenProxmark(port, waitCOMPort, 20, false, speed);
|
||||
OpenProxmark(&session.current_device, port, waitCOMPort, 20, false, speed);
|
||||
}
|
||||
|
||||
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark\n");
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
}
|
||||
|
||||
if ((port != NULL) && (!session.pm3_present))
|
||||
|
@ -1060,10 +1076,11 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Clean up the port
|
||||
if (session.pm3_present) {
|
||||
CloseProxmark();
|
||||
CloseProxmark(session.current_device);
|
||||
}
|
||||
|
||||
if (session.window_changed) // Plot/Overlay moved or resized
|
||||
preferences_save();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
|
|
@ -49,6 +49,7 @@ int push_cmdscriptfile(char *path, bool stayafter);
|
|||
const char *get_my_executable_path(void);
|
||||
const char *get_my_executable_directory(void);
|
||||
const char *get_my_user_directory(void);
|
||||
void pm3_init(void);
|
||||
void main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <pthread.h>
|
||||
#include "common.h"
|
||||
#include "comms.h"
|
||||
#include "ansi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -46,6 +47,7 @@ typedef struct {
|
|||
clientdebugLevel_t client_debug_level;
|
||||
// uint8_t device_debug_level;
|
||||
char *history_path;
|
||||
pm3_device *current_device;
|
||||
} session_arg_t;
|
||||
|
||||
extern session_arg_t session;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue