Get proxmark.sh supporting WSL

This commit is contained in:
Philippe Teuwen 2019-07-13 00:06:19 +02:00
commit d11684fcab
3 changed files with 43 additions and 7 deletions

View file

@ -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... 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] ## [unreleased][unreleased]
- Add support for WSL in proxmark.sh (@doegox)
- Add documentation for usage of Proxmark3 under WSL (@doegox) - Add documentation for usage of Proxmark3 under WSL (@doegox)
- Change: replace ukbhit by kbd_enter_pressed, not requiring tcgetattr (@xianglin1998/@doegox) - Change: replace ukbhit by kbd_enter_pressed, not requiring tcgetattr (@xianglin1998/@doegox)
- Add config for RaspberryPi in JTAG tools (@doegox) - Add config for RaspberryPi in JTAG tools (@doegox)

View file

@ -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`. 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 ```sh
sudo chmod 666 /dev/ttySX 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: If you installed a X Server and compiled the Proxmark3 with QT4 support, you've to export the `DISPLAY` environment variable:
```sh ```sh
@ -136,14 +141,27 @@ and add it to your Bash profile for the next times:
echo "export DISPLAY=:0" >> ~/.bashrc 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 ```sh
client/flasher /dev/ttySX -b bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf 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 ```sh
client/proxmark3 /dev/ttySX client/proxmark3 /dev/ttySX
``` ```

View file

@ -11,7 +11,6 @@ function wait4proxmark_Linux {
sleep .1 sleep .1
done done
local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1` local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1`
echo >&2 -e "Found proxmark on ${PM3}\n"
echo $PM3 echo $PM3
} }
@ -41,6 +40,20 @@ function wait4proxmark_Windows {
echo $PM3 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") SCRIPT=$(basename -- "$0")
if [ "$SCRIPT" = "proxmark3.sh" ]; then if [ "$SCRIPT" = "proxmark3.sh" ]; then
@ -61,7 +74,11 @@ else
fi fi
HOSTOS=$(uname | awk '{print toupper($0)}') HOSTOS=$(uname | awk '{print toupper($0)}')
if [ "$HOSTOS" = "LINUX" ]; then if [ "$HOSTOS" = "LINUX" ]; then
if uname -a|grep -q Microsoft; then
PORT=$(wait4proxmark_WSL)
else
PORT=$(wait4proxmark_Linux) PORT=$(wait4proxmark_Linux)
fi
elif [ "$HOSTOS" = "DARWIN" ]; then elif [ "$HOSTOS" = "DARWIN" ]; then
PORT=$(wait4proxmark_macOS) PORT=$(wait4proxmark_macOS)
elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then