mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-15 01:33:00 -07:00
multiple proxmark device support [Mohamed Elsabagh]
This commit is contained in:
parent
bd84638614
commit
602ac4d7c5
3 changed files with 60 additions and 5 deletions
|
@ -113,6 +113,8 @@ usb_dev_handle* findProxmark(int verbose, unsigned int *iface)
|
||||||
{
|
{
|
||||||
struct usb_bus *busses, *bus;
|
struct usb_bus *busses, *bus;
|
||||||
usb_dev_handle *handle = NULL;
|
usb_dev_handle *handle = NULL;
|
||||||
|
struct prox_unit units[50];
|
||||||
|
int iUnit = 0;
|
||||||
|
|
||||||
usb_find_busses();
|
usb_find_busses();
|
||||||
usb_find_devices();
|
usb_find_devices();
|
||||||
|
@ -129,16 +131,48 @@ usb_dev_handle* findProxmark(int verbose, unsigned int *iface)
|
||||||
handle = usb_open(dev);
|
handle = usb_open(dev);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "open failed: %s!\n", usb_strerror());
|
fprintf(stderr, "open fabiled: %s!\n", usb_strerror());
|
||||||
return NULL;
|
//return NULL;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
*iface = dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
|
*iface = dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
struct prox_unit unit = {handle, {0}};
|
||||||
|
usb_get_string_simple(handle, desc->iSerialNumber, unit.serial_number, sizeof(unit.serial_number));
|
||||||
|
units[iUnit++] = unit;
|
||||||
|
|
||||||
|
//return handle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iUnit > 0) {
|
||||||
|
int iSelection = 0;
|
||||||
|
|
||||||
|
fprintf(stdout, "\nConnected units:\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < iUnit; i++)
|
||||||
|
fprintf(stdout, "\t%d. SN: %s\n", i+1, units[i].serial_number);
|
||||||
|
|
||||||
|
if (iUnit > 1) {
|
||||||
|
while (iSelection < 1 || iSelection > iUnit) {
|
||||||
|
fprintf(stdout, "Which unit do you want to connect to? ");
|
||||||
|
fscanf(stdin, "%d", &iSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
iSelection = 1;
|
||||||
|
iSelection --;
|
||||||
|
|
||||||
|
for (int i = 0; i < iUnit; i++) {
|
||||||
|
if (iSelection == i) continue;
|
||||||
|
usb_close(units[i].handle);
|
||||||
|
units[i].handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return units[iSelection].handle;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,9 @@ struct usb_dev_handle* FindProxmark(int verbose, unsigned int *iface);
|
||||||
struct usb_dev_handle* OpenProxmark(int verbose);
|
struct usb_dev_handle* OpenProxmark(int verbose);
|
||||||
void CloseProxmark(void);
|
void CloseProxmark(void);
|
||||||
|
|
||||||
|
struct prox_unit {
|
||||||
|
usb_dev_handle *handle;
|
||||||
|
char serial_number[256];
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
18
common/usb.c
18
common/usb.c
|
@ -95,7 +95,7 @@ static const uint8_t DeviceDescriptor[] = {
|
||||||
0x01,0x00, // Device release number (0001)
|
0x01,0x00, // Device release number (0001)
|
||||||
0x01, // Manufacturer string descriptor index
|
0x01, // Manufacturer string descriptor index
|
||||||
0x02, // Product string descriptor index
|
0x02, // Product string descriptor index
|
||||||
0x00, // Serial Number string descriptor index (None)
|
0x03, // Serial Number string descriptor index
|
||||||
0x01, // Number of possible configurations (1)
|
0x01, // Number of possible configurations (1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,10 +201,26 @@ static const uint8_t StringDescriptor2[] = {
|
||||||
't', 0x00,
|
't', 0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Serial Number
|
||||||
|
// TODO: Pick yours! Don't forget to modify the length, if needed.
|
||||||
|
static const uint8_t StringDescriptor3[] = {
|
||||||
|
18, // Length
|
||||||
|
0x03, // Type is string
|
||||||
|
'C', 0x00,
|
||||||
|
'h', 0x00,
|
||||||
|
'a', 0x00,
|
||||||
|
'n', 0x00,
|
||||||
|
'g', 0x00,
|
||||||
|
'e', 0x00,
|
||||||
|
'M', 0x00,
|
||||||
|
'e', 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
static const uint8_t * const StringDescriptors[] = {
|
static const uint8_t * const StringDescriptors[] = {
|
||||||
StringDescriptor0,
|
StringDescriptor0,
|
||||||
StringDescriptor1,
|
StringDescriptor1,
|
||||||
StringDescriptor2,
|
StringDescriptor2,
|
||||||
|
StringDescriptor3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue