pm3_console() in Python/Lua/C: replace passthru by capture and quiet

This commit is contained in:
Philippe Teuwen 2024-10-29 21:12:20 +01:00
parent 57ec287ab0
commit de96479d80
16 changed files with 4341 additions and 4193 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Changed `pm3_console()` - Python/Lua/C: replace `passthru` by `capture` and `quiet` (@doegox)
- Fixed `hf iclass list` - annotation crc handled better (@iceman1001) - Fixed `hf iclass list` - annotation crc handled better (@iceman1001)
- Fixed `hf_mf_uscuid_prog.lua` - bad divisions and code style fixes (@iceman1001) - Fixed `hf_mf_uscuid_prog.lua` - bad divisions and code style fixes (@iceman1001)
- Changed `hf iclass info` - now checks for cards silicon version (@antiklesys) - Changed `hf iclass info` - now checks for cards silicon version (@antiklesys)

View file

@ -13,3 +13,4 @@
ln -s build/proxmark3 . ln -s build/proxmark3 .
) )
ln -s ../pyscripts/pm3.py ln -s ../pyscripts/pm3.py
ln -s ../lualibs/dkjson.lua

View file

@ -1,4 +1,8 @@
#!/bin/bash #!/bin/bash
cd .. (
make -j cd ..
make -j
)
ln -s ../pyscripts/pm3.py
ln -s ../lualibs/dkjson.lua

View file

@ -10,7 +10,7 @@ for line in p.grabbed_output:gmatch("[^\r\n]+") do
end end
print("Device:", p.name) print("Device:", p.name)
p:console("Rem passthru remark! :coffee:", true) p:console("Rem passthru remark! :coffee:", false, false)
local json = require("dkjson") local json = require("dkjson")
print("Fetching prefs:") print("Fetching prefs:")

View file

@ -11,7 +11,7 @@ for line in p.grabbed_output.split('\n'):
if "uC:" in line: if "uC:" in line:
print(line) print(line)
print("Device:", p.name) print("Device:", p.name)
p.console("Rem passthru remark! :coffee:", True) p.console("Rem passthru remark! :coffee:", capture=False, quiet=False)
import json import json
print("Fetching prefs:") print("Fetching prefs:")

View file

@ -9,6 +9,6 @@ int main(int argc, char *argv[]) {
} }
pm3 *p; pm3 *p;
p = pm3_open(argv[1]); p = pm3_open(argv[1]);
pm3_console(p, "hw status", true); pm3_console(p, "hw status", false, false);
pm3_close(p); pm3_close(p);
} }

View file

@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
p = pm3_open(argv[1]); p = pm3_open(argv[1]);
// Execute the command // Execute the command
pm3_console(p, "hw status", false); pm3_console(p, "hw status", true, true);
const char *buf = pm3_grabbed_output_get(p); const char *buf = pm3_grabbed_output_get(p);
const char *line_start = buf; const char *line_start = buf;

View file

@ -12,7 +12,7 @@ for line in p.grabbed_output:gmatch("[^\r\n]+") do
end end
print("Device:", p.name) print("Device:", p.name)
p:console("Rem passthru remark! :coffee:", true) p:console("Rem passthru remark! :coffee:", false, false)
local json = require("dkjson") local json = require("dkjson")
print("Fetching prefs:") print("Fetching prefs:")

View file

@ -11,7 +11,7 @@ for line in p.grabbed_output.split('\n'):
if "uC:" in line: if "uC:" in line:
print(line) print(line)
print("Device:", p.name) print("Device:", p.name)
p.console("Rem passthru remark! :coffee:", True) p.console("Rem passthru remark! :coffee:", capture=False, quiet=False)
import json import json
print("Fetching prefs:") print("Fetching prefs:")

View file

@ -21,7 +21,7 @@
typedef struct pm3_device pm3; typedef struct pm3_device pm3;
pm3 *pm3_open(const char *port); pm3 *pm3_open(const char *port);
int pm3_console(pm3 *dev, const char *cmd, bool passthru); int pm3_console(pm3 *dev, const char *cmd, bool capture, bool quiet);
const char *pm3_grabbed_output_get(pm3 *dev); const char *pm3_grabbed_output_get(pm3 *dev);
const char *pm3_name_get(pm3 *dev); const char *pm3_name_get(pm3 *dev);
void pm3_close(pm3 *dev); void pm3_close(pm3 *dev);

View file

@ -538,7 +538,7 @@ if args.final_check:
cmd = f"hf mf fchk -f keys_{uid:08x}.dic --no-default --dump" cmd = f"hf mf fchk -f keys_{uid:08x}.dic --no-default --dump"
if args.debug: if args.debug:
print(cmd) print(cmd)
p.console(cmd, passthru=True) p.console(cmd, capture=False, quiet=False)
else: else:
print() print()
print(plus + color("found keys:", fg="green")) print(plus + color("found keys:", fg="green"))

View file

@ -66,8 +66,8 @@ class pm3(object):
_pm3.pm3_swiginit(self, _pm3.new_pm3(*args)) _pm3.pm3_swiginit(self, _pm3.new_pm3(*args))
__swig_destroy__ = _pm3.delete_pm3 __swig_destroy__ = _pm3.delete_pm3
def console(self, cmd, passthru=False): def console(self, cmd, capture=True, quiet=True):
return _pm3.pm3_console(self, cmd, passthru) return _pm3.pm3_console(self, cmd, capture, quiet)
name = property(_pm3.pm3_name_get) name = property(_pm3.pm3_name_get)
grabbed_output = property(_pm3.pm3_grabbed_output_get) grabbed_output = property(_pm3.pm3_grabbed_output_get)

View file

@ -58,12 +58,14 @@ void pm3_close(pm3_device_t *dev) {
free_grabber(); free_grabber();
} }
int pm3_console(pm3_device_t *dev, const char *cmd, bool passthru) { int pm3_console(pm3_device_t *dev, const char *cmd, bool capture, bool quiet) {
// For now, there is no real device context: // For now, there is no real device context:
(void) dev; (void) dev;
uint8_t prev_printAndLog = g_printAndLog; uint8_t prev_printAndLog = g_printAndLog;
if (! passthru) { if (capture) {
g_printAndLog |= PRINTANDLOG_GRAB; g_printAndLog |= PRINTANDLOG_GRAB;
}
if (quiet) {
g_printAndLog &= ~PRINTANDLOG_PRINT; g_printAndLog &= ~PRINTANDLOG_PRINT;
} }
int ret = CommandReceived(cmd); int ret = CommandReceived(cmd);

View file

@ -11,8 +11,11 @@
#ifdef PYWRAP #ifdef PYWRAP
#include <Python.h> #include <Python.h>
%typemap(default) bool passthru { %typemap(default) bool capture {
$1 = Py_False; $1 = Py_True;
}
%typemap(default) bool quiet {
$1 = Py_True;
} }
#endif #endif
typedef struct { typedef struct {
@ -37,7 +40,7 @@ typedef struct {
pm3_close($self); pm3_close($self);
} }
} }
int console(char *cmd, bool passthru = false); int console(char *cmd, bool capture = true, bool quiet = true);
char const * const name; char const * const name;
char const * const grabbed_output; char const * const grabbed_output;
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff