From d11684fcabc4545647d12f033c89eeabdd20a8c0 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 13 Jul 2019 00:06:19 +0200 Subject: [PATCH] Get proxmark.sh supporting WSL --- CHANGELOG.md | 1 + .../Windows-Installation-Instructions.md | 28 +++++++++++++++---- proxmark3.sh | 21 ++++++++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a276440d7..2fb002175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] + - Add support for WSL in proxmark.sh (@doegox) - Add documentation for usage of Proxmark3 under WSL (@doegox) - Change: replace ukbhit by kbd_enter_pressed, not requiring tcgetattr (@xianglin1998/@doegox) - Add config for RaspberryPi in JTAG tools (@doegox) diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index 1617ec6ec..69f24dcf8 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -116,14 +116,19 @@ Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmar To use the compiled client and flasher, the only difference is that the Proxmark3 port is translated from your `comX` port where "X" is the com port number assigned to proxmark3 under Windows, to a `/dev/ttySX`. -You will need to give permission to the current user to access `/dev/ttySX`: (change X to your port number) +Depending on the Windows version, you might need to give permission to the current user to access `/dev/ttySX`: (change X to your port number) + +```sh +ls -al /dev/ttySX +groups|grep dialout +``` + +If group ownership is `dialout` and your user is member of `dialout` group, all is fine. Else you'll have to provide access to `/dev/ttySX`: (Unfortunately the access rights of the port won't survive and will have to be fixed again next time.) ```sh sudo chmod 666 /dev/ttySX ``` -Unfortunately the access rights of the port won't survive and will have to be fixed again next time. - If you installed a X Server and compiled the Proxmark3 with QT4 support, you've to export the `DISPLAY` environment variable: ```sh @@ -136,14 +141,27 @@ and add it to your Bash profile for the next times: echo "export DISPLAY=:0" >> ~/.bashrc ``` -To flash, you've to call the flasher manually and specify the correct port: +To flash: In principle, the helper script `flash-all.sh` should auto-detect your COMX==/dev/ttySX port, so you can just try: + +```sh +./flash-all.sh +``` + +If port detection failed, you'll have to call the flasher manually and specify the correct port: ```sh client/flasher /dev/ttySX -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf ``` -Similarly, to run the client: +Similarly, to run the client, you may try: + +```sh +./proxmark3.sh +``` + +Or, by specifying the COM port manually: ```sh client/proxmark3 /dev/ttySX ``` + diff --git a/proxmark3.sh b/proxmark3.sh index b4aa51ffb..39eb80779 100755 --- a/proxmark3.sh +++ b/proxmark3.sh @@ -11,7 +11,6 @@ function wait4proxmark_Linux { sleep .1 done local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1` - echo >&2 -e "Found proxmark on ${PM3}\n" echo $PM3 } @@ -41,6 +40,20 @@ function wait4proxmark_Windows { echo $PM3 } +function wait4proxmark_WSL { + echo >&2 "Waiting for Proxmark to appear..." + while true; do + device=$(wmic.exe path Win32_SerialPort where "PNPDeviceID like '%VID_9AC4&PID_4B8F%'" get DeviceID,PNPDeviceID 2>/dev/null | awk 'NR==2') + if [[ $device != "" ]]; then + PM3=${device/ */} + PM3="/dev/ttyS${PM3#COM}" + break + fi + sleep .1 + done + echo $PM3 +} + SCRIPT=$(basename -- "$0") if [ "$SCRIPT" = "proxmark3.sh" ]; then @@ -61,7 +74,11 @@ else fi HOSTOS=$(uname | awk '{print toupper($0)}') if [ "$HOSTOS" = "LINUX" ]; then - PORT=$(wait4proxmark_Linux) + if uname -a|grep -q Microsoft; then + PORT=$(wait4proxmark_WSL) + else + PORT=$(wait4proxmark_Linux) + fi elif [ "$HOSTOS" = "DARWIN" ]; then PORT=$(wait4proxmark_macOS) elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then