How to decode/parse response data sent by the socket.io HTTP long-polling protocoll - socket.io

I will give you some information first!
I am currently trying to decode the server data socket.io sends as response to the client (when using Http long-polling) as I am trying to intercept the communication. I don't have access to the client-side socket instance.
Though I would like to be able to have the same JSON data the client-socket instance would end up with!
The content type of the socket.io responses is: 'application/octet-stream'
Calling Response.body() on the Response object returns the following Buffer:
<Buffer 00 01 02 08 ff 34 32 5b 22 75 70 64 61 74 65 55 73 65 72 73 52 6f 6f 6d 22 2c 7b 22 72 6f 6f 6d 22 3a 22 48 65 69 6c 69 67 74 75 6d 22 2c 22 75 73 65 ... 83 more bytes>
Calling Response.text() on the Response object returns the following string:
☺☻�42["updateUsersRoom",{"room":"Heiligtum","userid":13132,"imgthumb":"thumb_ffkqOEBwQXbf_pngfindcomrealisticspiderwebpngpng.png"}]
Now you might think that Response.text() looks okay-ish, however it is very 'inconsistent'. There are these random "broken" characters like '☺☻�42' every here and there and sometimes it even sends mutliple messages per response.
What I've tried is using the decode methods of both socket.io-parser and engine.io- parser, trying to feed it the data Request.body() returned. However it always returns:
{ type: 'error', data: 'parser error' }
I tried digging through the engine.io source code as well, trying to find out how they handle responses but I simply can't get it to work. This might require some deeper knowledge about socket.io, but I hope somebody can help me!
Thank you in advance.

Related

Use null.Time values in a golang template

I'm using gopkg.in/guregu/null.v4 to get some data from a Postgres DB and the results are coming back fine, and I can put them into json format and the world is happy... however, I'm trying to email the results using a template and have hit a problem.
The structure is (partially)
type DataQuery struct {
Date null.Time `json:"DateTime"`
....
The template is
{{define "plainBody"}}
Hi,
Here are the results for the check run for today.
The number of rows returned is {{.Rows}}
The data is
{{ range .Data}}
{{.Date}}
{{end}}
{{end}}
And the results of running that template are
Hi,
Here are the results for the check run for today.
The number of rows returned is 57
The data is
{{2021-09-13 00:00:00 +0000 +0000 true}}
{{2021-08-16 00:00:00 +0000 +0000 true}}
{{2021-09-19 00:00:00 +0000 +0000 true}}
{{2021-09-18 00:00:00 +0000 +0000 true}}
I tried using {{.Date.EncodeText}} and ended up with
[50 48 50 49 45 48 57 45 49 51 84 48 48 58 48 48 58 48 48 90]
[50 48 50 49 45 48 56 45 49 54 84 48 48 58 48 48 58 48 48 90]
[50 48 50 49 45 48 57 45 49 57 84 48 48 58 48 48 58 48 48 90]
For the datetime fields (which might be a []byte of the strings but I'm not sure.
If I use {{Date.Value}} I get
2021-09-13 00:00:00 +0000 +0000
The other field types (string, int, float) all work fine with
{{Variable.ValueOrZero}}
I think I'm close.. but can't quite crack it for the date time fields
First, you are using html/template which provides context-sensitive escaping, that's why you're seeing those + sequences. If you want text output, use text/template instead. For details, see Template unnecessarily escaping `<` to `<` but not `>`
Next, null.Time is not just a simple time.Time value, it wraps other fields too (whether the time is valid). When simply outputting it, that valid field will also be rendered (the true texts in your output).
You may render only its Time field: {{.Date.Time}}.
With these changes output will be for example:
Hi,
Here are the results for the check run for today.
The number of rows returned is 2
The data is
2021-09-20 12:10:00 +0000 UTC
2021-10-11 13:50:00 +0000 UTC
Try it on the Go Playground.

Felica (TYPE 3 NFC card) NDEF Message including the attribute block example ACR1252U

I am hoping someone can help,
I am trying to write an NDEF URI message to a felica type card to store a link to a web resource. I am using a ACR1252U reader from advanced card systems.
Block 0 is for attribute data
Block 1 onwards is user data where I would like to store the ndef record.
Does any one have an example of an encoded command to send to the card ie what should be written in block 0 and maybe a sample ndef message encoded to suit
ie
Default:
Block 0 data: {10h, 01h, 01h, 00h, 09h, 00h, 00h, 00h, 00h, 00h, 01h, 00h, 00h, 00h, 00h, 1Ch} is meant to be for the attribute data but I am not sure this is correct for a NDEF record
i have then written to block 1
D1 01 13 55 01 69 74 64 69 73 63 6F 76 65 72 79 2E 63 6F 6D 2E 61 75
which should be a URI (WWW) type NDEF record with payload itdiscovery.com.au
when I try to scan the card with NFC tools (android) it detects the card type enter image description here
BUT no ndef message or record - I am not sure if i have to specify the service type and location etc. I am at a bit of a loss ANY INSIGHT APPRECIATED.
Refer this flowenter image description here

mainCRTStartup() does not call main()

I ran a simple winsock client and placed the instruction _asm int 3 before WSAStartup. I placed a breakpoint at WS2_32!send, then g, then a breakpoint at ndis!NdisSendNetBufferLists, and saw the following calltrace (with some parts omitted):
00 ndis!NdisSendNetBufferLists
...
1b 80d8ff20 89617a1f ndis!ndisMiniportDpc+0xe2
1c 80d8ff48 82891f7e ndis!ndisInterruptDpc+0xaf
1d 80d8ffa4 82891de0 nt!KiExecuteAllDpcs+0xfa
1e 80d8fff4 8289157c nt!KiRetireDpcList+0xd5
1f 8c3704f4 828082af nt!KiDispatchInterrupt+0x2c
20 8c37050c 82808449 hal!HalpCheckForSoftwareInterrupt+0x83
21 8c370518 82894d91 hal!HalEndSystemInterrupt+0x67
22 8c370518 82840e8f nt!KeUpdateSystemTimeAssist+0x5d
23 8c3705c4 82b652bf nt!KeThawExecution+0x1c8
24 8c3705dc 828e64ae nt!KdExitDebugger+0x67
25 8c3705f4 82b65604 nt!KdpReport+0xd5
26 8c370620 828e4b7b nt!KdpTrap+0x102
27 8c370bc4 8286f932 nt!KiDispatchException+0x21e
28 8c370c2c 82870a3f nt!CommonDispatchException+0x4a
29 8c370c2c 766e6c1a nt!KiTrap03+0x263
2a 001efec0 00211bfe WS2_32!send+0x1
2b 001efed4 00211af1
client!__scrt_narrow_environment_policy::initialize_environment+0x2e
[f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl # 78]
2c 001eff2c 0021199d client!_RTC_Shutdown+0x251
[f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl # 283]
2d 001eff34 00211c68 client!_RTC_Shutdown+0xfd
[f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl # 326]
2e 001eff3c 777cefac client!mainCRTStartup+0x8
[f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp # 17]
2f 001eff48 77673628 kernel32!BaseThreadInitThunk+0xe
30 001eff88 776735fb ntdll!__RtlUserThreadStart+0x70
31 001effa0 00000000 ntdll!_RtlUserThreadStart+0x1b
Observe that client!mainCRTStartup did not call client!main. Why? Shouldn't it call client!main?
Additional info: I used kernel debugging on Virtual Windows 7x86. The winsock client and server are in the same virtual machine (configured to use Bridged), but this problem is also present if they are on different machines.

getting extra bytes 82 00 in pc/sc response

I am trying to read data from sony felica card using pc/sc transparent session and transceive data object.
The response I am getting is for a read without encryption command is
c0 03 00 90 00 92 01 00 96 02 00 00 97 82 00 + Data
But according to the protocol, the response should be
c0 03 00 90 00 92 01 00 96 02 00 00 97 + Data
I am unable to figure out the last 82 00 appended in the response from the card.
Now when I try to authenticate with the card I get
c0 03 01 6F 01 90 00
which is a error in pc/sc. I want to resolve these extra bytes 82 00 which I believe will solve the issue with all the commands which require authentication and encryption.
The response data is BER-TLV encoded (see PC/SC 2.02, Part 3).
In BER-TLV encoding there are several possibilities to encode tag 0x97 with two octets of data 0xD0D1, e.g.:
97|02|D0D1 -- short form (see parsed)
97|8102|D0D1 -- long form with one octet with length (see parsed)
97|820002|D0D1 -- long form with two octets with length (see parsed)
97|83000002|D0D1 -- long form with three octets with length (see parsed)
...
Your reader is using two octets for sending the length of ICC Response data object (which is perfectly valid).
You should parse the response properly...Good luck!
PS: The above means, that the Data part of your truncated responses still contains one extra byte with the response length (i.e. Len|Data)

How to set header to a string in java using JMS

I am trying to set RFH2Header type to a message string. But it's not appending to the message.
Please help. Thanks in advance!!!!
Is My approach is correct ?? If i check in response queue, RFH Property gets added to bytes message.
String message1 = "MQ Message header test";
Message message11 = session.createTextMessage(message1);
MQRFH2 header = new MQRFH2();
ByteArrayOutputStream out = new ByteArrayOutputStream ();
DataOutput dout = new DataOutputStream(out);
header.write(dout);
byte[] outheaders = out.toByteArray();
byte[] bArray = message1.getBytes("UTF-8");
BytesMessage responseMessage = session.createBytesMessage(); // throws JMSException
responseMessage.writeBytes(outheaders);
responseMessage.writeBytes(bArray);
responseMessage.setJMSType("MQRFH2");
responseMessage.setJMSCorrelationID("12345678900000");
responseMessage.setJMSDeliveryMode(2);
responseMessage.setJMSPriority(4);
responseMessage.setJMSReplyTo(queue);
responseMessage.setStringProperty("JMS_IBM_Format", "MQRFH2");
responseMessage.setIntProperty("JMS_IBM_Encoding", MQConstants.MQENC_NATIVE);
responseMessage.setIntProperty("JMS_IBM_Character_Set", 1208);
responseMessage.setIntProperty("JMS_IBM_PutApplType", 11);
producer.send(responseMessage);
My output looks like below in response queue.., Please help , how to set header to a string
00000 4D 51 20 4D 65 73 73 61--67 65 20 68 65 61 64 65 |MQ Message heade|
00010 72 20 74 65 73 74 52 46--48 20 00 00 00 02 00 00 |r testRFH ......|
00020 00 24 00 00 00 00 00 00--00 00 20 20 20 20 20 20 |.$........ |
00030 20 20 00 00 00 00 00 00--04 B8 | .......� |
Not very clear about the question but in any case the following may be useful to you.
RFH2 is MQ specific while JMS is a standard. A MQ JMS application can not explicitly set RFH2 data as JMS message header. MQ JMS client internally sets the required RFH2 headers to build a JMS message while the message is being sent. The application can only set message body and a number of JMS properties using setJMSxxxx and user defined properties using setxxxProperty methods. For example the snippet below sets a string type property called MyStringProperty.
responseMessage.setStringProperty("MyStringProperty", "SomeString Data");
RFH2 data will be a stream of bytes with a fixed header part and variable data part as described here:http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q032000_.htm?lang=en. Hence you need to create BytesMessage if you want to send RFH2 data as part of message body.

Resources