diff --git a/pm3 b/pm3 index b3bee7ea5..2b2258b50 100755 --- a/pm3 +++ b/pm3 @@ -29,7 +29,7 @@ function get_pm3_list_Linux { N=$1 PM3LIST=() for DEV in $(find /dev/ttyACM* 2>/dev/null); do - if udevadm info -q property -n "$DEV" |grep -q "ID_VENDOR=proxmark.org"; then + if udevadm info -q property -n "$DEV" | grep -q "ID_VENDOR=proxmark.org"; then PM3LIST+=("$DEV") if [ ${#PM3LIST[*]} -ge $N ]; then return @@ -39,7 +39,7 @@ function get_pm3_list_Linux { if $FINDBTDONGLE; then # check if the HC-06-USB white dongle is present (still, that doesn't tell us if it's paired with a Proxmark3...) for DEV in $(find /dev/ttyUSB* 2>/dev/null); do - if udevadm info -q property -n "$DEV" |grep -q "ID_MODEL=CP2104_USB_to_UART_Bridge_Controller"; then + if udevadm info -q property -n "$DEV" | grep -q "ID_MODEL=CP2104_USB_to_UART_Bridge_Controller"; then PM3LIST+=("$DEV") if [ ${#PM3LIST[*]} -ge $N ]; then return @@ -49,7 +49,7 @@ function get_pm3_list_Linux { fi if $FINDBTDIRECT; then # check if the MAC of a Proxmark3 was bound to a local rfcomm interface - for DEVMAC in $(rfcomm -a|grep " 20:19:0[45]"|sed 's/^\(.*\): \([0-9:]*\) .*/\1@\2/'); do + for DEVMAC in $(rfcomm -a 2>/dev/null | grep " 20:19:0[45]" | sed 's/^\(.*\): \([0-9:]*\) .*/\1@\2/'); do DEV=${DEVMAC/@*/} MAC=${DEVMAC/*@/} # check if Proxmark3 is actually present @@ -66,7 +66,7 @@ function get_pm3_list_Linux { function get_pm3_list_macOS { N=$1 PM3LIST=() - for DEV in $(ioreg -r -c "IOUSBHostDevice" -l|awk -F '"' ' + for DEV in $(ioreg -r -c "IOUSBHostDevice" -l | awk -F '"' ' $2=="USB Vendor Name"{b=($4=="proxmark.org")} b==1 && $2=="IODialinDevice"{print $4}'); do PM3LIST+=("$DEV") @@ -79,18 +79,10 @@ function get_pm3_list_macOS { function get_pm3_list_Windows { N=$1 PM3LIST=() - # Normal SERIAL PORTS (COM) - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_9AC4&PID_4B8F*' | Select DeviceID" 2>/dev/null|awk '/^COM/{print $1}'); do - DEV=${DEV/ */} - PM3LIST+=("$DEV") - if [ ${#PM3LIST[*]} -ge $N ]; then - return - fi - done - - #white BT dongle SERIAL PORTS (COM) - if $FINDBTDONGLE; then - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_10C4&PID_EA60*' | Select DeviceID" 2>/dev/null|awk '/^COM/{print $1}'); do + # Need to look for this first, the call to Win32_serialport "crashes" then native bt serial port. Don't ask why. + #BT direct SERIAL PORTS (COM) + if $FINDBTDIRECT; then + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Caption -like 'Standard Serial over Bluetooth link (COM*' | Select Name" 2> /dev/null | awk '$0 ~ /COM/{print substr($6,2,4)}'); do DEV=${DEV/ */} PM3LIST+=("$DEV") if [ ${#PM3LIST[*]} -ge $N ]; then @@ -99,43 +91,38 @@ function get_pm3_list_Windows { done fi - #BT direct SERIAL PORTS (COM) - if $FINDBTDIRECT; then - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Caption -like 'Standard Serial over Bluetooth link (COM*' | Select Name" 2> /dev/null | awk '$0 ~ /COM/{print substr($6,2,4)}'); do + # Normal SERIAL PORTS (COM) + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_9AC4&PID_4B8F*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do + DEV=${DEV/ */} + PM3LIST+=("$DEV") + if [ ${#PM3LIST[*]} -ge $N ]; then + return + fi + done + + #white BT dongle SERIAL PORTS (COM) + if $FINDBTDONGLE; then + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_10C4&PID_EA60*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do DEV=${DEV/ */} PM3LIST+=("$DEV") if [ ${#PM3LIST[*]} -ge $N ]; then return fi - done + done fi } function get_pm3_list_WSL { N=$1 PM3LIST=() - # Normal SERIAL PORTS (COM) - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_9AC4&PID_4B8F*' | Select DeviceID" 2>/dev/null|awk '/^COM/{print $1}'); do - DEV=${DEV/ */} - DEV="/dev/ttyS${DEV#COM}" - # ttyS counterpart takes some more time to appear - if [ -e "$DEV" ]; then - PM3LIST+=("$DEV") - if [ ! -w "$DEV" ]; then - echo "[!!] Let's give users read/write access to $DEV" - sudo chmod 666 "$DEV" - fi - if [ ${#PM3LIST[*]} -ge $N ]; then - return - fi - fi - done - #white BT dongle SERIAL PORTS (COM) - if $FINDBTDONGLE; then - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_10C4&PID_EA60*' | Select DeviceID" 2>/dev/null|awk '/^COM/{print $1}'); do + # Need to look for this first, the call to Win32_serialport "crashes" then native bt serial port. Don't ask why. + #BT direct SERIAL PORTS (COM) + if $FINDBTDIRECT; then + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Caption -like 'Standard Serial over Bluetooth link (COM*' | Select Name" 2> /dev/null | awk '$0 ~ /COM/{print substr($6,2,4)}'); do + DEV=${DEV/ */} - DEV="/dev/ttyS${DEV#COM}" + DEV="/dev/ttyS${DEV#COM}" # ttyS counterpart takes some more time to appear if [ -e "$DEV" ]; then PM3LIST+=("$DEV") @@ -151,12 +138,28 @@ function get_pm3_list_WSL { done fi - #BT direct SERIAL PORTS (COM) - if $FINDBTDIRECT; then - for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Caption -like 'Standard Serial over Bluetooth link (COM*' | Select Name" 2> /dev/null | awk '$0 ~ /COM/{print substr($6,2,4)}'); do + # Normal SERIAL PORTS (COM) + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_9AC4&PID_4B8F*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do + DEV=${DEV/ */} + DEV="/dev/ttyS${DEV#COM}" + # ttyS counterpart takes some more time to appear + if [ -e "$DEV" ]; then + PM3LIST+=("$DEV") + if [ ! -w "$DEV" ]; then + echo "[!!] Let's give users read/write access to $DEV" + sudo chmod 666 "$DEV" + fi + if [ ${#PM3LIST[*]} -ge $N ]; then + return + fi + fi + done + #white BT dongle SERIAL PORTS (COM) + if $FINDBTDONGLE; then + for DEV in $(powershell.exe -command "Get-CimInstance -ClassName Win32_serialport | Where-Object PNPDeviceID -like '*VID_10C4&PID_EA60*' | Select DeviceID" 2>/dev/null | awk '/^COM/{print $1}'); do DEV=${DEV/ */} - DEV="/dev/ttyS${DEV#COM}" + DEV="/dev/ttyS${DEV#COM}" # ttyS counterpart takes some more time to appear if [ -e "$DEV" ]; then PM3LIST+=("$DEV")