Firmware update for Phywhisperer

Hello, I would like to consult you about some questions. It is the first time for me to use phywhisperer and I want to perform USB sniffing operation. I have downloaded the code from GitHub, installed the driver and connected the device.

WARNING: Root :Your firmware is overdue - latest is 1.1. Suggested to update Firmware, as you may experience errors

I saw it, too

https://chipwhisperer.readthedocs.io/en/latest/api.html#firmware-update this link, I want to ask next, chipwhisperer firmware updates and phywhisperer firmware update is the same? Is there anything else I should pay attention to?

Hi,

You can update the firmware using the program_sam3u() method. For now, you’ll need to specify the path to the firmware file (should be phywhisperer/firmware/phywhisperer/phywhisperer-SAM3U1C.bin, but I should be able to push out a quick update that adds in a similar method as the hardware_type for the ChipWhisperer platform.

EDIT: I also want to mention that I believe this is firmware update just adds driver autodetect (so you don’t need to go through the driver install), so this update is nothing critical and the warning you get should be safe to ignore.

EDIT 2: Nevermind, seems like this is already implemented. Simply call program_sam3u('COMPORT') and it should program.

Alex

Hi,Alex
I implemented the program_SAM3u () function according to your suggestion, but there was still an error. The corresponding serial port device could not be found. The device was connected as follows:
image

The serial port of phywhisperer could not be found in the device manager of the computer. We could only find the COM port of our target board, so we did not pass the program_SAM3u () function. The error was reported as follows:

Please contact me if you have any good suggestions
Best wishes
ShiTou

You need to open Device Manager and check what com port the bootloader has shown up as and replace "COM5" with that com port.

EDIT: Whoops, missed a part of your post. I’d recommend disconnecting everything from the phywhisperer except the Control PC USB. Has the firmware been erased (i.e. can you still connect to the PhyWhisperer as usual)? If so, you can connect and run phy.auto_program() if you have the newest update from git.

Alex

1 Like

Hi,Alex
I have finished the firmware update of the phywhisperer equipment according to the method you mentioned, and now the software can run normally without error, and the function of reading data is normal。

I have another question to ask, which data is read by the read_capture_data () function. I have not yet communicated with my target board when reading the data(Communicate with the target board before reading data) ,but this function returns the result, which is in the file below.

ReturnResult.zip (51.6 KB)

I think it should be like this: the computer and the target board establish a connection, and then the computer sends the data. After the target board receives the data, it encrypts the data and returns the encryption result to the computer. In this process, it monitors or sniffs through the phywhisper USB, and analyzes the data or protocol sent or received。

Excuse me, is there any problem with the process I understand? Or if I want to do this, can the phywhisper device be implemented?
Best wishes
ShiTou

Hi ShiTou,

It looks like you have been able to successfully use the PW-USB to capture the raw USB traffic. What PW-USB lets you do with that is:

  • interface with ViewSB to interpret the raw USB data
  • have exact timestamps of when the raw USB data was sent
  • ability to generate programmable trigger pulses based on specific patterns in the raw USB data
  • detect whether the PW-USB’s PHY saw any error conditions, which could be used to detect whether an attack was successful

Any further analysis of protocols running on top of the USB link are up to the user.

Regards,
J-P

Hi J-P,
Thank you very much and look forward to more communication in the future.
Best wishes.
ShiTou

Hi,Alex
I met some problems in the use of the equipment, I need your help,The test environment I built is as follows:
image

I set up the interaction with our development board through the serial debugging assistant,
Send plaintext “0123456789 abcdef0123456789abcdef”,
Receive the ciphertext “363 eff6cde1adea8b244ad2e3c4ebdc8”,
I wanted to capture this data by doing a phywhisperer sniffing operation,The script used is as follows

Call the read_captureData () function to get the following data:

ReturnResult.zip (51.6 KB)

I analyzed the process, and I thought what I read was the data of the electrical process on the target board, not the data that I wanted to send and receive.

I checked the API manual, tried calling the read_reg () function, and got the results shown below

But it seems that these data are not related to the data sent and received by the target board. I would like to ask whether the data interacting with the target board can be read through the phywhisperer? If so, what Settings are required? If not, are there other ways to get the data and analyze it?

ShiTou

Hi ShiTou,

1- I think there is a disconnect between what PhyWhisperer can do and what you’re expecting it do to.
PhyWhisperer has some USB analysis capabilities, but it’s not a USB analyzer, and we make this clear on the PhyWhisperer github page:

Basic USB sniffing capability exists in this tool, as it’s useful when deciding on the effect your glitch is having. If you require a more robust USB analyzer the TotalPhase Beagle 480 comes highly recommended by Colin (no connection - he just really likes them).

PW collects and timestamps the raw USB data that’s decoded by the USB PHY. If you send a particular string like “0123456789 abcdef0123456789abcdef” over a USB-to-serial link (I’m guessing this is what you’re doing), this data is going to be encapsulated in other protocols before it gets transmitted by the USB PHY. We provide an interface to ViewSB to help parse and analyze the raw USB data. How far you can get with this depends on the capabilities of ViewSB, which is an external tool. See here for how to interface with ViewSB.

2- Your calls to phy.read_reg() with an incrementing address are not the correct way to read the captured data. Have a closer look at read_capture_data() in usb.py to see how it should be done (or just use read_capture_data() directly). What your pasted code is doing is reading all of the PW’s register space; that’s not the way to read the captured data.

Hope this helps,
Jean-Pierre

Hi,Jean-Pierre
I have seen your reply, I downloaded the files in the link, copied them to Linux system environment, used the command “python3 setup.py install” to install, used the command "./ viewsb.sh phywhisperer "to run the program, and the error message of the program is as follows:

I searched the web for this problem and saw a response from a user: delete unused arguments from the function. I tried it, but it didn’t work very well.

I also tried to run the project in Windows 10 system, but there were some problems when importing the package.
I used Python 3.9, and the error message is as follows:

I used Python 3.6, and the error message is as follows:

Up to now, the viewsb project can’t run. I look forward to your suggestions or comments.

Best wishes.
ShiTou

Hi ShiTou,

I’m unable to replicate the errors that you get.
It had been a few months since I ran ViewSB so I updated to the latest code to see what’s changed. I found that Python >3.7 is now required due to the new requirement for python-usb-protocol. So I did a fresh install of Lubuntu 20.04.
I pulled and installed the master branch of:

  • phywhisperer
  • ViewSB
  • python-usb-protocol

and everything works for me; the only difference from before is that I need to specify the ViewSB frontend explicitly:
viewsb.sh phywhisperer [qt|cli|tui]

I should note that the last time I tried, ViewSB did not work in Windows. I was able to run it in Linux and MacOS.
I hope this helps,
Jean-Pierre

Hi,Jean-Pierre
I re-downloaded three parts of the code from Git today, including

  • phywhisperer
  • ViewSB
  • Python - usb protocol.

You used Ubuntu20.04 in your reply. I also downloaded and set up a Linux environment. The re-downloaded content was put into the virtual machine, but the operation process was not very smooth, such as:

  • No modue named ‘setuptools’
  • No nodule named pip
  • env:‘pip’ : No such file or directory

I’ve looked up various solutions, but none of them worked.
The process of upgrading Ubuntu to Python is not going well either, and I don’t know what to do now. I need your help with a little more detail

Hi ShiTou,
You simply need to install the missing packages.
From my command-line history, I see the following:

apt-get install python3-pip
pip3 install construct
pip3 install bitstruct
pip3 install urwid
pip3 install jupyter
pip3 install PySide2 # only needed if you want the Qt GUI in ViewSB

I may have done some additional installs in a different shell, but I think these should cover it.
Otherwise, it should not be too difficult to identify and install any additional missing packages.

To install the phywhisperer, viewsb, and python-usb-protocol tools, I did this:
python3 -m pip install -e . --user

Good luck,
Jean-Pierre

Hi,Jean-Pierre
First of all, thank you very much for your reply. I installed several missing packages today, including

  • PIP3 (this has been bothering me for a while),
  • Usb_protocol,
  • Crcmod,

And what you mentioned

  • The construct,
  • Bitstruct,
  • urwid
  • Jupyter and Pyside2 (failed several times due to poor network)

I rebuilt and installed the files under the phywhisperer, viewsb, python-USB-protocol sections, and finally executed the viewsb.sh command.

I searched the information about usbmon on the net, followed the prompts, mounted debugfs, query the current device as follows

Inquire about a USB line
image

I would like to ask whether this situation is under control and what should we do next? I look forward to your suggestions

Best wishes
shitou

The square brackets here:

viewsb.sh phywhisperer [qt|cli|tui]

mean “pick one of the options”. This is standard notation.
You are meant to run one of the following:

  • viewsb.sh phywhisperer qt
  • viewsb.sh phywhisperer cli
  • viewsb.sh phywhisperer tui

Hi,Jean-Pierre
I ran these commands according to different usage

  • 1.viewsb.sh phywhisperer qt

    1. ./viewsb.sh phywhisperer qt

    1. sudo ./viewsb.sh qt

  • 4.sudo ./viewsb.sh phywhisperer qt

shitou

Hi shitou,

  1. I can’t read the error message.
  2. This is what you would get if phywhisperer isn’t properly installed. Here are a few things to try to make sure that it is:
    a) run python3, then import phywhisperer and make sure there is no error
    b) make sure that the PhyWhisperer USB device is passed onto the VM (if using VirtualBox: Devices menu, under USB, then select PhyWhisperer-USB.
    c) check that you can run our phywhisperer notebooks in Jupyter (it looks like you did this on Windows previously; does it work in your Linux VM)?
    d) if that doesn’t work, did you follow the Linux-specific installation instructions here?
    e) make sure phywhisperer is listed as an available backend when you run viewsb.sh --list-backends
    f) the qt frontend won’t work if you don’t install pyside2.
  3. don’t try that, it doesn’t make sense

Jean-Pierre

Hi,Jean-Pierre,
The phywhisperer has been installed, using “Import phywhisperer” will not report an error. I listed the USB devices on the VM and found the Phywhisperer devices. The information is as follows:

T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  5 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=2b3e ProdID=c610 Rev= 1.00
S:  Manufacturer=NewAE Technology Inc.
S:  Product=PhyWhisperer-USB
S:  SerialNumber=50203120385347513230383133333030
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

I have installed Jupyter, and the interface is as follows:

Now I can use the command/ viewsb.sh phywhisperer cli or./ viewsb.sh phywhisperer tui

But the same error is reported with the following error message:

Traceback (most recent call last):
  File "/home/shitou/shitou/ViewSB-master(1)/ViewSB-master/viewsb/backends/phywhisperer.py", line 149, in run
    self.pw_device.run_capture(size=self.size, burst=self.burst, pattern=self.pattern, mask=self.mask, timeout=self.timeout, halt_callback=halt_callback)
TypeError: run_capture() got an unexpected keyword argument 'timeout'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/shitou/shitou/ViewSB-master(1)/ViewSB-master/viewsb/ipc.py", line 22, in run
    multiprocessing.Process.run(self)
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/shitou/shitou/ViewSB-master(1)/ViewSB-master/viewsb/ipc.py", line 117, in _subordinate_process_entry
    task.run()
  File "/home/shitou/shitou/ViewSB-master(1)/ViewSB-master/viewsb/backends/phywhisperer.py", line 152, in run
    self.pw_device.close()
  File "/home/shitou/.local/lib/python3.8/site-packages/phywhisperer/usb.py", line 742, in close
    self.commthread.join()
AttributeError: 'Usb' object has no attribute 'commthread'

When I use the command "/ viewsb.sh A box will appear with some information, as follows:

I feel that the final data is about to come out.

shitou

Hi ShiTou,

Let’s start by taking ViewSB out of the equations for a moment.
Are you able to successfully run any of our example notebooks in Jupyter, in the Linux VM?

Jean-Pierre

Hi,Jean-Pierre
To be honest, I haven’t heard of ViewSB before, and the same is true for Jupyter, which is just getting started. Viewsb hasn’t run on Jupyter yet.I don’t know much about Linux,A lot of things need to be found on the Internet or asked colleagues,So this period of time in the Linux system environment build progress is slow.

So far only the Phywhisperer device has been connected to a Windows system and some data has been captured.

shitou