Home
%3CLINGO-SUB%20id%3D%22lingo-sub-779586%22%20slang%3D%22en-US%22%3EDetect%20Network%20beaconing%20via%20Intra-Request%20time%20delta%20patterns%20in%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779586%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId-1794464732%22%20id%3D%22toc-hId-1794464732%22%20id%3D%22toc-hId-1794464732%22%20id%3D%22toc-hId-1794464732%22%20id%3D%22toc-hId-1794464732%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EIntroduction%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3ENetwork%20beaconing%20is%20generally%20described%20as%20network%20traffic%20originating%20from%20victim%60s%20network%20towards%20adversary%20controlled%20infrastructure%20that%20occurs%20at%20regular%20intervals%20which%20could%20be%20an%20indication%20of%20malware%20infection%20or%20compromised%20host%20doing%20data%20exfiltration.%20%26nbsp%3BThis%20article%20will%20discuss%20the%20use%20case%20of%20detecting%20network%20beaconing%20via%20intra-request%20time%20delta%20patterns%20using%20KQL%20(Kusto%20query%20language)%20in%20Azure%20Sentinel.%20%26nbsp%3BThe%20logic%20or%20technique%20of%20the%20use-case%20was%20originally%20discussed%20at%20threat%20hunting%20project%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FThreatHuntingProject%2FThreatHunting%2Fblob%2Fmaster%2Fhunts%2Fbeacon_detection_via_intra_request_time_deltas.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3Eand%20also%20blogged%20with%20the%20open%20source%20network%20analytics%20tool%20(flare)%20implementation%20by%20huntoperator%20%3CA%20href%3D%22http%3A%2F%2Fwww.austintaylor.io%2Fdetect%2Fbeaconing%2Fintrusion%2Fdetection%2Fsystem%2Fcommand%2Fcontrol%2Fflare%2Felastic%2Fstack%2F2017%2F06%2F10%2Fdetect-beaconing-with-flare-elasticsearch-and-intrusion-detection-systems%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20%26nbsp%3BImplementing%20this%20technique%20natively%20using%20KQL%20allows%20defenders%20to%20quickly%20apply%20it%20over%20multiple%20network%20data%20sources%20and%20easily%20set%20up%20alerts%20within%20Azure%20Sentinel.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--757692229%22%20id%3D%22toc-hId--757692229%22%20id%3D%22toc-hId--757692229%22%20id%3D%22toc-hId--757692229%22%20id%3D%22toc-hId--757692229%22%3E%3CSTRONG%3EUse%20case%20workflow%3A%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EThe%20diagram%20below%20outlines%20the%20various%20stages%20in%20compiling%20this%20detection%20and%20associated%20KQL%20operators%20underneath%20each%20stage.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124963i09F774D34D7799C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22workflow.png%22%20title%3D%22workflow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20is%20sample%20screenshot%20of%20data%20transformation%20from%20Original%20Unsampled%20or%20non-aggregated%20network%20connection%20logs%20to%20Alert%20Results%20post%20executing%20the%20detection%20query%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124964i60D41E1C8EE0F17D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Events-to-Alerts.png%22%20title%3D%22Events-to-Alerts.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EQuery%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3EGithub%20Link%3A%20%3CA%20title%3D%22PaloAlto%20Network%20Beaconing%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FCommonSecurityLog%2FPaloAlto-NetworkBeaconing.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPaloAlto%20Network%20Beaconing%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Elet%20starttime%20%3D%202d%3B%0Alet%20endtime%20%3D%201d%3B%0Alet%20%20TimeDeltaThreshold%20%3D%2010%3B%0Alet%20TotalEventsThreshold%20%3D%2015%3B%0Alet%20PercentBeaconThreshold%20%3D%2080%3B%0Alet%20PrivateIPregex%20%3D%20%40%22%5E127%5C.%7C%5E10%5C.%7C%5E172%5C.1%5B6-9%5D%5C.%7C%5E172%5C.2%5B0-9%5D%5C.%7C%5E172%5C.3%5B0-1%5D%5C.%7C%5E192%5C.168%5C.%22%3B%0ACommonSecurityLog%0A%7C%20where%20DeviceVendor%20%3D%3D%22Palo%20Alto%20Networks%22%20and%20Activity%20%20%3D%3D%20%22TRAFFIC%22%3B%0A%7C%20where%20TimeGenerated%20between%20(ago(starttime)..ago(endtime))%0A%7C%20extend%20DestinationIPType%20%3D%20iff(DestinationIP%20matches%20regex%20PrivateIPregex%2C%22private%22%20%2C%22public%22%20)%0A%7C%20where%20DestinationIPType%20%3D%3D%22public%22%3B%0A%7C%20project%20TimeGenerated%20%2C%20SourceIP%20%2C%20SourcePort%20%2C%20DestinationIP%2C%20DestinationPort%2C%20ReceivedBytes%2C%20SentBytes%0A%7C%20sort%20by%20SourceIP%20asc%2CTimeGenerated%20asc%2C%20DestinationIP%20asc%2C%20DestinationPort%20asc%0A%7C%20serialize%0A%7C%20extend%20nextTimeGenerated%20%3D%20next(TimeGenerated%2C%201)%2C%20nextSourceIP%20%3D%20next(SourceIP%2C%201)%0A%7C%20extend%20TimeDeltainSeconds%20%3D%20datetime_diff(%22second%22%2CnextTimeGenerated%2CTimeGenerated)%0A%7C%20where%20SourceIP%20%3D%3D%20nextSourceIP%0A%2F%2FWhitelisting%20criteria%2F%20threshold%20criteria%0A%7C%20where%20TimeDeltainSeconds%20%26gt%3B%20TimeDeltaThreshold%20%0A%7C%20project%20TimeGenerated%2C%20TimeDeltainSeconds%2C%20SourceIP%2C%20SourcePort%2CDestinationIP%2CDestinationPort%2C%20ReceivedBytes%2C%20SentBytes%0A%7C%20summarize%20count()%2C%20sum(ReceivedBytes)%2C%20sum(SentBytes)%2C%20make_list(TimeDeltainSeconds)%20by%20TimeDeltainSeconds%2C%20bin(TimeGenerated%2C%201h)%2C%20SourceIP%2C%20DestinationIP%2C%20DestinationPort%0A%7C%20summarize%20(MostFrequentTimeDeltaCount%2C%20MostFrequentTimeDeltainSeconds)%3Darg_max(count_%2C%20TimeDeltainSeconds)%2C%20TotalEvents%3Dsum(count_)%2C%20TotalSentBytes%3Dsum(sum_SentBytes)%2CTotalReceivedBytes%3Dsum(sum_ReceivedBytes)%20by%20bin(TimeGenerated%2C%201h)%2C%20SourceIP%2C%20DestinationIP%2C%20DestinationPort%0A%7C%20where%20TotalEvents%20%26gt%3BTotalEventsThreshold%20%0A%7C%20extend%20BeaconPercent%20%3D%20MostFrequentTimeDeltaCount%2Ftoreal(TotalEvents)%20*%20100%0A%7C%20where%20BeaconPercent%20%26gt%3B%20PercentBeaconThreshold%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-985118106%22%20id%3D%22toc-hId-985118106%22%20id%3D%22toc-hId-985118106%22%20id%3D%22toc-hId-985118106%22%20id%3D%22toc-hId-985118106%22%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CU%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EStep%201%3A%20Load%20Raw%20logs-%20unsampled%20network%20connections%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20this%20stage%2C%20we%20will%20select%20the%20data%20source%20which%20will%20have%20unsampled%20or%20non-aggregated%20raw%20logs.%20The%20data%20source%20can%20be%20network%20firewall%2C%20proxy%20logs%20etc.%20Below%20section%20of%26nbsp%3B%20the%20query%20refers%20to%20selecting%20the%20data%20source%20(in%20this%20example-%20Palo%20Alto%20Firewall)%20and%20loading%20the%20relevant%20data.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ECommonSecurityLog%0A%7C%20where%20DeviceVendor%20%3D%3D%22Palo%20Alto%20Networks%22%20and%20Activity%20%20%3D%3D%20%22TRAFFIC%22%0A%7C%20where%20TimeGenerated%20between%20(ago(starttime)..ago(endtime))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1567038855%22%20id%3D%22toc-hId--1567038855%22%20id%3D%22toc-hId--1567038855%22%20id%3D%22toc-hId--1567038855%22%20id%3D%22toc-hId--1567038855%22%3E%3CU%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CSTRONG%3EStep%202%3A%20Filter%20%E2%80%93%20Internal%20to%20External%20Traffic%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FH2%3E%0A%3CP%3EThis%20step%20involves%20filtering%20the%20raw%20logs%20loaded%20in%20the%20first%20stage%20to%20only%20focus%20on%20traffic%20directing%20from%20internal%20networks%20to%20external%20Public%20networks.%20This%20is%20achieved%20by%20populating%20IP%20Type%20as%20Private%20and%20Public%20based%20on%20PrivateIP%20regex.%20You%20can%20use%20any%20other%20data%20sources%20such%20as%20joining%20against%20internal%20asset%20inventory%20data%20source%20with%20matches%20as%20Internal%20and%20rest%20as%20external.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%7C%20extend%20DestinationIPType%20%3D%20iff(DestinationIP%20matches%20regex%20PrivateIPregex%2C%22private%22%2C%22public%22%20)%0A%7C%20where%20DestinationIPType%20%3D%3D%22public%22%0A%7C%20project%20TimeGenerated%20%2C%20SourceIP%20%2C%20SourcePort%20%2C%20DestinationIP%2C%20DestinationPort%2C%20ReceivedBytes%2C%20SentBytes%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-175771480%22%20id%3D%22toc-hId-175771480%22%20id%3D%22toc-hId-175771480%22%20id%3D%22toc-hId-175771480%22%20id%3D%22toc-hId-175771480%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CU%3E%3CSTRONG%3EStep%203%3A%20Data%20Serialization%20%E2%80%93%20sort%2C%20reorder%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EThis%20step%20is%20used%20to%20reorder%20the%20logs%20using%20%3CCODE%3Eserialize%20%3C%2FCODE%3E%20operator.%20It%20is%20required%20to%20reorder%20the%20data%20in%20correct%20order%20as%20we%20will%20calculate%20time%20delta%20from%20sequential%20events%20for%20the%20same%20source%20addresses.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%7C%20sort%20by%20SourceIP%20asc%2CTimeGenerated%20asc%2C%20DestinationIP%20asc%2C%20DestinationPort%20asc%0A%7C%20serialize%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1918581815%22%20id%3D%22toc-hId-1918581815%22%20id%3D%22toc-hId-1918581815%22%20id%3D%22toc-hId-1918581815%22%20id%3D%22toc-hId-1918581815%22%3E%3CFONT%20size%3D%224%22%3E%3CU%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3EStep%204%3A%20Time%20Delta%20Calculation%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EThis%20step%20is%20used%20to%20calculate%20time%20delta%20using%20%3CCODE%3E%3CEM%3Eprev()%3C%2FEM%3E%3C%2FCODE%3E%20and%20%3CCODE%3E%3CEM%3Enext()%3C%2FEM%3E%3C%2FCODE%3E%20functions.%20In%20order%20to%20use%20these%20functions%2C%20the%20data%20should%20be%20in%20correct%20order%20achieved%20from%20Step-3.%20The%20timestamp%20of%20the%20next%20event%20is%20accessed%20using%20next%20function%20and%20later%20%3CCODE%3E%3CEM%3Edatetime_diff()%3C%2FEM%3E%3C%2FCODE%3E%20is%20used%20to%20calculate%20time%20difference%20between%20two%20timestamps.%20It%20is%20made%20sure%20that%20source%20IP%20address%20of%20the%20next%20event%20is%20same.%20The%20unit%20used%20is%20in%20seconds.%20Final%20output%20is%20projected%20with%20selected%20columns%20along%20with%20data%20transfer%20in%20bytes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%7C%20extend%20nextTimeGenerated%20%3D%20next(TimeGenerated%2C%201)%2C%20nextSourceIP%20%3D%20next(SourceIP%2C%201)%0A%7C%20extend%20TimeDeltainSeconds%20%3D%20datetime_diff(%E2%80%98second%E2%80%99%2CnextTimeGenerated%2CTimeGenerated)%0A%7C%20where%20SourceIP%20%3D%3D%20nextSourceIP%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--633575146%22%20id%3D%22toc-hId--633575146%22%20id%3D%22toc-hId--633575146%22%20id%3D%22toc-hId--633575146%22%20id%3D%22toc-hId--633575146%22%3E%3CFONT%20size%3D%224%22%3E%3CU%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3EStep%205%3A%20Data%20Reshaping-%20aggregation%20using%20window%20functions%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20this%20step%2C%20data%20resulted%20from%20step%204%20is%20further%20aggregated%20to%20downsample%20the%20data%20per%20hour%20time%20window%20without%20losing%20the%20context.%20First%2C%20In%20addition%20to%20using%20%3CCODE%3Esum()%20%3C%2FCODE%3E%20and%20%3CCODE%3Ecount()%3C%2FCODE%3E%20functions%20to%20aggregate%2C%20%3CCODE%3Emake_list()%20%3C%2FCODE%3E%20is%20used%20to%20make%20array%20of%20Time%20Delta%20values%20which%20are%20grouped%20by%20sourceip%2C%20destinationip%20and%20destinationports.%20Later%2C%20This%20array%20of%20values%20is%20transformed%20into%20count%20of%20each%20values%20to%20find%20most%20frequent%20or%20repetitive%20timedelta%20value%20using%20%3CCODE%3Earg_max()%3C%2FCODE%3E%20function.%20%26nbsp%3BAt%20the%20end%2C%20BeaconPercent%20is%20calculated%20using%20simple%20formula%20%3A%20count%20of%20most%20frequent%20time%20delta%20divided%20by%20total%20events.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%7C%20project%20TimeGenerated%2C%20TimeDeltainSeconds%2C%20SourceIP%2C%20SourcePort%2CDestinationIP%2CDestinationPort%2C%20ReceivedBytes%2C%20SentBytes%0A%7C%20summarize%20count()%2C%20sum(ReceivedBytes)%2C%20sum(SentBytes)%2C%20make_list(TimeDeltainSeconds)%20by%20TimeDeltainSeconds%2C%20bin(TimeGenerated%2C%201h)%2C%20SourceIP%2C%20DestinationIP%2C%20DestinationPort%0A%7C%20summarize%20(MostFrequentTimeDeltaCount%2C%20MostFrequentTimeDeltainSeconds)%3Darg_max(count_%2C%20TimeDeltainSeconds)%2C%20TotalEvents%3Dsum(count_)%2C%20TotalSentBytes%3Dsum(sum_SentBytes)%2CTotalReceivedBytes%3Dsum(sum_ReceivedBytes)%20by%20bin(TimeGenerated%2C%201h)%2C%20SourceIP%2C%20DestinationIP%2C%20DestinationPort%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1109235189%22%20id%3D%22toc-hId-1109235189%22%20id%3D%22toc-hId-1109235189%22%20id%3D%22toc-hId-1109235189%22%20id%3D%22toc-hId-1109235189%22%3E%3CU%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CSTRONG%3EStep%206%3A%20Filter%20%E2%80%93%20Global%20Threshold%20Parameters%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FH2%3E%0A%3CP%3EAt%20various%20stages%20of%20the%20query%2C%20filtering%20is%20used%20to%20reduce%20the%20input%20data%20set%20in%20scope.%20At%20the%20top%20of%20the%20query%2C%20we%20have%20several%20global%20arguments%20declared%20which%20can%20be%20tweaked%20for%20alerting.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ETimeDeltathreshold%3A%20%3C%2FSTRONG%3EThe%20value%20refers%20to%20the%20timedelta%20in%20seconds%20between%202%20connections.%20With%20this%20parameters%20%2C%20noisy%20events%20with%20very%20low%20threshold%20value%20(such%20as%201%20seconds%20to%2010%20seconds)%20will%20be%20filtered%20and%20not%20considered%20for%20alerting.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ETotalEventsThreshold%3A%20%3C%2FSTRONG%3EThe%20value%20refers%20to%20the%20total%20count%20of%20events%20seen%20between%20the%20same%20source%20and%20destination%20aggregated%20per%20destination%20port%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3EPercentBeaconThreshold%3A%20%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EThe%20value%20refers%20to%20the%20percentage%20of%20beacon%20values%20based%20on%20the%20formula%20of%20mostfrequenttimedelta%2Ftotalevents%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId--1442921772%22%20id%3D%22toc-hId--1442921772%22%20id%3D%22toc-hId--1442921772%22%20id%3D%22toc-hId--1442921772%22%20id%3D%22toc-hId--1442921772%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-299888563%22%20id%3D%22toc-hId-299888563%22%20id%3D%22toc-hId-299888563%22%20id%3D%22toc-hId-299888563%22%20id%3D%22toc-hId-299888563%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EInterpreting%20Results%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20this%20case%2C%20we%20will%20start%20hunting%20with%20unsampled%20or%20non-aggregated%20network%20connection%20logs%20from%20any%20network%20sensor%20logs.%20The%20logs%20should%20include%20at%20least%20sourceport%20and%20destinationPort%20along%20with%20source%20and%20destination%20address%20fields.%3C%2FP%3E%0A%3CP%3EBelow%20is%20an%20example%20output%20of%20Palo%20Alto%20traffic%20logs%20from%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124970iEDC07CE997D82465%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22BaseLogs.PNG%22%20title%3D%22BaseLogs.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3BAfter%20executing%20the%20query%20and%20based%20on%20the%20globally%20configured%20threshold%2C%20alerts%20will%20be%20triggered.%20Example%20alert%20results%20will%20look%20like%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20984px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125013i04A46650CBB34AF8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Alert_Results.PNG%22%20title%3D%22Alert_Results.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EApart%20from%20the%20known%20fields%20from%20the%20original%20logs%20such%20as%20TimeGenerated%2C%20SourceIP%2C%20DestinationIP%2C%20DestinationPort%2C%20TotalEvents%2CTotalSentBytes%2CTotalReceivedBytes%2C%20below%20additional%20enriched%20fields%20are%20populated%20by%20query.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3E%3CEM%3EMostFrequentTimeDeltainSenconds%20%3A%20%3C%2FEM%3E%3C%2FSTRONG%3ERepetitive%20Time%20interval%20between%20successive%20network%20connection%20in%20seconds.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CEM%3EMostFrequentTimeDeltaCount%3A%20%3C%2FEM%3E%3C%2FSTRONG%3ECount%20of%20the%20MostFrequentTimeDeltaInSeconds%20occurred%20within%20the%20timestamp.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CEM%3EBeaconPercent%3A%20%3C%2FEM%3E%3C%2FSTRONG%3EPercentage%20of%20beaconing%20calculated%20based%20on%20formula%20of%20MostFrequentTimeDeltaCount%2FTotalEvents*%20100%20.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20alert%20indicates%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E91%25%20beaconing%20traffic%20seen%20from%20the%20source%20address%20192.168.10.10%20towards%20destination%20address-%2067.217.69.224.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3ETotal%20243%20events%20observed%20in%20the%20hour%202019-05-25%2008%3A00%20to%2009%3A00.%3C%2FLI%3E%0A%3CLI%3EOut%20of%20those%2C%20222%20events%20seen%20with%2014%20seconds%20time%20intervals.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWhois%20query%20for%20the%20IP%20reveals%2C%20it%20is%20registered%20with%20LogmeIn.%20This%20could%20be%20benign%20behavior%20if%20you%20are%20using%20the%20application%20in%20your%20environments%2C%20else%20this%20could%20be%20indication%20of%20unauthorized%20installation%20on%20compromised%20host.%20Similar%20ways%2C%20you%20could%20detect%20other%20legitimate%20or%20unauthorized%20applications%20usage%20exhibiting%20beaconing%20behaviors.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124972i26E41B1AB5EA0AC9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22whois-logmein.png%22%20title%3D%22whois-logmein.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1366991833%22%20id%3D%22toc-hId--1366991833%22%20id%3D%22toc-hId--1366991833%22%20id%3D%22toc-hId--1366991833%22%20id%3D%22toc-hId--1366991833%22%3E%3CU%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CSTRONG%3EThings%20to%20remember%20before%20onboarding%20this%20detection%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FU%3E%3C%2FH2%3E%0A%3CP%3EThe%20way%20this%20detection%20is%20designed%2C%20there%20are%20some%20limitations%20or%20things%20to%20be%20considered%20before%20on-boarding%20this%20detection%20in%20your%20environment.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESince%20detection%20requires%20unsampled%20network%20connection%20logs%2C%20you%20should%20not%20on-board%20detection%20for%20environments%20which%20has%20multiple%20hosts%20behind%20a%20proxy%20and%20firewall%2Fnetwork%20sensor%20logs%20shows%20only%20proxy%20IP%20address%20as%20source%20or%20if%20you%20are%20doing%20aggregation%20at%20any%20stage%20of%20your%20data%20ingestion.%3C%2FLI%3E%0A%3CLI%3EThe%20detection%20is%20not%20filtered%20for%20any%20specific%20ports%20but%20consider%20approaches%20to%20reduce%20the%20input%20data%20scope%20by%20filtering%20traffic%20either%20to%20known%20destination%20addresses%20or%20destination%20ports%20if%20those.%20Time%20delta%20calculation%20is%20an%20expensive%20operation%20and%20reducing%20the%20input%20data%20set%20to%20correct%20scope%20will%20make%20it%20more%20efficient.%3C%2FLI%3E%0A%3CLI%3EYou%20will%20also%20see%20legitimate%20beaconing%20traffic%20to%20known%20device%20vendors%20such%20as%20traffic%20towards%20Microsoft%20related%20to%20windows%20update%2C%20traffic%20to%20device%20manufacture%20vendors%20or%20any%20other%20legitimate%20application%20or%20agent%20configured%20to%20initiate%20network%20connection%20at%20scheduled%20intervals.%20Based%20on%20historical%20analysis%20you%20can%20understand%20baseline%2C%20and%20use%20it%20to%20filter%20such%20IP%20ranges%20to%20reduce%20false%20positives.%3C%2FLI%3E%0A%3CLI%3ELastly%2C%20the%20detection%20is%20alerted%20based%20on%20the%20most%20repetitive%20time%20delta%20values%20but%20adversary%20can%20also%20add%20jitter%20or%20randomness%20so%20time%20intervals%20values%20between%20individual%20network%20connection%20will%20look%20different%20and%20will%20not%20match%20to%20PercentBeacon%20threshold%20values.%20You%20could%20still%20use%20your%20baseline%20analysis%20and%20other%20parameters%20of%20the%20dataset%20and%20derive%20additional%20hunting%20queries.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-375818502%22%20id%3D%22toc-hId-375818502%22%20id%3D%22toc-hId-375818502%22%20id%3D%22toc-hId-375818502%22%20id%3D%22toc-hId-375818502%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-2118628837%22%20id%3D%22toc-hId-2118628837%22%20id%3D%22toc-hId-2118628837%22%20id%3D%22toc-hId-2118628837%22%20id%3D%22toc-hId-2118628837%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EConclusion%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20this%20article%2C%20we%20looked%20into%20previously%20discussed%20technique%20of%20detecting%20beaconing%20using%20intra-time%20delta%20patterns%20and%20how%20it%20can%20be%20implemented%20using%20native%20KQL%20within%20Azure%20Sentinel.%20The%20logic%20of%20the%20detection%20involves%20various%20stages%20starting%20from%20loading%20raw%20logs%20to%20doing%20various%20data%20transformation%20and%20finally%20alerting%20the%20results%20based%20on%20globally%20configured%20threshold%20values.%3C%2FP%3E%0A%3CP%3EUnsampled%2F%20non-aggregated%20network%20connection%20logs%20are%20very%20voluminous%20in%20nature%20and%20finding%20actionable%20events%20are%20always%20challenging.%26nbsp%3B%20Even%20if%20you%20follow%20traditional%20approaches%20such%20as%20matching%20with%20IOCs%2C%20application%20or%20service%20profiling%2C%20various%20type%20of%20visualizations%20%2C%20due%20to%20the%20sheer%20scale%20of%20the%20data%20%2Cresults%20from%20such%20techniques%20are%20not%20often%20directly%20actionable%20for%20analysts%20and%20need%20further%20ways%20to%20hunt%20for%20malicious%20traffic.%20With%20this%20unique%20analysis%20technique%2C%20we%20can%20find%20beacon%20like%20traffic%20patterns%20from%20your%20internal%20networks%20towards%20untrusted%20public%20destinations%20and%20directly%20investigate%20the%20results.%20The%20output%20alert%20results%20also%20provide%20useful%20context%20on%20the%20type%20of%20network%20traffic%20seen%20with%20basic%20packet%20statistics%20and%20why%20it%20has%20categorized%20as%20beaconing%20with%20additional%20attributes%20such%20as%20amount%20of%20data%20transferred%20to%20assist%20analysts%20to%20do%20alert%20triage.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20example%20covered%20in%20the%20article%2C%20we%20were%20able%20to%20detect%20logmein%20traffic%20which%20was%20exhibiting%20beaconing%20behavior%20based%20on%20the%20repetitive%20time%20delta%20patterns%20in%20the%20given%20hour.%20We%20also%20talked%20about%20the%20scenarios%20where%20detection%20should%20not%20be%20onboarded%20depending%20on%20how%20environment%20is%20setup%20or%20data%20ingestion%20is%20set%20up.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESpecial%20thanks%20to%20Microsoft%20Kusto%20Discussions%20community%20who%20assisted%20with%20Data%20Reshaping%20stage%20of%20the%20query.%20You%20can%20also%20ask%20questions%20related%20to%20KQL%20at%20stackoverflow%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2Ftagged%2Fkusto%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHappy%20hunting.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--433528124%22%20id%3D%22toc-hId--433528124%22%20id%3D%22toc-hId--433528124%22%20id%3D%22toc-hId--433528124%22%20id%3D%22toc-hId--433528124%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1309282211%22%20id%3D%22toc-hId-1309282211%22%20id%3D%22toc-hId-1309282211%22%20id%3D%22toc-hId-1309282211%22%20id%3D%22toc-hId-1309282211%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EReferences%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3EThreatHunting%20Project-%20Github%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FThreatHuntingProject%2FThreatHunting%2Fblob%2Fmaster%2Fhunts%2Fbeacon_detection_via_intra_request_time_deltas.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FThreatHuntingProject%2FThreatHunting%2Fblob%2Fmaster%2Fhunts%2Fbeacon_detection_via_intra_request_time_deltas.md%3C%2FA%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EDetect%20Beaconing%20with%20Flare%2C%20Elastic%20Stack%2C%20and%20Intrusion%20Detection%20Systems%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CA%20href%3D%22http%3A%2F%2Fwww.austintaylor.io%2Fdetect%2Fbeaconing%2Fintrusion%2Fdetection%2Fsystem%2Fcommand%2Fcontrol%2Fflare%2Felastic%2Fstack%2F2017%2F06%2F10%2Fdetect-beaconing-with-flare-elasticsearch-and-intrusion-detection-systems%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.austintaylor.io%2Fdetect%2Fbeaconing%2Fintrusion%2Fdetection%2Fsystem%2Fcommand%2Fcontrol%2Fflare%2Felastic%2Fstack%2F2017%2F06%2F10%2Fdetect-beaconing-with-flare-elasticsearch-and-intrusion-detection-systems%2F%3C%2FA%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECommand%20and%20Control%20%3A%20MITRE%20Technique%20TA0011%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fattack.mitre.org%2Ftactics%2FTA0011%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fattack.mitre.org%2Ftactics%2FTA0011%2F%3C%2FA%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EKQL%20operators%20syntax%20and%20example%20usage%20documentation%3A%0A%3CUL%3E%0A%3CLI%3ESerialize%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fserializeoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fserializeoperator%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Eprev%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fprevfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fprevfunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Enext%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fnextfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fnextfunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Edatetime_diff%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fdatetime-difffunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fdatetime-difffunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Earg-max%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Farg-max-aggfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Farg-max-aggfunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Emake_list%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmakelist-aggfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmakelist-aggfunction%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-779586%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20will%20discuss%20the%20use%20case%20of%20detecting%20network%20beaconing%20via%20intra-request%20time%20delta%20patterns%20using%20KQL%20(Kusto%20query%20language)%20in%20Azure%20Sentinel.%20%26nbsp%3BThe%20logic%20or%20technique%20of%20the%20use-case%20was%20originally%20discussed%20at%20threat%20hunting%20project%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FThreatHuntingProject%2FThreatHunting%2Fblob%2Fmaster%2Fhunts%2Fbeacon_detection_via_intra_request_time_deltas.md%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehere%3C%2FA%3Eand%20also%20blogged%20with%20the%20open%20source%20network%20analytics%20tool%20(flare)%20implementation%20by%20huntoperator%20%3CA%20href%3D%22http%3A%2F%2Fwww.austintaylor.io%2Fdetect%2Fbeaconing%2Fintrusion%2Fdetection%2Fsystem%2Fcommand%2Fcontrol%2Fflare%2Felastic%2Fstack%2F2017%2F06%2F10%2Fdetect-beaconing-with-flare-elasticsearch-and-intrusion-detection-systems%2F%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehere%3C%2FA%3E.%20%26nbsp%3BImplementing%20this%20technique%20natively%20using%20KQL%20allows%20defenders%20to%20quickly%20apply%20it%20over%20multiple%20network%20data%20sources%20and%20easily%20set%20up%20alerts%20within%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124961iAC68536DA1CD6973%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22workflow.png%22%20title%3D%22workflow.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-779586%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Sentinel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDetection%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-833730%22%20slang%3D%22en-US%22%3ERe%3A%20Detect%20Network%20beaconing%20via%20Intra-Request%20time%20delta%20patterns%20in%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-833730%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20I%20can't%20think%20of%20a%20single%20reason%20why%20I'd%20beacon%20on%20a%20consistent%20time%20basis%2C%26nbsp%3B%20I%20can't%20imagine%20anything%20in%26nbsp%3B%20c2%20network%20is%20time%20sensitive%2C%20so%20just%20fire%20things%20randomly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-834625%22%20slang%3D%22en-US%22%3ERe%3A%20Detect%20Network%20beaconing%20via%20Intra-Request%20time%20delta%20patterns%20in%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-834625%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F44446%22%20target%3D%22_blank%22%3E%40Tony%20Roth%3C%2FA%3E%26nbsp%3Bfor%20reviewing%20detection%20and%20leaving%20the%20comment.%20Beaconing%20often%20happens%20at%20regular%20intervals%20although%20c2%20networks%2Fframeworks%20can%20change%20and%20add%20randomness%20to%20communication%20pattern%2C%20it%20is%20still%20good%20idea%20to%20monitor%20periodic%20communication%20from%20internal%20hosts%20to%20unknown%20public%20addresses.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20approaches%20were%20suggested%20to%20reduce%20false%20positives%20or%20filter%20the%20benign%20traffic%20such%20as%20tweaking%20timedelta%2F%20percent%20beacon%20threshold%2C%20profiling%20network%20and%20segregating%20known%20destination%20IP%20ranges%2Fregistrant%20org.%20If%20you%20have%20any%20generic%20tuning%20recommendation%2C%20we%20would%20gladly%20accept%20via%20Pull%20Request%20to%20the%20sentinel%20repo.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-836793%22%20slang%3D%22en-US%22%3ERe%3A%20Detect%20Network%20beaconing%20via%20Intra-Request%20time%20delta%20patterns%20in%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-836793%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%26nbsp%3B%20I%20get%20that%20monitoring%20this%20is%20valuable%20but%20I%20somewhat%20think%20that%20the%20malware%20authors%20are%20on%20to%20this%20now.%26nbsp%3B%20I%20know%20its%20a%20game%20of%20cat%20and%20mouse%20so%20every%20bit%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Introduction

Network beaconing is generally described as network traffic originating from victim`s network towards adversary controlled infrastructure that occurs at regular intervals which could be an indication of malware infection or compromised host doing data exfiltration.  This article will discuss the use case of detecting network beaconing via intra-request time delta patterns using KQL (Kusto query language) in Azure Sentinel.  The logic or technique of the use-case was originally discussed at threat hunting project here and also blogged with the open source network analytics tool (flare) implementation by huntoperator here.  Implementing this technique natively using KQL allows defenders to quickly apply it over multiple network data sources and easily set up alerts within Azure Sentinel. 

 

Use case workflow:

The diagram below outlines the various stages in compiling this detection and associated KQL operators underneath each stage.

workflow.png

 

 

Below is sample screenshot of data transformation from Original Unsampled or non-aggregated network connection logs to Alert Results post executing the detection query

Events-to-Alerts.png

 

Query:

Github Link: PaloAlto Network Beaconing

 

let starttime = 2d;
let endtime = 1d;
let  TimeDeltaThreshold = 10;
let TotalEventsThreshold = 15;
let PercentBeaconThreshold = 80;
let PrivateIPregex = @"^127\.|^10\.|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168\.";
CommonSecurityLog
| where DeviceVendor =="Palo Alto Networks" and Activity  == "TRAFFIC";
| where TimeGenerated between (ago(starttime)..ago(endtime))
| extend DestinationIPType = iff(DestinationIP matches regex PrivateIPregex,"private" ,"public" )
| where DestinationIPType =="public";
| project TimeGenerated , SourceIP , SourcePort , DestinationIP, DestinationPort, ReceivedBytes, SentBytes
| sort by SourceIP asc,TimeGenerated asc, DestinationIP asc, DestinationPort asc
| serialize
| extend nextTimeGenerated = next(TimeGenerated, 1), nextSourceIP = next(SourceIP, 1)
| extend TimeDeltainSeconds = datetime_diff("second",nextTimeGenerated,TimeGenerated)
| where SourceIP == nextSourceIP
//Whitelisting criteria/ threshold criteria
| where TimeDeltainSeconds > TimeDeltaThreshold 
| project TimeGenerated, TimeDeltainSeconds, SourceIP, SourcePort,DestinationIP,DestinationPort, ReceivedBytes, SentBytes
| summarize count(), sum(ReceivedBytes), sum(SentBytes), make_list(TimeDeltainSeconds) by TimeDeltainSeconds, bin(TimeGenerated, 1h), SourceIP, DestinationIP, DestinationPort
| summarize (MostFrequentTimeDeltaCount, MostFrequentTimeDeltainSeconds)=arg_max(count_, TimeDeltainSeconds), TotalEvents=sum(count_), TotalSentBytes=sum(sum_SentBytes),TotalReceivedBytes=sum(sum_ReceivedBytes) by bin(TimeGenerated, 1h), SourceIP, DestinationIP, DestinationPort
| where TotalEvents >TotalEventsThreshold 
| extend BeaconPercent = MostFrequentTimeDeltaCount/toreal(TotalEvents) * 100
| where BeaconPercent > PercentBeaconThreshold

 

 

Step 1: Load Raw logs- unsampled network connections

In this stage, we will select the data source which will have unsampled or non-aggregated raw logs. The data source can be network firewall, proxy logs etc. Below section of  the query refers to selecting the data source (in this example- Palo Alto Firewall) and loading the relevant data.  

 

CommonSecurityLog
| where DeviceVendor =="Palo Alto Networks" and Activity  == "TRAFFIC"
| where TimeGenerated between (ago(starttime)..ago(endtime))

 

Step 2: Filter – Internal to External Traffic

This step involves filtering the raw logs loaded in the first stage to only focus on traffic directing from internal networks to external Public networks. This is achieved by populating IP Type as Private and Public based on PrivateIP regex. You can use any other data sources such as joining against internal asset inventory data source with matches as Internal and rest as external.  

 

| extend DestinationIPType = iff(DestinationIP matches regex PrivateIPregex,"private","public" )
| where DestinationIPType =="public"
| project TimeGenerated , SourceIP , SourcePort , DestinationIP, DestinationPort, ReceivedBytes, SentBytes

 

Step 3: Data Serialization – sort, reorder

This step is used to reorder the logs using serialize operator. It is required to reorder the data in correct order as we will calculate time delta from sequential events for the same source addresses.

 

| sort by SourceIP asc,TimeGenerated asc, DestinationIP asc, DestinationPort asc
| serialize

 

Step 4: Time Delta Calculation

This step is used to calculate time delta using prev() and next() functions. In order to use these functions, the data should be in correct order achieved from Step-3. The timestamp of the next event is accessed using next function and later datetime_diff() is used to calculate time difference between two timestamps. It is made sure that source IP address of the next event is same. The unit used is in seconds. Final output is projected with selected columns along with data transfer in bytes.

 

| extend nextTimeGenerated = next(TimeGenerated, 1), nextSourceIP = next(SourceIP, 1)
| extend TimeDeltainSeconds = datetime_diff(‘second’,nextTimeGenerated,TimeGenerated)
| where SourceIP == nextSourceIP

 

Step 5: Data Reshaping- aggregation using window functions

In this step, data resulted from step 4 is further aggregated to downsample the data per hour time window without losing the context. First, In addition to using sum() and count() functions to aggregate, make_list() is used to make array of Time Delta values which are grouped by sourceip, destinationip and destinationports. Later, This array of values is transformed into count of each values to find most frequent or repetitive timedelta value using arg_max() function.  At the end, BeaconPercent is calculated using simple formula : count of most frequent time delta divided by total events.

 

 | project TimeGenerated, TimeDeltainSeconds, SourceIP, SourcePort,DestinationIP,DestinationPort, ReceivedBytes, SentBytes
| summarize count(), sum(ReceivedBytes), sum(SentBytes), make_list(TimeDeltainSeconds) by TimeDeltainSeconds, bin(TimeGenerated, 1h), SourceIP, DestinationIP, DestinationPort
| summarize (MostFrequentTimeDeltaCount, MostFrequentTimeDeltainSeconds)=arg_max(count_, TimeDeltainSeconds), TotalEvents=sum(count_), TotalSentBytes=sum(sum_SentBytes),TotalReceivedBytes=sum(sum_ReceivedBytes) by bin(TimeGenerated, 1h), SourceIP, DestinationIP, DestinationPort

 

Step 6: Filter – Global Threshold Parameters

At various stages of the query, filtering is used to reduce the input data set in scope. At the top of the query, we have several global arguments declared which can be tweaked for alerting.

  • TimeDeltathreshold: The value refers to the timedelta in seconds between 2 connections. With this parameters , noisy events with very low threshold value (such as 1 seconds to 10 seconds) will be filtered and not considered for alerting.
  • TotalEventsThreshold: The value refers to the total count of events seen between the same source and destination aggregated per destination port
  • PercentBeaconThreshold: The value refers to the percentage of beacon values based on the formula of mostfrequenttimedelta/totalevents

 

Interpreting Results:

In this case, we will start hunting with unsampled or non-aggregated network connection logs from any network sensor logs. The logs should include at least sourceport and destinationPort along with source and destination address fields.

Below is an example output of Palo Alto traffic logs from Azure Sentinel.

 

BaseLogs.PNG

 

 After executing the query and based on the globally configured threshold, alerts will be triggered. Example alert results will look like below.

 

Alert_Results.PNG

 

Apart from the known fields from the original logs such as TimeGenerated, SourceIP, DestinationIP, DestinationPort, TotalEvents,TotalSentBytes,TotalReceivedBytes, below additional enriched fields are populated by query.

  • MostFrequentTimeDeltainSenconds : Repetitive Time interval between successive network connection in seconds.
  • MostFrequentTimeDeltaCount: Count of the MostFrequentTimeDeltaInSeconds occurred within the timestamp.
  • BeaconPercent: Percentage of beaconing calculated based on formula of MostFrequentTimeDeltaCount/TotalEvents* 100 .

The alert indicates

  • 91% beaconing traffic seen from the source address 192.168.10.10 towards destination address- 67.217.69.224. 
  • Total 243 events observed in the hour 2019-05-25 08:00 to 09:00.
  • Out of those, 222 events seen with 14 seconds time intervals. 

Whois query for the IP reveals, it is registered with LogmeIn. This could be benign behavior if you are using the application in your environments, else this could be indication of unauthorized installation on compromised host. Similar ways, you could detect other legitimate or unauthorized applications usage exhibiting beaconing behaviors.

 

whois-logmein.png

 

Things to remember before onboarding this detection:

The way this detection is designed, there are some limitations or things to be considered before on-boarding this detection in your environment.

  • Since detection requires unsampled network connection logs, you should not on-board detection for environments which has multiple hosts behind a proxy and firewall/network sensor logs shows only proxy IP address as source or if you are doing aggregation at any stage of your data ingestion.
  • The detection is not filtered for any specific ports but consider approaches to reduce the input data scope by filtering traffic either to known destination addresses or destination ports if those. Time delta calculation is an expensive operation and reducing the input data set to correct scope will make it more efficient.
  • You will also see legitimate beaconing traffic to known device vendors such as traffic towards Microsoft related to windows update, traffic to device manufacture vendors or any other legitimate application or agent configured to initiate network connection at scheduled intervals. Based on historical analysis you can understand baseline, and use it to filter such IP ranges to reduce false positives.
  • Lastly, the detection is alerted based on the most repetitive time delta values but adversary can also add jitter or randomness so time intervals values between individual network connection will look different and will not match to PercentBeacon threshold values. You could still use your baseline analysis and other parameters of the dataset and derive additional hunting queries.

 

Conclusion:

In this article, we looked into previously discussed technique of detecting beaconing using intra-time delta patterns and how it can be implemented using native KQL within Azure Sentinel. The logic of the detection involves various stages starting from loading raw logs to doing various data transformation and finally alerting the results based on globally configured threshold values.

Unsampled/ non-aggregated network connection logs are very voluminous in nature and finding actionable events are always challenging.  Even if you follow traditional approaches such as matching with IOCs, application or service profiling, various type of visualizations , due to the sheer scale of the data ,results from such techniques are not often directly actionable for analysts and need further ways to hunt for malicious traffic. With this unique analysis technique, we can find beacon like traffic patterns from your internal networks towards untrusted public destinations and directly investigate the results. The output alert results also provide useful context on the type of network traffic seen with basic packet statistics and why it has categorized as beaconing with additional attributes such as amount of data transferred to assist analysts to do alert triage. 

From the example covered in the article, we were able to detect logmein traffic which was exhibiting beaconing behavior based on the repetitive time delta patterns in the given hour. We also talked about the scenarios where detection should not be onboarded depending on how environment is setup or data ingestion is set up.

 

Special thanks to Microsoft Kusto Discussions community who assisted with Data Reshaping stage of the query. You can also ask questions related to KQL at stackoverflow here.

 

Happy hunting.

 

References:

  • ThreatHunting Project- Github

https://github.com/ThreatHuntingProject/ThreatHunting/blob/master/hunts/beacon_detection_via_intra_r...

  • Detect Beaconing with Flare, Elastic Stack, and Intrusion Detection Systems

http://www.austintaylor.io/detect/beaconing/intrusion/detection/system/command/control/flare/elastic...

  • Command and Control : MITRE Technique TA0011

https://attack.mitre.org/tactics/TA0011/

3 Comments
Occasional Contributor

So I can't think of a single reason why I'd beacon on a consistent time basis,  I can't imagine anything in  c2 network is time sensitive, so just fire things randomly.

Microsoft

Thanks @Tony Roth for reviewing detection and leaving the comment. Beaconing often happens at regular intervals although c2 networks/frameworks can change and add randomness to communication pattern, it is still good idea to monitor periodic communication from internal hosts to unknown public addresses. 

Some approaches were suggested to reduce false positives or filter the benign traffic such as tweaking timedelta/ percent beacon threshold, profiling network and segregating known destination IP ranges/registrant org. If you have any generic tuning recommendation, we would gladly accept via Pull Request to the sentinel repo.

Occasional Contributor

Yes,  I get that monitoring this is valuable but I somewhat think that the malware authors are on to this now.  I know its a game of cat and mouse so every bit helps.