-
Notifications
You must be signed in to change notification settings - Fork 3
/
Lync-Skype4B-Plugin2.00.lua
3182 lines (2445 loc) · 139 KB
/
Lync-Skype4B-Plugin2.00.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
----------------------------------------------------------------------------------------------------------------------
-- Name: Microsoft Lync / Skype for Business Wireshark Plugin
-- Version: v2.0.0 (20/3/2016)
-- Date: 1/5/2014
-- Created By: James Cussen
-- Web Site: http://www.myskypelab.com
-- Notes: For more information on this plugin visit http://www.myskypelab.com/2014/05/microsoft-lync-wireshark-plugin.html
-- Feedback: If you have feedback on the plugin you can send it to mylynclab<at>gmail<dot>com
--
-- Copyright: Copyright (c) 2016, James Cussen (www.myskypelab.com) All rights reserved.
-- Licence: Redistribution and use of script, source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-- 1) Redistributions of script code must retain the above copyright notice, this list of conditions and the following disclaimer.
-- 2) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-- 3) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-- 4) This license does not include any resale or commercial use of this software.
-- 5) Any portion of this software may not be reproduced, duplicated, copied, sold, resold, or otherwise exploited for any commercial purpose without express written consent of James Cussen.
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; LOSS OF GOODWILL OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- Protocol Documentation: [MS-TURNBWM] http://msdn.microsoft.com/en-us/library/ff595670.aspx
-- [MS-TURN] http://msdn.microsoft.com/en-us/library/cc431507.aspx
-- [MS-RTP] http://msdn.microsoft.com/en-us/library/cc431492.aspx
-- [MS-SRTP] http://msdn.microsoft.com/en-us/library/cc431516.aspx
-- [MS-RTASPF] http://msdn.microsoft.com/en-us/library/cc308725.aspx
-- [MS-RTPDT] http://msdn.microsoft.com/en-us/library/cc485841.aspx
-- [MS-ICE] http://msdn.microsoft.com/en-us/library/dd922095.aspx
-- [MS-ICE2] http://msdn.microsoft.com/en-us/library/cc431504.aspx
-- ICE RFC5245 - https://tools.ietf.org/html/rfc5245
-- STUN RFC5389 - http://tools.ietf.org/html/rfc5389
-- ICE-19 - http://tools.ietf.org/html/draft-ietf-mmusic-ice-19
-- RTP / RTCP - http://tools.ietf.org/html/rfc3550
--
-- Release Notes:
-- 1.00 Initial Release.
-- - This Wireshark plugin is designed to dissect Lync AV Edge and Internal Edge AV traffic. Captures can be taken on the Edge server (Capturing AV Edge External traffic, and Internal Interface traffic), or it can also be used on the client side for decoding STUN and RTP/RTCP traffic.
-- - This Wireshark plugin dissects STUN/TURN traffic on Microsoft Lync Edge port 3478 (STUN, RTCP, RTP)
-- - This Wireshark plugin dissects traffic on Microsoft Lync Edge port 443 (STUN, RTCP, RTP)
-- - This Wireshark plugin dissects dynamically assigned RTP and RTCP traffic by using ports allocated in STUN requests.
-- - Dissector can be turned on/off within Wireshark Preferences. (Edit->Preferences->Protocols->LYNC_SKYPE_PLUGIN)
-- - Port numbers can be changed within Wireshark Preferences. (Edit->Preferences->Protocols->LYNC_SKYPE_PLUGIN)
-- - If you enter “lync_skype_plugin” in the Filter bar, only the traffic that is being decoded by the Lync Plugin will be displayed.
-- - To be used with the latest release of Wireshark
--
-- 2.00 Wireshark 2.0 update
-- - Some updates to work with Wireshark 2.0+ (Thank you to Vladimir Vysotsky for feedback)
-- - Changed the naming of the plugin to LYNC_SKYPE_PLUGIN.
-- - Big updates to RTP and STUN classification to fix detection issues.
-- - Added TLS pass-through to the Wireshark default SSL dissector for Hello, Handshaking, and Application data. So now you can have the plugin running all the time and still troubleshoot TLS handshaking issues on port 443. This also makes the plugin better for client side testing.
-- - Corrected some issues with decoding 0x0013 Data Attribute encapsulated data.
-- - The decoding of port 443 can have false positive matches for different packet types. The amount of false positive in this version of the plugin has been greatly decreased.
-- - Widened the scope of RTP port classification from 1024-59999 (which was limited for Edge use) to 1024-65535. This makes the plugin work better when testing client side connections.
-- - And more!
--
-------------------------------------------------------------------------------------------------------------------------
do
local lync_wrapper_proto = Proto("lync_skype_plugin", "Microsoft Lync Skype Plugin");
--PREFERENCES
local prefs = lync_wrapper_proto.prefs
prefs.port3478 = Pref.bool( "Decode UDP Port (Default 3478)", true, "Decode UDP Port (Default 3478)" )
prefs.port443 = Pref.bool( "Decode Internal TCP Port (Default 443)", true, "Decode Internal TCP Port (Default 443)")
prefs.portexternal443 = Pref.bool( "Decode External AV TCP Port (Default 443)", true, "Decode External AV TCP Port (Default 443)")
prefs.port50000 = Pref.bool( "Decode 1024-65535 Dynamic Ports", true, "Decode 1024-65535 Dynamic Ports")
prefs.udpprotocolport = Pref.uint( "UDP Port (default 3478)", 3478)
prefs.tcpprotocolport = Pref.uint( "TCP Internal Port (default 443)", 443)
prefs.tcpexternalprotocolport = Pref.uint( "TCP External AV Port (default 443)", 443)
prefs.showorginal = Pref.bool( "Show orginal wireshark dissection tree", false, "Show orginal wireshark dissection tree")
-- FIELDS
local F_stuntype = ProtoField.string("lync_wrapper_proto.stuntype","Type")
local F_stunname = ProtoField.string("lync_wrapper_proto.stunname","Name")
local F_attribute = ProtoField.string("lync_wrapper_proto.attribute","Attribute")
local F_attribute_sub = ProtoField.string("lync_wrapper_proto.attribute.attribute_sub","AttributeType")
local f_tcp_srcport = Field.new("tcp.srcport")
local f_tcp_dstport = Field.new("tcp.dstport")
local f_udp_srcport = Field.new("udp.srcport")
local f_udp_dstport = Field.new("udp.dstport")
-- ADD THE FIELDS TO THE PROTOCOL
lync_wrapper_proto.fields = {F_stuntype, F_stunname, F_attribute, F_attribute_sub}
-- DECLARE THE FIELDS WE NEED TO READ
local original_stun_dissector
-- GET THE ORIGINAL SSL DISSECTOR
local tcp_dissector_table = DissectorTable.get("tcp.port")
original_ssl_dissector = tcp_dissector_table:get_dissector(443)
function lync_wrapper_proto.dissector(tvbuffer, pinfo, treeitem)
if tvbuffer:len() > 1 then
-- THIS WILL INCLUDE THE ORIGINAL WIRESHARK DISSECTION TREE IN ADDITION TO THE LYNC EDGE DISSECTOR TREE
if prefs.showorginal then
original_stun_dissector:call(tvbuffer, pinfo, treeitem)
end
-- CREATE NEW TREE PANE FOR MSSTUN PROTOCOL
local subtreeitem = treeitem:add(lync_wrapper_proto, tvbuffer)
-- IF THIS IS A TCP PACKET THEN OFFSET THE FRAMING
tcpOffset = 0
-- MAGIC COOKIE 0x2112A442
-- TCP FRAMING CHECK STUN
frameCheck = tvbuffer(0,1):uint()
if tvbuffer:len() >= 12 then
magiccookie = tvbuffer:range(8,4):uint()
else
magiccookie = 0
end
stunDataindIcationCheck = tvbuffer:range(4,2):uint()
if frameCheck == 0x02 and magiccookie == 0x2112a442 or stunDataindIcationCheck == 0x0115 then -- MAGIC COOKIE CHECK
if f_tcp_srcport() ~= nil and f_tcp_dstport() ~= nil then -- CHECK IF TCP
tcpOffset = 4
subtreeitem:add(F_stunname, tvbuffer(0,4), cmd_str)
:set_text("TCP Framing Bytes - Turn Control Message (4 Bytes)")
end
end
-- TCP FRAMING CHECK FOR END-TO-END DATA
if frameCheck == 0x03 then
if f_tcp_srcport() ~= nil and f_tcp_dstport() ~= nil then
packetlength = tvbuffer:len()
length = tvbuffer(2,2):uint()
-- CHECK LENGTH
if (length + 4) == packetlength then
tcpOffset = 6
subtreeitem:add(F_stunname, tvbuffer(0,6), cmd_str)
:set_text("TCP Framing Bytes - End-to-End Data Message (6 Bytes)")
--Set the Protcol and Info Columns
pinfo.cols.protocol = "MSSTUN"
pinfo.cols.info = "STUN END-TO-END DATA (Content Sharing)"
attribute_bytes = tostring(tvbuffer:range(0,1)):upper()
attributeTree = subtreeitem:add(F_stunname, tvbuffer(0,1), attribute_bytes)
attributeTree:set_text("Type: " .. "(0x" .. attribute_bytes .. ")")
attribute_bytes = tostring(tvbuffer:range(1,1)):upper()
attributeTree = subtreeitem:add(F_stunname, tvbuffer(1,1), attribute_bytes)
attributeTree:set_text("Reserved: " .. "(0x" .. attribute_bytes .. ")")
attribute_bytes = tostring(tvbuffer:range(2,2)):upper()
attributeTree = subtreeitem:add(F_stunname, tvbuffer(2,2), attribute_bytes)
attributeTree:set_text("Payload Length: " .. "(0x" .. attribute_bytes .. ")")
attribute_bytes = tostring(tvbuffer:range(4,2)):upper()
attributeTree = subtreeitem:add(F_stunname, tvbuffer(4,2), attribute_bytes)
attributeTree:set_text("RTP Length: " .. "(0x" .. attribute_bytes .. ")")
attributeTree = subtreeitem:add(F_attribute_sub, tvbuffer(6,tvbuffer:len()-6), cmd_str)
attributeTree:set_text("End-to-End Data: " .. tostring(tvbuffer(6,tvbuffer:len()-6)))
end
end
end
-- TCP FRAMING RTP/RTCP
--RFC 4571 Section 2
-- 0 1 2 3
--0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-----------------------------------------------------------------
--| LENGTH | RTP or RTCP packet ... |
-----------------------------------------------------------------
frameCheck2 = tvbuffer(0,2):uint()
totalPacketLength = tvbuffer:len()
framesize = totalPacketLength - 2
magiccookie = tvbuffer:range(4+tcpOffset,4)
if f_tcp_srcport() ~= nil and f_tcp_dstport() ~= nil then -- CHECK IF IT'S TCP TRAFFIC
if frameCheck2 ~= 0x1603 and frameCheck2 ~= 0x1703 then -- CHECK THAT IT'S NOT TLS TRAFFIC
if magiccookie ~= 0x2112a442 then -- CHECK THAT IT'S NOT A STUN PACKET
if frameCheck2 == framesize then -- 2.0 CHECK - THE FRAMING BITS SHOULD EQUAL THE LENGTH OF THE PACKET
tcpOffset = 2
subtreeitem:add(F_stunname, tvbuffer(0,2), cmd_str)
:set_text("TCP Framing Bytes (2 Byte)")
end
end
end
end
-- GET THE ATTRIBUTE
attribute = tvbuffer(tcpOffset,2):uint()
-- CHECK IF IT'S A MICROSOFT STUN ATTRIBUTE
standard_attribute = tvbuffer(tcpOffset,1):uint()
if tvbuffer:len() >= 8 then
magiccookie = tvbuffer:range(4+tcpOffset,4):uint() -- MAGIC COOKIE
else
magiccookie = 0
end
--MAGICCOOKIE == 0x2112A442
if attribute ~= 0x0300 and magiccookie == 0x2112a442 or attribute == 0x0115 then
-- CHECK for MS STUN!
if standard_attribute == 0x00 or standard_attribute == 0x01 then
cmd = tvbuffer(tcpOffset,2):uint()
cmd_str = "unknown 0x00 0x01 (Possible incorrect packet classification)"
if cmd == 0x0001 then
cmd_str = "STUN BINDING REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0101 then
cmd_str = "STUN BINDING RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0111 then
cmd_str = "STUN BINDING ERROR RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0011 then
cmd_str = "STUN BINDING INDICATION"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0002 then
cmd_str = "STUN SHARED SECRET REQUEST - NOT SUPPORTED"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0102 then
cmd_str = "STUN SHARED SECRET RESPONSE - NOT SUPPORTED"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0112 then
cmd_str = "STUN SHARED SECRET ERROR RESPONSE - NOT SUPPORTED"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0003 then
cmd_str = "STUN ALLOCATE REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0103 then
cmd_str = "STUN ALLOCATE RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0113 then
cmd_str = "STUN ALLOCATE ERROR RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0004 then
cmd_str = "STUN SEND REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0104 then
cmd_str = "STUN REFRESH RESPONSE - NOT SUPPORTED"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0114 then
cmd_str = "STUN REFRESH ERROR RESPONSE - NOT SUPPORTED"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0115 then
cmd_str = "STUN DATA INDICATION"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0006 then
cmd_str = "STUN SET ACTIVE DESTINATION REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0016 then
cmd_str = "STUN SEND INDICATION"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0106 then
cmd_str = "STUN SET ACTIVE DESTINATION RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0116 then
cmd_str = "STUN SET ACTIVE DESTINATION ERROR RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0017 then
cmd_str = "STUN DATA INDICATION"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0008 then
cmd_str = "STUN CREATE PERM REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0108 then
cmd_str = "STUN CREATE PERM RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0118 then
cmd_str = "STUN CREATE_PERM ERROR RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0009 then
cmd_str = "STUN CHANNEL BIND REQUEST"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0109 then
cmd_str = "STUN CHANNEL BIND RESPONSE"
pinfo.cols.protocol = "MSSTUN"
elseif cmd == 0x0119 then
cmd_str = "STUN CHANNEL BIND ERROR RESPONSE"
pinfo.cols.protocol = "MSSTUN"
else
-- NO MATCH
cmd_str = ""
--IF IT'S ON PORT 443 THEN ASSUME THEN TRY THE TLS DECODER
if f_tcp_srcport() ~= nil and f_tcp_dstport() ~= nil then
if f_tcp_srcport().value == 443 or f_tcp_dstport().value == 443 then
original_ssl_dissector:call(tvbuffer, pinfo, treeitem) --DECODE AS TLS
end
end
end
--cmd_str = cmd_str .. " attribute = " .. tostring(attribute):upper() .. " standard_attribute = " .. tostring(standard_attribute):upper() .. " Magic Cookie = " .. tostring(magiccookie):upper()
field1_val = tostring(bit.tohex(tvbuffer(tcpOffset,2):uint(),4)):upper()
subtreeitem:add(F_stunname, tvbuffer(tcpOffset,2), cmd_str)
:set_text("Command String: " .. cmd_str .. " (0x" .. field1_val .. ")")
attribute_length = string.format("%i", tvbuffer(2+tcpOffset,2):uint())
subtreeitem:add(F_stunname, tvbuffer(2+tcpOffset,2), attribute_length)
:set_text("Attribute Length: " .. attribute_length .. " Bytes")
field1_val = tostring(tvbuffer:range(4+tcpOffset,4)):upper()
subtreeitem:add(F_stunname, tvbuffer(4+tcpOffset,4), cmd_str)
:set_text("Magic Cookie: " .. "0x" .. field1_val)
field1_val = tostring(tvbuffer:range(8+tcpOffset,12)):upper()
subtreeitem:add(F_stunname, tvbuffer(8+tcpOffset,12), cmd_str)
:set_text("Transaction ID: 0x" .. field1_val)
--SET THE PROTCOL AND INFO COLUMNS
pinfo.cols.info = cmd_str
offset = 20 + tcpOffset
relativePosition = 0
-- START READING ATTRIBUTES - LOOK FOR MICROSOFT EXTENSIONS
while true do
-- POSITION IN PACKET
local absolutePosition = offset + relativePosition
-- GET THE ATTRIBUTE
local attribute = tvbuffer(absolutePosition,2):uint()
-- CHECK IF IT'S A MICROSOFT ATTRIBUTE
local ms_attribute = tvbuffer(absolutePosition,1):uint()
-- GET THE LENGTH OF THE ATTRIBUTE
local lengthOfCommand = tvbuffer(absolutePosition+2,2):uint()
-- CALCULATE THE FINAL POSITION
local finalPosition = absolutePosition + lengthOfCommand + 4
--NON MICROSOFT SPECIFIC ATTRIBUTES
if ms_attribute == 0x00 then
-- DEFINED IN IETFDRAFT-STUN-02
if attribute == 0x0001 then
att_str = "Mapped Address"
elseif attribute == 0x0006 then
att_str = "Username"
elseif attribute == 0x0008 then
att_str = "Message Integrity"
elseif attribute == 0x0009 then
att_str = "Error Code"
elseif attribute == 0x000A then
att_str = "Unknown Attributes"
elseif attribute == 0x000D then
att_str = "Lifetime"
elseif attribute == 0x000E then
att_str = "Alternate Server"
elseif attribute == 0x000F then
att_str = "Magic Cookie"
elseif attribute == 0x0010 then
att_str = "Bandwidth"
elseif attribute == 0x0011 then
att_str = "Destination Address"
elseif attribute == 0x0012 then
att_str = "Remote Address"
elseif attribute == 0x0013 then
att_str = "Data"
elseif attribute == 0x0014 then
att_str = "Nonce"
elseif attribute == 0x0015 then
att_str = "Realm"
elseif attribute == 0x0017 then
att_str = "Requested Address Family"
elseif attribute == 0x0020 then
att_str = "XOR Mapped Address"
elseif attribute == 0x0024 then
att_str = "Priority (RFC5245)"
elseif attribute == 0x0025 then
att_str = "Use-Candidate (RFC5245)"
end
attribute_val = tostring(bit.tohex(tvbuffer(absolutePosition,2):uint(),4)):upper()
attributeTree = subtreeitem:add(F_attribute, tvbuffer(absolutePosition,lengthOfCommand+4), attribute_val)
attributeTree:set_text("Attribute: 0x" .. attribute_val .. " (" .. att_str .. ")")
attribute_length = string.format("%i", tvbuffer(absolutePosition+2,2):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+2,2), attribute_length)
:set_text("Attribute Length: " .. attribute_length .. " Bytes")
-- Defined in IETFDRAFT-STUN-02
if attribute == 0x0001 then
--att_str = "Mapped Address"
attribute_bytes = tostring(bit.tohex(tvbuffer(absolutePosition+4,1):uint(),1)):upper()
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,1), attribute_length)
:set_text("Reserved " .. attribute_bytes)
fam_type = tvbuffer(absolutePosition+5,1):uint()
if fam_type == 0x01 then
att_str = "IPv4"
att_bytes = "0x01"
elseif fam_type == 0x02 then
att_str = "IPv6"
att_bytes = "0x02"
end
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+5,1), attribute_length)
:set_text("Family: " .. att_str .. " (" .. att_bytes .. ")")
port = tvbuffer(absolutePosition+6,2):uint()
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+6,2):uint())
portstring = string.format("%i", port)
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("Port: " .. portstring .. " " .. attribute_bytes)
if fam_type == 0x01 then
oct1 = tvbuffer(absolutePosition+8,1):uint()
oct2 = tvbuffer(absolutePosition+9,1):uint()
oct3 = tvbuffer(absolutePosition+10,1):uint()
oct4 = tvbuffer(absolutePosition+11,1):uint()
ip1string = string.format("%i", oct1)
ip2string = string.format("%i", oct2)
ip3string = string.format("%i", oct3)
ip4string = string.format("%i", oct4)
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+8,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,4), attribute_length)
:set_text("Address-IPv4: " .. ip1string .. "." .. ip2string .. "." .. ip3string .. "." .. ip4string .. " " .. attribute_bytes)
elseif fam_type == 0x02 then
-- Not decoding IPv6 fully yet. Need some capture data to test against.
attribute_bytes = tostring(tvbuffer:range(absolutePosition+8,16))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,16), attribute_length)
:set_text("Address_IPv6: 0x" .. attribute_bytes)
end
elseif attribute == 0x0006 then
--att_str = "Username"
attribute_bytes = tostring(tvbuffer:range(absolutePosition+4,lengthOfCommand-4))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,lengthOfCommand), attribute_length)
:set_text("Username (<prefix,rounded-time,clientIP,hmac>): 0x" .. attribute_bytes)
elseif attribute == 0x0008 then
--att_str = "Message Integrity"
attribute_bytes = tostring(tvbuffer:range(absolutePosition+4,lengthOfCommand-4))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,lengthOfCommand), attribute_length)
:set_text("HMAC HASH: 0x" .. attribute_bytes)
elseif attribute == 0x0009 then
--att_str = "Error Code"
-- 0 1 2 3
-- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-- | 0 |Class| Number |
-- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-- | Reason Phrase (variable) ..
-- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
local bits = tvbuffer(absolutePosition+4,3):uint()
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,3), attribute_length)
:set_text("Reserved Bytes: 0x" .. tostring(bit.tohex((bit.band(bits,0xFFFFF0)),6)))
local bits2 = tvbuffer(absolutePosition+6,1):uint()
local bits3 = tvbuffer(absolutePosition+7,1):uint()
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("Error Code: " .. string.format("%01d", (bit.band(bits2,0x0F))) .. string.format("%02d", (bit.band(bits3,0xFF))))
-- Convert to ASCII
local asc = ""
for i = absolutePosition+8, absolutePosition+8+lengthOfCommand-4 do
local c = tvbuffer(i,1):uint()
asc = string.format("%s%c", asc, c)
end
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,lengthOfCommand-4), attribute_length)
:set_text("Error: " .. asc)
elseif attribute == 0x000A then
--att_str = "Unknown Attributes"
attribute_bytes = tostring(bit.tohex(tvbuffer(absolutePosition+4,2):uint(),4))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+2,2), attribute_length)
:set_text("Attribute 1 Type: 0x" .. attribute_bytes)
attribute_bytes = tostring(bit.tohex(tvbuffer(absolutePosition+6,2):uint(),4))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+2,2), attribute_length)
:set_text("Attribute 2 Type: 0x" .. attribute_bytes)
elseif attribute == 0x000D then
--att_str = "Lifetime"
attribute_bytes = string.format("%i", tvbuffer(absolutePosition+4,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,4), attribute_length)
:set_text("Lifetime: " .. attribute_bytes .. " Seconds")
elseif attribute == 0x000E then
--att_str = "Alternate Server"
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+4,1):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,1), attribute_length)
:set_text("Reserved " .. attribute_bytes)
fam_type = tvbuffer(absolutePosition+5,1):uint()
if fam_type == 0x01 then
att_str = "IPv4"
att_bytes = "0x01"
elseif fam_type == 0x02 then
att_str = "IPv6"
att_bytes = "0x02"
end
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+5,1), attribute_length)
:set_text("Family: " .. att_str .. " (" .. att_bytes .. ")")
port = tvbuffer(absolutePosition+6,2):uint()
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+6,2):uint())
portstring = string.format("%i", port)
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("Port: " .. portstring .. " " .. attribute_bytes)
if fam_type == 0x01 then
oct1 = tvbuffer(absolutePosition+8,1):uint()
oct2 = tvbuffer(absolutePosition+9,1):uint()
oct3 = tvbuffer(absolutePosition+10,1):uint()
oct4 = tvbuffer(absolutePosition+11,1):uint()
ip1string = string.format("%i", oct1)
ip2string = string.format("%i", oct2)
ip3string = string.format("%i", oct3)
ip4string = string.format("%i", oct4)
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+8,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,4), attribute_length)
:set_text("Address-IPv4: " .. ip1string .. "." .. ip2string .. "." .. ip3string .. "." .. ip4string .. " " .. attribute_bytes)
elseif fam_type == 0x02 then
-- Not decoding IPv6 fully yet.
attribute_bytes = tostring(tvbuffer:range(absolutePosition+8,16))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,16), attribute_length)
:set_text("Address_IPv6: 0x" .. attribute_bytes)
end
elseif attribute == 0x000F then
--att_str = "Magic Cookie"
attribute_bytes = tostring(bit.tohex(tvbuffer(absolutePosition+4,4):uint(),8)):upper()
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,4), attribute_length)
:set_text("Magic Cookie: 0x" .. attribute_bytes)
elseif attribute == 0x0010 then
--att_str = "Bandwidth"
attribute_bytes = string.format("%i", tvbuffer(absolutePosition+4,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,4), attribute_length)
:set_text("Bandwidth (peak): " .. attribute_bytes .. " kbps")
elseif attribute == 0x0011 then
--att_str = "Desitination Address"
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+4,1):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,1), attribute_length)
:set_text("Reserved " .. attribute_bytes)
fam_type = tvbuffer(absolutePosition+5,1):uint()
if fam_type == 0x01 then
att_str = "IPv4"
att_bytes = "0x01"
elseif fam_type == 0x02 then
att_str = "IPv6"
att_bytes = "0x02"
end
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+5,1), attribute_length)
:set_text("Family: " .. att_str .. " (" .. att_bytes .. ")")
port = tvbuffer(absolutePosition+6,2):uint()
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+6,2):uint())
portstring = string.format("%i", port)
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("Port: " .. portstring .. " " .. attribute_bytes)
-----------------------------------------------
-- Decode the 1024-65535 range ports from STUN
-----------------------------------------------
if prefs.port50000 then
if port >= 1024 and port <= 65535 then
myproto_udp_init(port)
myproto_tcp_init(port)
--RTCP
myproto_udp_init(port+1) --RTCP Port
myproto_tcp_init(port+1) --RTCP Port
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("(INFO: Added " .. portstring .. " to decode.)")
else
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("(INFO: Not in 1024-65535 range. Not Added " .. portstring .. " to decode.)")
end
else
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("(INFO: Removed " .. portstring .. " from decode.)")
myproto_udp_remove_init(port)
myproto_tcp_remove_init(port)
myproto_udp_remove_init(port+1) -- RTCP Port
myproto_tcp_remove_init(port+1) -- RTCP Port
end
if fam_type == 0x01 then
oct1 = tvbuffer(absolutePosition+8,1):uint()
oct2 = tvbuffer(absolutePosition+9,1):uint()
oct3 = tvbuffer(absolutePosition+10,1):uint()
oct4 = tvbuffer(absolutePosition+11,1):uint()
ip1string = string.format("%i", oct1)
ip2string = string.format("%i", oct2)
ip3string = string.format("%i", oct3)
ip4string = string.format("%i", oct4)
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+8,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,4), attribute_length)
:set_text("Address-IPv4: " .. ip1string .. "." .. ip2string .. "." .. ip3string .. "." .. ip4string .. " " .. attribute_bytes)
elseif fam_type == 0x02 then
-- Not decoding IPv6 fully yet.
attribute_bytes = tostring(tvbuffer:range(absolutePosition+8,16))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,16), attribute_length)
:set_text("Address_IPv6: 0x" .. attribute_bytes)
end
elseif attribute == 0x0012 then
--att_str = "Remote Address"
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+4,1):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,1), attribute_length)
:set_text("Reserved " .. attribute_bytes)
fam_type = tvbuffer(absolutePosition+5,1):uint()
if fam_type == 0x01 then
att_str = "IPv4"
att_bytes = "0x01"
elseif fam_type == 0x02 then
att_str = "IPv6"
att_bytes = "0x02"
end
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+5,1), attribute_length)
:set_text("Family: " .. att_str .. " (" .. att_bytes .. ")")
port = tvbuffer(absolutePosition+6,2):uint()
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+6,2):uint())
portstring = string.format("%i", port)
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+6,2), attribute_length)
:set_text("Port: " .. portstring .. " " .. attribute_bytes)
if fam_type == 0x01 then
oct1 = tvbuffer(absolutePosition+8,1):uint()
oct2 = tvbuffer(absolutePosition+9,1):uint()
oct3 = tvbuffer(absolutePosition+10,1):uint()
oct4 = tvbuffer(absolutePosition+11,1):uint()
ip1string = string.format("%i", oct1)
ip2string = string.format("%i", oct2)
ip3string = string.format("%i", oct3)
ip4string = string.format("%i", oct4)
attribute_bytes = string.format("(0x%X)", tvbuffer(absolutePosition+8,4):uint())
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,4), attribute_length)
:set_text("Address-IPv4: " .. ip1string .. "." .. ip2string .. "." .. ip3string .. "." .. ip4string .. " " .. attribute_bytes)
elseif fam_type == 0x02 then
-- Not decoding IPv6 fully yet.
attribute_bytes = tostring(tvbuffer:range(absolutePosition+8,16))
attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+8,16), attribute_length)
:set_text("Address_IPv6: 0x" .. attribute_bytes)
end
elseif attribute == 0x0013 then
--att_str = "Data"
attribute_bytes = tostring(tvbuffer:range(absolutePosition+4,lengthOfCommand))
dataTree = attributeTree:add(F_attribute_sub, tvbuffer(absolutePosition+4,lengthOfCommand), attribute_length)
dataTree:set_text("Data: " .. attribute_bytes)
rtpTcpOffset = 0
-- If it's TCP then apply 2 bytes of framing
if f_tcp_srcport() ~= nil and f_tcp_dstport() ~= nil then
if f_tcp_srcport().value or f_tcp_dstport().value then
rtpTcpOffset = 2
dataTree:add(F_stunname, tvbuffer(absolutePosition+4,2), cmd_str)
:set_text("TCP Framing Bytes (2 Byte)")
end
end
local datatype = tvbuffer(absolutePosition+4+rtpTcpOffset,1):uint()
-- STUN CHECK
stuncmdbyte = tvbuffer(absolutePosition+4+rtpTcpOffset,1):uint()
stuncmd = tvbuffer(absolutePosition+4+rtpTcpOffset,2):uint()
-- Check if encapsulated data is a STUN message
if stuncmdbyte == 0x00 or stuncmdbyte == 0x01 then
stuncmd_str = "unknown (Possible incorrect packet classification)"
if stuncmd == 0x0001 then
stuncmd_str = "STUN BINDING REQUEST"
elseif stuncmd == 0x0101 then
stuncmd_str = "STUN BINDING RESPONSE"
elseif stuncmd == 0x0111 then
stuncmd_str = "STUN BINDING ERROR RESPONSE"
elseif stuncmd == 0x0011 then
stuncmd_str = "STUN BINDING INDICATION"
elseif stuncmd == 0x0002 then
stuncmd_str = "STUN SHARED SECRET REQUEST - NOT SUPPORTED"
elseif stuncmd == 0x0102 then
stuncmd_str = "STUN SHARED SECRET RESPONSE - NOT SUPPORTED"
elseif stuncmd == 0x0112 then
stuncmd_str = "STUN SHARED SECRET ERROR RESPONSE - NOT SUPPORTED"
elseif stuncmd == 0x0003 then
stuncmd_str = "STUN ALLOCATE REQUEST"
elseif stuncmd == 0x0103 then
stuncmd_str = "STUN ALLOCATE RESPONSE"
elseif stuncmd == 0x0113 then
stuncmd_str = "STUN ALLOCATE ERROR RESPONSE"
elseif stuncmd == 0x0004 then
stuncmd_str = "STUN SEND REQUEST"
elseif stuncmd == 0x0104 then
stuncmd_str = "STUN REFRESH RESPONSE - NOT SUPPORTED"
elseif stuncmd == 0x0114 then
stuncmd_str = "STUN REFRESH ERROR RESPONSE - NOT SUPPORTED"
elseif stuncmd == 0x0115 then
stuncmd_str = "STUN DATA INDICATION"
elseif stuncmd == 0x0006 then
stuncmd_str = "STUN SET ACTIVE DESTINATION REQUEST"
elseif stuncmd == 0x0016 then
stuncmd_str = "STUN SEND INDICATION"
elseif stuncmd == 0x0106 then
stuncmd_str = "STUN SET ACTIVE DESTINATION RESPONSE"
elseif stuncmd == 0x0116 then
stuncmd_str = "STUN SET ACTIVE DESTINATION ERROR RESPONSE"
elseif stuncmd == 0x0017 then
stuncmd_str = "STUN DATA INDICATION"
elseif stuncmd == 0x0008 then
stuncmd_str = "STUN CREATE PERM REQUEST"
elseif stuncmd == 0x0108 then
stuncmd_str = "STUN CREATE PERM RESPONSE"
elseif stuncmd == 0x0118 then
stuncmd_str = "STUN CREATE_PERM ERROR RESPONSE"
elseif stuncmd == 0x0009 then
stuncmd_str = "STUN CHANNEL BIND REQUEST"
elseif stuncmd == 0x0109 then
stuncmd_str = "STUN CHANNEL BIND RESPONSE"
elseif stuncmd == 0x0119 then
stuncmd_str = "STUN CHANNEL BIND ERROR RESPONSE"
end
attribute_bytes = tostring(tvbuffer:range(absolutePosition+4+rtpTcpOffset,2)):upper()
dataTree:add(F_stunname, tvbuffer(absolutePosition+4+rtpTcpOffset,2), attribute_bytes)
:set_text("STUN Message: " .. "Command String: " .. stuncmd_str .. " (0x" .. attribute_bytes .. ")")
attribute_length_int = tvbuffer(absolutePosition+6+rtpTcpOffset,2):uint()
attribute_length = string.format("%i", tvbuffer(absolutePosition+6+rtpTcpOffset,2):uint())
dataTree:add(F_stunname, tvbuffer(absolutePosition+6+rtpTcpOffset,2), attribute_length)
:set_text("Attribute Length: " .. attribute_length .. " Bytes")
field1_val = tostring(tvbuffer:range(absolutePosition+8+rtpTcpOffset,4)):upper()
dataTree:add(F_stunname, tvbuffer(absolutePosition+8+rtpTcpOffset,4), cmd_str)
:set_text("Magic Cookie: " .. "0x" .. field1_val)
field1_val = tostring(tvbuffer:range(absolutePosition+12+rtpTcpOffset,12)):upper()
dataTree:add(F_stunname, tvbuffer(absolutePosition+12+rtpTcpOffset,12), cmd_str)
:set_text("Transaction ID: 0x" .. field1_val)
--Set the Protcol and Info Columns
pinfo.cols.info = cmd_str .. " : Encapsulated Data = " .. stuncmd_str
--Limited decoding of the rest of the encapsulated STUN request...
offset2 = absolutePosition + 24 + rtpTcpOffset
relativePosition2 = 0
-- Start reading Attributes - look for microsoft extensions
-- Attribute Loop
while true do
-- position in packet
local absolutePosition2 = offset2 + relativePosition2
-- Get the attribute
local attribute2 = tvbuffer(absolutePosition2,2):uint()
-- Check if it's a microsoft attribute
local ms_attribute2 = tvbuffer(absolutePosition2,1):uint()
-- Get the Length of the attribute
local lengthOfCommand2 = tvbuffer(absolutePosition2+2,2):uint()
-- Calculate the final position
local finalPosition2 = absolutePosition2 + lengthOfCommand2 + 4
--Non Microsoft Specific Attributes
-- Defined in IETFDRAFT-STUN-02
if attribute2 == 0x0001 then
att_str2 = "Mapped Address"
elseif attribute2 == 0x0006 then
att_str2 = "Username"
elseif attribute2 == 0x0008 then
att_str2 = "Message Integrity"
elseif attribute2 == 0x0009 then
att_str2 = "Error Code"
elseif attribute2 == 0x000A then
att_str2 = "Unknown Attributes"
elseif attribute2 == 0x000D then
att_str2 = "Lifetime"
elseif attribute2 == 0x000E then
att_str2 = "Alternate Server"
elseif attribute2 == 0x000F then
att_str2 = "Magic Cookie"
elseif attribute2 == 0x0010 then
att_str2 = "Bandwidth"
elseif attribute2 == 0x0011 then
att_str2 = "Destination Address"
elseif attribute2 == 0x0012 then
att_str2 = "Remote Address"
elseif attribute2 == 0x0013 then
att_str2 = "Data"
elseif attribute2 == 0x0014 then
att_str2 = "Nonce"
elseif attribute2 == 0x0015 then
att_str2 = "Realm"
elseif attribute2 == 0x0017 then
att_str2 = "Requested Address Family"
elseif attribute2 == 0x0020 then
att_str2 = "XOR Mapped Address"
elseif attribute2 == 0x0024 then
att_str2 = "Priority (RFC5245)"
elseif attribute2 == 0x0025 then
att_str2 = "Use-Candidate (RFC5245)"
-- Microsoft Specific Attributes for STUN
elseif attribute2 == 0x8008 then
att_str2 = "MS-Version"
elseif attribute2 == 0x8006 then
att_str2 = "MS-Attribute"
elseif attribute2 == 0x8020 then
att_str2 = "XOR Mapped Address"
elseif attribute2 == 0x8022 then
att_str2 = "Software (RFC5389)"
elseif attribute2 == 0x8023 then
att_str2 = "Alternate-Server (RFC5389)"
elseif attribute2 == 0x8028 then
att_str2 = "Fingerprint (RFC5389)"
elseif attribute2 == 0x8029 then
att_str2 = "Ice Controlled (ICE-19)"
elseif attribute2 == 0x802A then
att_str2 = "Ice Controlling (ICE-19)"
elseif attribute2 == 0x8050 then
att_str2 = "MS-Sequence Number"
elseif attribute2 == 0x8054 then
att_str2 = "Candidate Identifier"
elseif attribute2 == 0x8055 then
att_str2 = "MS-Service Quality"
elseif attribute2 == 0x8056 then
att_str2 = "Bandwidth Admission Control Message"
elseif attribute2 == 0x8057 then
att_str2 = "Bandwidth Reservation Identifier"
elseif attribute2 == 0x8058 then
att_str2 = "Bandwidth Reservation Amount"
elseif attribute2 == 0x8059 then
att_str = "Remote Site Address"
elseif attribute2 == 0x805A then
att_str2 = "Remote Relay Site Address"
elseif attribute2 == 0x805B then
att_str2 = "Local Site Address"
elseif attribute2 == 0x805C then
att_str2 = "Local Relay Site Address"
elseif attribute2 == 0x805D then
att_str2 = "Remote Site Address Response"
elseif attribute2 == 0x805E then
att_str2 = "Remote Relay Site Address Response"
elseif attribute2 == 0x805F then
att_str2 = "Local Site Address Response"
elseif attribute2 == 0x8060 then
att_str2 = "Local Relay Site Address Response"
elseif attribute2 == 0x8061 then
att_str2 = "SIP Dialog Identifier"
elseif attribute2 == 0x8062 then
att_str2 = "SIP Call Identifier"
elseif attribute2 == 0x8068 then
att_str2 = "Location Profile"
elseif attribute2 == 0x8070 then
att_str2 = "Implementation Version"
elseif attribute2 == 0x8090 then
att_str2 = "MS-Alternate Mapped Address"
else
att_str2 = "Error: No Match (Possible incorrect packet classification)"
end
attribute_val2 = tostring(bit.tohex(tvbuffer(absolutePosition2,2):uint(),4)):upper()
attributeTree2 = dataTree:add(F_attribute, tvbuffer(absolutePosition2,lengthOfCommand2+4), attribute_val2)
attributeTree2:set_text("Data Attribute: 0x" .. attribute_val2 .. " (" .. att_str2 .. ")")
attribute_length2Int = tvbuffer(absolutePosition2+2,2):uint()
attribute_length2 = string.format("%i", tvbuffer(absolutePosition2+2,2):uint())
attributeTree2:add(F_attribute_sub, tvbuffer(absolutePosition2+2,2), attribute_length2)
:set_text("Data Attribute Length: " .. attribute_length2 .. " Bytes")
attributeTree2:add(F_attribute_sub, tvbuffer(absolutePosition2+4, attribute_length2Int) , cmd_str)
:set_text("Data: 0x" .. tostring( tvbuffer(absolutePosition2+4,attribute_length2Int)))
-- If the length of the attribute is 00 then assume there is an error and break loop
if lengthOfCommand2 == 0x0000 then
attributeTree2:add(F_attribute_sub, tvbuffer(absolutePosition2+2,2), attribute_length2)
:set_text("Error with data length value")
break
end
-- If the length of the attribute is longer than the packet length then assume there is an error and break loop
if lengthOfCommand2 > attribute_length2Int then
attributeTree2:add(F_attribute_sub, tvbuffer(absolutePosition2+2,2), attribute_length2)
:set_text("Error with data length value")
break
end
-- attribute_length_int
if finalPosition2 >= (attribute_length_int + absolutePosition + 24 + rtpTcpOffset) then
break
end
relativePosition2 = finalPosition2 - offset2
end
end
-- RTP CHECK
-- Check Data payload starts with 80 or 81 or 82 and assume RTP. This method whilst not ideal works in majority of cases with Lync.
if datatype == 128 or datatype == 129 or datatype == 130 then
attribute_bytes = tostring(tvbuffer:range(absolutePosition+5+rtpTcpOffset,1)):upper()
dataTree:add(F_stunname, tvbuffer(absolutePosition+5+rtpTcpOffset,1), attribute_bytes)
:set_text("RTP Message: " .. "(0x" .. attribute_bytes .. ")")
local bits = tvbuffer(absolutePosition+4+rtpTcpOffset,1):uint()
payload = bit.rshift(bit.band(bits,0xC0),6)
att_str = "RTP PAYLOAD TYPE"