For example:
%PDF-1.3..%.....
...1 0 obj..<<..
from
25 50 44 46 2D 31 2E 33 0D 0A 25 E2 E3 CF D3 0D
0A 0D 0A 31 20 30 20 6F 62 6A 0D 0A 3C 3C 0D 0A
Do they represent numbers that don't fit in ASCII?
Related
Can someone explain me, what is that compression method used?
I tried to reverse engeneer old application. It using tcp connection and send messages using json.
All data was the plain json, but that data is json value "pb_rsp" was binary and i cant uncompress that.
120113837000265, Xanthus, EliteDog, flag30, 574949063200274 - thats a plain data. Around them some unknown separators.
I think thats encoded json, but cant detect method, help please
�
9181129d4be64c36ad42401c8227226f��
"Z
120113837000265Xanthus *8
84860c8bfafb48b1b6ef8b595fcf6246EEDEliteDog"flag30�(��0#H����0P�����0X�����0`j�
574949063200274Z
120113837000265Xanthus *8
84860c8bfafb48b1b6ef8b595fcf6246EEDEliteDog"flag30� �����0(�����02�(0#ZJ
107107ddR
or hex
1A D5 02 0A 0F 35 37 35 30 33 30 39 37 36 39 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 97 91 A4 EF D2 30 40 CF C5 C4 EF D2 30 48 01 50 9B E1 1C 5A 27 08 98 11 28 01 30 0E 40 50 4A 0C 0A 06 31 30 37 30 30 38 10 5A 18 5A 4A 0C 0A 06 31 30 37 30 30 39 10 0A 18 0A 52 00 5A 19 08 E0 12 28 02 30 0E 40 50 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 EB 12 28 05 30 0E 40 64 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 E1 12 28 04 30 0E 40 64 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 99 11 28 03 30 0E 40 64 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F 1A C7 02 0A 0F 35 37 35 30 33 31 30 32 38 30 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 A1 A6 A4 EF D2 30 40 D9 DA C4 EF D2 30 48 01 50 9B E1 1C 5A 19 08 B4 10 28 01 30 0E 40 46 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 BF 10 28 02 30 0D 40 5F 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 B5 10 28 05 30 0E 40 5F 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 BE 10 28 04 30 0E 40 5F 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 C1 10 28 03 30 0E 40 5F 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 60 AA F9 0F 1A C7 02 0A 0F 35 37 35 30 33 31 31 35 34 37 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 E3 B6 A4 EF D2 30 40 9B EB C4 EF D2 30 48 01 50 9B E1 1C 5A 19 08 FD 11 28 03 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 FC 11 28 01 30 0E 40 46 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 86 12 28 04 30 0D 40 5A 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 FE 11 28 05 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 81 12 28 02 30 0E 40 46 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F 1A D5 02 0A 0F 35 37 35 30 33 31 32 30 34 34 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 86 C6 A4 EF D2 30 40 BE FA C4 EF D2 30 48 01 50 9B E1 1C 5A 27 08 A2 11 28 01 30 0E 40 3C 4A 0C 0A 06 31 30 37 30 30 38 10 63 18 63 4A 0C 0A 06 31 30 37 30 30 39 10 01 18 01 52 00 5A 19 08 E4 12 28 02 30 0E 40 41 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 E2 12 28 05 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 E5 12 28 04 30 0E 40 46 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 EC 12 28 03 30 0E 40 55 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F
or base64
Ev8HCiAwYjk5MGU1NzIwNzU0ZTNlODhlYTc2MDc3YmViNWNmYxji2AsicAoPMTQ1MTk2NDk1MDAwMjk0Eghzb29uMTAwNBoVcGljXzEwX0tlZXJtYW5fTElOU0hJKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIohpEMMA9ABUjLneju0jBQm5GO79IwWIvtjO/SMGABapwCCg81NzQ5OTUyNTY5MDAyNzQScAoPMTQ1MTk2NDk1MDAwMjk0Eghzb29uMTAwNBoVcGljXzEwX0tlZXJtYW5fTElOU0hJKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIgk+2M79IwKJuRju/SMDIbCOwSKAQwDEBfSgwKBjEwNzEwNxBkGGRSAggBMhsItRAoAzAMQF9KDAoGMTA3MTA3EGQYZFICCAEyGQi0ECgBMAlARkoMCgYxMDcwMDcQZBhkUgAyGQi4ECgCMA5AVUoMCgYxMDcyMDcQZBhkUgAyGQi2ECgFMA5AWkoMCgYxMDcyMDcQZBhkUgBqgAIKDzU3NDk5NjA5MTQwMDI3NBJYCg8xNjk1ODE1MjIwMDAyNjUSBUt3b24yIAwqOAogODQ4NjBjOGJmYWZiNDhiMWI2ZWY4YjU5NWZjZjYyNDYSA0VFRBoIRWxpdGVEb2ciBWZsYWczMOunEiCYi+ru0jAo0KLq7tIwMhkIuBAoAjAOQDJKDAoGMTA3MjA3EGQYZFIAMhkIgBIoATALQDxKDAoGMTA3MDA3EGQYZFIAMhkI/xEoBTAOQEZKDAoGMTA3MjA3EGQYZFIAMhkIthAoBDAOQEZKDAoGMTA3MjA3EGQYZFIAMhkIgRIoAzAOQEZKDAoGMTA3MTA3EGQYZFIAaoUCCg81NzUwMDUzNTMxMDAyNzQSWwoOMTk4NDcxMjQwMDAyNzESCUFtYW5kYTI2NSAGKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIgo5367tIwKLPc/+7SMDIZCOQSKAEwDkBBSgwKBjEwNzAwNxBkGGRSADIZCOASKAIwCkBBSgwKBjEwNzAwNxBkGGRSADIZCJoRKAMwCUAFSgwKBjEwNzIwNxBkGGRSADIbCOESKAQwDUBkSgwKBjEwNzIwNxBkGGRSAggCMhkI6xIoBTAMQGRKDAoGMTA3MTA3EGQYZFIAggEGOTAwMDM3sAEBugEPNTc0OTk1MjU2OTAwMjc0
Thanks
Thats not a gzip or zip
I have captured a packet using libpcap and have the packet data in a char array. When I print it in hex and ascii the output is
47 45 54 20 2f 62 72 6f 77 73 65 2f 64 69 63 74 GET /browse/dict
69 6f 6e 61 72 79 3f 73 3d 74 20 48 54 54 50 2f ionary?s=t HTTP/
31 2e 31 0d 0a 48 6f 73 74 3a 20 77 77 77 2e 64 1.1..Host: www.d
69 63 74 69 6f 6e 61 72 79 2e 63 6f 6d 0d 0a 55 ictionary.com..U
73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c ser-Agent: Mozil
.....
......
41 31 25 32 43 31 30 31 25 33 41 31 25 32 43 32 A1%2C101%3A1%2C2
25 33 41 31 25 32 43 31 30 32 25 33 41 31 25 32 %3A1%2C102%3A1%2
43 31 30 33 25 33 41 31 25 32 43 33 25 33 41 31 C103%3A1%2C3%3A1
............
.....
Now I want to convert above http request/response from captured packet to html tags. How can I do that?
I was working on a project and just when I saved the file, my power cut off. Now my html file is corrupted and I have no backup of it.
I just remembered that I might have a cache of it in Firefox. So, first I tried CacheViewer from Firefox official add-ons store. This add-on would install and then required a restart, after the restart it would disappear.
So instead, I tried the old fashioned way. I went to about:cache > Local Storage and whew, I was lucky enough that it was there and wasn't replaced with the blank corrupted html file.
Now I have some sort (Catch Entry Information) of file. The left side has the binary code, while the right side has the proper html code with some unnecessary . periods in it.
This is what my this file looks like:
00000000: 3c 21 64 6f 63 74 79 70 65 20 68 74 6d 6c 3e 0d <!doctype html>.
00000010: 0a 3c 68 74 6d 6c 3e 0d 0a 3c 68 65 61 64 3e 0d .<html>..<head>.
00000020: 0a 3c 6d 65 74 61 20 63 68 61 72 73 65 74 3d 22 .<meta charset="
00000030: 75 74 66 2d 38 22 3e 0d 0a 3c 74 69 74 6c 65 3e utf-8">..<title>
00000040: 46 69 74 41 70 70 3c 2f 74 69 74 6c 65 3e 0d 0a FitApp</title>..
00000050: 3c 73 74 79 6c 65 3e 40 66 6f 6e 74 2d 66 61 63 <style>#font-fac
00000060: 65 20 7b 0a 20 20 66 6f 6e 74 2d 66 61 6d 69 6c e {. font-famil
00000070: 79 3a 20 22 52 6f 62 6f 74 6f 2d 6c 69 67 68 74 y: "Roboto-light
00000080: 22 3b 0a 20 20 73 72 63 3a 20 75 72 6c 28 22 2e ";. src: url(".
00000090: 2e 2f 66 6f 6e 74 73 2f 52 6f 62 6f 74 6f 2d 4c ./fonts/Roboto-L
000000a0: 69 67 68 74 2e 74 66 66 22 29 20 66 6f 72 6d 61 ight.tff") forma
000000b0: 74 28 22 74 72 75 65 74 79 70 65 22 29 2c 20 6c t("truetype"), l
000000c0: 6f 63 61 6c 28 22 52 6f 62 6f 74 6f 2d 6c 69 67 ocal("Roboto-lig
000000d0: 68 74 22 29 20 66 6f 72 6d 61 74 28 22 74 72 75 ht") format("tru
000000e0: 65 74 79 70 65 22 29 3b 0a 20 20 66 6f 6e 74 2d etype");. font-
000000f0: 77 65 69 67 68 74 3a 20 34 30 30 3b 0a 7d 0a 40 weight: 400;.}.#
How do I go about decoding this?
If there is a better way to download a catch file from Mozilla Firefox, please do mention.
Steps:
Copy all of that text into a text document, and save it.
Edit that text to make it only the column of hexadecimal characters.
Options for how to do this include shell commands, a find-replace using regex, or a column editing mode in your text editor.
Convert those hex encoded bytes into a binary file.
You should be able to paste those characters into any decent hex editor, and save it as a file.
BTW, the .'s in this case are substituted to replace the newline characters.
I'm trying to find a way to enable/disable my router whithout the need for manually using the browser. After a bit of snooping, it seems to me that I have to send a request like that [from WireShark]:
0000 9c 97 26 c9 c2 20 b0 48 7a 80 52 9c 08 00 45 00 ..&.. .Hz.R...E.
0010 02 2e 28 89 40 00 80 06 00 00 c0 a8 00 02 c0 a8 ..(.#...........
0020 00 01 d6 a8 00 50 34 fd c9 8d c9 ef dd 2d 50 18 .....P4......-P.
0030 fe da 83 74 00 00 50 4f 53 54 20 2f 77 61 6e 53 ...t..POST /wanS
0040 74 61 74 75 73 2e 6c 70 20 48 54 54 50 2f 31 2e tatus.lp HTTP/1.
0050 31 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 31 36 38 1..Host: 192.168
0060 2e 30 2e 31 0d 0a 55 73 65 72 2d 41 67 65 6e 74 .0.1..User-Agent
0070 3a 20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 57 : Mozilla/5.0 (W
0080 69 6e 64 6f 77 73 20 4e 54 20 36 2e 31 3b 20 57 indows NT 6.1; W
0090 4f 57 36 34 3b 20 72 76 3a 33 36 2e 30 29 20 47 OW64; rv:36.0) G
00a0 65 63 6b 6f 2f 32 30 31 30 30 31 30 31 20 46 69 ecko/20100101 Fi
00b0 72 65 66 6f 78 2f 33 36 2e 30 0d 0a 41 63 63 65 refox/36.0..Acce
00c0 70 74 3a 20 74 65 78 74 2f 68 74 6d 6c 2c 61 70 pt: text/html,ap
00d0 70 6c 69 63 61 74 69 6f 6e 2f 78 68 74 6d 6c 2b plication/xhtml+
00e0 78 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f xml,application/
00f0 78 6d 6c 3b 71 3d 30 2e 39 2c 2a 2f 2a 3b 71 3d xml;q=0.9,*/*;q=
0100 30 2e 38 0d 0a 41 63 63 65 70 74 2d 4c 61 6e 67 0.8..Accept-Lang
0110 75 61 67 65 3a 20 69 74 2d 49 54 2c 69 74 3b 71 uage: it-IT,it;q
0120 3d 30 2e 38 2c 65 6e 2d 55 53 3b 71 3d 30 2e 35 =0.8,en-US;q=0.5
0130 2c 65 6e 3b 71 3d 30 2e 33 0d 0a 41 63 63 65 70 ,en;q=0.3..Accep
0140 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 t-Encoding: gzip
0150 2c 20 64 65 66 6c 61 74 65 0d 0a 44 4e 54 3a 20 , deflate..DNT:
0160 31 0d 0a 52 65 66 65 72 65 72 3a 20 68 74 74 70 1..Referer: http
0170 3a 2f 2f 31 39 32 2e 31 36 38 2e 30 2e 31 2f 77 ://192.168.0.1/w
0180 61 6e 53 74 61 74 75 73 2e 6c 70 0d 0a 43 6f 6f anStatus.lp..Coo
0190 6b 69 65 3a 20 78 41 75 74 68 5f 53 45 53 53 49 kie: xAuth_SESSI
01a0 4f 4e 5f 49 44 3d 49 4d 45 74 4f 38 44 4c 45 73 ON_ID=IMEtO8DLEs
01b0 51 70 6d 54 77 69 64 67 43 59 6c 51 41 3d 0d 0a QpmTwidgCYlQA=..
01c0 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 Connection: keep
01d0 2d 61 6c 69 76 65 0d 0a 43 6f 6e 74 65 6e 74 2d -alive..Content-
01e0 54 79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f Type: applicatio
01f0 6e 2f 78 2d 77 77 77 2d 66 6f 72 6d 2d 75 72 6c n/x-www-form-url
0200 65 6e 63 6f 64 65 64 0d 0a 43 6f 6e 74 65 6e 74 encoded..Content
0210 2d 4c 65 6e 67 74 68 3a 20 32 39 0d 0a 0d 0a 72 -Length: 29....r
0220 6e 3d 49 4d 45 74 4f 38 44 4c 45 73 51 70 6d 54 n=IMEtO8DLEsQpmT
0230 77 69 64 67 43 59 6c 51 41 25 33 44 widgCYlQA%3D
As you can see, it ends with 'rn=IMEtO8DLEsQpmTwidgCYlQA%3D', that is the session cookie.
Putting a 'normal' request the router goes back to index instead of performing the action, probably for the lack of 'rn=IMEtO8DLEsQpmTwidgCYlQA%3D'.
Until now, I tried using Wget (under windows...) but I can't find a way to add the last info.
So I would know if
there is a way to add an header that is not header-compliant (use of = instead of : ) using wGet or if
there is a tool more suited for that task (I'm looking for cUrl but I don't think it acts different from wGet).
The batch file (plain ol' DOS) I wrote for testing wGet is:
#title %~n0
#cls
#set _wget="C:\Program Files (x86)\GnuWin32\bin\wget"
#set _url=http://192.168.0.1/
#set _urls=http://192.168.0.1/standard.lp
#set _urlw=http://192.168.0.1/wanStatus.lp
#set _post=--post-data="/wanStatus.lp HTTP/1.1"
#set _cook=./cookies.txt
#set _hdr1="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
#set _hdr2="Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3"
#set _hdr3="Accept-Encoding: gzip, deflate"
#set _hdr4="DNT: 1"
#set _agnt="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0"
#set _rfr="Referer: http://192.168.0.1/wanStatus.lp"
#set _opt=--server-response --timestamping --user-agent=%_agnt% --keep-session-cookies --referer=%_rfr% --save-headers --header=%_hdr1% --header=%_hdr2% --header=%_hdr3% --header=%_hdr4% --debug
%_wget% %_opt% --save-cookies %_cook% %_url%
%_wget% %_opt% --load-cookies %_cook% %_urlw%
#FOR /F "eol=# tokens=1,6,7* delims= " %%i in (F:\wget\cookies.txt) do #(
#echo i=%%i j=%%j k=%%k l=%%l
#set _ckhost=%%i
#set _ckname=%%j
#set _ckval=%%k
)
#echo host=%_ckhost% cookie name=%_ckname% value=%_ckval%
#if "%_ckname%"=="xAuth_SESSION_ID" set _rn=rn=%_ckval%
#if "%_rn:~-1%"=="=" set _rn=%_rn:~0,-1%%%3D
#echo _rn='%_rn%'
%_wget% %_opt% --load-cookies %_cook% %_post% --header="%_rn%" %_url%
but it ends up this way:
F:\wget>"C:\Program Files (x86)\GnuWin32\bin\wget" --server-response --timestamping --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0" --keep-session-cookies --referer="Referer: http://192.168.0.1/wanStatus.lp" --save-headers --header="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --header="Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3" --header="Accept-Encoding: gzip, deflate" --header="DNT: 1" --debug --load-cookies ./cookies.txt --post-data="/wanStatus.lp HTTP/1.1" --header="rn=MGyN4YpepJoE6kSXPVT9lgA%3D" http://192.168.0.1/
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
Setting --load-cookies (loadcookies) to ./cookies.txt
Setting --post-data (postdata) to /wanStatus.lp HTTP/1.1
Setting --header (header) to rn=MGyN4YpepJoE6kSXPVT9lgA%3D
C:\Program Files (x86)\GnuWin32\bin\wget: --header: intestazione "rn=MGyN4YpepJoE6kSXPVT9lgA%3D" non valida.
Thank you very much for any suggestion! Or for links pointing to pages where I can find a solution (I spent a looot of time googling around...).
Luca
Note: I think it's useless to add here the HTML and JS code of the page in the router that generate the line rn=MGyN4YpepJoE6kSXPVT9lgA%3D, but if you need it, I can report it.
Look careful at the captured data and you might notice that these data are not part of the header. The header ends with \r\n\r\n (Bytes 021b..021e) and your "session cookie" is not a cookie (which would be part of the header) but the body of the POST request. Thus you need to use --post-data 'rn=MGyN...'
With a websocket server(C program) running in Cygwin, which does the handshaking&echoing back the messages from client.
With Firefox(Version 13.0.1), the two parties work together very well - handshaking , receiving and echoing back.
But with Chrome(Version 23.0.1271.97 m), after the handshaking step, the client always triggers onerror - "undefined", then onclose.
I was wondering:
Are there any differences between Firefox and Chrome how they handle websocket?
Here is the HTML code(Thanks to stackoverflow guys contribution):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function connect() {
var ws = new WebSocket("ws://localhost:8080/service");
ws.onopen = function () {
alert("About to send data");
ws.send("Hello World"); // I WANT TO SEND THIS MESSAGE TO THE SERVER!!!!!!!!
alert("Message sent!");
};
ws.onmessage = function (evt) {
alert("About to receive data");
var received_msg = evt.data;
alert("Message received = "+received_msg);
};
ws.onclose = function () {
// websocket is closed.
alert("Connection is closed...");
};
ws.onerror = function (evt) {
alert("ERROR: "+evt.data);
};
};
</script>
</head>
<body style="font-size:xx-large" >
<div>
Click here to start</div>
</body>
</html>
Here is data log captured on server side with Firefox:
websocket server received:
0001 47 45 54 20 2f 73 65 72 76 69 63 65 20 48 54 54 GET /service HTT
0002 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 6c 6f 63 P/1.1..Host: loc
0003 61 6c 68 6f 73 74 3a 38 30 38 30 0d 0a 55 73 65 alhost:8080..Use
0004 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c 61 r-Agent: Mozilla
0005 2f 35 2e 30 20 28 57 69 6e 64 6f 77 73 20 4e 54 /5.0 (Windows NT
0006 20 36 2e 31 3b 20 57 4f 57 36 34 3b 20 72 76 3a 6.1; WOW64; rv:
0007 31 33 2e 30 29 20 47 65 63 6b 6f 2f 32 30 31 30 13.0) Gecko/2010
0008 30 31 30 31 20 46 69 72 65 66 6f 78 2f 31 33 2e 0101 Firefox/13.
0009 30 2e 31 0d 0a 41 63 63 65 70 74 3a 20 74 65 78 0.1..Accept: tex
0010 74 2f 68 74 6d 6c 2c 61 70 70 6c 69 63 61 74 69 t/html,applicati
0011 6f 6e 2f 78 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 on/xhtml+xml,app
0012 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 lication/xml;q=0
0013 2e 39 2c 2a 2f 2a 3b 71 3d 30 2e 38 0d 0a 41 63 .9,*/*;q=0.8..Ac
0014 63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 65 cept-Language: e
0015 6e 2d 75 73 2c 65 6e 3b 71 3d 30 2e 35 0d 0a 41 n-us,en;q=0.5..A
0016 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 ccept-Encoding:
0017 67 7a 69 70 2c 20 64 65 66 6c 61 74 65 0d 0a 43 gzip, deflate..C
0018 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d onnection: keep-
0019 61 6c 69 76 65 2c 20 55 70 67 72 61 64 65 0d 0a alive, Upgrade..
0020 53 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 56 65 Sec-WebSocket-Ve
0021 72 73 69 6f 6e 3a 20 31 33 0d 0a 4f 72 69 67 69 rsion: 13..Origi
0022 6e 3a 20 6e 75 6c 6c 0d 0a 53 65 63 2d 57 65 62 n: null..Sec-Web
0023 53 6f 63 6b 65 74 2d 4b 65 79 3a 20 61 41 48 6e Socket-Key: aAHn
0024 63 31 77 66 6e 68 39 39 53 6d 59 67 4d 50 6b 4d c1wfnh99SmYgMPkM
0025 57 77 3d 3d 0d 0a 50 72 61 67 6d 61 3a 20 6e 6f Ww==..Pragma: no
0026 2d 63 61 63 68 65 0d 0a 43 61 63 68 65 2d 43 6f -cache..Cache-Co
0027 6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63 68 65 0d ntrol: no-cache.
0028 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f 63 .Upgrade: websoc
0029 6b 65 74 0d 0a 0d 0a ket....
websocket server sent:
0001 48 54 54 50 2f 31 2e 31 20 31 30 31 20 53 77 69 HTTP/1.1 101 Swi
0002 74 63 68 69 6e 67 20 50 72 6f 74 6f 63 6f 6c 73 tching Protocols
0003 0d 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f ..Upgrade: webso
0004 63 6b 65 74 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e cket..Connection
0005 3a 20 55 70 67 72 61 64 65 0d 0a 53 65 63 2d 57 : Upgrade..Sec-W
0006 65 62 53 6f 63 6b 65 74 2d 41 63 63 65 70 74 3a ebSocket-Accept:
0007 20 74 66 48 33 51 6f 70 47 2f 61 50 78 49 4c 65 tfH3QopG/aPxILe
0008 55 75 49 39 48 38 34 46 49 35 63 77 3d 0d 0a 53 UuI9H84FI5cw=..S
0009 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 50 72 6f ec-WebSocket-Pro
0010 74 6f 63 6f 6c 3a 20 63 68 61 74 0d 0a 0d 0a tocol: chat....
Sent OKAY.
websocket server received:
0001 81 8b 75 cb 87 1a 3d ae eb 76 1a eb d0 75 07 a7 ..u...=..v...u..
0002 e3 .
websocket server sent:
...
Data log with Chrome:
websocket server received:
0001 47 45 54 20 2f 73 65 72 76 69 63 65 20 48 54 54 GET /service HTT
0002 50 2f 31 2e 31 0d 0a 55 70 67 72 61 64 65 3a 20 P/1.1..Upgrade:
0003 77 65 62 73 6f 63 6b 65 74 0d 0a 43 6f 6e 6e 65 websocket..Conne
0004 63 74 69 6f 6e 3a 20 55 70 67 72 61 64 65 0d 0a ction: Upgrade..
0005 48 6f 73 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a Host: localhost:
0006 38 30 38 30 0d 0a 4f 72 69 67 69 6e 3a 20 6e 75 8080..Origin: nu
0007 6c 6c 0d 0a 53 65 63 2d 57 65 62 53 6f 63 6b 65 ll..Sec-WebSocke
0008 74 2d 4b 65 79 3a 20 6a 79 38 30 61 2b 50 72 73 t-Key: jy80a+Prs
0009 35 48 71 62 36 62 58 50 2f 43 58 51 51 3d 3d 0d 5Hqb6bXP/CXQQ==.
0010 0a 53 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 56 .Sec-WebSocket-V
0011 65 72 73 69 6f 6e 3a 20 31 33 0d 0a 53 65 63 2d ersion: 13..Sec-
0012 57 65 62 53 6f 63 6b 65 74 2d 45 78 74 65 6e 73 WebSocket-Extens
0013 69 6f 6e 73 3a 20 78 2d 77 65 62 6b 69 74 2d 64 ions: x-webkit-d
0014 65 66 6c 61 74 65 2d 66 72 61 6d 65 0d 0a 0d 0a eflate-frame....
websocket server sent:
0001 48 54 54 50 2f 31 2e 31 20 31 30 31 20 53 77 69 HTTP/1.1 101 Swi
0002 74 63 68 69 6e 67 20 50 72 6f 74 6f 63 6f 6c 73 tching Protocols
0003 0d 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f ..Upgrade: webso
0004 63 6b 65 74 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e cket..Connection
0005 3a 20 55 70 67 72 61 64 65 0d 0a 53 65 63 2d 57 : Upgrade..Sec-W
0006 65 62 53 6f 63 6b 65 74 2d 41 63 63 65 70 74 3a ebSocket-Accept:
0007 20 4d 39 2f 58 41 4e 67 35 52 32 58 4f 4d 50 49 M9/XANg5R2XOMPI
0008 4d 67 2f 54 6b 50 38 6e 5a 38 67 6f 3d 0d 0a 53 Mg/TkP8nZ8go=..S
0009 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 50 72 6f ec-WebSocket-Pro
0010 74 6f 63 6f 6c 3a 20 63 68 61 74 0d 0a 0d 0a tocol: chat....
Sent OKAY.
Guys.
Here is my experience about the issue.
Yesterday, my php simple chatting socket script worked well in both of firefox and chrome. Suddenly it did not work in chrome today. Not sure why? But after the request header value was printed, I found that the header length was longer than 1024 byte.
(I tested by getting 1024 byte in server.php under a domain without login).
Maybe after I logged into the domain, cache length was added into the http request header.
I increased the length value for socket_read function to 5120 byte before performed handshaking. It was enough value to get full request header.
My problem was solved since server.php handshaking function could validate sec-websocket-key from request header.
Hope other guys to take care of websocket request header length.
Regards,
Yin