@@ -597,7 +597,11 @@ static void set_my_user_directory(void) {
597
597
static void show_help (bool showFullHelp , char * exec_name ) {
598
598
599
599
PrintAndLogEx (NORMAL , "\nsyntax: %s [-h|-t|-m|--fulltext]" , exec_name );
600
+ #ifdef HAVE_PYTHON
601
+ PrintAndLogEx (NORMAL , " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-y <python_script_file>]|[-s <cmd_script_file>] [-i] [-d <0|1|2>]" , exec_name );
602
+ #else // HAVE_PYTHON
600
603
PrintAndLogEx (NORMAL , " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-s <cmd_script_file>] [-i] [-d <0|1|2>]" , exec_name );
604
+ #endif // HAVE_PYTHON
601
605
PrintAndLogEx (NORMAL , " %s [-p] <port> --flash [--unlock-bootloader] [--image <imagefile>]+ [-w] [-f] [-d <0|1|2>]" , exec_name );
602
606
603
607
if (showFullHelp ) {
@@ -615,7 +619,11 @@ static void show_help(bool showFullHelp, char *exec_name) {
615
619
PrintAndLogEx (NORMAL , " -m/--markdown dump all interactive command list at once in markdown syntax" );
616
620
PrintAndLogEx (NORMAL , " -b/--baud serial port speed (only needed for physical UART, not for USB-CDC or BT)" );
617
621
PrintAndLogEx (NORMAL , " -c/--command <command> execute one Proxmark3 command (or several separated by ';')." );
618
- PrintAndLogEx (NORMAL , " -l/--lua <lua script file> execute lua script." );
622
+ PrintAndLogEx (NORMAL , " -l/--lua <lua_script_file> execute Lua script." );
623
+ #ifdef HAVE_PYTHON
624
+ // Technically, --lua and --py are identical and interexchangeable
625
+ PrintAndLogEx (NORMAL , " -y/--py <python_script_file> execute Python script." );
626
+ #endif // HAVE_PYTHON
619
627
PrintAndLogEx (NORMAL , " -s/--script-file <cmd_script_file> script file with one Proxmark3 command per line" );
620
628
PrintAndLogEx (NORMAL , " -i/--interactive enter interactive mode after executing the script or the command" );
621
629
PrintAndLogEx (NORMAL , " --incognito do not use history, prefs file nor log files" );
@@ -631,7 +639,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
631
639
PrintAndLogEx (NORMAL , " %s -- runs the pm3 client in OFFLINE mode" , exec_name );
632
640
PrintAndLogEx (NORMAL , "\n to execute different commands from terminal:\n" );
633
641
PrintAndLogEx (NORMAL , " %s " SERIAL_PORT_EXAMPLE_H " -c \"hf mf chk --1k\" -- execute cmd and quit client" , exec_name );
634
- PrintAndLogEx (NORMAL , " %s " SERIAL_PORT_EXAMPLE_H " -l hf_read -- execute lua script `hf_read` and quit client" , exec_name );
642
+ PrintAndLogEx (NORMAL , " %s " SERIAL_PORT_EXAMPLE_H " -l hf_read -- execute Lua script `hf_read` and quit client" , exec_name );
635
643
PrintAndLogEx (NORMAL , " %s " SERIAL_PORT_EXAMPLE_H " -s mycmds.txt -- execute each pm3 cmd in file and quit client" , exec_name );
636
644
PrintAndLogEx (NORMAL , "\n to flash fullimage and bootloader:\n" );
637
645
PrintAndLogEx (NORMAL , " %s " SERIAL_PORT_EXAMPLE_H " --flash --unlock-bootloader --image bootrom.elf --image fullimage.elf" , exec_name );
@@ -756,7 +764,7 @@ void pm3_init(void) {
756
764
int main (int argc , char * argv []) {
757
765
pm3_init ();
758
766
bool waitCOMPort = false;
759
- bool addLuaExec = false;
767
+ bool addScriptExec = false;
760
768
bool stayInCommandLoop = false;
761
769
char * script_cmds_file = NULL ;
762
770
char * script_cmd = NULL ;
@@ -939,21 +947,36 @@ int main(int argc, char *argv[]) {
939
947
continue ;
940
948
}
941
949
942
- // execute lua script
950
+ // execute Lua script
943
951
if (strcmp (argv [i ], "-l" ) == 0 || strcmp (argv [i ], "--lua" ) == 0 ) {
944
952
if (i + 1 == argc || strlen (argv [i + 1 ]) == 0 ) {
945
- PrintAndLogEx (ERR , _RED_ ("ERROR:" ) " missing lua script specification after -l \n" );
953
+ PrintAndLogEx (ERR , _RED_ ("ERROR:" ) " missing Lua script specification after --lua \n" );
946
954
show_help (false, exec_name );
947
955
return 1 ;
948
956
}
949
957
script_cmd = argv [++ i ];
950
958
if (script_cmd == NULL || strlen (script_cmd ) == 0 ) {
951
959
return 1 ;
952
960
}
953
- addLuaExec = true;
961
+ addScriptExec = true;
954
962
continue ;
955
963
}
956
-
964
+ #ifdef HAVE_PYTHON
965
+ // execute Python script
966
+ if (strcmp (argv [i ], "-y" ) == 0 || strcmp (argv [i ], "--py" ) == 0 ) {
967
+ if (i + 1 == argc || strlen (argv [i + 1 ]) == 0 ) {
968
+ PrintAndLogEx (ERR , _RED_ ("ERROR:" ) " missing Python script specification after --py\n" );
969
+ show_help (false, exec_name );
970
+ return 1 ;
971
+ }
972
+ script_cmd = argv [++ i ];
973
+ if (script_cmd == NULL || strlen (script_cmd ) == 0 ) {
974
+ return 1 ;
975
+ }
976
+ addScriptExec = true;
977
+ continue ;
978
+ }
979
+ #endif // HAVE_PYTHON
957
980
// go to interactive instead of quitting after a script/command
958
981
if (strcmp (argv [i ], "-i" ) == 0 || strcmp (argv [i ], "--interactive" ) == 0 ) {
959
982
stayInCommandLoop = true;
@@ -1032,7 +1055,7 @@ int main(int argc, char *argv[]) {
1032
1055
PrintAndLogEx (ERR , _RED_ ("ERROR:" ) " execute command: " _YELLOW_ ("command not found" ) ".\n" );
1033
1056
return 2 ;
1034
1057
} else {
1035
- if (addLuaExec ) {
1058
+ if (addScriptExec ) {
1036
1059
// add "script run " to command
1037
1060
int len = strlen (script_cmd ) + 11 + 1 ;
1038
1061
char * ctmp = (char * ) calloc (len , sizeof (uint8_t ));
0 commit comments