mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
ADD: 'script list' - now sorts the scripts in alphabetic order. It needs the extra define, in order to scandir and alphasort to work.
and this made our own version of le32toh function complain. So this is removed from util.c and where it was used a new define replaced it (LE32TOH)
This commit is contained in:
parent
db34c61aa0
commit
6c4d1560e9
5 changed files with 31 additions and 33 deletions
|
@ -8,6 +8,9 @@
|
|||
// Some lua scripting glue to proxmark core.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// this define is needed for scandir/alphasort to work
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -68,32 +71,32 @@ int CmdHelp(const char * Cmd)
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate list of available commands, what it does is
|
||||
* Generate a sorted list of available commands, what it does is
|
||||
* generate a file listing of the script-directory for files
|
||||
* ending with .lua
|
||||
*
|
||||
*/
|
||||
int CmdList(const char *Cmd)
|
||||
{
|
||||
DIR *dp;
|
||||
struct dirent *ep;
|
||||
int CmdList(const char *Cmd) {
|
||||
|
||||
char script_directory_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
strcpy(script_directory_path, get_my_executable_directory());
|
||||
strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY);
|
||||
dp = opendir(script_directory_path);
|
||||
|
||||
if (dp != NULL)
|
||||
{
|
||||
while ((ep = readdir (dp)) != NULL)
|
||||
{
|
||||
if(str_ends_with(ep->d_name, ".lua"))
|
||||
PrintAndLog("%-21s %s", ep->d_name, "A script file");
|
||||
struct dirent **namelist;
|
||||
int n;
|
||||
|
||||
n = scandir(script_directory_path, &namelist, NULL, alphasort);
|
||||
if (n == -1) {
|
||||
PrintAndLog ("Couldn't open the scripts-directory");
|
||||
return 1;
|
||||
}
|
||||
(void) closedir (dp);
|
||||
}
|
||||
else
|
||||
PrintAndLog ("Couldn't open the scripts-directory");
|
||||
return 0;
|
||||
|
||||
for (uint16_t i = 0; i < n; i++) {
|
||||
if(str_ends_with(namelist[i]->d_name, ".lua"))
|
||||
PrintAndLog("%-21s %s", namelist[i]->d_name, "A script file");
|
||||
free(namelist[i]);
|
||||
}
|
||||
free(namelist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "nonce2key.h"
|
||||
|
||||
// called with a uint8_t *x array
|
||||
#define LE32TOH(x) (uint32_t)( ( (x)[3]<<24) | ( (x)[2]<<16) | ( (x)[1]<<8) | (x)[0]);
|
||||
|
||||
int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_t ks_info, uint64_t * key) {
|
||||
struct Crypto1State *state;
|
||||
uint32_t i, pos, rr = 0, nr_diff;
|
||||
|
@ -241,7 +244,7 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey, bool verbose) {
|
|||
uint32_t nt0 = data.nonce; // first tag challenge (nonce)
|
||||
uint32_t nr0_enc = data.nr; // first encrypted reader challenge
|
||||
uint32_t ar0_enc = data.ar; // first encrypted reader response
|
||||
//uint32_t uid1 = le32toh(data+16);
|
||||
//uint32_t uid1 = LE32TOH(data+16);
|
||||
uint32_t nt1 = data.nonce2; // second tag challenge (nonce)
|
||||
uint32_t nr1_enc = data.nr2; // second encrypted reader challenge
|
||||
uint32_t ar1_enc = data.ar2; // second encrypted reader response
|
||||
|
@ -294,11 +297,11 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey, bool verbose) {
|
|||
}
|
||||
|
||||
int tryMfk64_ex(uint8_t *data, uint64_t *outputkey){
|
||||
uint32_t uid = le32toh(data);
|
||||
uint32_t nt = le32toh(data+4); // tag challenge
|
||||
uint32_t nr_enc = le32toh(data+8); // encrypted reader challenge
|
||||
uint32_t ar_enc = le32toh(data+12); // encrypted reader response
|
||||
uint32_t at_enc = le32toh(data+16); // encrypted tag response
|
||||
uint32_t uid = LE32TOH(data);
|
||||
uint32_t nt = LE32TOH(data+4); // tag challenge
|
||||
uint32_t nr_enc = LE32TOH(data+8); // encrypted reader challenge
|
||||
uint32_t ar_enc = LE32TOH(data+12); // encrypted reader response
|
||||
uint32_t at_enc = LE32TOH(data+16); // encrypted tag response
|
||||
return tryMfk64(uid, nt, nr_enc, ar_enc, at_enc, outputkey);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "common.h"
|
||||
#include "mifare.h" // nonces_t struct
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "util.h" // FALSE / TRUE
|
||||
#include "proxmark3.h"
|
||||
#include "mifarehost.h"
|
||||
|
||||
|
|
|
@ -534,11 +534,6 @@ void xor(unsigned char * dst, unsigned char * src, size_t len) {
|
|||
int32_t le24toh (uint8_t data[3]) {
|
||||
return (data[2] << 16) | (data[1] << 8) | data[0];
|
||||
}
|
||||
#ifndef ANDROID
|
||||
uint32_t le32toh (uint8_t *data) {
|
||||
return (uint32_t)( (data[3]<<24) | (data[2]<<16) | (data[1]<<8) | data[0]);
|
||||
}
|
||||
#endif
|
||||
// Pack a bitarray into a uint32_t.
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits) {
|
||||
|
||||
|
|
|
@ -151,9 +151,7 @@ extern void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length)
|
|||
|
||||
extern void xor(unsigned char * dst, unsigned char * src, size_t len);
|
||||
extern int32_t le24toh (uint8_t data[3]);
|
||||
#ifndef ANDROID
|
||||
extern uint32_t le32toh (uint8_t *data);
|
||||
#endif
|
||||
|
||||
extern uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits);
|
||||
extern void rol(uint8_t *data, const size_t len);
|
||||
extern uint32_t SwapBits(uint32_t value, int nrbits);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue