Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the recording pen time under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Bought a recorder, the effect is much better than using a notebook microphone to record and save electricity. Of course, I also tried to record on my mobile phone, but it didn't take long for me to stop recording (Android is so unreliable).

My recording needs to record more accurate time information. How does the recording pen know what time it is? Fortunately, it did not follow the trend, there is no need to connect to the Internet!

It comes with a Mini Program called "time synchronization tool for recording pens" (English name is "SetUDiskTime", which can be found). Is an EXE file, and a DLL file. The function is great, no ads, no recommendations, no need to sign up for a messy account, and you don't even need to open a browser to visit other people's website. Just click a box to show the current time, make sure and set the time. These days, such a simple Windows software is really rare.

However, it doesn't support the Linux I use. Although I tried to make sure that the recorder had power all the time, time was lost several times and its FAT file system was dirty several times. Every time I have to turn on the WinXP virtual machine to set the time, how troublesome.

Wine is not good, hardware-related things are basically impossible. Trace with Procmon, there is no complex operation, the main part is a few DeviceIoControl calls, but do not see the call parameters. I tried IDA, but I couldn't understand it. However, it does know that it sends SCSI commands directly to the device through IOCTL_SCSI_PASSTHROUGH.

Since you can't track it, try to catch the bag of USB. I wanted to use Wireshark, but the WinXP version of Wireshark doesn't seem to support it. I also tried to assign the device to VBox and then grabbed the packet on Linux. As a result, permission denied... I'm root. I've been deny.

So, grab the bag on Windows. There is a software called USBPcap, download and install the latest version, only to encounter bug. Then try the old version. The official website does not give the download address of the old version, but it is easy to see the download link with the version number. Just go to commit log to find the old version number and replace it with https://dl.bintray.com/desowin/USBPcap/USBPcapSetup-1.0.0.7.exe.

Grab the bag, take it to Linux and throw it to Wireshark for interpretation. It's very small, less than 50 bags, and most of them are duplicated. It was quickly located to a key position:

A 0xcc command is sent and the device replies "ACTIONSUSBD", presumably to get the device ready. Then a 0xb0 command is sent with 7 bytes of data, and the time is set. Simple and clear, unlike the so-called "Internet of things" such as Xiaomi air purifiers, communications are encrypted to prevent people from making good use of them.

So, how do these 7 bytes transmit time data? I first checked the UNIX timestamp, which is not correct. Later, the string looked like YYYYMMDDHHMMSS format, but it was obviously not the time at that time. Ah, it's hexadecimal! Do a few mental calculations, match! Then take out my Python calculator and make sure that the year is a 16-bit integer in small end order.

All right, all the details of the agreement have been figured out, and then there is the implementation. I thought I had to write a C program and transfer some ioctl, but then the netizen said that there was a sg3_utils package. Very good, directly use the Python tone, so as not to study how to write those ioctl.

#! / usr/bin/env python3import osimport sysimport structimport subprocessimport datetimedef set_time (dev): cmd = ['sg_raw','-slots, '7cycles, dev,' b0th, '00bands,' 00bands, '00bands,' 00bands, '00bands,' 00bands, '00bands,' 07bands, '00bands,' 00bands, '00bands,' 00bands] p = subprocess.Popen (cmd, stdin=subprocess.PIPE) Stderr=subprocess.PIPE) dt = datetime.datetime.now () data = struct.pack ('

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report