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

@ -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...
## [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_mf_uscuid_prog.lua` - bad divisions and code style fixes (@iceman1001)
- Changed `hf iclass info` - now checks for cards silicon version (@antiklesys)

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

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

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

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

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

@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
p = pm3_open(argv[1]);
// 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 *line_start = buf;

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

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

@ -21,7 +21,7 @@
typedef struct pm3_device pm3;
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_name_get(pm3 *dev);
void pm3_close(pm3 *dev);

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

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

@ -58,12 +58,14 @@ void pm3_close(pm3_device_t *dev) {
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:
(void) dev;
uint8_t prev_printAndLog = g_printAndLog;
if (! passthru) {
if (capture) {
g_printAndLog |= PRINTANDLOG_GRAB;
}
if (quiet) {
g_printAndLog &= ~PRINTANDLOG_PRINT;
}
int ret = CommandReceived(cmd);

@ -11,8 +11,11 @@
#ifdef PYWRAP
#include <Python.h>
%typemap(default) bool passthru {
$1 = Py_False;
%typemap(default) bool capture {
$1 = Py_True;
}
%typemap(default) bool quiet {
$1 = Py_True;
}
#endif
typedef struct {
@ -37,7 +40,7 @@ typedef struct {
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 grabbed_output;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff