-
Notifications
You must be signed in to change notification settings - Fork 733
Improve SIP packet detection using heuristic parsing #2024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+278
−9
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
f8b2d4d
add initial heuristic detection for SIP packets
sorooshm78 07ca6b7
add comment
sorooshm78 f4fba28
refactor move helper methods to private, keep public API minimal
sorooshm78 d18abd0
use function dissectSipHeuristic
sorooshm78 6c6acda
Remove unused #include <iostream>
sorooshm78 2f2cc66
move the implementation to SipLayer.cpp
sorooshm78 09cb3f9
Merge branch 'dev' into add-sip-heuristic
sorooshm78 8362e31
Merge branch 'dev' into add-sip-heuristic
sorooshm78 dfc161c
refactor: use SipRequestFirstLine and SipResponseFirstLine static par…
sorooshm78 9f5c52d
Remove unused helper functions
sorooshm78 29063ca
Merge branch 'dev' into add-sip-heuristic
sorooshm78 fdae169
Revert add-sip-heuristic to match dev
sorooshm78 86eca5f
Add heuristic SIP message type detection in dissectSipHeuristic
sorooshm78 0e57e98
Merge branch 'dev' into add-sip-heuristic
sorooshm78 718582b
Resolve conflict
sorooshm78 c36d86b
add parameter and return descriptions to SIP parsing functions
sorooshm78 605d700
fix(spelling): correct "heristic" → "heuristic"
sorooshm78 4e1ef25
remove unnecessary blank line in SipLayer heuristic check
sorooshm78 7b1f3e5
Change data parameter to const uint8_t* in dissectSipHeuristic
sorooshm78 e8c6e61
style: trim trailing whitespace (fix CI)
sorooshm78 140eab5
Fix doxygen fails for CI
sorooshm78 56aaa9a
style: apply clang-format for CI
sorooshm78 8ac29ed
refactor SIP layer detection logic
sorooshm78 82c4f1c
Fix SIP version parsing bug and correctly extract version from reques…
sorooshm78 e72a1bf
Rename lineEnd to firstLineEnd
sorooshm78 508c436
Oops, fix mistake
sorooshm78 3c04854
replace c-style cast with reinterpret_cast for pointer conversion
sorooshm78 24f30ac
refactor
sorooshm78 b865994
style: apply clang-format for CI
sorooshm78 57409ae
Add SipContentBasedDetectionTest for SIP detection by content on non-…
sorooshm78 b34c27b
Add sip_non_default_port.pcap
sorooshm78 44997b9
Unify SIP first line parsing into single method
sorooshm78 1b24343
Return std::pair from parseFirstLine to separate validation from data
sorooshm78 3d926f6
Use std::move to optimize string assignment
sorooshm78 60da646
fix typo
sorooshm78 36962be
Refactor code
sorooshm78 3dc1140
Fixed mistake
sorooshm78 53e1198
refactor code
sorooshm78 65221a8
refactor code
sorooshm78 e5e6ac9
remove SipMethodShortMap
sorooshm78 c3a7b6d
refactor code
sorooshm78 0bfd050
Merge branch 'dev' into add-sip-heuristic
Dimi1010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 5056c2a5e282ac49c3b41e570800450003e60000400040118c1fc0a81444c0a81553d03dcc9c03d20000494e56495445207369703a31303036403139322e3136382e32312e38333a3532333830205349502f322e300d0a5669613a205349502f322e302f554450203139322e3136382e32302e36383a35333330393b72706f72743b6272616e63683d7a39684734624b506a39336161623839353831623034623239383762353561353332303331643731320d0a4d61782d466f7277617264733a2037300d0a46726f6d3a203c7369703a31303035403139322e3136382e32312e38333e3b7461673d61353062666662356464643334323665386638343865636537643064333839620d0a546f3a203c7369703a31303036403139322e3136382e32312e38333e0d0a436f6e746163743a203c7369703a31303035403139322e3136382e32302e36383a35333330393b6f623e0d0a43616c6c2d49443a2030633362616232636562653334656339393761383064616134333436623339330d0a435365713a20313230303320494e564954450d0a416c6c6f773a20505241434b2c20494e564954452c2041434b2c204259452c2043414e43454c2c205550444154452c20494e464f2c205355425343524942452c204e4f544946592c2052454645522c204d4553534147452c204f5054494f4e530d0a537570706f727465643a207265706c616365732c2031303072656c2c2074696d65722c206e6f72656665727375620d0a53657373696f6e2d457870697265733a20313830300d0a4d696e2d53453a2039300d0a557365722d4167656e743a204d6963726f5349502f332e32322e330d0a436f6e74656e742d547970653a206170706c69636174696f6e2f7364700d0a436f6e74656e742d4c656e6774683a2020203334320d0a0d0a763d300d0a6f3d2d2033393735343231383631203339373534323138363120494e20495034203139322e3136382e32302e36380d0a733d706a6d656469610d0a623d41533a38340d0a743d3020300d0a613d582d6e61743a300d0a6d3d617564696f2034303034205254502f41565020382030203130310d0a633d494e20495034203139322e3136382e32302e36380d0a623d544941533a36343030300d0a613d727463703a3430303520494e20495034203139322e3136382e32302e36380d0a613d73656e64726563760d0a613d7274706d61703a382050434d412f383030300d0a613d7274706d61703a302050434d552f383030300d0a613d7274706d61703a3130312074656c6570686f6e652d6576656e742f383030300d0a613d666d74703a31303120302d31360d0a613d737372633a31333038393936333420636e616d653a343938653434356430336530346262360d0a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 5056c2a5e282ac49c3b41e570800450003960000400040118c6fc0a81444c0a81553e0f2cc9c038200005349502f322e3020323030204f4b0d0a5669613a205349502f322e302f554450203139322e3136382e32312e38333a35323338303b72706f72743d35323338303b72656365697665643d3139322e3136382e32312e38333b6272616e63683d7a39684734624b396a6a676536483430356335610d0a43616c6c2d49443a2030633166623163352d353966352d313233662d316162302d3030353035366135383034390d0a46726f6d3a2022457874656e73696f6e203130303522203c7369703a31303035403139322e3136382e32312e38333e3b7461673d3963745174324e355a6d3546440d0a546f3a203c7369703a31303036403139322e3136382e32302e36383b6f623e3b7461673d35323065343635313963653934333532626566323630366161616436333333630d0a435365713a2031303836353634333820494e564954450d0a416c6c6f773a20505241434b2c20494e564954452c2041434b2c204259452c2043414e43454c2c205550444154452c20494e464f2c205355425343524942452c204e4f544946592c2052454645522c204d4553534147452c204f5054494f4e530d0a436f6e746163743a203c7369703a31303036403139322e3136382e32302e36383a35373538363b6f623e0d0a537570706f727465643a207265706c616365732c2031303072656c2c2074696d65722c206e6f72656665727375620d0a436f6e74656e742d547970653a206170706c69636174696f6e2f7364700d0a436f6e74656e742d4c656e6774683a2020203331390d0a0d0a763d300d0a6f3d2d2033393735343231383631203339373534323138363220494e20495034203139322e3136382e32302e36380d0a733d706a6d656469610d0a623d41533a38340d0a743d3020300d0a613d582d6e61743a300d0a6d3d617564696f2034303036205254502f4156502038203130310d0a633d494e20495034203139322e3136382e32302e36380d0a623d544941533a36343030300d0a613d727463703a3430303720494e20495034203139322e3136382e32302e36380d0a613d73656e64726563760d0a613d7274706d61703a382050434d412f383030300d0a613d7274706d61703a3130312074656c6570686f6e652d6576656e742f383030300d0a613d666d74703a31303120302d31360d0a613d737372633a3134393431323030333120636e616d653a313739363565373334373065373364390d0a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,6 +166,39 @@ PTF_TEST_CASE(SipRequestLayerParsingTest) | |
|
|
||
| } // SipRequestLayerParsingTest | ||
|
|
||
| PTF_TEST_CASE(SipDetectionByContentOnNonStandardPort) | ||
sorooshm78 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| timeval time; | ||
| gettimeofday(&time, nullptr); | ||
|
|
||
| // Load SIP Request packet with non-standard ports: UDP src=53309, dst=52380 | ||
| auto rawPacket1 = createPacketFromHexResource("PacketExamples/sip_non_default_port1.dat"); | ||
| pcpp::Packet sipReqNonStandardPort(rawPacket1.get()); | ||
|
|
||
| PTF_ASSERT_TRUE(sipReqNonStandardPort.isPacketOfType(pcpp::SIPRequest)); | ||
|
|
||
| auto sipReqLayer = sipReqNonStandardPort.getLayerOfType<pcpp::SipRequestLayer>(); | ||
| PTF_ASSERT_NOT_NULL(sipReqLayer); | ||
|
|
||
| PTF_ASSERT_EQUAL(sipReqLayer->getFirstLine()->getMethod(), pcpp::SipRequestLayer::SipINVITE, enum); | ||
| PTF_ASSERT_EQUAL(sipReqLayer->getFirstLine()->getUri(), "sip:[email protected]:52380"); | ||
| PTF_ASSERT_EQUAL(sipReqLayer->getFirstLine()->getVersion(), "SIP/2.0"); | ||
|
|
||
| // Load SIP Response packet with non-standard ports: UDP src=53309, dst=52380 | ||
| auto rawPacket2 = createPacketFromHexResource("PacketExamples/sip_non_default_port2.dat"); | ||
| pcpp::Packet sipResNonStandardPort(rawPacket2.get()); | ||
|
|
||
| PTF_ASSERT_TRUE(sipResNonStandardPort.isPacketOfType(pcpp::SIPResponse)); | ||
|
|
||
| auto sipRespLayer = sipResNonStandardPort.getLayerOfType<pcpp::SipResponseLayer>(); | ||
| PTF_ASSERT_NOT_NULL(sipRespLayer); | ||
|
|
||
| PTF_ASSERT_EQUAL(sipRespLayer->getFirstLine()->getStatusCode(), pcpp::SipResponseLayer::Sip200OK, enum); | ||
| PTF_ASSERT_EQUAL(sipRespLayer->getFirstLine()->getStatusCodeAsInt(), 200); | ||
| PTF_ASSERT_EQUAL(sipRespLayer->getFirstLine()->getStatusCodeString(), "OK"); | ||
| PTF_ASSERT_EQUAL(sipRespLayer->getFirstLine()->getVersion(), "SIP/2.0"); | ||
| } // SipDetectionByContentOnNonStandardPort | ||
|
|
||
| PTF_TEST_CASE(SipRequestLayerCreationTest) | ||
| { | ||
| auto rawPacketAndBuf1 = createPacketAndBufferFromHexResource("PacketExamples/sip_req1.dat"); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.