Home
%3CLINGO-SUB%20id%3D%22lingo-sub-561413%22%20slang%3D%22en-US%22%3ESecurity%20Investigation%20with%20Azure%20Sentinel%20and%20Jupyter%20Notebooks%20%E2%80%93%20Part%203%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-561413%22%20slang%3D%22en-US%22%3E%3CP%3EAuthor%3A%20Ian%20Hellen%20(%40ianhellen)%20%3CBR%20%2F%3EPrincipal%20Software%20Development%20Engineer%2C%20MSTIC%2C%20Microsoft%20Cloud%20and%20AI%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F432921%22%20target%3D%22_self%22%3Epart%201%3C%2FA%3E%20of%20this%20article%20we%20started%20with%20a%20Threat%20Intelligence%20(TI)%20report%20of%20malicious%20Command%20and%20Control%20(C2)%20IP%20addresses%20which%20we%20found%20in%20our%20Azure%20Sentinel%20data.%20We%20were%20able%20to%20see%20activity%20relating%20to%20one%20of%20these%20IPs%20in%20our%20alerts%20set%20and%20used%20additional%20TI%20and%20Geo-IP%20data%20sets%20to%20get%20more%20information%20on%20these%20IP%20addresses.%20In%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F483466%22%20target%3D%22_self%22%3Epart%202%3C%2FA%3E%2C%20our%20investigation%20moved%20to%20a%20Linux%20host%2C%20where%20we%20used%20Linux%20audit%20logs%20to%20view%20logins%20with%20external%20IPs%20and%20process%20sessions%20to%20confirm%20the%20presence%20of%20an%20attacker.%20From%20there%20we%20looked%20at%20network%20data%20and%20found%20another%20host%20communicating%20with%20the%20same%20C2%20IP%20address.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20final%20part%20we%E2%80%99ll%20be%20first%20looking%20at%20activity%20on%20this%20second%20host.%20This%20time%20it%20is%20a%20Windows%20host%2C%20where%20despite%20different%20logs%20formats%2C%20the%20investigation%20approach%20is%20similar%20to%20the%20Linux%20host.%20We%20will%20also%20be%20using%20some%20unsupervised%20machine%20learning%20to%20help%20up%20narrow%20down%20the%20important%20data.%20Lastly%2C%20we%20will%20take%20a%20brief%20look%20at%20Office%20365%20data%20to%20see%20if%20there%20are%20signs%20of%20attacker%20activity%20there.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1736043463%22%20id%3D%22toc-hId-1736043463%22%3E%3CFONT%20size%3D%225%22%3EThe%20Hunting%20Notebook%20-%20%3C%2FFONT%3E%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Step-by-Step%2520Linux-Windows-Office%2520Investigation.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3E%3CU%3E%3CFONT%20size%3D%225%22%3Enbviewer%20Version%3C%2FFONT%3E%3C%2FU%3E%3C%2FEM%3E%3C%2FA%3E%3C%2FH2%3E%0A%3CP%3EI%E2%80%99ve%20made%20some%20updates%20to%20the%20notebook%20from%20last%20time%2C%20so%20please%20check%20out%20the%20updated%20version.%20The%20GitHub%20copy%20is%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Step-by-Step%2520Linux-Windows-Office%2520Investigation.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Ehere%3C%2FEM%3E%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--816113498%22%20id%3D%22toc-hId--816113498%22%3E%3CFONT%20size%3D%225%22%3EA%20second%20host%20communicating%20with%20the%20C2%20IP%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20the%20previous%20part%20we%20identified%20our%20second%20victim%20host%20from%20the%20network%20data.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20943px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113067iC0889193F74FA6B9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22new-host-details.png%22%20title%3D%22new-host-details.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20want%20to%20examine%20this%20host%20in%20the%20same%20way%20that%20we%20did%20for%20the%20Linux%20host%20earlier.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-730183332%22%20id%3D%22toc-hId-730183332%22%3E%3CFONT%20size%3D%224%22%3ELooking%20at%20Logon%20Sessions%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EWe%20use%20the%20time%20stamp%20of%20Linux%20host%20alert%20to%20automatically%20set%20the%20origin%20time%20for%20%3CSTRONG%3EQueryTime%3C%2FSTRONG%3E%20widget.%20This%20lets%20us%20cascade%20the%20time%20window%20of%20the%20attack%20through%20all%20subsequent%20queries%20in%20the%20notebook.%20If%20you%20run%20the%20same%20notebook%20for%20several%20alerts%2C%20it%E2%80%99s%20all%20too%20easy%20to%20get%20things%20out%20of%20sync.%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%20769px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113068i76C9F459E7E6A659%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22logon-query-times.png%22%20title%3D%22logon-query-times.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERunning%20the%20query%20over%20this%20period%20we%20get%20201%20distinct%20logins%2C%20which%20is%20a%20lot%20to%20sift%20through.%20We%20can%20use%20%3CEM%3Epandas%3C%2FEM%3E%20to%20group%20the%20data%20by%20%3CEM%3EAccount%3C%2FEM%3E%20and%20%3CEM%3ELogonType.%3C%2FEM%3E%20This%20shows%20two%20accounts%20using%20Remote%20Desktop%20Protocol%20(RDP)%20logons%20(type%2010)%2C%20which%20is%20a%20popular%20target%20for%20brute%20force%20attackes.%20The%20individual%20logon%20events%20are%20also%20shown%20in%20a%20timeline%2C%20with%20the%20RDP%20logons%20shown%20in%20green.%20Note%20that%20all%20of%20these%20happened%20well%20before%20our%20original%20Linux%20alert%2C%20suggesting%20that%20the%20Windows%20host%20was%20attacked%20first.%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%20970px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113069iFE83C1FF2AEDC5ED%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22logons-by-type.png%22%20title%3D%22logons-by-type.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20Jupyter%20notebook%20I%20also%20show%20an%20example%20of%20using%20clustering%20to%20group%20these%20logons%20into%20manageable%20sets%20but%20for%20data%20like%20this%2C%20where%20we%20are%20grouping%20by%20just%20one%20or%20two%20discrete%20features%20(with%20a%20small%20number%20of%20possible%20values)%20using%20%3CEM%3Epandas%3C%2FEM%3E%20is%20simpler%20and%20more%20understandable.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHaving%20identified%20the%20subset%20of%20logons%20that%20we%20want%20to%20look%20at%20we%20can%20use%20the%20%3CEM%3Emsticpy%3C%2FEM%3E%20%3CSTRONG%3Edisplay_logon_data%3C%2FSTRONG%3E%20function%20to%20print%20out%20the%20grouped%20logons%20in%20a%20friendlier%20format%20than%20a%20table.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20773px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113070i4870F15DA7C968D8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22logon-details.png%22%20title%3D%22logon-details.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20logon%20data%20for%20this%20account%20(see%20details%20in%20the%20notebook)%2C%20we%20notice%20a%20few%20things%20for%20the%20%E2%80%9Cian%E2%80%9D%20account%20(any%20resemblance%20to%20persons%20living%20or%20dead%20is%20entirely%20coincidental)%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThere%20were%20a%20series%20of%20failed%20logons%20for%20this%20account.%3C%2FLI%3E%0A%3CLI%3EThere%20were%20some%20successful%20logons%20of%20both%20type%203%20(Network)%20and%20type%2010%20(RDP)%3C%2FLI%3E%0A%3CLI%3EAt%20least%20some%20of%20these%20originated%20from%20our%20attacker%20IP%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWe%20now%20want%20to%20look%20at%20the%20processes%20that%20ran%20in%20these%20sessions%2C%20to%20see%20what%20our%20attacker%20was%20up%20to.%20Since%20these%20logons%20occurred%20significantly%20early%20than%20our%20alert%2C%20we%20need%20to%20set%20our%20query%20origin%20time%20to%20match%20the%20session%20that%20we%20are%20interested%20in.%20Querying%20for%20process%20creation%20events%20(ID%204688)%20for%20this%20period%20we%20get%203772%20events%20%E2%80%93%20a%20lot%20to%20look%20through!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1821973629%22%20id%3D%22toc-hId--1821973629%22%3E%3CFONT%20size%3D%224%22%3ESide%20Note%20-%20clustering%20data%20to%20identify%20unique%20events%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EWe%20can%20use%20a%20few%20techniques%20to%20try%20to%20remove%20uninteresting%20events%20from%20this%20set.%20For%20example%2C%20selecting%20a%20subset%20of%20columns%20(e.g.%20process%20name%2C%20command%20line%20and%20account)%20and%20finding%20the%20unique%20combinations%20might%20be%20good%20enough%20to%20eliminate%20most%20of%20the%20noise.%20In%20many%20cases%2C%20though%2C%20this%20isn%E2%80%99t%20enough.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20common%20to%20see%20repetitive%20system%20and%20administrative%20events%20that%20have%20some%20variable%20command%20line%20content%20but%20otherwise%20identical.%20For%20example%3A%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%2F113071i8F6D8F89360C9D2E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Repetitive%20commands.png%22%20title%3D%22Repetitive%20commands.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20human%20can%20easily%20recognize%20that%20these%20are%20essentially%20a%20repetition%20of%20the%20same%20process%20and%20probably%20not%20very%20interesting%2C%20if%20they%20occur%20in%20hundreds%20or%20thousands.%20What%20we%20want%20to%20do%20is%20capture%20the%20essence%20of%20the%20command%20line%20intent%20while%20dropping%20the%20instance-specific%20variables.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20do%20that%20by%20focusing%20on%20the%20structure%20(or%20syntax)%20rather%20than%20the%20content%20of%20the%20command%20line.%20There%20are%20several%20ways%20to%20slice%20this%20but%20a%20simply%20counting%20common%20delimiter%20characters%20such%20as%20spaces%2C%20switch%20and%20path%20separators%20(-%2C%20%2F%2C%20%5C)%2C%20dots%2C%20etc.%20can%20give%20good%20enough%20separation%20between%20variants%20of%20the%20same%20command%20line.%20By%20ignoring%20content%20between%20the%20separators%2C%20it%20also%20allows%20us%20to%20group%20together%20events%20with%20a%20common%20pattern.%20We%20could%20get%20more%20sophisticated%20by%20taking%20into%20account%20the%20ordering%20of%20the%20syntactic%20separators%2C%20but%20this%20usually%20isn%E2%80%99t%20necessary.%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%20425px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113072i017B816F01FABF39%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22cmdline-boxplot.png%22%20title%3D%22cmdline-boxplot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20partial%20graph%20shows%20the%20variability%20of%20the%20number%20of%20delimiters%20in%20command%20lines%20for%20some%20processes%20in%20our%20data%20set.%20Those%20with%20a%20single%20vertical%20bar%20indicates%20no%20variance%20in%20the%20samples%2C%20while%20others%2C%20like%20cmd.exe%2C%20net.exe%20and%20rundll32.exe%20show%20significant%20variability%20in%20their%20command%20line%20structure.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EClustering%2C%20an%20unsupervised%20machine%20learning%20method%2C%20can%20also%20help%20%E2%80%93%20bypassing%20the%20need%20(if%20we%20do%20it%20correctly)%20to%20manually%20group%20and%20sort%20the%20different%20features%20of%20our%20events.%20Most%20clustering%20algorithms%20require%20that%20you%20know%20the%20number%20of%20clusters%20beforehand%2C%20which%2C%20in%20this%20case%2C%20we%20don't.%20The%26nbsp%3B%3CEM%3EDBSCAN%3C%2FEM%3E%20algorithm%2C%20in%20contrast%2C%20will%20dynamically%20create%20new%20clusters%20and%20assign%20events%20to%20them%20based%20on%20a%20%3CEM%3Edistance%3C%2FEM%3E%20measure.%20You%20supply%20the%20algorithm%20with%20a%20set%20of%20features%20that%20are%20used%20to%20calculate%20the%20distance%2C%20the%20minimum%20cluster%20size%20and%20a%20distance%20metric.%20You%20can%20think%20of%20each%20feature%20as%20magnitude%20along%20a%20dimension%20(x%2C%20y%2C%20z%20and%20whatever%20comes%20after%20z)%20%E2%80%93%20so%20every%20process%20instance%20will%20have%20coordinates%20in%20multi-dimensional%20space.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVisualizing%20more%20than%203%20dimensions%20is%20a%20bit%20tricky%20for%20most%20people%20(including%20me).%20Here%20is%20an%20example%20using%20just%20two%20dimensions%20-%20the%20process%20name%20and%20the%20command%20line%20syntax%20delimiters.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20969px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113074i2B3E3AAA7CBFFF5E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22cluster-subset.png%22%20title%3D%22cluster-subset.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EA%20single%20dot%20means%20that%20there%20is%20only%20one%20sample%20in%20the%20data%20set.%20Where%20there%20are%20multiple%20instances%20you%20can%20see%20horizontal%20banding%20(courtesy%20of%20the%20%3CSTRONG%3Ecatplot%3C%2FSTRONG%3E%20function%20from%20the%20wonderful%26nbsp%3B%3CEM%3ESeaborn%3C%2FEM%3E%26nbsp%3Bpackage).%20This%20means%20that%20there%20are%20multiple%20instances%20that%20share%20the%20same%20command%20line%20token%20value.%20If%20we%20to%20draw%20boundaries%20around%20each%20grouping%20of%20command%20line%20token%20score%20and%20process%20name%2C%20we'd%20have%20our%20clusters.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhere%20two%20or%20more%20events%20coincide%20(within%20the%20minimum%20distance%20specified)%20they%20are%20considered%20part%20of%20the%20same%20cluster.%20Features%20need%20to%20be%20numeric%20and%20have%20a%20good%20separation%20of%20values%20across%20the%20variation%20that%20we%20are%20interested%20in%20capturing.%3C%2FP%3E%0A%3CP%3EIn%20our%20example%20we%E2%80%99ve%20chosen%20four%20columns%20to%20provide%20features%20for%20clustering%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ECommandline%3C%2FSTRONG%3E%20(reduced%20to%20tokens)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ENewProcessName%3C%2FSTRONG%3E%20(the%20process%20path%20converted%20to%20a%20numeric%20score%20based%20on%20character%20values)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EAccount%3C%2FSTRONG%3E%20(converted%20to%20a%20score%20in%20the%20same%20way)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EIsSystemSession%3C%2FSTRONG%3E%20(a%201%20indicates%20that%20the%20process%20is%20running%20in%20the%20system%20context%20and%200%20otherwise)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EUsing%20these%20features%2C%20we%20can%20reduce%20a%20large%20event%20set%20to%20a%20more%20manageable%20set%20of%20distinct%20event%20patterns%20that%20makes%20viewing%20and%20analyzing%20much%20more%20tractable.%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%20938px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113075iB3E14D4070579736%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clustered-logons.png%22%20title%3D%22clustered-logons.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20graph%20shows%20clustering%20applied%20to%20logon%20sessions%20(the%20duplicated%20items%20are%20different%20logon%20clusters%20because%20we%20grouped%20on%20both%20account%20name%20and%20logon%20type).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--79163294%22%20id%3D%22toc-hId--79163294%22%3E%3CFONT%20size%3D%224%22%3EProcesses%20in%20the%20Logon%20Sessions%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3ERunning%20our%20set%20of%203771%20process%20events%20through%20the%20clustering%20algorithm%20yields%20170%20distinct%20patterns%20%E2%80%93%20which%20seems%20a%20lot%20more%20manageable.%20It%E2%80%99s%20possible%20to%20look%20through%20all%20the%20processes%20but%20we%E2%80%99re%20mostly%20interested%20in%20the%20processes%20belonging%20to%20the%20suspicious%20logon%20sessions.%20We%20can%20use%20a%20nice%20trick%20with%20%3CEM%3Epandas%3C%2FEM%3E%20and%20Jupyter%20widgets%20to%20interactively%20select%20a%20session%20and%20display%20its%20processes.%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%2F113076i388C1E32E3520426%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22processes-in-logon-session.png%22%20title%3D%22processes-in-logon-session.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20ipywidget%20%3CSTRONG%3Einteractive()%3C%2FSTRONG%3E%20function%20in%20the%20code%20above%20binds%20selection%20events%20in%20our%20logon%20session%20list%20to%20the%20view_logon_session%20function.%20This%20function%20receives%20the%20selected%20value%20from%20the%20first%20list%20as%20an%20argument%20and%20uses%20the%20corresponding%20%3CSTRONG%3ELogonId%3C%2FSTRONG%3E%20to%20filter%20and%20display%20the%20dataframe%20of%20processes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20processes%20in%20question%20reveal%20some%20obvious%20attacker%20traits%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eopening%20a%20scripted%20FTP%20session%3C%2FLI%3E%0A%3CLI%3Eenumerating%20and%20adding%20users%3C%2FLI%3E%0A%3CLI%3Eadding%20these%20users%20to%20the%20Administrators%20group%3C%2FLI%3E%0A%3CLI%3Eremoving%20security%20protections%20on%20Terminal%20Services%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1663647041%22%20id%3D%22toc-hId-1663647041%22%3E%3CFONT%20size%3D%224%22%3EOther%20Windows%20Events%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EIn%20the%20notebook%20I%20also%20retrieve%20counts%20of%20all%20unique%20event%20types%20for%20each%20logon.%20This%20confirms%20the%20user%20account%20and%20group%20manipulation%20seen%20in%20the%20processes%20above%20as%20well%20as%20failed%20account%20logon%20and%20privilege%20assignment%20and%20other%20nefarious%20deeds.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20817px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113077i1D43F42D2D4CB738%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22other-events.png%22%20title%3D%22other-events.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--691996415%22%20id%3D%22toc-hId--691996415%22%3E%3CFONT%20size%3D%225%22%3EOffice%20365%20Data%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3ESo%20far%2C%20we%E2%80%99ve%20look%20at%20two%20examples%20of%20host%20investigation%2C%20network%20data%2C%20and%20TI%20lookups.%20Having%20Office%20activity%20data%20available%20in%20Azure%20Sentinel%20makes%20it%20easy%20to%20look%20for%20evidence%20of%20our%20attacker%20there%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20a%20real%20case%2C%20you%20might%20by%20now%20have%20accumulated%20several%20C2%20IP%20addresses%20used%20by%20the%20attacker%20and%20need%20to%20search%20for%20these.%20You%20might%20also%20choose%20to%20look%20at%20the%20O365%20activity%20related%20to%20the%20accounts%20on%20one%20or%20both%20compromised%20hosts.%20%26nbsp%3BOne%20of%20our%20users%20may%20have%20left%20something%20like%20browsing%20history%20on%20the%20host%2C%20indicating%20which%20O365%20account%20they%20own.%20If%20you%20can%20find%20out%20which%20O365%20accounts%20correspond%20to%20the%20local%20user%20accounts%2C%20be%20sure%20to%20look%20at%20the%20activity%20on%20these%20accounts.%20You%20should%20also%20treat%20the%20IP%20addresses%20of%20the%20compromised%20hosts%20as%20now%20hostile%20and%20be%20searching%20for%20activity%20related%20to%20these.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20our%20simplified%20example%20we%20are%20going%20to%20limit%20the%20search%20to%20the%20same%20C2%20IP%20that%20we%20have%20been%20pursuing%20throughout%20this%20blog.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-854300415%22%20id%3D%22toc-hId-854300415%22%3E%3CFONT%20size%3D%224%22%3EIP%20Addresses%20Office%20Activity%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EWe%20want%20to%20cast%20quite%20a%20wide%20net%20so%20we%E2%80%99ll%20search%20over%20several%20days%20around%20the%20time%20of%20the%20original%20alert%20%E2%80%93%20you%E2%80%99d%20want%20to%20have%20your%20start%20date%20earlier%20than%20the%20earliest%20evidence%20of%20an%20attack.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20713px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113078iED4CE0417E96F488%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22office-activity-ip.png%22%20title%3D%22office-activity-ip.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20see%20a%20few%20login%20failures%20as%20well%20as%20successful%20logins%20%E2%80%93%20maybe%20the%20attacker%20was%20trying%20variants%20of%20the%20password%20used%20on%20one%20of%20the%20hosts.%20The%20account%20name%20seems%20like%20it%20might%20be%20the%20same%20person%20whose%20account%20was%20broken%20into%20on%20the%20Windows%20host.%20We%20also%20see%20a%20significant%20number%20of%20file%20download%20operations%20from%20Sharepoint%20but%20not%20much%20else.%20This%20could%20be%20a%20simple%20attempt%20to%20exfiltrate%20useful%20data%20like%20financial%20reports%20or%20company%20confidential%20information%20of%20some%20type.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%20%E2%80%93%20Authentication%20activity%20is%20no%20longer%20logged%20to%20the%20O365%20activity%20logs%20(as%20shown%20here).%20You%20will%20find%20this%20data%20in%20the%20Azure%20Active%20Directory%20SigninLogs%20table.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20955px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113079i271DC61FC022E4C1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22office-activity-timeline.png%22%20title%3D%22office-activity-timeline.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20timeline%20shows%20these%20download%20events%20all%20happened%20in%20quick%20succession.%20This%20likely%20means%20a%20top-level%20folder%20was%20selected%20and%20the%20whole%20contents%20downloaded%20in%20one%20go.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20rapidity%20of%20these%20operations%20gives%20us%20a%20hint%20as%20to%20an%20alternative%20way%20of%20detecting%20this%20behavior%20without%20relying%20on%20the%20C2%20IP.%20Using%20pandas%20time%20series%20capabilities%2C%20we%20can%20%3CSTRONG%3Eresample%3C%2FSTRONG%3E%20the%20data%2C%20chopping%20it%20into%2010%20second%20slices%2C%20grouped%20by%20user%2C%20IP%20address%20and%20operation.%20We%20can%20then%20easily%20query%20for%20high%20repetitions%20of%20events%20within%20each%2010%20second%20window.%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%2F113080i4D982D99E5B6F63E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22high-freq-events.png%22%20title%3D%22high-freq-events.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20a%20more%20sophisticated%20approach%20to%20time%20series%20analysis%20be%20sure%20to%20check%20our%20Tim%20Burrell%E2%80%99s%20article%20%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FTime-series-analysis-applied-in-a-security-hunting-context%2Fba-p%2F472433%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ETime%20series%20analysis%20applied%20in%20a%20security%20hunting%20context%3C%2FA%3E%3C%2FEM%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1501343041%22%20id%3D%22toc-hId--1501343041%22%3E%3CFONT%20size%3D%225%22%3EObservation%20Summary%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EYou%20may%20have%20noticed%20calls%20to%20the%20%3CSTRONG%3Eadd_observation%3C%2FSTRONG%3E%20function%20appearing%20in%20the%20notebook%20(like%20the%20cell%20above).%20This%20a%20simple%20idea%20to%20allow%20you%20to%20capture%20data%20that%20is%20central%20to%20the%20investigation.%20As%20well%20as%20a%20caption%20(must%20be%20unique)%20and%20description%2C%20you%20can%20also%20capture%20a%20dataframe%20or%20other%20data%20object%20such%20as%20an%20image%20or%20plot.%20You%20can%20also%20include%20a%20link%20to%20a%20bookmark%20defined%20in%20the%20relevant%20section%20of%20the%20notebook%20(add%20an%20'a'%20tag%20with%20id%20attribute%20containing%20the%20name%20of%20your%20bookmark%20at%20the%20location%20you%20want%20to%20link%20to%2C%20e.g.%26nbsp%3B%3CA%20id%3D%22%26quot%3Bo365_logons%26quot%3B%22%20target%3D%22_blank%22%3E%3C%2FA%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20collected%20observations%20items%20are%20available%20to%20be%20displayed%20together%20at%20the%20end%20of%20the%20notebook%20using%20a%20simple%20for%20loop%20and%20the%20%3CSTRONG%3Edisplay()%3C%2FSTRONG%3E%20function.%20Items%20are%20displayed%20in%20the%20order%20that%20they%20were%20added.%20If%20you%20later%20re-run%20a%20cell%20that%20calls%20%3CSTRONG%3Eadd_observation%3C%2FSTRONG%3E%20it%20will%20replace%20the%20original%20entry%20in%20its%20original%20position%2C%20provided%20you%20keep%20the%20same%20caption.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-241467294%22%20id%3D%22toc-hId-241467294%22%3E%3CFONT%20size%3D%225%22%3EConclusion%3C%2FFONT%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3EWe%20started%20part%201%20with%20a%20threat%20intelligence%20report%20and%20a%20list%20of%20IP%20address%20indicators%20of%20compromise.%3C%2FLI%3E%0A%3CLI%3ESearching%20through%20our%20Azure%20Sentinel%20data%20we%20found%20one%20of%20these%20IP%20addresses%20appearing%20in%20multiple%20data%20sets.%3C%2FLI%3E%0A%3CLI%3EOne%20of%20these%20led%20us%20to%20a%20Linux%20host%20where%20we%20were%20able%20to%20confirm%20compromise.%3C%2FLI%3E%0A%3CLI%3EWe%20used%20network%20data%20to%20show%20the%20link%20between%20the%20host%20and%20our%20C2%20IP%2C%20and%20discovered%20communications%20to%20another%20host.%3C%2FLI%3E%0A%3CLI%3EIn%20this%20part%20of%20the%20blog%2C%20we%20analyzed%20logon%2C%20process%20and%20other%20event%20data%20on%20a%20Windows%20host%20and%20were%20able%20to%20confirm%20that%20it%20too%20was%20compromised.%3C%2FLI%3E%0A%3CLI%3EWe%20introduced%20some%20techniques%20for%20aggregating%20data%20into%20more%20manageable%20sizes%20using%20feature%20extraction%20and%20cluster%20and%20also%20looked%20at%20using%20Jupyter%20widgets%20to%20create%20an%20interactive%20link%20between%20two%20DataFrames.%3C%2FLI%3E%0A%3CLI%3EFinally%2C%20we%20confirmed%20that%20our%20attacker%20was%20also%20active%20in%20an%20Office%20account%20and%20identified%20a%20likely%20data%20exfiltration.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1425413102%22%20id%3D%22toc-hId--1425413102%22%3E%3CFONT%20size%3D%225%22%3EPrevious%20Parts%3C%2FFONT%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F432921%22%20target%3D%22_self%22%3EPart%201%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F483466%22%20target%3D%22_self%22%3EPart%202%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-317397233%22%20id%3D%22toc-hId-317397233%22%3E%3CFONT%20size%3D%225%22%3EReferences%3C%2FFONT%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22http%3A%2F%2Fpandas.pydata.org%2Fpandas-docs%2Fstable%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EPandas%20Documentation%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2Fmsticpy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Emsticpy%3C%2FEM%3E%3C%2FA%3E%20Python%20package%20containing%20tools%20used%20in%20these%20notebooks%20developed%20engineers%20on%20the%20Microsoft%20Threat%20Intelligence%20team.%20It%20is%20available%20on%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2Fmsticpy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EGitHub%3C%2FEM%3E%3C%2FA%3E%20along%20with%20several%20notebooks%20documenting%20the%20use%20of%20the%20tools%20and%20on%20%3CA%20href%3D%22https%3A%2F%2Fpypi.org%2Fproject%2Fmsticpy%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EPyPi%3C%2FEM%3E%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2Fjupyter-Kqlmagic%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EKqlmagic%3C%2FEM%3E%3C%2FA%3E%20%3CSPAN%3Eis%20a%20Jupyter-friendly%20package%20developed%20by%20Michael%20Binstock.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fscikit-learn.org%2Fstable%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EScikit-Learn%20Machine%20Learning%20in%20Python%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fscikit-learn.org%2Fstable%2Fmodules%2Fclustering.html%23dbscan%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EScikit-Learn%20DBSCAN%20clustering%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fseaborn.pydata.org%2Findex.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ESeaborn%20Statistical%20Visualization%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-2060207568%22%20id%3D%22toc-hId-2060207568%22%3E%3CFONT%20size%3D%224%22%3E%3CSPAN%3EReading%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftomaugspurger.github.io%2Fmodern-1-intro.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EModern%20Pandas%3C%2FEM%3E%3C%2FA%3E%20by%20Tom%20Augspurger%3C%2FLI%3E%0A%3CLI%3E%3CEM%3EPython%20for%20Data%20Analysis%3A%20Data%20Wrangling%20with%20Pandas%2C%20NumPy%2C%20and%20IPython%3C%2FEM%3E%20by%20Wes%20McKinney%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId--491949393%22%20id%3D%22toc-hId--491949393%22%3E%3CFONT%20size%3D%225%22%3EMore%20Notebooks%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EAzure%20Sentinel%20sample%20Jupyter%20notebooks%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Ehere%3C%2FEM%3E%3C%2FA%3E%20on%20GitHub.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWindows%20Alert%20Investigation%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Investigation%2520-%2520Process-Alerts.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%26nbsp%3B%3C%2FEM%3E%3C%2FA%3Eor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Investigation%2520-%2520Process-Alerts.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EWindows%20Host%20Explorer%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Windows-Host-Explorer.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%26nbsp%3B%3C%2FEM%3E%3C%2FA%3Eor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Windows-Host-Explorer.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EOffice%20365%20Exploration%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Office365-Exploring.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%3C%2FEM%3E%3C%2FA%3E%20or%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Office365-Exploring.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECross-Network%20Hunting%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Linux-Windows-Office.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%26nbsp%3B%3C%2FEM%3E%3C%2FA%3Eor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Linux-Windows-Office.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAlso%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Defender-ATP%2FAutomating-Security-Operations-Using-Windows-Defender-ATP-APIs%2Fba-p%2F294434%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%3CEM%3EAutomating%20Security%20Operations%20Using%20Windows%20Defender%20ATP%20APIs%20with%20Python%20and%20Jupyter%20Notebooks%3C%2FEM%3E%3C%2FA%3E%20by%20John%20Lambert.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-561413%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20part%203%20we%20investigate%20Windows%20logon%20sessions%20and%20processes%2C%20and%20look%20at%20O365%20activity.%20Also%20show%20how%20to%20use%20clustering%20to%20reduce%20noise%20when%20looking%20at%20large%20numbers%20of%20events.%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%2F113066iAE8929C3C9E6B1C5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22HeaderGraphic.png%22%20title%3D%22HeaderGraphic.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-561413%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EInvestigation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Enotebooks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Author: Ian Hellen (@ianhellen)
Principal Software Development Engineer, MSTIC, Microsoft Cloud and AI

 

In part 1 of this article we started with a Threat Intelligence (TI) report of malicious Command and Control (C2) IP addresses which we found in our Azure Sentinel data. We were able to see activity relating to one of these IPs in our alerts set and used additional TI and Geo-IP data sets to get more information on these IP addresses. In part 2, our investigation moved to a Linux host, where we used Linux audit logs to view logins with external IPs and process sessions to confirm the presence of an attacker. From there we looked at network data and found another host communicating with the same C2 IP address.

 

In this final part we’ll be first looking at activity on this second host. This time it is a Windows host, where despite different logs formats, the investigation approach is similar to the Linux host. We will also be using some unsupervised machine learning to help up narrow down the important data. Lastly, we will take a brief look at Office 365 data to see if there are signs of attacker activity there.

 

The Hunting Notebook - nbviewer Version

I’ve made some updates to the notebook from last time, so please check out the updated version. The GitHub copy is here.

 

A second host communicating with the C2 IP

In the previous part we identified our second victim host from the network data.

new-host-details.png

We want to examine this host in the same way that we did for the Linux host earlier.

 

Looking at Logon Sessions

We use the time stamp of Linux host alert to automatically set the origin time for QueryTime widget. This lets us cascade the time window of the attack through all subsequent queries in the notebook. If you run the same notebook for several alerts, it’s all too easy to get things out of sync.

 

logon-query-times.png

 

Running the query over this period we get 201 distinct logins, which is a lot to sift through. We can use pandas to group the data by Account and LogonType. This shows two accounts using Remote Desktop Protocol (RDP) logons (type 10), which is a popular target for brute force attackes. The individual logon events are also shown in a timeline, with the RDP logons shown in green. Note that all of these happened well before our original Linux alert, suggesting that the Windows host was attacked first.

 

logons-by-type.png

 

In the Jupyter notebook I also show an example of using clustering to group these logons into manageable sets but for data like this, where we are grouping by just one or two discrete features (with a small number of possible values) using pandas is simpler and more understandable.

 

Having identified the subset of logons that we want to look at we can use the msticpy display_logon_data function to print out the grouped logons in a friendlier format than a table.logon-details.png

 

From the logon data for this account (see details in the notebook), we notice a few things for the “ian” account (any resemblance to persons living or dead is entirely coincidental):

  • There were a series of failed logons for this account.
  • There were some successful logons of both type 3 (Network) and type 10 (RDP)
  • At least some of these originated from our attacker IP

We now want to look at the processes that ran in these sessions, to see what our attacker was up to. Since these logons occurred significantly early than our alert, we need to set our query origin time to match the session that we are interested in. Querying for process creation events (ID 4688) for this period we get 3772 events – a lot to look through!

 

Side Note - clustering data to identify unique events

We can use a few techniques to try to remove uninteresting events from this set. For example, selecting a subset of columns (e.g. process name, command line and account) and finding the unique combinations might be good enough to eliminate most of the noise. In many cases, though, this isn’t enough.

 

It’s common to see repetitive system and administrative events that have some variable command line content but otherwise identical. For example:Repetitive commands.png

 

A human can easily recognize that these are essentially a repetition of the same process and probably not very interesting, if they occur in hundreds or thousands. What we want to do is capture the essence of the command line intent while dropping the instance-specific variables.

 

We can do that by focusing on the structure (or syntax) rather than the content of the command line. There are several ways to slice this but a simply counting common delimiter characters such as spaces, switch and path separators (-, /, \), dots, etc. can give good enough separation between variants of the same command line. By ignoring content between the separators, it also allows us to group together events with a common pattern. We could get more sophisticated by taking into account the ordering of the syntactic separators, but this usually isn’t necessary.

 

cmdline-boxplot.png

 

This partial graph shows the variability of the number of delimiters in command lines for some processes in our data set. Those with a single vertical bar indicates no variance in the samples, while others, like cmd.exe, net.exe and rundll32.exe show significant variability in their command line structure.

 

Clustering, an unsupervised machine learning method, can also help – bypassing the need (if we do it correctly) to manually group and sort the different features of our events. Most clustering algorithms require that you know the number of clusters beforehand, which, in this case, we don't. The DBSCAN algorithm, in contrast, will dynamically create new clusters and assign events to them based on a distance measure. You supply the algorithm with a set of features that are used to calculate the distance, the minimum cluster size and a distance metric. You can think of each feature as magnitude along a dimension (x, y, z and whatever comes after z) – so every process instance will have coordinates in multi-dimensional space.

 

Visualizing more than 3 dimensions is a bit tricky for most people (including me). Here is an example using just two dimensions - the process name and the command line syntax delimiters.cluster-subset.png

A single dot means that there is only one sample in the data set. Where there are multiple instances you can see horizontal banding (courtesy of the catplot function from the wonderful Seaborn package). This means that there are multiple instances that share the same command line token value. If we to draw boundaries around each grouping of command line token score and process name, we'd have our clusters.

 

Where two or more events coincide (within the minimum distance specified) they are considered part of the same cluster. Features need to be numeric and have a good separation of values across the variation that we are interested in capturing.

In our example we’ve chosen four columns to provide features for clustering:

  • Commandline (reduced to tokens)
  • NewProcessName (the process path converted to a numeric score based on character values)
  • Account (converted to a score in the same way)
  • IsSystemSession (a 1 indicates that the process is running in the system context and 0 otherwise)

Using these features, we can reduce a large event set to a more manageable set of distinct event patterns that makes viewing and analyzing much more tractable.

 

clustered-logons.png

This graph shows clustering applied to logon sessions (the duplicated items are different logon clusters because we grouped on both account name and logon type).

 

Processes in the Logon Sessions

Running our set of 3771 process events through the clustering algorithm yields 170 distinct patterns – which seems a lot more manageable. It’s possible to look through all the processes but we’re mostly interested in the processes belonging to the suspicious logon sessions. We can use a nice trick with pandas and Jupyter widgets to interactively select a session and display its processes.processes-in-logon-session.png

 

The ipywidget interactive() function in the code above binds selection events in our logon session list to the view_logon_session function. This function receives the selected value from the first list as an argument and uses the corresponding LogonId to filter and display the dataframe of processes.

 

The processes in question reveal some obvious attacker traits:

  • opening a scripted FTP session
  • enumerating and adding users
  • adding these users to the Administrators group
  • removing security protections on Terminal Services

 

Other Windows Events

In the notebook I also retrieve counts of all unique event types for each logon. This confirms the user account and group manipulation seen in the processes above as well as failed account logon and privilege assignment and other nefarious deeds.

other-events.png

 

Office 365 Data

So far, we’ve look at two examples of host investigation, network data, and TI lookups. Having Office activity data available in Azure Sentinel makes it easy to look for evidence of our attacker there as well.

 

In a real case, you might by now have accumulated several C2 IP addresses used by the attacker and need to search for these. You might also choose to look at the O365 activity related to the accounts on one or both compromised hosts.  One of our users may have left something like browsing history on the host, indicating which O365 account they own. If you can find out which O365 accounts correspond to the local user accounts, be sure to look at the activity on these accounts. You should also treat the IP addresses of the compromised hosts as now hostile and be searching for activity related to these.

 

In our simplified example we are going to limit the search to the same C2 IP that we have been pursuing throughout this blog.

 

IP Addresses Office Activity

We want to cast quite a wide net so we’ll search over several days around the time of the original alert – you’d want to have your start date earlier than the earliest evidence of an attack.office-activity-ip.png

 

We can see a few login failures as well as successful logins – maybe the attacker was trying variants of the password used on one of the hosts. The account name seems like it might be the same person whose account was broken into on the Windows host. We also see a significant number of file download operations from Sharepoint but not much else. This could be a simple attempt to exfiltrate useful data like financial reports or company confidential information of some type.

 

Note – Authentication activity is no longer logged to the O365 activity logs (as shown here). You will find this data in the Azure Active Directory SigninLogs table.

office-activity-timeline.png

 

The timeline shows these download events all happened in quick succession. This likely means a top-level folder was selected and the whole contents downloaded in one go.

 

The rapidity of these operations gives us a hint as to an alternative way of detecting this behavior without relying on the C2 IP. Using pandas time series capabilities, we can resample the data, chopping it into 10 second slices, grouped by user, IP address and operation. We can then easily query for high repetitions of events within each 10 second window.

 

high-freq-events.png

 

For a more sophisticated approach to time series analysis be sure to check our Tim Burrell’s article Time series analysis applied in a security hunting context.

 

Observation Summary

You may have noticed calls to the add_observation function appearing in the notebook (like the cell above). This a simple idea to allow you to capture data that is central to the investigation. As well as a caption (must be unique) and description, you can also capture a dataframe or other data object such as an image or plot. You can also include a link to a bookmark defined in the relevant section of the notebook (add an 'a' tag with id attribute containing the name of your bookmark at the location you want to link to, e.g. <a id="o365_logons"></a>).

 

The collected observations items are available to be displayed together at the end of the notebook using a simple for loop and the display() function. Items are displayed in the order that they were added. If you later re-run a cell that calls add_observation it will replace the original entry in its original position, provided you keep the same caption.

 

Conclusion

  • We started part 1 with a threat intelligence report and a list of IP address indicators of compromise.
  • Searching through our Azure Sentinel data we found one of these IP addresses appearing in multiple data sets.
  • One of these led us to a Linux host where we were able to confirm compromise.
  • We used network data to show the link between the host and our C2 IP, and discovered communications to another host.
  • In this part of the blog, we analyzed logon, process and other event data on a Windows host and were able to confirm that it too was compromised.
  • We introduced some techniques for aggregating data into more manageable sizes using feature extraction and cluster and also looked at using Jupyter widgets to create an interactive link between two DataFrames.
  • Finally, we confirmed that our attacker was also active in an Office account and identified a likely data exfiltration.

 

Previous Parts

References

Reading

  • Modern Pandas by Tom Augspurger
  • Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython by Wes McKinney

More Notebooks

Azure Sentinel sample Jupyter notebooks can be found here on GitHub.

Also: