What kind of checksum algorithm? - checksum

i trying to comunicate with an bluetooth device and already have the commando codes. the problem is i think theres is a checksum algorithm implemented and i dont know which one. Already tried some algorithms but without success. Here are some commando codes as hex array:
C0 54 07 00 01 00 00 01 10 02 FA
C0 54 07 00 01 00 00 02 10 02 22
C0 54 07 00 00 00 00 02 10 02 0C
C0 54 07 01 00 00 00 02 10 02 AC
C0 54 07 01 00 00 01 02 10 02 56
C0 54 07 01 00 00 01 02 10 03 F0
C0 54 07 01 00 00 01 02 11 03 88
The first 3 bytes are always the same so i dont think hey are included in the calculation. Must be the adress or something similar. The 7 Bytes in the middle: the adjacent byte arrays are always differ in just one byte. I captured the commandos with wireshark while i changed one parameter after another on the device successively. On the device are 7 function. That indicates that each of the 7 bytes should be for one different parameter. The last byte shold be a checksum, i think. because its always a different one. I i would appreciate if somebody can help!

Related

Display NAL H.264 UDP Stream (in VLC)

I am trying to display the video my (PAUL) drone is sending to my over a UDP connection.
Frames look like (hexdump):
00 00 01 a1 00 1d 00 03
90 1a 00 00 a0 8a dc 0c
00 00 00 00 03 00 00 00
d0 02 40 02 00 04 00 00
90 1a 00 00 19 00 ......
Frames always start (trough my observation) with:
00 00 01 a
Are these NAL units?
I am want to display this in VLC player but don't know how to stream it to the VLC media player.
It looks a lot like a valid h.264 bitstream, but its not. 00 00 01 does look like a start code, But after a start code the first bit MUST be 0. a in binary is 1010 hence not valid.

wireshark display filter on specific byte in a raw ethernet packet

I am trying to filter packets where the 15th byte (i.e. the 1st payload byte after the 14 byte header) is a specific value, either 0x00 or 0x01.
The packets I am interested in are raw ethernet, i.e. at the logical-link control layer so I also filter on LLC as the protocol
Here is what I tried:
llc && (frame[14:1] == 00 || frame[14:1] == 01)
this comes up green so I'm pretty sure the syntax is correct. Its only displaying packets where Protocol is LLC but its also letting through packets where the 15th byte is 0x02 which I want to avoid
Any ideas how I can succesfully target the 15th byte value, or to put it another way, the 1st byte value of the payload?
example packet (copied from wireshark) where 15th byte is 0x00:
0000 01 01 01 01 01 01 02 02 02 02 02 02 00 0e 00 05 ................
0010 00 00 00 05 00 00 00 00 00 00 00 01 ............
example packet where 15th byte is 0x01:
0000 02 02 02 02 02 02 01 01 01 01 01 01 00 0a 01 05 ................
0010 00 00 00 0d 00 00 00 f1 00 00 00 00 00 00 00 00 ................
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030 00 00 00 00 00 00 00 00 00 00 00 00 ............
I'd like to have wireshark display both these packets
There is a 3rd type of packet where the 15th byte is 0x02:
0000 02 02 02 02 02 02 01 01 01 01 01 01 00 39 02 ec .............9..
0010 41 61 02 a2 21 44 2b 0c 00 02 00 1c 0c 02 00 00 Aa..!D+.........
0020 00 00 00 00 00 00 00 00 00 00 00 ee 91 20 04 46 ............. .F
0030 22 44 2b cc 01 03 00 00 00 00 00 00 00 00 00 00 "D+.............
0040 00 00 00 00 00 00 00 .......
This type of packet I would like to exclude with the filter. My filter above still displays these 0x02 packets.
Here is the wireshark display filter requested:
llc and (frame[14] == 0 or frame[14] == 1)
Wireshark counts the first byte in each frame as byte 0, so the 15th byte is frame[14]. You do not need the colon for a single byte (as described in the docs). and and && are equivalent. or and || are also equivalent.

APDU Write block commands on mifare 1K with ACR122U reader

Please,
I am trying to write a simple Binary Block to mifare 1k tag with a ACR122U reader.
I am trying write to block 01, 5 bytes, text:'teste' and read it back.
But I always get an error 6300 when update this block.
Any thoughts?
I am using windows 8.1/delphi xe8.
My log is:
SCardEstablishContext succeeded.
Card State changed in ACS ACR122U PICC Interface 0 to available
New reader found: ACS ACR122U PICC Interface 0
Card inserted in ACS ACR122U PICC Interface 0
ATR = 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A
SCardConnect (shared) succeeded.
Active Protocol: T=1
ISO 14443 A, Part3 Card Type: Mifare Standard 1K is detected
Sending APDU to card: FF 82 00 01 06 FF FF FF FF FF FF
SCardTransmit succeeded.
Card response status word: 9000 (OK)
Sending APDU to card: FF 86 00 00 05 01 00 01 60 01
SCardTransmit succeeded.
Card response status word: 9000 (OK)
Sending APDU to card: FF 86 00 00 05 01 00 01 60 01
SCardTransmit succeeded.
Card response status word: 9000 (OK)
Sending APDU to card: FF D6 00 01 05 74 65 73 74 65
SCardTransmit succeeded.
Card response status word: 6300 (State of non-volatile memory changed.)
This is easily resolved by reading the documentation.
You're writing to a block and you have to provide a complete block of information. The only option for Lc is x04 or x10 - four bytes or sixteen bytes. For the Mifare 1K, it's prettly clear that you need to supply 16 bytes. You have only 5 bytes of data, so pad the rest with zeros.
| CMD | block1 | 16 bytes | data ...
FF D6 00 01 10 74 65 73 74 65 00 00 00 00 00 00 00 00 00 00 00

Use wireshark to analyze raw stream without frame seperator

My wifi sniff device can output data to a raw file. But it may begin with the middle of a frame, and each frame starts right after another. A pcap file must contain packet headers, which I don't have. So I tried to discard the half complete frame at the beginning of the file, and put the rest into a pcap file with one packet. Then wireshark can analyze the first frame, even with wrong packet size.
My question is how to make wireshark analyze the remaining frames ?
Edit: This is a sample pcap with 2 frame, but without the second packet header
00000000 D4 C3 B2 A1 02 00 04 00 00 00 00 00 00 00 00 00 Ôò¡............
00000010 FF FF 00 00 69 00 00 00 05 00 00 00 00 00 00 00 ÿÿ..i...........
00000020 80 00 00 00 80 00 00 00 08 02 00 00 01 00 5E 00 €...€.........^.
00000030 00 FC E8 94 F6 3C 5F 40 20 68 9D 9A 4B D7 70 73 .üèâ€Ã¶<_# h.Å¡K×ps
00000040 AA AA 03 00 00 00 08 00 46 00 00 20 38 F8 00 00 ªª......F.. 8ø..
00000050 01 02 48 D5 C0 A8 01 66 E0 00 00 FC 94 04 00 00 ..HÕÀ¨.fà..üâ€...
00000060 16 00 09 03 E0 00 00 FC 08 02 00 00 01 00 5E 7F ....à..ü......^.
00000070 FF FA E8 94 F6 3C 5F 40 20 68 9D 9A 4B D7 F0 75 ÿúèâ€Ã¶<_# h.Å¡K×ðu
00000080 AA AA 03 00 00 00 08 00 46 00 00 20 38 F9 00 00 ªª......F.. 8ù..
00000090 01 02 39 D6 C0 A8 01 66 EF FF FF FA 94 04 00 00 ..9ÖÀ¨.fïÿÿúâ€...
000000A0 16 00 FA 04 EF FF FF FA ..ú.ïÿÿú
My question is how to make wireshark analyze the remaining frames ?
Detect the beginnings and ends of frames in your bit sequence, and put each frame into a separate record in the pcap file.
If there's nothing in the bit sequence to allow your software to determine where one frame ends and another frame begins, there's nothing in the bit sequence to allow Wireshark to do so, so if you want to have Wireshark analyzer frames past the first frame, you are FORCED to ensure that there's something in the bit stream to determine frame boundaries, and you might as well have your software break the bit stream into frames.

Reading a Bluetooth data stream from an Arduino with iOS

I'm trying to read data from an Arduino board on an iOS device via Bluetooth. In particular, I'm using the Coin Bluetooth prototype board.
While I am able to receive data on the iOS device from the Arduino, I'm having trouble making sense of the data order seen on the iOS device. On the Arduino, I'm doing something simple to start... just sending three consecutive bytes over and over:
void loop()
{
mySerial.write((byte)1);
mySerial.write((byte)2);
mySerial.write((byte)3);
}
On iOS, I'm able to read the data into an NSData object, and when printing out the result in hex, I have something that looks like the following:
0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00
02 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 00 00 00 00 00 00 00 00 00 00 00 00 00
01 02 03 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 01 00 00 00 00 00 00 00 00 00 00 00 00
03 02 03 01 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 01 04 00 00 00 00 00 00 00 00 00 00 00
02 02 03 01 04 00 00 00 00 00 00 00 00 00 00 00 03 01 02 03 04 00 00 00 00 00 00 00 00 00 00 00
01 01 02 03 04 00 00 00 00 00 00 00 00 00 00 00 03 01 02 03 04 00 00 00 00 00 00 00 00 00 00 00
01 01 02 03 04 00 00 00 00 00 00 00 00 00 00 00 02 03 01 02 04 00 00 00 00 00 00 00 00 00 00 00
01 03 01 02 04 00 00 00 00 00 00 00 00 00 00 00 03 01 02 03 04 00 00 00 09 00 00 00 00 00 00 00
01 01 02 03 04 00 00 00 09 00 00 00 00 00 00 00 03 01 02 03 04 00 00 00 0a 00 00 00 00 00 00 00
03 01 02 03 04 00 00 00 0a 00 00 00 00 00 00 00 02 03 01 02 04 00 00 00 0b 00 00 00 00 00 00 00
01 03 01 02 04 00 00 00 0b 00 00 00 00 00 00 00 01 02 03 01 04 00 00 00 0c 00 00 00 00 00 00 00
While it's clear that the correct data is being read, what I have been unable to determine is how to properly frame the data between the board and iOS device. Above, it appears that the data is not always received in the correct order (e.g. sequences of 03 02 03 can be found), and strange values appear as well (0c and 04?). I can't seem to make sense of why this would happen, or how to go about ensuring the data on the iOS device is read from the device in order. Can someone provide any insight into why the data looks like it does above, or general Arduino serial data writing rules that can be used to ensure proper data framing?
EDIT:
On the iOS side, I'm getting the data from CoreBluetooth via the delegate function
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
And the NSData* I'm inspecting comes from characteristic.value.

Resources