Home
%3CLINGO-SUB%20id%3D%22lingo-sub-915721%22%20slang%3D%22en-US%22%3EIdentifying%20Threat%20Hunting%20opportunities%20in%20your%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-915721%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId-1846066372%22%20id%3D%22toc-hId-1846066372%22%3E%3CFONT%20size%3D%225%22%20color%3D%22%23008080%22%3E%3CSTRONG%3EKey%20Principles%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EStarting%20Point%2C%20Data%20Knowledge%20and%20Learning%2C%20Pivoting%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23008080%22%3EStarting%20Point%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EFor%20this%20article%2C%20our%20starting%20point%20will%20be%20Self-identified%20or%20Free%20Hunting%20opportunities%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20few%20items%20we%20need%20to%20understand%20when%20we%20Free%20Hunt%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWhat%20do%20you%20%3CSTRONG%3Ealready%20know%3C%2FSTRONG%3E%20about%20your%20data%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20do%20you%20%3CSTRONG%3Eneed%20to%20learn%3C%2FSTRONG%3E%20about%20your%20data%3F%3C%2FLI%3E%0A%3CLI%3EHow%20do%20you%20pivot%20in%20the%20data%20from%20one%20entity%20to%20other%20interesting%20entities%20so%20you%20can%20build%20a%20picture%20or%20story%20of%20what%20occurred%3F%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWe%20want%20to%20learn%20from%20our%20data%2C%20build%20queries%20from%20the%20learning%20to%20identify%20interesting%20hunting%20opportunities%20and%20then%20pivot%20from%20those%20items%20you%20identify%20to%20build%20an%20attack%20sequence%20or%20story.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--706090589%22%20id%3D%22toc-hId--706090589%22%3E%3CFONT%20size%3D%225%22%20color%3D%22%23008080%22%3E%3CSTRONG%3EData%20Knowledge%20and%20Learning%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23008080%22%3EData%20Knowledge%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELeverage%20your%20practical%20knowledge%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYou%20already%20have%20some%20information%20about%20your%20environment%2C%20and%20you%20may%20know%20all%20the%20datatypes%20(logs)%20you%20have%20along%20with%20the%20interesting%20properties%20in%20those%20data%20sets%2C%20but%20it%20is%20best%20to%20clearly%20document%20and%20understand%20what%20you%20know.%3C%2FP%3E%0A%3CP%3ETo%20start%20to%20build%20an%20understanding%20of%20the%20norms%20for%20your%20data%2C%20ask%20yourself%20these%20questions%20(among%20others)%20and%20this%20can%20lead%20you%20to%20hunting%20methods.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWhat%20do%20you%20know%20about%20your%20environment%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20datatypes%20do%20you%20have%20and%20what%20properties%20(entities)%20do%20they%20have%20in%20them%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20data%20types%20can%20I%20bring%20together%20to%20clarify%20activity%20when%20hunting%3F%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBuild%20a%20matrix%20of%20what%20you%20have%20and%20identify%20common%20entities%20and%20then%20you%20can%20target%20areas%20of%20opportunities.%3C%2FP%3E%0A%3CP%3EHere%20is%20an%20example%20of%20a%20matrix%20we%20put%20together%3A%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%20777px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137655i762BBC1C0023291E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22EntityTable.JPG%22%20title%3D%22EntityTable.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23008080%3B%20font-family%3A%20inherit%3B%20font-size%3A%20large%3B%22%3EData%20Learning%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELearn%20from%20your%20data%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAsk%20yourself%20some%20questions%20that%20help%20you%20identify%20an%20area%20of%20interest.%26nbsp%3B%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWhat%E2%80%99s%20anomalous%20for%20my%20environment%3F%20%E2%80%93%20We%20should%20never%20see%20an%20inbound%20connection%20via%20public%20IP%20address%20connecting%20to%20my%20internal%20web%20server%3C%2FLI%3E%0A%3CLI%3EWhat%20is%20rare%20activity%3F%20%E2%80%93%20It%20would%20be%20rare%20for%20this%20account%20type%20to%20access%20this%20system%20type%20except%20at%20a%20given%20time%20or%20during%20a%20given%20exercise%20like%20patching.%3C%2FLI%3E%0A%3CLI%3EWhat%20is%20common%3F%20%E2%80%93%20How%20can%20we%20identify%20what%20is%20common%20and%20what%20is%20rare%2C%20without%20knowing%20it%20is%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20is%20expected%3F%20%E2%80%93%20It%20is%20normal%20to%20see%20this%20type%20of%20download%20on%20my%20SharePoint%20server.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%202%2C%20Anomalous%20and%20Rare%20for%20the%20environment%20are%20really%20what%20we%20are%20trying%20to%20get%20to%20with%20our%20hunting%2C%20so%20let%E2%80%99s%20look%20at%20Common%20and%20Expected.%26nbsp%3B%20How%20do%20we%20identify%20what%20is%20Common%20or%20what%20is%20Expected%20in%20the%20environment%3F%26nbsp%3B%20How%20do%20we%20exclude%20what%20is%20expected%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EFocus%20on%20a%20specific%20datatype%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIn%20this%20case%2C%20we%20chose%20the%20SecurityEvent%20datatype%20available%20in%20Azure%20Sentinel%20as%20this%20has%20a%20rich%20set%20of%20information%20related%20to%20process%20executions%20and%20as%20it%20is%20one%20of%20the%20more%20commonly%20collected%20data%20types%2C%20it%20is%20likely%20available%20to%20most%20Azure%20Sentinel%20users%20via%20Log%20Analytics.%26nbsp%3B%20What%20do%20we%20want%20to%20know%20about%20this%20data%3F%26nbsp%3B%20Let%E2%80%99s%20use%20this%20question%20related%20to%20Commonality%20(or%20Rarity)%20-%20%E2%80%9CHow%20can%20we%20identify%20what%20is%20common%20and%20what%20is%20rare%2C%20without%20knowing%20it%20is%3F%E2%80%9D.%26nbsp%3B%20We%20can%20use%20simple%20counts%20and%20distributions%20to%20understand%20this%2C%20but%20what%20about%20using%20something%20like%20Entropy%20to%20understand%20what%20is%20Rare%20in%20my%20data%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESide%20Note%3A%3C%2FSTRONG%3E%20%3CEM%3EWe%20had%20a%20question%20asked%20to%20my%20team%20about%20using%20Entropy%20in%20determining%20Process%20rarity%20for%20Security%20Event%20data%20related%20to%20Azure%20VMs.%26nbsp%3B%20I%20am%20not%20an%20expert%20in%20this%2C%20so%20I%20did%20some%20research%20and%20found%20a%20nice%20simplified%20explanation%20of%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fmedium.com%2Fudacity%2Fshannon-entropy-information-gain-and-picking-balls-from-buckets-5810d35d54b4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EShannon%20Entropy%3C%2FEM%3E%3C%2FA%3E%3CEM%3E%20which%20I%20used%20to%20create%20a%20query%20that%20shows%20me%20Process%20Rarity%20for%20a%20given%20VM%20and%20across%20all%20VMs%20in%20the%20Azure%20environment.%3C%2FEM%3E%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%2F137656iDB4E986AFCD3732E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ShannonEntropy.jpg%22%20title%3D%22ShannonEntropy.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EWe%20won%E2%80%99t%20go%20through%20the%20specifics%20of%20the%20%3C%2FSPAN%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FHunting%2520Queries%2FSecurityEvent%2FProcessEntropy.yaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%20hunting%20query%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20that%20was%20built%20for%20this%2C%20just%20know%20that%20it%20allowed%20me%20to%20see%20something%20interesting%20in%20the%20data%20that%20I%20may%20not%20have%20seen%20as%20it%20could%20have%20been%20lost%20in%20the%20noise%20of%20data.%26nbsp%3B%20Rare%2C%20but%20maybe%20not%20rare%20enough%20to%20show%20up%20in%20other%20algorithms%20with%20more%20constraints.%20%26nbsp%3BThis%20query%20is%20not%20meant%20to%20be%20an%20alert%2C%20it%20potentially%20provides%20False%20Positives%2C%20but%20that%E2%80%99s%20fine%E2%80%A6we%20are%20hunting%20after%20all!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAgain%2C%20this%20is%20just%20one%20example%20of%20understanding%20your%20data%2C%20you%20can%20apply%20the%20same%20concepts%20to%20any%20datatype%20to%20identify%20a%20starting%20point%20for%20your%20hunting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENow%20that%20we%20understand%20our%20data%3C%2FSTRONG%3E%20and%20we%20have%20a%20query%20that%20gives%20me%20a%20view%20into%20an%20interesting%20data%20point%2C%20%3CSTRONG%3E%3CU%3Ewhat%20next%3F%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EUse%20the%20matrix%20you%20built%20above%20to%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIdentify%20common%20entities%20across%20datatypes%20(logs)%3C%2FLI%3E%0A%3CLI%3EIdentify%20the%20datatypes%20you%20think%20are%20most%20likely%20related%20and%20interesting%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThen%20Pivot%20to%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EProvide%20additional%20context%3C%2FLI%3E%0A%3CLI%3EBuild%20out%20the%20attack%20sequence%20or%20story%3C%2FLI%3E%0A%3CLI%3EEventually%20build%20custom%20alerts%20and%20hunting%20queries%20and%20where%20appropriate%20contribute%20to%20the%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%3Ecommunity%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-1036719746%22%20id%3D%22toc-hId-1036719746%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--1515437215%22%20id%3D%22toc-hId--1515437215%22%3E%3CFONT%20size%3D%225%22%20color%3D%22%23008080%22%3EPivoting%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23008080%22%3EProcess%20related%20pivoting%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELet%E2%80%99s%20see%20this%20in%20action%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EStarting%20with%20the%20home-grown%20query%20from%20above%20and%20then%20pivoting%20into%20associated%20datatypes%20to%20reveal%20the%20security%20story.%20(The%20names%20have%20been%20changed%20to%20protect%20the%20innocent.)%26nbsp%3B%20Of%20note%2C%20the%20lower%20the%20ProcessEntropy%20and%20Weight%2C%20the%20rarer%20it%20is.%20Below%20are%20the%20results%20of%20my%20ProcessEntropy%20query.%26nbsp%3B%20Sorting%20by%20Weight%20and%20ProcessEntropy%20values%20that%20are%20the%20lowest%2C%20we%20can%20see%20some%20rare%20processes%20executing.%20Near%20the%20bottom%20of%20the%20list%2C%20we%20see%20something%20more%20interesting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPstest.exe%20and%20IEX%20on%20the%20command%20line%20is%20unexpected.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.utility%2Finvoke-expression%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIEX%20is%20a%20PowerShell%20cmdlet%3C%2FA%3E%2C%20so%20clearly%20this%20coming%20from%20a%20process%20other%20than%20PowerShell%20is%20odd%2C%20so%20this%20call%20coming%20from%20a%20process%20other%20than%20PowerShell%20is%20odd.%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%2F137657i4BE0E4033BA08D5D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22IEX.JPG%22%20title%3D%22IEX.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ENow%20that%20we%20have%20the%20entities%20(TimeGenerated%2C%20Computer%2C%20Account%20and%20so%20on)%20listed%20above%2C%20we%20are%20probably%20interested%20in%20what%20all%20occurred%20around%20this%20time.%26nbsp%3B%20I%20can%20take%20existing%20queries%20in%20Azure%20Sentinel%20and%20modify%20them%20slightly%20for%20my%20needs.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20we%20may%20be%20interested%20in%20what%20occurred%20along%20with%20the%20activity%20identified%20in%20my%20ProcessEntropy%20query%20above%20and%20we%20will%20want%20to%20be%20able%20to%20decode%20that%20string%20so%20we%20can%20verify%20if%20it%20is%20malicious%20or%20expected%20behavior.%26nbsp%3B%20By%20looking%20at%20the%20Analytics%20tab%20in%20Azure%20Sentinel%20we%20can%20see%20various%20associated%20queries%20for%20the%20Data%20Source%20(datatype)%20of%20SecurityEvent.%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%2F137658i605C2C8CB8FF3030%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ProcessEntropyAlert.JPG%22%20title%3D%22ProcessEntropyAlert.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3ESpecifically%2C%20look%20at%20%3C%2FSPAN%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3ENew%20processes%20observed%20in%20the%20last%2024%20hours%20%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Ehunting%20query%20and%20use%20that%20as%20my%20starter.%26nbsp%3B%20Simply%20choose%20that%20query%20and%20select%20%3C%2FSPAN%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3EView%20Results%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20which%20will%20take%20you%20directly%20into%20the%20Log%20Analytics%20blade.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EModify%20the%20query%20to%20include%20only%20the%20Computer%20we%20are%20interested%20in.%26nbsp%3B%20In%20this%20query%2C%20we%20aggregate%20the%20Computers%20into%20one%20field%2C%20so%20we%20would%20use%20the%20following%20to%20get%20only%20the%20Computer%20we%20are%20interested%20in%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20where%20Computers%20has%20%22GodzillaProd1%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdditionally%2C%20we%20want%20to%20decode%20the%20base64%20string%20to%20determine%20what%20is%20occurring.%20%26nbsp%3BTwo%20methods%20of%20parsing%20the%20string%20are%20shown%20below%2C%26nbsp%3Bone%20via%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fparseoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eparse%20operator%3C%2FA%3E%20and%20another%20via%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fsplitfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Esplit%20function%3C%2FA%3E%2C%20and%20then%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fbase64_decode_tostringfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ebase64%20decode%20function%3C%2FA%3E%20used.%26nbsp%3BAdditional%20methods%20of%20decoding%20are%20also%20available%20when%20using%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fmsticpy%2Fsectools%2Fbase64unpack.py%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EJupyter%20and%20MSTICPY%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20parse%20ProcessCommandLine%20with%20*%20%22FromBase64STring('%22%20parse_Base64%20%22'%22%20*%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20extend%20split_Base64%20%3D%20tostring(split(tostring(split(ProcessCommandLine%2C%20%22('%22)%5B-1%5D)%2C%22')%22)%5B0%5D)%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20extend%20split_Decoded%20%3D%20base64_decodestring(split_Base64)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20we%20run%20the%20query%2C%20we%20can%20see%20the%20decoded%20results%2C%20and%20this%20looks%20potentially%20bad.%26nbsp%3B%20Generally%2C%20downloading%20information%20gathering%20tools%2C%20such%20as%20Sysinternal%20tools%2C%20via%20encoded%20scripts%20is%20something%20done%20to%20hide%20activity.%26nbsp%3B%20We%20will%20want%20to%20investigate%20this%20further%3A%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%20829px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137661i5FF40226506AD697%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Base64Decode.JPG%22%20title%3D%22Base64Decode.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20we%20are%20pretty%20sure%20this%20is%20at%20a%20minimum%20unwanted%20behavior%20or%20more%20likely%20malicious%2C%20we%20need%20to%20build%20the%20attack%20sequence%20or%20story.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20are%20my%20next%20steps%3F%3C%2FSTRONG%3E%20%E2%80%93%20Let%E2%80%99s%20ask%20questions%20about%20the%20entities%20we%20have.%26nbsp%3B%20Some%20questions%20we%20would%20ask%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWhat%20datatypes%20do%20we%20have%20where%20we%20can%20see%20what%20happened%20related%20to%20network%20connections%20so%20we%20can%20get%20the%20related%20IP%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20datatypes%20do%20we%20have%20that%20show%20group%20memberships%20for%20the%20account%3F%3C%2FLI%3E%0A%3CLI%3EWhat%20datatypes%20do%20we%20have%20in%20cloud%20specific%20services%20that%20can%20show%20us%20activity%20related%20to%20the%20account%3F%3C%2FLI%3E%0A%3CLI%3EHow%20far%20widespread%20is%20this%3F%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ETo%20help%20understand%20what%20datatypes%20contain%20your%20interesting%20entity%2C%20search%20on%20them%2C%20just%20be%20sure%20to%20scope%20the%20time%20properly.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20we%20can%20see%20which%20datatypes%20have%20information%20about%20one%20of%20the%20interesting%20accounts%3A%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%20498px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137663i9253D4BA68C03773%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22SearchExample1.JPG%22%20title%3D%22SearchExample1.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CFONT%20color%3D%22%23008080%22%3ENetwork%20related%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23008080%22%3EPivoting%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELet%E2%80%99s%20look%20at%20how%20the%20VM%20shows%20up%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIn%20the%20cloud%20data%3C%2FSTRONG%3E%20and%20specifically%20some%20network%20details.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20know%20the%20Computer%20name%20where%20the%20initial%20hits%20were%20determined%20and%20so%20we%20can%20look%20at%20the%20Heartbeat%20table%20to%20see%20what%20the%20IP%20is%20for%20the%20VM.%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%20477px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137664i215C9D7175D4D753%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22HeartBeat.JPG%22%20title%3D%22HeartBeat.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20this%20point%2C%20we%20can%20easily%20pivot%20into%20the%20network%20data%2C%20in%20this%20case%20WireData%20related%20to%20the%20IP%20of%20the%20VM.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20good%20thing%20to%20look%20for%20is%20to%20see%20what%20Outbound%20connections%20have%20occurred%20and%20if%20there%20is%20outbound%20data%20transfer.%3C%2FP%3E%0A%3CP%3EWe%20have%20a%20query%20for%20that%20looks%20for%20outbound%20connections%20and%20it%20looks%20for%20only%20public%20connections%20by%20excluding%20connections%20to%20internal%20IPs%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3Elet%20PrivateIPregex%20%3D%20%40'%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.'%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3EWireData%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20where%20TimeGenerated%20between%20(ago(starttime)..ago(endtime))%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20where%20Direction%20%3D%3D%20%22Outbound%22%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20extend%20RemoteIPType%20%3D%20iff(RemoteIP%20matches%20regex%20PrivateIPregex%2C%22private%22%20%2C%22public%22%20)%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%7C%20where%20RemoteIPType%20%3D%3D%22public%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20query%20results%20show%20that%20we%20do%20have%20connections%20to%20an%20external%20IP%20with%20around%209mb%20of%20data%20sent.%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%2F137665iA72A26FBB7EF33F1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22WireDATA.JPG%22%20title%3D%22WireDATA.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20next%20want%20to%20see%20if%20your%20curated%20Bring%20Your%20Own%20Threat%20Intel%20(BYOTI)%20has%20any%20references%20to%20this%20IP%20so%20we%20can%20further%20validate%20malicious%20activity.%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%2F137666i513EC02E6BE8E76B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ThreatIntelSample.JPG%22%20title%3D%22ThreatIntelSample.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20be%20asking%20why%20no%20alert%20was%20fired%20for%20this.%26nbsp%3B%20There%20potentially%20could%20have%20been%20an%20alert%2C%20but%20in%20this%20case%2C%20this%20was%20in%20custom%20BYOTI%20that%20was%20added%20after%20the%20malicious%20activity%20already%20occurred%2C%20so%20it%20was%20not%20available%20at%20the%20time%20of%20the%20attack.%20%26nbsp%3BTherefore%2C%20it%20is%20important%20to%20use%20multiple%20methods%20across%20time%20to%20identify%20malicious%20behavior.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20now%20know%20that%20this%20is%20malicious%2C%20and%20we%20need%20to%20understand%20what%20else%20happened.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23008080%22%3EAccount%20Related%20Pivoting%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELet%E2%80%99s%20look%20at%20what%20groups%20may%20be%20involved%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20%E2%80%9Cbaduser%E2%80%9D%20and%20%E2%80%9Cshainw%E2%80%9D%20accounts%20identified%20initially%20will%20provide%20us%20our%20pivot%20point.%26nbsp%3B%20We%20have%20some%20built%20in%20hunting%20queries%20that%20will%20help%20us.%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%2F137667i2DB3DF42BDEB927B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22UserAddedtoPrivGroup.JPG%22%20title%3D%22UserAddedtoPrivGroup.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20great%20thing%20about%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FHunting%2520Queries%2FSecurityEvent%2FUserAccountAddedToPrivlegeGroup.yaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Equery%3C%2FA%3E%2C%20is%20we%20have%20already%20included%20WellKnownLocalSID%20and%20WellKnownGroupSID%20mappings%20for%20you%20to%20see%20if%20there%20was%20addition%20to%20a%20high%20privilege%20group.%26nbsp%3B%20As%20you%20can%20see%20below%2C%20the%20%E2%80%9Cbad%20user%E2%80%9D%20was%20added%20to%20the%20Builtin%5CAdministrators%20group%20by%20the%20%E2%80%9Cshainw%E2%80%9D%20account.%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%20779px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137669i0270B21D56758C6A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22UserAddedtoPrivGroupQuery.JPG%22%20title%3D%22UserAddedtoPrivGroupQuery.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENow%20let%E2%80%99s%20see%20what%20the%20cloud%20specific%20logs%20show%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EFor%20the%20accounts%20we%20are%20interested%20in%2C%20what%20do%20we%20know%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWe%20know%20the%20%E2%80%9Cshainw%E2%80%9D%20account%20added%20in%20the%20%E2%80%9Cbad%20user%E2%80%9D%20account%3C%2FLI%3E%0A%3CLI%3EWe%20can%20assume%20%E2%80%9Cshainw%E2%80%9D%20is%20compromised%3C%2FLI%3E%0A%3CLI%3EWe%20know%20this%20account%20has%20Azure%20level%20access%2C%20just%20not%20sure%20exactly%20what%20level.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWe%20have%20this%20information%20from%20the%20Security%20Events%3A%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%2F137670i9989DB0BC7DC8ADE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22UserAddedtoPrivGroupResult.JPG%22%20title%3D%22UserAddedtoPrivGroupResult.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20same%20concept%20of%20groups%20applies%20to%20AzureAD%2C%20we%20need%20to%20see%20if%20the%20%E2%80%9Cshainw%E2%80%9D%20account%20added%20any%20users%20to%20any%20groups%20in%20Azure.%26nbsp%3B%20Here%20we%20will%20look%20for%20when%20a%20member%20is%20added%20to%20a%20group%20in%20Azure%20and%20specifically%20Initiated%20by%20our%20known%20high%20privileged%20account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20the%20user%20shainw%40godzillanet.com%20added%20baduser%40godzillanet.com%20to%20the%20CloudAdmins%20group.%26nbsp%3B%20Not%20good.%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%2F137671iE51B3E2D5F2E41FE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22AuditLogs.JPG%22%20title%3D%22AuditLogs.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThings%20seem%20to%20be%20getting%20worse%20and%20now%20you%20remember%20that%20your%20WireData%20showed%20a%20good%20size%20of%20data%20sent%20from%20the%20VM%20that%20was%20compromised.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-227373120%22%20id%3D%22toc-hId-227373120%22%3E%3CFONT%20size%3D%225%22%20color%3D%22%23008080%22%3EData%20Exfiltration%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3E%3CSTRONG%3ENow%20let%E2%80%99s%20see%20what%20might%20have%20been%20taken.%3C%2FSTRONG%3E%3CSTRONG%3E%26nbsp%3B%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThere%20are%20potentially%20many%20datatypes%20to%20look%20at%2C%20but%20we%20will%20be%20smart%20and%20identify%20where%20this%20baduser%20shows%20up%20first%2C%20before%20digging%20in%20any%20deeper.%26nbsp%3B%20Here%20is%20where%20we%20can%20use%20the%20search%20feature%20again.%26nbsp%3B%20We%20can%20clearly%20see%20below%20that%20the%20account%20shows%20up%20in%20many%20logs%20and%20very%20interestingly%20in%20OfficeActivity.%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%20834px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137673i5045402B919B7E9C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22SearchExample2.JPG%22%20title%3D%22SearchExample2.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EProbably%20getting%20a%20bit%20nervous%20now%20that%20we%20know%20there%20is%20a%20compromise%20and%20maybe%20data%20was%20pulled%20from%20the%20environment%2C%20but%20what%20data%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20are%20most%20interested%20in%20the%20OfficeActivity%20data%20as%20we%20know%20emails%20and%20documents%20flow%20through%20that%20space.%26nbsp%3B%20Looking%20up%20the%20UserKey%20for%20our%20account%20indicates%20some%20very%20useful%20information%20was%20accessed%20by%20the%20adversary%20during%20the%20attack.%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%2F137675i060970DF27F3CE29%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22OfficeActivity.JPG%22%20title%3D%22OfficeActivity.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20widespread%20is%20this%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAs%20we%20are%20getting%20a%20bit%20long%20on%20this%20investigation%2C%20we%20will%20only%20do%20one%20more%20pivot%20back%20into%20the%20VM%20and%20on-prem%20side.%26nbsp%3B%20Let%E2%80%99s%20just%20have%20a%20quick%20look%20at%20what%20Computers%20and%20Resources%20this%20account%20may%20have%20shown%20up%20on%3A%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%20655px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137676i13A64BD25D0365DC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22SearchExample3.JPG%22%20title%3D%22SearchExample3.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1970183455%22%20id%3D%22toc-hId-1970183455%22%3E%3CFONT%20color%3D%22%23008080%22%3ESummary%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EIn%20summary%2C%20discovery%20of%20malicious%20activity%20can%20be%20found%20in%20many%20ways%2C%20this%20is%20just%20one%20method%20used%20by%20Threat%20Hunters%20at%20Microsoft.%26nbsp%3B%20Go%20find%20your%20next%20adversary%20and%20share%20your%20findings%20with%20the%20community.%26nbsp%3B%20Some%20of%20the%20activity%20identified%20in%20this%20blog%20is%20generally%20available%20as%20Detections%20or%20Hunting%20Queries%20in%20the%20Azure%20Sentinel%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%3EGitHub%3C%2FA%3E.%26nbsp%3B%20There%20is%20opportunity%20for%20other%20Detections%20and%20Hunting%20Queries%20that%20we%20will%20continue%20to%20produce%20over%20time.%26nbsp%3B%20Feel%20free%20to%20improve%20the%20current%20queries%20or%20come%20up%20with%20your%20own%20queries%20for%20pivoting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOur%20mission%3A%20There%20are%20always%20new%20attack%20techniques%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGo%20Discover%20it%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20Detection%20or%20Hunting%20query%20for%20it%3C%2FLI%3E%0A%3CLI%3EShare%20the%20query%20with%20the%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%3Ecommunity%20GitHub%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EYour%20query%20may%20eventually%20be%20included%20in%20the%20Detection%20or%20Hunting%20sections%20of%20Azure%20Sentinel%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23008080%22%3EResources%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAzure%20Logging%20and%20Auditing%20-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsecurity%2Ffundamentals%2Flog-audit%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsecurity%2Ffundamentals%2Flog-audit%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EKQL%20used%20in%20Log%20Analytics%20queries%20-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flog-query%2Fquery-language%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flog-query%2Fquery-language%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EMSTICPY%20Github%20-%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%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAzure%20Resource%20Explorer%20-%20%3CA%20href%3D%22https%3A%2F%2Fresources.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fresources.azure.com%2F%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAzure%20Sentinel%20GitHub%20-%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%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAzure%20Sentinel%20Tech%20Community%20Blog%20%E2%80%93%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2Fbg-p%2FAzureSentinelBlog%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2Fbg-p%2FAzureSentinelBlog%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EGA%20announcement%20-%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fsecurity%2Fblog%2F2019%2F09%2F24%2Fazure-sentinel-cloud-native-siem-empowers-defenders-generally-available%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fsecurity%2Fblog%2F2019%2F09%2F24%2Fazure-sentinel-cloud-native-siem-empowers-defenders-generally-available%2F%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%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-915721%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20Sentinel%20allows%20for%20a%20very%20nice%20investigation%20experience%20when%20pivoting%20on%20interesting%20entities%20that%20are%20brought%20to%20you%20via%20Analytics%20and%20Hunting%20queries.%26nbsp%3B%20Threat%20Hunters%20also%20review%20security%20blogs%2C%20discuss%20security%20issues%20with%20community%20groups%2C%20look%20at%20attack%20sequences%20based%20on%20alerts%20and%20so%20on.%20These%20are%20all%20examples%20of%20directed%20or%20provided%20threat%20hunting%20opportunities.%26nbsp%3B%20What%20about%20self-identifying%20threat%20hunting%20opportunities%2C%20or%20what%20we%20call%20%E2%80%9CFree%20Hunting%E2%80%9D%3F%26nbsp%3B%20There%20are%20a%20multitude%20of%20ways%20to%20start%20hunting%20in%20your%20Azure%20Sentinel%20data%20via%20Log%20Analytics%20and%20we%20will%20provide%20just%20one%20of%20the%20methods%20of%20doing%20so%20in%20this%20article.%26nbsp%3B%20This%20article%20is%20meant%20to%20share%20a%20method%20or%20process%20for%20threat%20hunting%2C%20it%20is%20not%20meant%20to%20be%20exhaustive%20nor%20prescriptive%20and%20does%20not%20include%20many%20post-hunting%20steps%20such%20as%20Alert%20Creation%2C%20Eviction%2C%20Remediation%20and%20so%20on.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-915721%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Key Principles

Starting Point, Data Knowledge and Learning, Pivoting

Starting Point

For this article, our starting point will be Self-identified or Free Hunting opportunities

 

A few items we need to understand when we Free Hunt:

  • What do you already know about your data?
  • What do you need to learn about your data?
  • How do you pivot in the data from one entity to other interesting entities so you can build a picture or story of what occurred?

We want to learn from our data, build queries from the learning to identify interesting hunting opportunities and then pivot from those items you identify to build an attack sequence or story.

 

Data Knowledge and Learning

 

Data Knowledge

Leverage your practical knowledge

You already have some information about your environment, and you may know all the datatypes (logs) you have along with the interesting properties in those data sets, but it is best to clearly document and understand what you know.

To start to build an understanding of the norms for your data, ask yourself these questions (among others) and this can lead you to hunting methods.

 

  • What do you know about your environment?
  • What datatypes do you have and what properties (entities) do they have in them?
  • What data types can I bring together to clarify activity when hunting?

Build a matrix of what you have and identify common entities and then you can target areas of opportunities.

Here is an example of a matrix we put together:

 

EntityTable.JPG

 

Data Learning

Learn from your data

Ask yourself some questions that help you identify an area of interest.  For example:

 

  • What’s anomalous for my environment? – We should never see an inbound connection via public IP address connecting to my internal web server
  • What is rare activity? – It would be rare for this account type to access this system type except at a given time or during a given exercise like patching.
  • What is common? – How can we identify what is common and what is rare, without knowing it is?
  • What is expected? – It is normal to see this type of download on my SharePoint server.

 

The first 2, Anomalous and Rare for the environment are really what we are trying to get to with our hunting, so let’s look at Common and Expected.  How do we identify what is Common or what is Expected in the environment?  How do we exclude what is expected?

 

Focus on a specific datatype

In this case, we chose the SecurityEvent datatype available in Azure Sentinel as this has a rich set of information related to process executions and as it is one of the more commonly collected data types, it is likely available to most Azure Sentinel users via Log Analytics.  What do we want to know about this data?  Let’s use this question related to Commonality (or Rarity) - “How can we identify what is common and what is rare, without knowing it is?”.  We can use simple counts and distributions to understand this, but what about using something like Entropy to understand what is Rare in my data?

 

Side Note: We had a question asked to my team about using Entropy in determining Process rarity for Security Event data related to Azure VMs.  I am not an expert in this, so I did some research and found a nice simplified explanation of Shannon Entropy which I used to create a query that shows me Process Rarity for a given VM and across all VMs in the Azure environment.

 

ShannonEntropy.jpg

 

We won’t go through the specifics of the Azure Sentinel hunting query that was built for this, just know that it allowed me to see something interesting in the data that I may not have seen as it could have been lost in the noise of data.  Rare, but maybe not rare enough to show up in other algorithms with more constraints.  This query is not meant to be an alert, it potentially provides False Positives, but that’s fine…we are hunting after all!

 

Again, this is just one example of understanding your data, you can apply the same concepts to any datatype to identify a starting point for your hunting.

 

Now that we understand our data and we have a query that gives me a view into an interesting data point, what next?

Use the matrix you built above to:

  • Identify common entities across datatypes (logs)
  • Identify the datatypes you think are most likely related and interesting

Then Pivot to:

  • Provide additional context
  • Build out the attack sequence or story
  • Eventually build custom alerts and hunting queries and where appropriate contribute to the community

 

Pivoting

Process related pivoting

 

Let’s see this in action

Starting with the home-grown query from above and then pivoting into associated datatypes to reveal the security story. (The names have been changed to protect the innocent.)  Of note, the lower the ProcessEntropy and Weight, the rarer it is. Below are the results of my ProcessEntropy query.  Sorting by Weight and ProcessEntropy values that are the lowest, we can see some rare processes executing. Near the bottom of the list, we see something more interesting.

 

Pstest.exe and IEX on the command line is unexpected. IEX is a PowerShell cmdlet, so clearly this coming from a process other than PowerShell is odd, so this call coming from a process other than PowerShell is odd.

 

IEX.JPG

 

Now that we have the entities (TimeGenerated, Computer, Account and so on) listed above, we are probably interested in what all occurred around this time.  I can take existing queries in Azure Sentinel and modify them slightly for my needs.

 

For example, we may be interested in what occurred along with the activity identified in my ProcessEntropy query above and we will want to be able to decode that string so we can verify if it is malicious or expected behavior.  By looking at the Analytics tab in Azure Sentinel we can see various associated queries for the Data Source (datatype) of SecurityEvent.

 

ProcessEntropyAlert.JPG

 

Specifically, look at New processes observed in the last 24 hours hunting query and use that as my starter.  Simply choose that query and select View Results which will take you directly into the Log Analytics blade.

Modify the query to include only the Computer we are interested in.  In this query, we aggregate the Computers into one field, so we would use the following to get only the Computer we are interested in:

 

| where Computers has "GodzillaProd1"

 

Additionally, we want to decode the base64 string to determine what is occurring.  Two methods of parsing the string are shown below, one via the parse operator and another via the split function, and then a base64 decode function used. Additional methods of decoding are also available when using Jupyter and MSTICPY.

 

| parse ProcessCommandLine with * "FromBase64STring('" parse_Base64 "'" *

| extend split_Base64 = tostring(split(tostring(split(ProcessCommandLine, "('")[-1]),"')")[0])

| extend split_Decoded = base64_decodestring(split_Base64) 

 

When we run the query, we can see the decoded results, and this looks potentially bad.  Generally, downloading information gathering tools, such as Sysinternal tools, via encoded scripts is something done to hide activity.  We will want to investigate this further:

 

Base64Decode.JPG

 

Now that we are pretty sure this is at a minimum unwanted behavior or more likely malicious, we need to build the attack sequence or story.

 

What are my next steps? – Let’s ask questions about the entities we have.  Some questions we would ask:

  • What datatypes do we have where we can see what happened related to network connections so we can get the related IP?
  • What datatypes do we have that show group memberships for the account?
  • What datatypes do we have in cloud specific services that can show us activity related to the account?
  • How far widespread is this?

To help understand what datatypes contain your interesting entity, search on them, just be sure to scope the time properly.

For example, we can see which datatypes have information about one of the interesting accounts:

 

SearchExample1.JPG

 

Network related Pivoting

 

Let’s look at how the VM shows up

In the cloud data and specifically some network details. 

We know the Computer name where the initial hits were determined and so we can look at the Heartbeat table to see what the IP is for the VM.

 

HeartBeat.JPG

 

At this point, we can easily pivot into the network data, in this case WireData related to the IP of the VM. 

A good thing to look for is to see what Outbound connections have occurred and if there is outbound data transfer.

We have a query for that looks for outbound connections and it looks for only public connections by excluding connections to internal IPs:

 

let PrivateIPregex = @'^127\.|^10\.|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168\.';

WireData

| where TimeGenerated between (ago(starttime)..ago(endtime))

| where Direction == "Outbound"

| extend RemoteIPType = iff(RemoteIP matches regex PrivateIPregex,"private" ,"public" )

| where RemoteIPType =="public"

 

The query results show that we do have connections to an external IP with around 9mb of data sent.

 

WireDATA.JPG

 

We next want to see if your curated Bring Your Own Threat Intel (BYOTI) has any references to this IP so we can further validate malicious activity.

 

ThreatIntelSample.JPG

 

You may be asking why no alert was fired for this.  There potentially could have been an alert, but in this case, this was in custom BYOTI that was added after the malicious activity already occurred, so it was not available at the time of the attack.  Therefore, it is important to use multiple methods across time to identify malicious behavior.

 

We now know that this is malicious, and we need to understand what else happened. 

 

Account Related Pivoting

 

Let’s look at what groups may be involved

The “baduser” and “shainw” accounts identified initially will provide us our pivot point.  We have some built in hunting queries that will help us.

 

UserAddedtoPrivGroup.JPG

 

The great thing about this query, is we have already included WellKnownLocalSID and WellKnownGroupSID mappings for you to see if there was addition to a high privilege group.  As you can see below, the “bad user” was added to the Builtin\Administrators group by the “shainw” account.

 

UserAddedtoPrivGroupQuery.JPG

 

Now let’s see what the cloud specific logs show

For the accounts we are interested in, what do we know:

  • We know the “shainw” account added in the “bad user” account
  • We can assume “shainw” is compromised
  • We know this account has Azure level access, just not sure exactly what level.

We have this information from the Security Events:

 

UserAddedtoPrivGroupResult.JPG

 

The same concept of groups applies to AzureAD, we need to see if the “shainw” account added any users to any groups in Azure.  Here we will look for when a member is added to a group in Azure and specifically Initiated by our known high privileged account.

 

As you can see, the user shainw@godzillanet.com added baduser@godzillanet.com to the CloudAdmins group.  Not good.

 

AuditLogs.JPG

 

Things seem to be getting worse and now you remember that your WireData showed a good size of data sent from the VM that was compromised.

 

Data Exfiltration

Now let’s see what might have been taken. 

There are potentially many datatypes to look at, but we will be smart and identify where this baduser shows up first, before digging in any deeper.  Here is where we can use the search feature again.  We can clearly see below that the account shows up in many logs and very interestingly in OfficeActivity.

 

SearchExample2.JPG

 

Probably getting a bit nervous now that we know there is a compromise and maybe data was pulled from the environment, but what data? 

 

We are most interested in the OfficeActivity data as we know emails and documents flow through that space.  Looking up the UserKey for our account indicates some very useful information was accessed by the adversary during the attack.

 

OfficeActivity.JPG

 

How widespread is this?

As we are getting a bit long on this investigation, we will only do one more pivot back into the VM and on-prem side.  Let’s just have a quick look at what Computers and Resources this account may have shown up on:

 

SearchExample3.JPG

 

Summary

In summary, discovery of malicious activity can be found in many ways, this is just one method used by Threat Hunters at Microsoft.  Go find your next adversary and share your findings with the community.  Some of the activity identified in this blog is generally available as Detections or Hunting Queries in the Azure Sentinel GitHub.  There is opportunity for other Detections and Hunting Queries that we will continue to produce over time.  Feel free to improve the current queries or come up with your own queries for pivoting.

 

Our mission: There are always new attack techniques

  • Go Discover it
  • Create a Detection or Hunting query for it
  • Share the query with the community GitHub
  • Your query may eventually be included in the Detection or Hunting sections of Azure Sentinel

 

Resources