%3CLINGO-SUB%20id%3D%22lingo-sub-1579484%22%20slang%3D%22en-US%22%3EGuided%20Hunting%20Notebook%3A%20Base64-Encoded%20Linux%20Commands%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579484%22%20slang%3D%22en-US%22%3E%3CP%3EMSTIC%20has%20observed%20an%20increasing%20number%20of%20Linux%20attackers%20encoding%20their%20scripts%20into%20Base64%20both%20for%20ease%20of%20use%20and%20to%20avoid%20detection.%20Because%20the%20commands%20are%20encoded%2C%20it%20can%20be%20time-intensive%20and%20inefficient%20to%20hone%20in%20on%20malicious%20Base64-encoded%20commands%20by%20looking%20at%20raw%20log%20data.%20To%20solve%20this%20problem%2C%20we%20have%20created%20a%20Jupyter%20notebook%20that%20makes%20this%20process%20easier%20by%20scoring%20and%20ranking%20Base64%20commands%20found%20in%20your%20Sentinel%20data.%20This%20notebook%20can%20be%20accessed%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel-Notebooks%2Fblob%2Fmaster%2FGuided%2520Hunting%2520-%2520Base64-Encoded%2520Linux%2520Commands.ipynb%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%26nbsp%3Band%20will%20be%20explained%20in%20detail%20in%20this%20blog.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20blog%20series%20written%20last%20year%20covers%20the%20use%20of%20Jupyter%20notebooks%20in%20threat%20hunting%20in%20more%20detail.%20Here%20are%20links%20to%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%2C%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%2C%3C%2FA%3E%26nbsp%3Band%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fsecurity-investigation-with-azure-sentinel-and-jupyter-notebooks%2Fba-p%2F561413%22%20target%3D%22_self%22%3EPart%203%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOther%20notebooks%20you%20can%20access%20now%20are%20available%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel-Notebooks%2Ftree%2F4d7a341abfab3955dedc278dc9431c4d38c6e2e5%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%20Notebook%20Github%3C%2FA%3E%20and%20cover%20Windows%20host%20exploration%2C%20IP%20Addresses%2C%20Domains%20%26amp%3B%20URLs%2C%20Linux%20hosts%2C%20and%20much%20more.%20These%20notebooks%20are%20all%20built%20using%20Microsoft%20Threat%20Intelligence%20Center%E2%80%99s%20Python%20API%20%3CA%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Findex.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMSTICpy%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EPlease%20note%20that%20all%20notebooks%20are%20live%20on%20Github%20and%20under%20revision%20so%20be%20aware%20that%20the%20notebooks%20you%20use%20might%20be%20slightly%20different%20from%20those%20described%20in%20blog%20posts.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1295210253%22%20id%3D%22toc-hId--1295210281%22%3EIntro%3C%2FH2%3E%0A%3CP%3EMany%20of%20our%20Azure%20customers%20use%20Linux%20virtual%20machines%2C%20and%20we%20are%20always%20looking%20for%20ways%20to%20help%20our%20customers%20in%20their%20security%20investigations.%20Thus%2C%20we%E2%80%99ve%20been%20working%20on%20expanding%20coverage%20on%20Linux-specific%20investigations.%20This%20Guided%20Hunting%3A%20Base64-Encoded%20Linux%20Commands%20Notebook%20was%20created%20in%20response%20to%20an%20increasing%20number%20of%20attackers%20encoding%20their%20bash%20commands%20into%20Base64.%20This%20is%20often%20seen%20in%20crypto%20mining%20attacks.%20A%20specific%20case%20of%20this%20is%20discussed%20and%20analyzed%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Flearning-from-cryptocurrency-mining-attack-scripts-on-linux%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20notebook%20attempts%20to%20query%20for%20and%20analyze%20Base64-encoded%20commands%20found%20in%20execve%20logs%20in%20your%20Azure%20Sentinel%20workspace.%20It%20then%20walks%20you%20through%20an%20investigation%20and%20scoring%20process%20that%20will%20highlight%20the%20commands%20most%20likely%20to%20be%20malicious%2C%20which%20can%20focus%20your%20investigation%20down%20to%20individual%20hosts%20and%20lead%20to%20further%20exploration%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fexplorer-notebook-series-the-linux-host-explorer%2Fba-p%2F1138273%22%20target%3D%22_self%22%3ELinux%20Host%20Explorer%20Notebook%3C%2FA%3E%20or%20any%20other%20tools%20and%20methodologies%20you%20prefer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20blog%20will%20walk%20you%20through%20the%20setup%20and%20use%20of%20this%20notebook.%20It%20may%20be%20helpful%20to%20run%20the%20notebook%20yourself%20as%20you%20read%20through%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1192302580%22%20id%3D%22toc-hId-1192302552%22%3EAUOMS%20Agent%20Setup%3C%2FH2%3E%0A%3CP%3EAUOMS%20is%20a%20Microsoft%20audit%20collection%20tool%20that%20can%20collect%20events%20from%20kaudit%20or%20auditd%2Faudisp.%20The%20MSTIC%20research%20branch%20of%20it%20can%20forward%20events%20to%20Syslog%2C%20which%20can%20be%20collected%20and%20accessed%20on%20Azure%20Sentinel%20(see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsentinel%2Fconnect-syslog%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20link%3C%2FA%3E%20for%20more%20information%20on%20collecting%20Syslog%20in%20Sentinel)%2C%20making%20it%20a%20great%20option%20for%20collecting%20command%20line%20data%20and%20parsing%20it%20for%20Base64%20encodings.%20It%20can%20also%20be%20used%20for%20other%20command%20line%20parsing%2C%20which%20you%20can%20explore%20through%20your%20own%20Jupyter%20Notebooks%20or%20through%20queries%20on%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAUOMS%20can%20be%20installed%20and%20set%20up%20through%20the%20Linux%20terminal.%20You%20will%20need%20to%20install%20it%20on%20each%20host%20you%E2%80%99d%20like%20to%20collect%20data%20from%20in%20your%20Log%20Analytics%20workspace.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fhunting-threats-on-linux-with-azure-sentinel%2Fba-p%2F1344431%23%22%20target%3D%22_self%22%3EThis%20blog%3C%2FA%3E%20covers%20the%20installation%20and%20troubleshooting%20options%20in%20detail%2C%20as%20well%20as%20how%20you%20can%20create%20a%20Log%20Analytics%20workspace.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%E2%80%99ve%20installed%20AUOMS%2C%20you%20may%20want%20to%20check%20if%20the%20currently%20distributed%20version%20from%20Log%20Analytics%2FAzure%20Sentinel%20includes%20the%20Syslog%20output%20option%20by%20default.%20Do%20this%20by%20running%20the%20following%20code%20from%20the%20terminal%20of%20the%20machine%20you%20want%20to%20test%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%2Fopt%2Fmicrosoft%2Fauoms%2Fbin%2Fauomsctl%20status%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20will%20check%20if%20AUOMS%20running%20and%20reveal%20its%20version%20if%20it%20is.%20If%20the%20version%20is%202.1.8%20then%20it%20should%20include%20the%20Syslog%20output%20option.%20This%20means%20that%20if%20you%20put%20the%20syslog.conf%20file%20from%20the%20MSTIC-Research%20repo%20into%20the%20%2Fetc%2Fopt%2Fmicrosoft%2Fauoms%2Foutput.d%20directory%20and%20restart%20AUOMS%20it%20should%20start%20outputting%20to%20Syslog.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20also%20want%20to%20check%20out%20some%20of%20-ERR%3AREF-NOT-FOUND-these%20parsers%20to%20test%20your%20system%20once%20AUOMS%20is%20installed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20your%20machines%20connected%20to%20Log%20Analytics%2C%20you%20can%20run%20the%20parsing%20queries%20by%20following%20these%20steps%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGo%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%2F%23home%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Portal%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3ESearch%20for%20%E2%80%9CAzure%20Sentinel%E2%80%9D%20in%20the%20search%20bar%20and%20press%20enter%3C%2FLI%3E%0A%3CLI%3EChoose%20your%20workspace%3C%2FLI%3E%0A%3CLI%3EClick%20%E2%80%9CLogs%E2%80%9D%20on%20the%26nbsp%3Bsidebar%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22sentinel2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211526i840CDD10380EF8A7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22sentinel2.png%22%20alt%3D%22sentinel2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EType%20and%20run%20your%20query%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22sentinel3.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211527i8E4246D47A7B74FB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22sentinel3.PNG%22%20alt%3D%22sentinel3.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20query%20is%20available%20in%20the%20-ERR%3AREF-NOT-FOUND-SyslogExecve.txt%20file%26nbsp%3Bfound%20in%20the%20Git%20repo.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--615151883%22%20id%3D%22toc-hId--615151911%22%3ESetting%20Up%20Jupyter%20Notebooks%3C%2FH2%3E%0A%3CP%3EYou%20can%20run%20this%20notebook%20in%20Azure%20via%20Azure%20Sentinel's%20notebook%20feature%20or%20locally.%20To%20run%20the%20notebook%20on%20Azure%2C%20see%20-ERR%3AREF-NOT-FOUND-this%20link.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20never%20run%20a%20Jupyter%20notebook%20or%20are%20unfamiliar%20with%20the%20process%2C%20-ERR%3AREF-NOT-FOUND-this%20article%20walks%20through%20installing%20and%20running%20Jupyter%20Notebook%20and%20Anaconda%20on%20your%20computer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20a%20more%20friendly%20user%20interface%2C%20you%20can%20also%20try%20running%20Jupyter%20Lab%20locally.%20Jupyter%20Lab%20is%20included%20as%20an%20application%20within%20your%20Anaconda%20installation.%20By%20running%20Anaconda%20Navigator%20on%20your%20machine%20(search%20for%20%E2%80%9CAnaconda%20Navigator%E2%80%9D%20in%20your%20Start%20search%20bar)%2C%20you%20should%20be%20able%20to%20choose%20between%20the%20two%20in%20the%20GUI.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22anaconda.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211528i0D879470D7DF56C7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22anaconda.png%22%20alt%3D%22anaconda.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20may%20be%20best%20to%20clone%20the%20Azure%20Sentinel%20Notebook%20repo%20first%20so%20you%20can%20use%20the%20guides%20to%20open%20up%20the%20Base64%20Notebook%20when%20the%20installation%20is%20finished.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1872360950%22%20id%3D%22toc-hId-1872360922%22%3EConfiguring%20the%20Notebook%3C%2FH2%3E%0A%3CP%3EOnce%20you%20have%20set%20up%20your%20Notebook%20environment%2C%20open%20up%20the%20-ERR%3AREF-NOT-FOUND-Guided%20Hunting%3A%20Base64-Encoded%20Linux%20Commands%20notebook.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EIf%20you%20are%20unfamiliar%20with%20using%20a%20Jupyter%20notebook%2C%20you%20may%20want%20to%20take%20a%20look%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel-Notebooks%2Fblob%2F4d7a341abfab3955dedc278dc9431c4d38c6e2e5%2FA%2520Getting%2520Started%2520Guide%2520For%2520Azure%2520Sentinel%2520Notebooks.ipynb%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGetting%20Started%20with%20Azure%20Sentinel%20Notebooks%3C%2FA%3E%20notebook%20first%3C%2FEM%3E%3CEM%3E.%20This%20notebook%20will%20guide%20you%20through%20the%20basics%20of%20Jupyter%20Notebook%20features%20and%20shortcuts%2C%20as%20well%20as%20some%20configuration%20tips%20and%20uses%20of%20notebooks%20in%20threat%20hunting.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20top%20of%20the%20notebook%20describes%20its%20purpose%3A%20to%20find%20and%20rank%20malicious%20command%20line%20data%20that%20has%20been%20encoded%20in%20Base64%2C%20with%20the%20hope%20that%20this%20will%20launch%20further%20investigation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20also%20lists%20the%20Python%20edition%20and%20libraries%20that%20will%20be%20used%20and%20the%20other%20data%20sources%20that%20will%20be%20included%20in%20the%20investigation.%20Running%20the%20first%20cell%20in%20the%20notebook%20will%20confirm%20that%20all%20of%20the%20technical%20configurations%20are%20in%20place.%20If%20not%2C%20it%20lists%20options%20for%20troubleshooting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22config.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211529i963BA876FAA1BD13%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22config.gif%22%20alt%3D%22config.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20also%20recommend%20that%20at%20this%20point%20you%20fill%20out%20the%20msticpyconfig.yaml%20file%20found%20in%20the%20Azure%20Sentinel%20Notebooks%20folder.%20See%20the%20-ERR%3AREF-NOT-FOUND-MSTICpy%20documentation%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eif%20you%20need%20help.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22msticpyconfig.PNG%22%20style%3D%22width%3A%20979px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211530i7D7851210AF924C0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22msticpyconfig.PNG%22%20alt%3D%22msticpyconfig.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20minimum%2C%20the%20notebook%20will%20require%20you%20to%20fill%20out%20the%20Azure%20Sentinel%20default%20workspace%20WorkspaceId%20and%20TenantId.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20WorkspaceId%20can%20be%20found%20on%20the%20Workplace%20Settings%20tab%20of%20Azure%20Sentinel.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22sentinel_workspaceid1.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211532i8135EA1BC20C4B07%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22sentinel_workspaceid1.png%22%20alt%3D%22sentinel_workspaceid1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20WorkspaceID%20will%20be%20on%20the%20first%20page%20once%20you%E2%80%99re%20there.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22workspace2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211533i81597F4B43819DAC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22workspace2.png%22%20alt%3D%22workspace2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20TenantID%20can%20be%20found%20on%20Azure%20Active%20Directory%0A%3CUL%3E%0A%3CLI%3ESearch%20for%20Azure%20Active%20Directory%20in%20the%20Azure%20Portal%20and%20press%20enter.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22aad1.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211534iDA93643325F3ABCF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22aad1.PNG%22%20alt%3D%22aad1.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EYour%20Tenant%20ID%20will%20be%20in%20the%20information%20box%20on%20the%20first%20page.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22aad2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211535i586DC5DA3250A9D4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22aad2.png%22%20alt%3D%22aad2.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-64906487%22%20id%3D%22toc-hId-64906459%22%3EThreat%20Intelligence%20Configuration%3C%2FH2%3E%0A%3CP%3ETo%20utilize%20Threat%20Intelligence%20in%20the%20notebook%2C%20you%20will%20also%20need%20to%20fill%20out%20TI%20Providers%20Section%20with%20at%20least%20one%20provider.%20In%20this%20blog's%20examples%2C%20we%20show%20how%20to%20use%20AlienVault%20OTX%20and%20IBM%20XForce%2C%20as%20they%20accept%20many%20queries%20at%20once.%20VirusTotal%20is%20also%20shown%20since%20it%20is%20commonly%20used%20for%20TI%20investigations.%20Note%2C%20however%2C%20that%20it%20may%20not%20process%20multiple%20queries%20as%20quickly%20so%20results%20will%20be%20varied.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20create%20free%20accounts%20on%20the%20following%20sites%20if%20you%20don%E2%80%99t%20have%20an%20account%20already.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fotx.alienvault.com%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAlienVault%20OTX%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fexchange.xforce.ibmcloud.com%2F%3F_ga%3D2.178129509.1324520826.1596082134-1489230310.1592186193%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIBM%20XForce%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdevelopers.virustotal.com%2Fv3.0%2Freference%23getting-started%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVirusTotal%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ETo%20find%20your%20AuthKey%2C%20navigate%20to%20the%20API%20page%20sections%2Fsettings%20on%20these%20websites%20once%20you%E2%80%99ve%20made%20an%20account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1742547976%22%20id%3D%22toc-hId--1742548004%22%3EConnecting%20to%20Azure%20Sentinel%3C%2FH2%3E%0A%3CP%3EThe%20next%20two%20cells%20will%20authenticate%20you%20with%20Azure%20Sentinel%20using%20MSTICpy%E2%80%99s%20data%20connector%20features.%20If%20you%20haven%E2%80%99t%20included%20your%20workplace%20ID%20and%20tenant%20ID%20in%20the%20msticpyconfig.yaml%20file%2C%20it%20will%20prompt%20you%20for%20them%20when%20you%20run%20the%20first%20cell.%20With%20this%20information%2C%20it%20will%20authenticate%20you%20with%20Log%20Analytics.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20second%20cell%20will%20authenticate%20you%20with%20your%20Workspace.%20Running%20it%20will%20load%20a%20feature%20called%20-ERR%3AREF-NOT-FOUND-KQLMagic%26nbsp%3Bthat%20will%20give%20you%20a%20code%20to%20paste%20into%20a%20separate%20browser%20window%20that%20will%20open.%20You%20can%20then%20log%20in%20with%20the%20appropriate%20Workspace%20credentials.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22loganalytics_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211537i18F2B600B92E0906%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22loganalytics_redo.gif%22%20alt%3D%22loganalytics_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-744964857%22%20id%3D%22toc-hId-744964829%22%3ESet%20Time%20Parameters%3C%2FH2%3E%0A%3CP%3EAfter%20running%20the%20cell%20in%20the%20Set%20Time%20Parameters%20section%20following%20your%20authentication%2C%20you%20will%20be%20prompted%20to%20enter%20a%20time%20range%20using%20a%20slider%20and%20some%20input%20boxes.%20This%20is%20the%20time%20range%20the%20KQL%20query%20will%20use%20to%20search%20for%20Base64%20commands%20so%20set%20it%20to%20the%20range%20you%20are%20investigating.%20Consider%20how%20many%20machines%20and%20how%20much%20data%20you%20will%20be%20querying%20when%20you%20set%20the%20time%20range%2C%20as%20that%20will%20affect%20performance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22timeframe_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211539iFFB146222A5B0733%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22timeframe_redo.gif%22%20alt%3D%22timeframe_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1062489606%22%20id%3D%22toc-hId--1062489634%22%3EGet%20Base64%20Commands%3C%2FH2%3E%0A%3CP%3EIn%20this%20section%2C%20the%20cell%20will%20run%20a%20query%20using%20the%20MSTICpy%20KQL%20functionalities%20and%20return%20a%20Python%20-ERR%3AREF-NOT-FOUND-Pandas%20data%20frame%20you%20will%20be%20able%20to%20explore%2C%20similar%20to%20what%20you%20would%20see%20if%20you%20ran%20the%20same%20query%20in%20Log%20Analytics%20in%20your%20workspace%20on%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20edit%20this%20KQL%20query%20as%20if%20you%20were%20in%20Log%20Analytics%20if%20you%20want%20to%20specify%20a%20type%20of%20Base64%20command%20or%20if%20you%20choose%20not%20to%20use%20AUOMS%20but%20have%20another%20equivalent%20data%20source.%20Note%20that%20the%20rest%20of%20the%20notebook%20relies%20upon%20the%20projected%20columns%20in%20their%20current%20format%20so%20if%20you%20make%20any%20changes%2C%20try%20not%20to%20change%20these%20columns.%20If%20you%20do%2C%20you%20will%20have%20to%20edit%20much%20of%20the%20rest%20of%20the%20notebook%20as%20well%20to%20accommodate%20those%20changes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22base64query.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211540iD09AC0E090A81CDF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22base64query.gif%22%20alt%3D%22base64query.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1425023227%22%20id%3D%22toc-hId-1425023199%22%3ECategorize%20Decoded%20Base64%20Commands%3C%2FH2%3E%0A%3CP%3EThe%20cell%20in%20this%20section%20will%20tag%20all%20the%20commands%20pulled%20from%20the%20query%20with%20its%20relevant%20categories.%20These%20categories%20are%20based%20on%20the%20bash%20commands%20and%20files%20present%20in%20the%20decoded%20commands%20and%20what%20they%20tend%20to%20be%20used%20for.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ENetwork%20connections%2Fdownloading%3A%20wget%2C%20curl%2C%20urllib.urlopen%3C%2FLI%3E%0A%3CLI%3EFile%20manipulation%3A%20chmod%2C%20chattr%2C%20touch%2C%20cp%2C%20mv%2C%20ln%2C%20sed%2C%20awk%2C%20echo%3C%2FLI%3E%0A%3CLI%3EHost%20enumeration%3A%20uname%2C%20grep%2C%20%2Fproc%2Fcpuinfo%3C%2FLI%3E%0A%3CLI%3EFile%2Fprocess%20deletion%2Fkilling%3A%20rm%2C%20pkill%3C%2FLI%3E%0A%3CLI%3EArchive%2Fcompression%20programs%3A%20tar%2C%20zip%2C%20gzip%2C%20bzip2%2C%20lzma%2C%20xz%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EConsider%20this%20a%20basic%20list%20of%20categories%20and%20commands%20to%20get%20started.%20If%20there%20are%20other%20categories%20or%20commands%2Ffile%20names%2Fprocesses%20you%20want%20to%20look%20for%20and%20categorize%20here%2C%20feel%20free%20to%20add%20them%20to%20the%20code.%20This%20can%20be%20especially%20useful%20if%20you%20are%20looking%20for%20a%20specific%20type%20of%20command%20as%20you%20can%20create%20your%20own%20standards.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20the%20cell%20is%20run%2C%20it%20will%20display%20all%20unique%20decoded%20commands%20found%20and%20a%20list%20of%20their%20categories.%20This%20can%20help%20you%20focus%20your%20investigation%20if%20you%E2%80%99re%20looking%20for%20a%20certain%20pattern%20of%20behavior.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22categorization_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211542iD870FC622F691C5D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22categorization_redo.gif%22%20alt%3D%22categorization_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1414520123%22%20id%3D%22toc-hId-1414520095%22%3EGTFOBins%20Classification%3C%2FH1%3E%0A%3CP%3EThis%20is%20similar%20to%20the%20%E2%80%9CCategorize%20Decoded%20Commands%E2%80%9D%20section%20above%2C%20but%20uses%20the%20open%20source%20-ERR%3AREF-NOT-FOUND-GTFOBins.%20GTFOBins%20is%20a%20vetted%20collection%20of%20bash%20commands%20frequently%20exploited%20by%20attackers%20as%20well%20as%20a%20reference%20as%20to%20how%20those%20commands%20may%20be%20used.%20We%20are%20using%20it%20to%20find%20potentially%20exploited%20commands%20in%20the%20dataset%20and%20tag%20those%20with%20their%20corresponding%20functionalities.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20cell%20in%20this%20section%20will%20print%20out%20GTFO%20Functions%20and%20what%20they%20mean%20if%20you%20are%20unfamiliar.%20It%20may%20also%20help%20to%20take%20a%20look%20at%20the%20-ERR%3AREF-NOT-FOUND-GTFOBins%20website%20itself.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERunning%20the%20second%20cell%20will%20create%20two%20new%20columns%20in%20the%20data%20frame%2C%20%E2%80%9CGTFO%20Bins%E2%80%9D%20and%20%E2%80%9CGTFO%20Functions%2C%E2%80%9D%20and%20display%20these.%20The%20GTFO%20Bins%20column%20will%20consist%20of%20links%20to%20more%20information%20on%20the%20GTFOBins%20website.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22gtfobins.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211544i2A160472B2023F3B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22gtfobins.gif%22%20alt%3D%22gtfobins.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBe%20aware%20that%20retrieving%20GTFO%20Functions%20may%20take%20a%20bit%20longer%20to%20run.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--516115960%22%20id%3D%22toc-hId--516115988%22%3EGenerating%20Scores%20and%20Rankings%3C%2FH2%3E%0A%3CP%3EThe%20cells%20under%20this%20section%20generate%20scores%20for%20each%20unique%20Base64%20command%20based%20on%20criteria%20such%20as%20frequency%20of%20the%20command%2C%20severity%20of%20TI%20lookup%20results%2C%20and%20related%20commands%20run.%20Each%20score%20is%20added%20to%20the%20data%20frame%20at%20the%20end%2C%20so%20you%20can%20view%20and%20rank%20each%20score%20individually%20or%20by%20the%20aggregate%20score.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20scores%20are%20not%20intended%20to%20be%20an%20exact%20scoring%20of%20whether%20a%20command%20is%20malicious.%20Rather%2C%20they%20provide%20a%20guide%20to%20analysts%20as%20to%20which%20commands%20to%20prioritize%20for%20investigation.%20They%20do%20not%20represent%20any%20mathematical%20value%20and%20are%20not%20calculated%20in%20comparison%20to%20any%20particular%20number%20other%20than%20each%20other.%20In%20general%2C%20higher%20scores%20are%20more%20likely%20to%20be%20malicious%20commands.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20your%20own%20ideas%20for%20how%20you%20want%20to%20score%20or%20rank%2C%20you%20can%20adjust%20the%20code%20in%20the%20following%20sections%20to%20do%20so.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-2100479592%22%20id%3D%22toc-hId-2100479564%22%3EFrequency%20Analysis%3C%2FH3%3E%0A%3CP%3EThis%20cell%20creates%20a%20frequency%20score%20for%20each%20command%20based%20on%20its%20frequency%20within%20the%20workspace%20and%20within%20its%20host.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20calculated%20as%20follows%3A%20%5B(1%20%2F%20frequency%20in%20workspace)%20%2B%20(1%20%2F%20frequency%20in%20its%20host)%5D%20%2F%202.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1%20divided%20by%20the%20frequency%20numbers%20results%20in%20bigger%20numbers%20for%20commands%20that%20occur%20fewer%20times%2C%20which%20gives%20rare%20commands%20higher%20scores.%20Dividing%20by%202%20normalizes%20this%20score%20to%20be%20under%201.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20data%20frame%20is%20shown%20again%20at%20the%20bottom%2C%20with%20frequency%20score%20added%20to%20the%20total%20score%20count.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22freq.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211545iED30C07079A7A968%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22freq.gif%22%20alt%3D%22freq.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-293025129%22%20id%3D%22toc-hId-293025101%22%3EIoC%20Extraction%3C%2FH3%3E%0A%3CP%3EThis%20section%20extracts%20Indicators%20of%20Compromise%20(IoCs)%20from%20the%20command%20lines%20using%20MSTICPy%E2%80%99s%20IoC%20extraction%20features.%20It%20will%20display%20the%20observables%20found%20(IPv4%2C%20IPv6%2C%20DNS%2C%20URL%2C%20Windows%20path%2C%20Linux%20path%2C%20MD5%20hash%2C%20SHA1%20hash%2C%20and%20SHA256%20hash)%2C%20the%20IoC%20types%2C%20and%20the%20original%20source%20indices%20of%20the%20rows%20in%20the%20previous%20data%20frame%20it%20was%20found%20in.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EIf%20you%20are%20interested%20in%20an%20observable%20pattern%20that%20is%20not%20being%20matched%2C%20see%20the%20-ERR%3AREF-NOT-FOUND-MSTICpy%20IoC%20Extraction%20documentation%20%3C%2FEM%3E%3CEM%3Efor%20more%20information%20on%20how%20to%20add%20your%20own.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20this%20data%20frame%20to%20get%20a%20quick%20glimpse%20of%20the%20unique%20IoCs%20found.%20This%20can%20be%20helpful%20if%20you%20are%20looking%20for%20something%20specific%20or%20to%20give%20another%20clue%20as%20to%20what%20the%20encoded%20command%20was%20doing.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20data%20will%20also%20be%20merged%20with%20the%20original%20data%20frame%20so%20you%20will%20be%20able%20to%20see%20which%20IoCs%20came%20from%20which%20commands.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ioc_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211548i410CA3F35508417B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ioc_redo.gif%22%20alt%3D%22ioc_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1514429334%22%20id%3D%22toc-hId--1514429362%22%3EThreat%20Intel%20Lookup%3C%2FH3%3E%0A%3CP%3EThis%20section%20allows%20you%20to%20use%20outside%20TI%20data%20to%20take%20in%20the%20IoCs%20you%20want%20to%20look%20up%20and%20get%20TI%20information%20on%20them.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20cell%20in%20this%20section%20will%20print%20out%20your%20current%20TI%20configurations%2C%20which%20you%20can%20set%20up%20in%20msticpyconfig.yaml.%20This%20was%20covered%20earlier%20in%20the%20blog%20in%20the%20%E2%80%9CConfiguring%20the%20Notebook%E2%80%9D%20section.%20Once%20you%20have%20this%20set%20up%2C%20run%20the%20second%20cell%20and%20use%20the%20select%20tool%20to%20choose%20which%20providers%20you%20want%20to%20use.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20use%20the%20select%20widget%20created%20by%20the%20third%20cell%20to%20pick%20the%20IoCs%20you%20want%20to%20look%20up.%20Run%20the%20next%20cell%20in%20this%20section%20for%20a%20data%20frame%20of%20TI%20results%20from%20different%20providers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20last%20cell%20will%20calculate%20severity%20scores%20based%20on%20how%20the%20providers%20ranked%20each%20IoC.%20Scores%20are%20calculated%20by%20looking%20up%20each%20unique%20IoC%20in%20each%20command%2C%20and%20adding%20the%20score%20corresponding%20to%20the%20highest%20severity%20rating%20given%20out%20of%20the%20providers%20you%20used.%20Commands%20with%20more%20high%20severity%20IoCs%20will%20score%20higher%20on%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ti_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211554iC21AAA26E2D61C3A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ti_redo.gif%22%20alt%3D%22ti_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-973083499%22%20id%3D%22toc-hId-973083471%22%3ERelated%20Alerts%3C%2FH3%3E%0A%3CP%3EThis%20section%20scores%20related%20Azure%20Sentinel%20alerts%20that%20took%20place%20in%20the%20given%20time%20frame.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20know%20of%20a%20time%20frame%20that%20you%E2%80%99re%20interested%20in%2C%20whether%20from%20perusing%20the%20data%20or%20from%20prior%20knowledge%2C%20you%20can%20use%20the%20time%20selector%20to%20focus%20in%20on%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERun%20the%20first%20cell%20to%20select%20a%20time%20in%20the%20widget.%20The%20second%20cell%20will%20display%20a%20list%20of%20alert%20types%20found%2C%20their%20names%2C%20and%20how%20many%20times%20they%20occurred%20in%20that%20time%20frame%20for%20each%20host.%20There%20will%20also%20be%20a%20data%20frame%20with%20in-depth%20information%20on%20each%20of%20the%20alerts%20found%20in%20each%20host.%20Finally%2C%20there%20will%20be%20a%20timeline%20that%20illustrates%20when%20alerts%20occurred%20within%20the%20time%20frame.%20This%20is%20done%20through%20the%20use%20of%20MSTICpy%E2%80%99s%20related%20alerts%20feature.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20final%20cell%20in%20this%20section%20will%20return%20a%20further%20revised%20Base64%20command%20data%20frame%20with%20Alert%20Scores%2C%20as%20well%20as%20the%20previous%20TI%20Severity%20Scores%20and%20Frequency%20Scores%2C%20both%20individually%20and%20added%20to%20Total%20Scores.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EScoring%20will%20be%20done%20based%20on%20the%20presence%20of%20high%20severity%20alerts%20found%3A%20each%20unique%20alert%20will%20add%20points%20to%20the%20score%20corresponding%20to%20severity%2C%20with%20high%20severity%20alerts%20scoring%20higher.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22related_alerts_redo.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211562i4CDA5076F9CB013C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22related_alerts_redo.gif%22%20alt%3D%22related_alerts_redo.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--963453683%22%20id%3D%22toc-hId--963453711%22%3EFinal%20Scores%20and%20Ranking%3C%2FH2%3E%0A%3CP%3EThe%20final%20section%20of%20the%20notebook%20brings%20together%20all%20the%20previous%20scoring%20and%20provides%20you%20with%20a%20final%20ranking%20of%20Base64%20encoded%20commands%20that%20are%20most%20likely%20to%20be%20malicious.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1653141869%22%20id%3D%22toc-hId-1653141841%22%3ECustomizing%20Your%20Data%20Frame%3C%2FH3%3E%0A%3CP%3EYou%20can%20use%20the%20selector%20widget%20from%20the%20first%20cell%20to%20choose%20which%20columns%20you%E2%80%99d%20like%20to%20view.%20The%20second%20cell%20will%20show%20those%20columns%20with%20the%20highest%20total%20scoring%20commands%20at%20the%20top.%20The%20widgets%20generated%20here%20allow%20you%20to%20choose%20a%20cutoff%20score%20for%20any%20of%20the%20scores%20displayed.%20The%20data%20frame%20also%20shows%20the%20relative%20makeup%20of%20each%20total%20score.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20bar%20chart%20created%20underneath%20further%20enhances%20this%20perception%20and%20allows%20you%20to%20see%20which%20factors%20led%20commands%20to%20score%20the%20way%20they%20did.%20The%20x-axis%20highlights%20the%20indices%2C%20so%20you%20can%20view%20the%20rest%20of%20the%20information%20by%20finding%20that%20index%20in%20the%20data%20frame.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--154312594%22%20id%3D%22toc-hId--154312622%22%3EOverall%20Timeline%3C%2FH3%3E%0A%3CP%3EThe%20final%20cell%20in%20the%20section%20creates%20a%20timeline%20out%20of%20all%20the%20base%2064%20command%20data%20retrieved.%20Mouse%20over%20each%20dot%20on%20the%20timeline%20for%20information%20on%20which%20command%20it%20referred%20to%20and%20its%20categories.%20This%20may%20be%20helpful%20in%20gaining%20a%20better%20understanding%20of%20possible%20attacker%20behavior%20and%20noting%20anomalies.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22final.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211563i8BE905B784134920%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22final.gif%22%20alt%3D%22final.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--2090849776%22%20id%3D%22toc-hId--2090849804%22%3ESummary%3C%2FH2%3E%0A%3CP%3EBase64%20commands%20are%20increasingly%20used%20by%20attackers%20on%20Linux%20hosts%20and%20are%20often%20uncaught%20by%20traditional%20detections.%20It%20can%20be%20helpful%2C%20when%20hunting%20or%20investigating%2C%20to%20take%20a%20deeper%20look%20at%20Base64-encoded%20commands.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20notebook%20creates%20a%20method%20for%20investigators%20to%20understand%20Base64%20encoded%20activity%20in%20their%20workspaces%20by%20providing%20an%20accessible%20way%20to%20rank%20encoded%20commands%20that%20are%20most%20likely%20to%20be%20malicious%20and%20multiple%20avenues%20through%20which%20to%20view%20and%20explore%20this%20data.%20Other%20notebooks%20and%20methodologies%20can%20be%20helpful%20for%20deeper%20explorations.%20You%20can%20find%20more%20blogs%20on%20these%20-ERR%3AREF-NOT-FOUND-here.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20interested%20in%20building%20your%20own%20notebooks%20in%20the%20TI%20space%2C%20you%20may%20also%20want%20to%20take%20a%20look%20at%20-ERR%3AREF-NOT-FOUND-MSTICpy%2C%20which%20offers%20plenty%20of%20tools%20and%20features%20for%20you%20to%20easily%20explore%20your%20datasets.%20Feel%20free%20to%20let%20the%20MSTIC%20team%20know%20if%20you%20encounter%20any%20issues%20or%20have%20any%20suggestions%20and%20contributions%20to%20make%20to%20our%20notebooks%20and%20MSTICpy.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-396663057%22%20id%3D%22toc-hId-396663029%22%3EAdditional%20Reading%20and%20References%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fgetting_started%2FIntroduction.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIntroduction%20to%20MSTICpy%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpandas.pydata.org%2Fpandas-docs%2Fstable%2Fuser_guide%2Findex.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPandas%20Documentation%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1579484%22%20slang%3D%22en-US%22%3E%3CP%3EMSTIC%20has%20observed%20an%20increasing%20number%20of%20Linux%20attackers%20encoding%20their%20scripts%20into%20Base64%20both%20for%20ease%20of%20use%20and%20to%20avoid%20detection.%20Because%20the%20commands%20are%20encoded%2C%20it%20can%20be%20time-intensive%20and%20inefficient%20to%20hone%20in%20on%20malicious%20Base64-encoded%20commands%20by%20looking%20at%20raw%20log%20data.%20To%20solve%20this%20problem%2C%20we%20have%20created%20a%20Jupyter%20notebook%20that%20makes%20this%20process%20easier%20by%20scoring%20and%20ranking%20Base64%20commands%20found%20in%20your%20Sentinel%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

MSTIC has observed an increasing number of Linux attackers encoding their scripts into Base64 both for ease of use and to avoid detection. Because the commands are encoded, it can be time-intensive and inefficient to hone in on malicious Base64-encoded commands by looking at raw log data. To solve this problem, we have created a Jupyter notebook that makes this process easier by scoring and ranking Base64 commands found in your Sentinel data. This notebook can be accessed here and will be explained in detail in this blog.

 

A blog series written last year covers the use of Jupyter notebooks in threat hunting in more detail. Here are links to Part 1, Part 2, and Part 3.

 

Other notebooks you can access now are available on the Azure Sentinel Notebook Github and cover Windows host exploration, IP Addresses, Domains & URLs, Linux hosts, and much more. These notebooks are all built using Microsoft Threat Intelligence Center’s Python API MSTICpy.

 

Please note that all notebooks are live on Github and under revision so be aware that the notebooks you use might be slightly different from those described in blog posts.

 

Intro

Many of our Azure customers use Linux virtual machines, and we are always looking for ways to help our customers in their security investigations. Thus, we’ve been working on expanding coverage on Linux-specific investigations. This Guided Hunting: Base64-Encoded Linux Commands Notebook was created in response to an increasing number of attackers encoding their bash commands into Base64. This is often seen in crypto mining attacks. A specific case of this is discussed and analyzed here.

 

This notebook attempts to query for and analyze Base64-encoded commands found in execve logs in your Azure Sentinel workspace. It then walks you through an investigation and scoring process that will highlight the commands most likely to be malicious, which can focus your investigation down to individual hosts and lead to further exploration using the Linux Host Explorer Notebook or any other tools and methodologies you prefer.

 

This blog will walk you through the setup and use of this notebook. It may be helpful to run the notebook yourself as you read through it.

 

AUOMS Agent Setup

AUOMS is a Microsoft audit collection tool that can collect events from kaudit or auditd/audisp. The MSTIC research branch of it can forward events to Syslog, which can be collected and accessed on Azure Sentinel (see this link for more information on collecting Syslog in Sentinel), making it a great option for collecting command line data and parsing it for Base64 encodings. It can also be used for other command line parsing, which you can explore through your own Jupyter Notebooks or through queries on Sentinel.

 

AUOMS can be installed and set up through the Linux terminal. You will need to install it on each host you’d like to collect data from in your Log Analytics workspace.

 

This blog covers the installation and troubleshooting options in detail, as well as how you can create a Log Analytics workspace.

 

Once you’ve installed AUOMS, you may want to check if the currently distributed version from Log Analytics/Azure Sentinel includes the Syslog output option by default. Do this by running the following code from the terminal of the machine you want to test:

 

 

/opt/microsoft/auoms/bin/auomsctl status

 

 

This will check if AUOMS running and reveal its version if it is. If the version is 2.1.8 then it should include the Syslog output option. This means that if you put the syslog.conf file from the MSTIC-Research repo into the /etc/opt/microsoft/auoms/output.d directory and restart AUOMS it should start outputting to Syslog.

 

You may also want to check out some of these parsers to test your system once AUOMS is installed.

 

Once you have your machines connected to Log Analytics, you can run the parsing queries by following these steps:

  • Go to the Azure Portal 
  • Search for “Azure Sentinel” in the search bar and press enter
  • Choose your workspace
  • Click “Logs” on the sidebar

sentinel2.png

  • Type and run your query

sentinel3.PNG

This query is available in the SyslogExecve.txt file found in the Git repo.

 

Setting Up Jupyter Notebooks

You can run this notebook in Azure via Azure Sentinel's notebook feature or locally. To run the notebook on Azure, see this link.

 

If you have never run a Jupyter notebook or are unfamiliar with the process, this article walks through installing and running Jupyter Notebook and Anaconda on your computer.

 

For a more friendly user interface, you can also try running Jupyter Lab locally. Jupyter Lab is included as an application within your Anaconda installation. By running Anaconda Navigator on your machine (search for “Anaconda Navigator” in your Start search bar), you should be able to choose between the two in the GUI.

 

anaconda.png

 

It may be best to clone the Azure Sentinel Notebook repo first so you can use the guides to open up the Base64 Notebook when the installation is finished.

 

Configuring the Notebook

Once you have set up your Notebook environment, open up the Guided Hunting: Base64-Encoded Linux Commands notebook.

 

If you are unfamiliar with using a Jupyter notebook, you may want to take a look at the Getting Started with Azure Sentinel Notebooks notebook first. This notebook will guide you through the basics of Jupyter Notebook features and shortcuts, as well as some configuration tips and uses of notebooks in threat hunting.

 

The top of the notebook describes its purpose: to find and rank malicious command line data that has been encoded in Base64, with the hope that this will launch further investigation.

 

It also lists the Python edition and libraries that will be used and the other data sources that will be included in the investigation. Running the first cell in the notebook will confirm that all of the technical configurations are in place. If not, it lists options for troubleshooting.

 

config.gif

 

We also recommend that at this point you fill out the msticpyconfig.yaml file found in the Azure Sentinel Notebooks folder. See the MSTICpy documentation if you need help.

 

msticpyconfig.PNG

 

At minimum, the notebook will require you to fill out the Azure Sentinel default workspace WorkspaceId and TenantId.

  • The WorkspaceId can be found on the Workplace Settings tab of Azure Sentinel.

sentinel_workspaceid1.png

 

  • The WorkspaceID will be on the first page once you’re there.

workspace2.png

 

  • The TenantID can be found on Azure Active Directory
    • Search for Azure Active Directory in the Azure Portal and press enter.

aad1.PNG

 

  • Your Tenant ID will be in the information box on the first page.

aad2.png

 

Threat Intelligence Configuration

To utilize Threat Intelligence in the notebook, you will also need to fill out TI Providers Section with at least one provider. In this blog's examples, we show how to use AlienVault OTX and IBM XForce, as they accept many queries at once. VirusTotal is also shown since it is commonly used for TI investigations. Note, however, that it may not process multiple queries as quickly so results will be varied.

 

You can create free accounts on the following sites if you don’t have an account already.

To find your AuthKey, navigate to the API page sections/settings on these websites once you’ve made an account.

 

Connecting to Azure Sentinel

The next two cells will authenticate you with Azure Sentinel using MSTICpy’s data connector features. If you haven’t included your workplace ID and tenant ID in the msticpyconfig.yaml file, it will prompt you for them when you run the first cell. With this information, it will authenticate you with Log Analytics.

 

The second cell will authenticate you with your Workspace. Running it will load a feature called KQLMagic that will give you a code to paste into a separate browser window that will open. You can then log in with the appropriate Workspace credentials.

 

loganalytics_redo.gif

 

Set Time Parameters

After running the cell in the Set Time Parameters section following your authentication, you will be prompted to enter a time range using a slider and some input boxes. This is the time range the KQL query will use to search for Base64 commands so set it to the range you are investigating. Consider how many machines and how much data you will be querying when you set the time range, as that will affect performance.

 

timeframe_redo.gif

 

Get Base64 Commands

In this section, the cell will run a query using the MSTICpy KQL functionalities and return a Python Pandas data frame you will be able to explore, similar to what you would see if you ran the same query in Log Analytics in your workspace on Sentinel.

 

You can edit this KQL query as if you were in Log Analytics if you want to specify a type of Base64 command or if you choose not to use AUOMS but have another equivalent data source. Note that the rest of the notebook relies upon the projected columns in their current format so if you make any changes, try not to change these columns. If you do, you will have to edit much of the rest of the notebook as well to accommodate those changes.

 

base64query.gif

 

Categorize Decoded Base64 Commands

The cell in this section will tag all the commands pulled from the query with its relevant categories. These categories are based on the bash commands and files present in the decoded commands and what they tend to be used for.

  • Network connections/downloading: wget, curl, urllib.urlopen
  • File manipulation: chmod, chattr, touch, cp, mv, ln, sed, awk, echo
  • Host enumeration: uname, grep, /proc/cpuinfo
  • File/process deletion/killing: rm, pkill
  • Archive/compression programs: tar, zip, gzip, bzip2, lzma, xz

Consider this a basic list of categories and commands to get started. If there are other categories or commands/file names/processes you want to look for and categorize here, feel free to add them to the code. This can be especially useful if you are looking for a specific type of command as you can create your own standards.

 

After the cell is run, it will display all unique decoded commands found and a list of their categories. This can help you focus your investigation if you’re looking for a certain pattern of behavior.

 

categorization_redo.gif

 

GTFOBins Classification

This is similar to the “Categorize Decoded Commands” section above, but uses the open source GTFOBins. GTFOBins is a vetted collection of bash commands frequently exploited by attackers as well as a reference as to how those commands may be used. We are using it to find potentially exploited commands in the dataset and tag those with their corresponding functionalities.

 

The first cell in this section will print out GTFO Functions and what they mean if you are unfamiliar. It may also help to take a look at the GTFOBins website itself.

 

Running the second cell will create two new columns in the data frame, “GTFO Bins” and “GTFO Functions,” and display these. The GTFO Bins column will consist of links to more information on the GTFOBins website.

 

gtfobins.gif

Be aware that retrieving GTFO Functions may take a bit longer to run.

 

Generating Scores and Rankings

The cells under this section generate scores for each unique Base64 command based on criteria such as frequency of the command, severity of TI lookup results, and related commands run. Each score is added to the data frame at the end, so you can view and rank each score individually or by the aggregate score.

 

These scores are not intended to be an exact scoring of whether a command is malicious. Rather, they provide a guide to analysts as to which commands to prioritize for investigation. They do not represent any mathematical value and are not calculated in comparison to any particular number other than each other. In general, higher scores are more likely to be malicious commands.

 

If you have your own ideas for how you want to score or rank, you can adjust the code in the following sections to do so.

 

Frequency Analysis

This cell creates a frequency score for each command based on its frequency within the workspace and within its host.

 

This is calculated as follows: [(1 / frequency in workspace) + (1 / frequency in its host)] / 2.

 

1 divided by the frequency numbers results in bigger numbers for commands that occur fewer times, which gives rare commands higher scores. Dividing by 2 normalizes this score to be under 1.

 

The data frame is shown again at the bottom, with frequency score added to the total score count.

 

freq.gif

 

IoC Extraction

This section extracts Indicators of Compromise (IoCs) from the command lines using MSTICPy’s IoC extraction features. It will display the observables found (IPv4, IPv6, DNS, URL, Windows path, Linux path, MD5 hash, SHA1 hash, and SHA256 hash), the IoC types, and the original source indices of the rows in the previous data frame it was found in.

 

If you are interested in an observable pattern that is not being matched, see the MSTICpy IoC Extraction documentation for more information on how to add your own.

 

You can use this data frame to get a quick glimpse of the unique IoCs found. This can be helpful if you are looking for something specific or to give another clue as to what the encoded command was doing.

 

This data will also be merged with the original data frame so you will be able to see which IoCs came from which commands.

 

ioc_redo.gif

 

Threat Intel Lookup

This section allows you to use outside TI data to take in the IoCs you want to look up and get TI information on them.

 

The first cell in this section will print out your current TI configurations, which you can set up in msticpyconfig.yaml. This was covered earlier in the blog in the “Configuring the Notebook” section. Once you have this set up, run the second cell and use the select tool to choose which providers you want to use.

 

Then, use the select widget created by the third cell to pick the IoCs you want to look up. Run the next cell in this section for a data frame of TI results from different providers.

 

The last cell will calculate severity scores based on how the providers ranked each IoC. Scores are calculated by looking up each unique IoC in each command, and adding the score corresponding to the highest severity rating given out of the providers you used. Commands with more high severity IoCs will score higher on this.

 

ti_redo.gif

 

 

Related Alerts

This section scores related Azure Sentinel alerts that took place in the given time frame.

 

If you know of a time frame that you’re interested in, whether from perusing the data or from prior knowledge, you can use the time selector to focus in on this.

 

Run the first cell to select a time in the widget. The second cell will display a list of alert types found, their names, and how many times they occurred in that time frame for each host. There will also be a data frame with in-depth information on each of the alerts found in each host. Finally, there will be a timeline that illustrates when alerts occurred within the time frame. This is done through the use of MSTICpy’s related alerts feature.

 

The final cell in this section will return a further revised Base64 command data frame with Alert Scores, as well as the previous TI Severity Scores and Frequency Scores, both individually and added to Total Scores.

 

Scoring will be done based on the presence of high severity alerts found: each unique alert will add points to the score corresponding to severity, with high severity alerts scoring higher.

 

related_alerts_redo.gif

 

Final Scores and Ranking

The final section of the notebook brings together all the previous scoring and provides you with a final ranking of Base64 encoded commands that are most likely to be malicious.

 

Customizing Your Data Frame

You can use the selector widget from the first cell to choose which columns you’d like to view. The second cell will show those columns with the highest total scoring commands at the top. The widgets generated here allow you to choose a cutoff score for any of the scores displayed. The data frame also shows the relative makeup of each total score.

 

The bar chart created underneath further enhances this perception and allows you to see which factors led commands to score the way they did. The x-axis highlights the indices, so you can view the rest of the information by finding that index in the data frame.

 

Overall Timeline

The final cell in the section creates a timeline out of all the base 64 command data retrieved. Mouse over each dot on the timeline for information on which command it referred to and its categories. This may be helpful in gaining a better understanding of possible attacker behavior and noting anomalies.

 

 

final.gif

 

Summary

Base64 commands are increasingly used by attackers on Linux hosts and are often uncaught by traditional detections. It can be helpful, when hunting or investigating, to take a deeper look at Base64-encoded commands.

 

This notebook creates a method for investigators to understand Base64 encoded activity in their workspaces by providing an accessible way to rank encoded commands that are most likely to be malicious and multiple avenues through which to view and explore this data. Other notebooks and methodologies can be helpful for deeper explorations. You can find more blogs on these here.

 

If you are interested in building your own notebooks in the TI space, you may also want to take a look at MSTICpy, which offers plenty of tools and features for you to easily explore your datasets. Feel free to let the MSTIC team know if you encounter any issues or have any suggestions and contributions to make to our notebooks and MSTICpy.

 

Additional Reading and References