%3CLINGO-SUB%20id%3D%22lingo-sub-1453204%22%20slang%3D%22en-US%22%3ERe%3A%20Web%20shell%20threat%20hunting%20with%26nbsp%3BAzure%20Sentinel%20and%20Microsoft%26nbsp%3BThreat%26nbsp%3BProtection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1453204%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome%20Blogpost%20!%20Thanks%20for%20sharing%20with%20the%20community%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fcool_40x40.gif%22%20alt%3D%22%3Acool%3A%22%20title%3D%22%3Acool%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1448065%22%20slang%3D%22en-US%22%3EWeb%20shell%20threat%20hunting%20with%26nbsp%3BAzure%20Sentinel%20and%20Microsoft%26nbsp%3BThreat%26nbsp%3BProtection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1448065%22%20slang%3D%22en-US%22%3E%3CP%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETom%20McElroy%2C%20Rob%20Mead%26nbsp%3B%26nbsp%3B%E2%80%93%20Microsoft%20Threat%20Intelligence%20Center%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20this%20blog%20we%20use%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAzure%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESentinel%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eenrich%20the%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Einvestigat%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eion%20of%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bendpoint%20web%20shell%20alerts%20from%20Microsoft%20Defender%20Advanced%20Threat%20Protection%20(MDATP)%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eby%20correlating%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewith%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eadditional%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edata%20sources%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Esuch%20as%20W3CIIS%20log%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20We%20then%20show%20how%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAzure%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESentinel%E2%80%99s%20Security%20Orchestration%20Automation%20and%20Response%20(SOAR)%20capabilities%20can%20be%20used%20to%20automatically%20develop%20and%20share%20new%20insights%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bfrom%20these%20logs%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bback%20with%20MDATP%2C%20triggered%20by%20one%20of%20its%20own%20alerts.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EA%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%98%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ew%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eeb%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eshell%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%99%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eis%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ea%20persistence%20mechanism%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebackdoor%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eoften%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eleveraged%20by%20attackers%20on%20web%20servers%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EU%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Esually%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethis%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Einvolve%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Es%20an%20attacker%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewriting%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Ba%20script%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Ba%20web%20application%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edirectory%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%20using%20it%20to%20execute%20commands%20from%20a%20remote%20location.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20the%20last%2018%20months%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%20profile%20of%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eweb%26nbsp%3Bshell%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bbased%26nbsp%3Battacks%20has%20increased%2C%20due%20in%20part%20to%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Enumber%20of%20vulnerabilities%20reported%20in%20web%20applications%20such%20as%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fportal.msrc.microsoft.com%2Fen-us%2Fsecurity-guidance%2Fadvisory%2FCVE-2019-0604%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ECVE-2019-0604%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bor%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fnvd.nist.gov%2Fvuln%2Fdetail%2FCVE-2019-16759%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ECVE-2019-16759%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20Multiple%20threat%20actors%20have%20also%20been%20seen%20to%20leverage%20web%20shells%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ein%20recent%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bcampaigns%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMicrosoft%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eha%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Es%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Breported%20on%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fsecurity%2Fblog%2F2019%2F12%2F12%2Fgallium-targeting-global-telecom%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EGALLIUM%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fsecurity%2Fblog%2F2020%2F02%2F04%2Fghost-in-the-shell-investigating-web-shell-attacks%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Eother%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E%26nbsp%3Bgroup%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3Es%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eearlier%20in%20the%20year%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%20data-contrast%3D%22auto%22%3EWeb%20shells%20are%20an%20attractive%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eremote%20access%20method%20for%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Battackers%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Esince%20the%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ey%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Boften%20sit%20on%20internet%20facing%20infrastructure%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Ba%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3En%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ed%20the%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eir%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eshort%20content%20length%20can%20make%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewriting%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eanti-virus%20signatures%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efor%20them%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edifficult.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETh%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ee%20scenario%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebelow%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehas%20been%20created%20t%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eo%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eform%20the%20basis%20of%20our%20investigation%20and%20enrichment%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20An%20attacker%20will%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bfirst%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bexploit%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fportal.msrc.microsoft.com%2Fen-us%2Fsecurity-guidance%2Fadvisory%2FCVE-2019-0604%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ECVE-2019-0604%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20a%20patched%20SharePoint%20vulnera%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebility%2C%20to%20place%20a%20web%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eshell%20file%20on%20the%20server.%20The%20attacker%20will%20then%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eleverage%20the%20shell%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ecopy%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eitself%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Einto%20another%20directory%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%20provide%20a%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bredundant%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bbackdoor%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22shell_graph.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198814i96FBFF346C902D49%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22shell_graph.png%22%20alt%3D%22Diagram%20showing%20where%20MDATP%20alerts%20trigger%20during%20our%20investigation.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EDiagram%20showing%20where%20MDATP%20alerts%20trigger%20during%20our%20investigation.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20will%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efocus%20our%20investigation%20on%20two%20areas%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3EW%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eeb%20shell%20installation%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BA%20web%20shell%20file%20is%20placed%20on%20the%20server%20and%20the%20code%20it%20contains%20or%20the%20behaviours%20it%20exhibits%20result%20in%20an%20MDATP%20alert.%20In%20this%20scenario%20the%20alert%20will%20contain%20details%20of%20the%20potential%20shell%20(e.g.%20c%3A%5Cmywebapp%5Cwebshell.aspx).%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3EW%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eeb%20shell%20activity%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20web%20server%20executes%20a%20series%20of%20suspicious%20commands%20that%20look%20like%20they%20might%20be%20web%20shell%20activity%2C%20and%20result%20in%20an%20MDATP%20alert.%20In%20this%20scenario%20the%20alert%20will%20contain%20details%20of%20the%20suspicious%20processes%20executed.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20480px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197222i168BBC4429083B2C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Example%20EDR%20alert%20for%20web%20shell%20installation%20in%20the%20MDATP%20Security%20Center.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EExample%20EDR%20alert%20for%20web%20shell%20installation%20in%20the%20MDATP%20Security%20Center.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1325927409%22%20id%3D%22toc-hId--1325927409%22%3EConnecting%20the%20data%20sources%3C%2FH2%3E%0A%3CP%3EMDATP%20alerts%20can%20be%20connected%20to%20Azure%20Sentinel%20using%20the%20-ERR%3AREF-NOT-FOUND-built%20in%20connector.%20Once%20enabled%2C%20alerts%20are%20written%20to%20the%20SecurityAlert%20table.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorTMcElroy_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20480px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197226i599D60AC68A4138D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Example%20of%20an%20MDATP%20alert%20in%20Azure%20Sentinel.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EExample%20of%20an%20MDATP%20alert%20in%20Azure%20Sentinel.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20evidence%20associated%20with%20an%20alert%20in%20this%20table%20can%20be%20found%20in%20the%20%E2%80%98Entities%E2%80%99%20field.%20This%20is%20where%20we%E2%80%99ll%20need%20to%20look%20to%20extract%20the%20details%20of%20suspicious%20files%20and%20processes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdditional%20visibility%20into%20web%20servers%20can%20be%20enabled%20by%20configuring%20collection%20of%20web%20server%20logs%20in%20Azure%20Sentinel.%20Although%20in%20this%20example%20we%20discuss%20collection%20from%20IIS%20web%20servers%2C%20data%20could%20also%20be%20collected%20from%20other%20server%20technologies%20such%20as%20Apache%20or%20Tomcat%20to%20enable%20similar%20investigations.%20For%20more%20detail%20on%20configuring%20IIS%20log%20collection%20for%20Azure%20Sentinel%20see%20-ERR%3AREF-NOT-FOUND-here.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Azure%20Sentinel%2C%20the%20W3CIIS%20table%20contains%20details%20of%20requests%20made%20to%20the%20web%20server%2C%20including%20the%20source%20IP%2C%20the%20request%20page%20and%20the%20user%20agent%20used.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20601px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197228iCA126EBF441E7EAB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Azure%20Sentinel's%20W3CIIS%20log%20table.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAzure%20Sentinel's%20W3CIIS%20log%20table.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1161585424%22%20id%3D%22toc-hId-1161585424%22%3EInvestigating%20the%20alerts%20and%20generating%20new%20insights%3C%2FH2%3E%0A%3CP%3EBy%20connecting%20MDATP%20alerts%20and%20relevant%20data%20sources%20to%20Azure%20Sentinel%2C%20we%20can%20gain%20additional%20insights%20and%20enrich%20our%20investigation.%20In%20the%20case%20of%20a%20web%20shell%2C%20we%20want%20to%20be%20able%20to%20answer%20questions%20such%20as%20how%20it%20got%20there%20and%20where%20the%20attack%20came%20from.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActing%20against%20the%20web%20shell%20alone%20may%20provide%20a%20highly%20motivated%20attacker%20with%20a%20window%20of%20opportunity%20to%20start%20diversifying%20their%20access%2C%20but%20by%20acting%20against%20the%20web%20shell%20with%20MDATP%20in%20parallel%20to%20identifying%20the%20attacker%E2%80%99s%20IP%20and%20user%20agent%20in%20Azure%20Sentinel%20a%20more%20developed%20picture%20of%20the%20attacks%20can%20be%20formed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-55195539%22%20id%3D%22toc-hId-55195539%22%3EWeb%20shell%20installation%3C%2FH4%3E%0A%3CP%3EIn%20the%20attack%20scenario%20there%20are%20two%20instances%20where%20a%20web%20shell%20file%20is%20placed%20onto%20the%20server%3B%20when%20the%20attacker%20uses%20Picker.aspx%20to%20deploy%20the%20initial%20shell%20and%20when%20the%20attacker%20copies%20the%20file%20into%20a%20new%20directory.%20Both%20actions%20trigger%20MDATP%20alerts%20for%20the%20web%20shell%20file%20which%20contain%20a%20filename%20for%20the%20shell%20that%20we%20can%20further%20investigate.%20The%20diagram%20below%20highlights%20where%20in%20the%20example%20scenario%20this%20activity%20takes%20place.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20484px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197230i204D7B0759E4B384%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22MDATP%20alerts%20when%20files%20are%20written%20to%20the%20system.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EMDATP%20alerts%20when%20files%20are%20written%20to%20the%20system.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20step%20is%20to%20extract%20web%20script%20filenames%20from%20alerts%20in%20the%20Azure%20Sentinel%20SecurityAlerts%20table.%20The%20information%20is%20stored%20in%20a%20JSON%20entity%2C%20we%20need%20to%20parse%20that%20to%20extract%20its%20name%20and%20location.%20The%20query%20below%20will%20perform%20the%20extraction%20and%20display%20the%20time%20the%20event%20was%20generated%2C%20the%20filename%20which%20is%20the%20name%20of%20the%20shell%20and%20the%20directory%20that%20the%20shell%20is%20in.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-745757013%22%20id%3D%22toc-hId-745757013%22%3EWeb%20shell%20file%20query%2C%20Part%201%2F2%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20timeWindow%20%3D%203d%3B%0A%2F%2FScript%20file%20extensions%20to%20match%20on%2C%20can%20be%20expanded%20for%20your%20environment%0Alet%20scriptExtensions%20%3D%20dynamic(%5B%22.php%22%2C%20%22.jsp%22%2C%20%22.js%22%2C%20%22.aspx%22%2C%20%22.asmx%22%2C%20%22.asax%22%2C%20%22.cfm%22%2C%20%22.shtml%22%5D)%3B%0ASecurityAlert%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeWindow)%0A%7C%20where%20ProviderName%20%3D%3D%20%22MDATP%22%0A%2F%2FParse%20and%20expand%20the%20alert%20JSON%0A%7C%20extend%20alertData%20%3D%20parse_json(Entities)%0A%7C%20mvexpand%20alertData%0A%7C%20where%20alertData.Type%20%3D%3D%20%22file%22%0A%2F%2FThis%20can%20be%20expanded%20to%20include%20more%20file%20types%0A%7C%20where%20alertData.Name%20has_any(scriptExtensions)%0A%7C%20extend%20FileName%20%3D%20tostring(alertData.Name)%2C%20Directory%20%3D%20tostring(alertData.Directory)%0A%7C%20project%20TimeGenerated%2C%20FileName%2C%20Directory%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20alert%20has%20been%20parsed%20to%20provide%20the%20file%20name%20that%20triggered%20the%20alert%2C%20%E2%80%98fonts.aspx%E2%80%99%2C%20and%20the%20location%20of%20the%20file.%20The%20web%20shell%20has%20been%20installed%20on%20a%20SharePoint%20server%20and%20written%20to%20the%20publicly%20accessible%20%E2%80%98Template%5CLayouts%E2%80%99%26nbsp%3B%20directory.%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%20image-alt%3D%22TMcElroy_0-1591611700260.png%22%20style%3D%22width%3A%20955px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197231i4DB02A4E86F43BCA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22TMcElroy_0-1591611700260.png%22%20alt%3D%22Parsed%20alert%20showing%20web%20shell%20location.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EParsed%20alert%20showing%20web%20shell%20location.%3C%2FSPAN%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%20can%20now%20expand%20our%20Kusto%20query%20to%20join%20the%20extracted%20file%20with%20the%20W3CIISLog%20table%20and%20find%20detail%20about%20web%20requests%20that%20were%20made%20to%20it.%20This%20is%20easy%20to%20do%20as%20we%20have%20the%20filename%20and%20the%20time%20the%20alert%20was%20generated.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId--1061697450%22%20id%3D%22toc-hId--1061697450%22%3EWeb%20shell%20file%20query%2C%20Part%202%2F2%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%7C%20join%20(%20%0AW3CIISLog%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeWindow)%20%0A%7C%20where%20csUriStem%20has_any(scriptExtensions)%20%0A%7C%20extend%20splitUriStem%20%3D%20split(csUriStem%2C%20%22%2F%22)%20%0A%7C%20extend%20FileName%20%3D%20splitUriStem%5B-1%5D%0A%7C%20summarize%20StartTime%3Dmin(TimeGenerated)%2C%20EndTime%3Dmax(TimeGenerated)%20by%20AttackerIP%3DcIP%2C%20AttackerUserAgent%3DcsUserAgent%2C%20SiteName%3DsSiteName%2C%20ShellLocation%3DcsUriStem%2C%20tostring(FileName)%20%0A)%20on%20FileName%0A%7C%20project%20StartTime%2C%20EndTime%2C%20AttackerIP%2C%20AttackerUserAgent%2C%20SiteName%2C%20ShellLocation%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBecause%20only%20the%20attacker%20knows%20the%20location%20of%20the%20web%20shell%2C%20we%20can%20be%20confident%20that%20requests%20for%20it%20in%20W3CIIS%20log%20are%20malicious.%20The%20results%20of%20the%20query%20above%20will%20provide%20indicators%20for%20the%20potential%20attacker%20-%20The%20attacker%20IP%20address%20and%20user%20agent.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197232iC0E7CE0E935F9960%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Potential%20attacker%20IP%20and%20user%20agent%20identified.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPotential%20attacker%20IP%20and%20user%20agent%20identified.%3C%2FSPAN%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%3EUsing%20these%20indicators%20we%20can%20investigate%20other%20actions%20the%20attacker%20has%20taken%20on%20the%20webserver.%20Some%20of%20these%20follow-on%20queries%20have%20been%20automated%20in%20a%20Notebook%20covered%20later%20in%20the%20post%2C%20but%20first%20we%20will%20explore%20what%26nbsp%3B%3CSPAN%20class%3D%22TextRun%20SCXW34589235%20BCX0%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW34589235%20BCX0%22%3Ecan%20be%20achieved%20if%20the%20alert%20doesn't%20provide%20the%20web%20shell%20filename%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22TextRun%20SCXW34589235%20BCX0%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW34589235%20BCX0%22%3E.%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22EOP%20SCXW34589235%20BCX0%22%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A1%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A240%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-724750805%22%20id%3D%22toc-hId-724750805%22%3EWeb%20shell%20activity%3C%2FH3%3E%0A%3CP%3EIn%20the%20example%20scenario%20the%20attacker%20uses%20the%20web%20shell%20to%20execute%20a%20command%20that%20copies%20itself%20to%20a%20backup%20location.%20In%20this%20case%20we%20can%20investigate%20with%20Azure%20Sentinel%20based%20upon%20the%20suspicious%20command%20execution%20alerts%20from%20MDATP.%20The%20diagram%20below%20highlights%20where%20in%20the%20example%20scenario%20this%20activity%20takes%20place.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20528px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197233iAE4864A6C25F084F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Suspicious%20command%20execution%20stage.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESuspicious%20command%20execution%20stage.%3C%2FSPAN%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%3EMultiple%20MDATP%20alerts%20may%20be%20received%20when%20suspicious%20commands%20are%20executed%20by%20an%20attacker%20through%20their%20web%20shell.%20In%20order%20to%20capture%20all%20alerts%20for%20web%20shell%20activity%20we%20will%20look%20for%20those%20that%20implicate%20the%20IIS%20worker%20process%20%E2%80%93%20w3wp.exe%2C%20by%20searching%20the%20evidence%20in%20the%20%E2%80%98Entities%E2%80%99%20field.%20For%20the%20purposes%20of%20our%20investigation%2C%20we%20can%20be%20confident%20that%20alerts%20involving%20w3wp.exe%20are%20related%20to%20web%20shells.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId--381639080%22%20id%3D%22toc-hId--381639080%22%3ECommand%20execution%20query%2C%20Part%201%2F4%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20timeRange%20%3D%203d%3B%0Alet%20alerts%20%3D%20SecurityAlert%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeRange)%0A%7C%20extend%20alertData%20%3D%20parse_json(Entities)%2C%20recordGuid%20%3D%20new_guid()%3B%0Alet%20shellAlerts%20%3D%20alerts%0A%7C%20where%20ProviderName%20%3D%3D%20%22MDATP%22%20%0A%7C%20mvexpand%20alertData%0A%7C%20where%20alertData.Type%20%3D%3D%20%22file%22%20and%20alertData.Name%20%3D%3D%20%22w3wp.exe%22%0A%7C%20distinct%20SystemAlertId%0A%7C%20join%20kind%3Dinner%20(alerts)%20on%20SystemAlertId%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDue%20to%20the%20behavioural%20nature%20of%20the%20detection%2C%20the%20alerts%20do%20not%20provide%20the%20web%20shell%20file%20name%2C%20we%20need%20to%20consider%20another%20method%20of%20correlating%20them%20with%20the%20W3CIISLog%20table.%20Here%20we%20will%20use%20the%20time%20of%20command%20execution%20in%20the%20SecurityAlert%20table%20to%20collect%20linked%20web%20request%20events%20from%20W3CIISLog%20table%2C%20this%20will%20give%20us%20some%20candidate%20files%20to%20investigate.%3C%2FP%3E%0A%3CP%3EBefore%20linking%20events%20we%20extend%20the%20query%20to%20extract%20the%20suspicious%20command%2C%20the%20time%20it%20was%20executed%20and%20the%20host%20it%20was%20executed%20on.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-2105873753%22%20id%3D%22toc-hId-2105873753%22%3ECommand%20execution%20query%2C%20Part%202%2F4%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%2F%2FScript%20file%20extensions%20to%20match%20on%2C%20can%20be%20expanded%20for%20your%20environment%0Alet%20scriptExtensions%20%3D%20dynamic(%5B%22.php%22%2C%20%22.jsp%22%2C%20%22.js%22%2C%20%22.aspx%22%2C%20%22.asmx%22%2C%20%22.asax%22%2C%20%22.cfm%22%2C%20%22.shtml%22%5D)%3B%0Alet%20alldata%20%3D%20shellAlerts%20%0A%7C%20mvexpand%20alertData%0A%7C%20extend%20Type%20%3D%20alertData.Type%3B%0A%2F%2FCollect%20alerts%20that%20match%20our%20shell%20criteria%0Alet%20filedata%20%3D%20alldata%20%0A%7C%20extend%20id%20%3D%20tostring(alertData.%24id)%20%0A%7C%20extend%20ImageName%20%3D%20alertData.Name%20%0A%7C%20where%20Type%20%3D%3D%20%22file%22%20and%20ImageName%20!%3D%20%22w3wp.exe%22%0A%7C%20extend%20imagefileref%20%3D%20id%3B%0A%2F%2FCollect%20commandline%20and%20execution%20data%20from%20the%20alert%0Alet%20commanddata%20%3D%20alldata%0A%7C%20extend%20CommandLine%20%3D%20tostring(alertData.CommandLine)%20%0A%7C%20extend%20creationtime%20%3D%20tostring(alertData.CreationTimeUtc)%20%0A%7C%20where%20Type%20%3D~%20%22process%22%20%0A%7C%20where%20isnotempty(CommandLine)%20%0A%7C%20extend%20imagefileref%20%3D%20tostring(alertData.ImageFile.%24ref)%3B%0A%2F%2FCollect%20information%20about%20the%20host%20where%20the%20command%20was%20executed%0Alet%20hostdata%20%3D%20alldata%0A%7C%20where%20Type%20%3D~%20%22host%22%0A%7C%20project%20HostName%20%3D%20tostring(alertData.HostName)%2C%20DnsDomain%20%3D%20tostring(alertData.DnsDomain)%2C%20SystemAlertId%0A%7C%20distinct%20HostName%2C%20DnsDomain%2C%20SystemAlertId%3B%0A%2F%2FNow%20we%20have%20extracted%20the%20file%20and%20command%20line%20information%20from%20the%20MDATP%20JSON%20object%2C%20re-combine%20them%0Afiledata%20%0A%7C%20join%20kind%3Dinner%20(%20%0Acommanddata%20%0A)%20on%20imagefileref%0A%7C%20join%20kind%3Dinner%20(hostdata)%20on%20SystemAlertId%0A%7C%20project%20DisplayName%2C%20recordGuid%2C%20TimeGenerated%2C%20ImageName%2C%20CommandLine%2C%20HostName%2C%20DnsDomain%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20attackers%20gain%20initial%20access%2C%20they%20often%20propagate%20their%20web%20shells%20into%20other%20directories%2C%20for%20redundancy%20and%2For%20to%20bypass%20restrictions%20the%20web%20server%20implements%20on%20code%20executing%20from%20the%20IIS%20web%20root.%20If%20they%20do%20this%20via%20a%20shell%20command%2C%20the%20name%20of%20the%20shell%20will%20appear%20on%20the%20command%20line.%20We%20can%20extract%20this%20value%20and%20place%20it%20in%20a%20column%20%E2%80%9CPossibleShell%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-298419290%22%20id%3D%22toc-hId-298419290%22%3ECommand%20execution%20query%2C%20Part%203%2F4%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%7C%20extend%20PossibleShell%20%3D%20iff(CommandLine%20has_any(scriptExtensions)%2C%20extract(%40'(%5Ba-zA-Z0-9%5C-%5C_%5D%2B%5C.%5Bphp%7Cjsp%7Cjs%7Caspx%7Casmx%7Casax%7Ccfm%7Cshtml%5D%2B)(%3F%3A%5Cs%7C%22%7C%24)'%2C%201%2C%20CommandLine)%20%2C%20%22n%2Fa%22%20)%20%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20output%20below%2C%20we%20can%20see%20the%20extracted%20commands%20and%20time%20created.%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%22image.png%22%20style%3D%22width%3A%20604px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197234i08FCB9517CD6B5DE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20can%20now%20expand%20the%20query%20to%20find%20the%20IP%20address%20and%20user%20agent%20of%20our%20attacker%20based%20upon%20the%20time%20of%20the%20suspicious%20command%20execution.%20By%20generating%20a%20time%20key%20we%20can%20join%20the%20SecurityAlert%20and%20W3CIISLog%20tables.%20This%20join%20will%20allow%20us%20to%20extract%20access%20to%20script%20files%20on%20the%20server%20during%20a%201%20minute%20window%20of%20the%20command%20executing%20%E2%80%93%20this%20will%20provide%20us%20with%20possible%20web%20shell%20files%20and%20which%20client%20IP%E2%80%99s%20and%20user%20agents%20were%20accessing%20them%20at%20the%20time.%20On%20busy%20web%20servers%20large%20numbers%20of%20scripts%20will%20be%20accessed%20throughout%20the%20day%20increasing%20the%20chances%20of%20a%20false%20positive.%20To%20help%20mitigate%20this%20the%20query%20will%20only%20present%20scripts%20that%20have%20had%20less%20than%203%20distinct%20client%20IP%20addresses%20visit%20them.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId--1509035173%22%20id%3D%22toc-hId--1509035173%22%3ECommand%20execution%20query%2C%20Part%204%2F4%3C%2FH5%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20lookupWindow%20%3D%201m%3B%0Alet%20lookupBin%20%3D%20lookupWindow%20%2F%202.0%3B%0Alet%20distinctIpThreshold%20%3D%203%3B%0Alet%20commandKeyedData%20%3D%20filedata%0A%2F%2FTime%20key%20the%20command%20line%20ready%20for%20join%20with%20web%20log%0A%7C%20join%20kind%3Dinner%20(%20%0Acommanddata%20%0A)%20on%20imagefileref%0A%7C%20join%20kind%3Dinner%20(hostdata)%20on%20SystemAlertId%0A%7C%20project%20recordGuid%2C%20TimeGenerated%2C%20ImageName%2C%20CommandLine%2C%20TimeKey%20%3D%20bin(TimeGenerated%2C%20lookupBin)%2C%20HostName%2C%20DnsDomain%0A%7C%20extend%20Start%20%3D%20TimeGenerated%3B%0A%2F%2FBaseline%20page%20access%20by%20unique%20IP%20to%20later%20limit%20results%0Alet%20baseline%20%3D%20W3CIISLog%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeRange)%0A%7C%20project-rename%20SourceIP%3DcIP%2C%20PageAccessed%3DcsUriStem%0A%7C%20summarize%20dcount(SourceIP)%20by%20PageAccessed%0A%7C%20where%20dcount_SourceIP%20%26lt%3B%3D%20distinctIpThreshold%3B%0A%2F%2F%20Time%20key%20join%20malicious%20command%20with%20web%20log%20to%20find%20correlated%20events%0AcommandKeyedData%0A%7C%20join%20kind%3Dinner%20(%0AW3CIISLog%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeRange)%0A%7C%20where%20csUriStem%20has_any(scriptExtensions)%20%0A%7C%20extend%20splitUriStem%20%3D%20split(csUriStem%2C%20%22%2F%22)%20%0A%7C%20extend%20FileName%20%3D%20splitUriStem%5B-1%5D%20%7C%20extend%20firstDir%20%3D%20splitUriStem%5B-2%5D%20%7C%20extend%20TimeKey%20%3D%20range(bin(TimeGenerated-lookupWindow%2C%20lookupBin)%2C%20bin(TimeGenerated%2C%20lookupBin)%2ClookupBin)%20%0A%7C%20mv-expand%20TimeKey%20to%20typeof(datetime)%20%0A%7C%20summarize%20StartTime%3Dmin(TimeGenerated)%2C%20EndTime%3Dmax(TimeGenerated)%20by%20Site%3DsSiteName%2C%20HostName%3DsComputerName%2C%20AttackerIP%3DcIP%2C%20AttackerUserAgent%3DcsUserAgent%2C%20csUriStem%2C%20filename%3Dtostring(FileName)%2C%20tostring(firstDir)%2C%20TimeKey%0A)%20on%20TimeKey%2C%20HostName%0A%7C%20where%20(StartTime%20-%20EndTime)%20between%20(0min%20..%20lookupWindow)%0A%7C%20extend%20attackerP%20%3D%20pack(AttackerIP%2C%20AttackerUserAgent)%20%0A%7C%20summarize%20Site%3Dmakeset(Site)%2C%20Attacker%3Dmake_bag(attackerP)%20by%20csUriStem%2C%20filename%2C%20tostring(ImageName)%2C%20CommandLine%2C%20HostName%0A%7C%20project%20Site%2C%20ShellLocation%3DcsUriStem%2C%20ShellName%3Dfilename%2C%20ParentProcess%3DImageName%2C%20CommandLine%2C%20Attacker%2C%20HostName%0A%7C%20join%20kind%3Dinner%20(baseline)%20on%20%24left.ShellLocation%20%3D%3D%20%24right.PageAccessed%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20we%20can%20see%20in%20the%20image%20below%20the%20query%20was%20able%20to%20successfully%20link%20the%20commands%20that%20were%20executed%20through%20a%20potential%20web%20shell%20on%20the%20server%2C%20this%20allows%20us%20to%20get%20the%20attackers%20IP%20address%20and%20their%20user%20agent%20for%20follow%20on%20queries.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20602px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197632iD58CA90D4A16F1FE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Attacker%20IP%20and%20user%20agent%20for%20follow-on%20queries.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAttacker%20IP%20and%20user%20agent%20for%20follow-on%20queries.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20will%20take%20these%20new%20insights%20on%20the%20attack%20and%20use%20them%20to%20identify%20other%20activity%20on%20the%20compromised%20web%20server.%20We%20could%20do%20this%20through%20additional%20queries%2C%20but%20to%20help%20speed%20the%20process%20up%20we%20have%20created%20a%20notebook%20that%20automatically%20enriches%20and%20reports%20interesting%20attacker%20activity.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--546833116%22%20id%3D%22toc-hId--546833116%22%3EBuilding%20out%20the%20investigation%20using%20Jupyter%20Notebooks%3C%2FH2%3E%0A%3CP%3EJupyter%20notebooks%20are%20a%20great%20way%20to%20pull%20these%20investigation%20steps%20together%20in%20one%20place%20for%20analysis.%20If%20you%20are%20new%20to%20Jupyter%20notebooks%20and%20would%20like%20to%20understand%20how%20it%20can%20help%20with%20Azure%20Sentinel%20investigations%20-ERR%3AREF-NOT-FOUND-Ian%20Hellen%20wrote%20a%20-ERR%3AREF-NOT-FOUND-series%20of%20blogs%20covering%20the%20topic.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20example%20below%20we%20built%20a%20notebook%20wrapping%20each%20of%20these%20steps%20into%20a%20single%20analysis%20flow%20and%20have%20added%20some%20additional%20analytics%20to%20help%20understand%20what%20the%20attacker%20may%20have%20been%20doing%20on%20your%20server.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20notebook%20uses%20the%20Kusto%20client%20built%20into%20-ERR%3AREF-NOT-FOUND-MSTICPy%20to%20enable%20it%20to%20communicate%20directly%20with%20your%20LogAnalytics%20server%2C%20we%20also%20use%20other%20MSTICPy%20dependencies%20to%20manipulate%20and%20investigate%20the%20data%20we%20recover.%20If%20you%20do%20not%20have%20MSTICPy%20configured%20in%20your%20environment%20already%20then%20go%20ahead%20and%20%E2%80%9Cpip%20install%20msticpy%E2%80%9D.%20More%20detailed%20instructions%20about%20installation%20and%20setup%20can%20be%20found%20in%20the%20-ERR%3AREF-NOT-FOUND-documentation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUpon%20loading%20into%20the%20notebook%20you%20will%20see%20a%20number%20of%20instructions%20that%20cover%20its%20use%2C%20begin%20by%20importing%20dependencies.%20Then%20configure%2C%20connect%20and%20authenticate%20with%20your%20LogAnalytics%20instance.%3C%2FP%3E%0A%3CP%3EOnce%20configured%20the%20notebook%20provides%20two%20different%20investigations%20to%20choose%20from%2C%20these%20match%20the%20two%20scenarios%20we%20discussed%20earlier%20in%20the%20post.%20You%20can%20investigate%20alerts%20that%20are%20based%20on%20a%20web%20shell%20file%20being%20detected%20or%20you%20can%20begin%20an%20investigation%20into%20alerts%20where%20suspicious%20command%20execution%20from%20a%20likely%20web%20shell%20have%20been%20detected.%20Each%20investigation%20will%20automate%20the%20previous%20queries%20and%20prepare%20the%20data%20for%20further%20enrichment%20in%20the%20notebook.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20investigate%20a%20suspicious%20file%20alert%2C%20you%20will%20start%20with%20the%20cell%20%E2%80%9CBegin%20File%20Investigation%E2%80%9D%20to%20be%20presented%20with%20the%20option%20to%20choose%20which%20potential%20web%20shell%20file%20you%20would%20like%20to%20investigate.%20The%20cell%20will%20automatically%20retrieve%20MDATP%20alert%20entities%20from%20your%20server%2C%20automating%20the%20manual%20hunting%20queries%20we%20executed%20earlier.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20see%20in%20the%20image%20below%20that%20a%20web%20shell%20called%20%E2%80%9Cfonts.aspx%E2%80%9D%20was%20dropped%20to%20the%20server%2C%20matching%20the%20output%20of%20our%20manual%20hunting%20queries.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20601px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197236iBF27432773AD6A24%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20investigate%20a%20suspicious%20command%20execution%20alert%2C%20you%20must%20first%20select%20the%20command%20you%20wish%20to%20investigate.%20Running%20the%20%E2%80%9CBegin%20Command%20Investigation%E2%80%9D%20cell%20will%20produce%20a%20list%20of%20suspicious%20commands%20detected%20by%20MDATP%20for%20you%20to%20choose%20from%2C%20again%20this%20information%20will%20be%20pulled%20directly%20from%20your%20server.%20You%20will%20need%20to%20select%20a%20GUID%20associated%20with%20the%20command%20you%20wish%20to%20investigate.%20%26nbsp%3BAs%20we%20discovered%20earlier%20in%20our%20investigation%20while%20running%20manual%20hunting%20queries%2C%20you%20can%20see%20in%20the%20image%20below%20that%20commands%20have%20been%20executed%20to%20copy%20a%20web%20shell%20file%20into%20different%20locations.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20591px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197237i85E66C4C82ADF40C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20this%20is%20similar%20to%20the%20Kusto%20query%20we%20wrote%20earlier%2C%20this%20time%20the%20script%20will%20perform%20a%20check%20to%20see%20if%20the%20file%20has%20only%20been%20accessed%20by%20a%20single%20client%20IP%2C%20this%20is%20a%20further%20step%20to%20help%20narrow%20down%20candidate%20web%20shell%20files.%20The%20web%20shell%20files%20will%20often%20only%20be%20accessed%20by%20an%20attacker%20and%20no%20other%20users%20on%20the%20server%2C%20therefore%20the%20number%20of%20IP%20addresses%20accessing%20them%20will%20often%20be%20a%20single%20IP.%20If%20the%20attacker%20is%20rotating%20their%20infrastructure%20regularly%20you%20can%20change%20the%20threshold%20at%20the%20top%20of%20the%20cell%20by%20changing%20the%20variable%20named%20%E2%80%9Caccess_threshold%E2%80%9D.%20The%20higher%20you%20increase%20this%20number%20the%20higher%20the%20risk%20of%20false%20positives%2C%20but%20on%20a%20production%20server%20this%20threshold%20can%20likely%20be%20raised%20quite%20high.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegardless%20of%20the%20type%20of%20alert%20you%20chose%20to%20investigate%20(file%20or%20command)%20we%20now%20have%20candidate%20files%20to%20investigate%2C%20we%20can%20enrich%20them%20with%20access%20information%20to%20provide%20us%20with%20a%20potential%20attacker%20IP%20and%20user%20agent.%20In%20the%20below%20image%20you%20can%20see%20that%20we%20have%20processed%20the%20candidate%20files%20and%20found%20potential%20attacker%20IP%E2%80%99s%20and%20user%20agents.%20If%20the%20%E2%80%9Caccess_threshold%E2%80%9D%20has%20been%20increased%20you%20may%20see%20files%20that%20have%20been%20accessed%20by%20legitimate%20users%20at%20a%20similar%20time%20as%20the%20command%20was%20executed%2C%20especially%20if%20the%20server%20is%20busy%20or%20the%20attack%20happens%20during%20core%20working%20hours.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20513px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197242iDC8338CFBF42E06E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20you%20can%20choose%20the%20attacker%20IP%20or%20user%20agent%20you%20want%20to%20investigate%2C%20or%20you%20can%20choose%20to%20investigate%20both.%20You%20will%20also%20need%20to%20specify%20a%20look-back%20file%20access%20time%20window%20as%20the%20notebook%20will%20try%20to%20determine%20which%20files%20the%20attacker%20accessed%20immediately%20before%20the%20web%20shell.%20By%20default%20it%20will%20look-back%20over%2030%20minutes%20of%20data%20before%20the%20suspected%20web%20shell%20execution.%20Once%20we%20have%20chosen%20these%20parameters%20it%20is%20time%20to%20continue%20executing%20the%20notebook%20to%20generate%20a%20report.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20have%20successfully%20taken%20an%20MDATP%20alert%20and%20enriched%20it%20with%20information%20that%20has%20allowed%20us%20to%20find%20both%20the%20web%20shell%20location%20and%20the%20attacker's%20information.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20dealing%20with%20a%20rapidly%20evolving%20incident%2C%20security%20teams%20can%20now%20act%20not%20only%20against%20the%20web%20shell%2C%20but%20the%20IP%20and%20user%20agent%20selectors%20generated%20that%20can%20be%20used%20to%20block%20or%20further%20investigate%20the%20attacker.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20are%20in%20a%20position%20where%20we%20can%20choose%20to%20remove%20the%20attacker%E2%80%99s%20access%20in%20parallel%20to%20the%20web%20shell%20removal.%20This%20effectively%20switches%20the%20focus%20of%20our%20investigation%20to%20the%20attacker%20and%20not%20the%20tools%20they%20have%20used.%20When%20countering%20hands%20on%20keyboard%20attacks%20from%20both%20advanced%20persistent%20threats%20and%20sophisticated%20cybercrime%20groups%2C%20understanding%20the%20attacker%20and%20their%20behavior%20is%20critical%20to%20successful%20eviction%20from%20the%20network.%20Removing%20the%20attacker's%20ability%20to%20communicate%20with%20their%20tools%20also%20removes%20any%20early%20warning%20the%20attacker%20may%20see%20and%20will%20hamper%20their%20ability%20to%20persist.%20The%20notebook%20contains%20a%20file%20history%20analytic%20that%20will%20allow%20the%20identification%20of%20files%20that%20may%20have%20been%20used%20to%20compromise%20the%20server%20so%20the%20entry%20point%20can%20also%20be%20investigated.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20notebook%20provides%20two%20built-in%20analytics%20to%20help%20get%20your%20investigation%20started.%20As%20well%20as%20reporting%20the%20attacker%20IP%2C%20user%20agent%2C%20the%20location%20of%20the%20shell%20and%20the%20website%20impacted%2C%20the%20notebook%20contains%20two%20analytics%20that%20it%20will%20generate%20a%20report%20on%20the%20following%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EFile%20History%3A%3C%2FSTRONG%3E%20This%20is%20a%20list%20of%20the%20files%20on%20the%20server%20accessed%20immediately%20before%20the%20web%20shell%20file%20was%20placed%20by%20the%20attacker.%20The%20option%20%E2%80%9Cprevious%20file%20access%20window%E2%80%9D%20can%20be%20used%20to%20configure%20how%20far%20the%20script%20looks%20back%20through%20the%20logs.%20These%20files%20are%20good%20leads%20to%20continue%20your%20investigation%2C%20in%20a%20scenario%20where%20a%20malicious%20web%20shell%20file%20was%20detected%20on%20the%20server%20you%20may%20be%20able%20to%20use%20this%20analytic%20to%20identify%20the%20page%20that%20was%20exploited%20immediately%20before%20the%20web%20shell%20is%20deployed%20by%20the%20actor.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EEarliest%20Server%20Access%3A%3C%2FSTRONG%3E%20This%20analytic%20looks%20back%20across%20your%20server%20logs%20and%20determines%20the%20earliest%20point%20that%20the%20attacker%20IP%20and%2For%20user%20agent%20accessed%20your%20server%2C%20this%20is%20limited%20by%20a%20time%20range%20and%20is%20configurable%20in%20the%20initial%20config%20%26amp%3B%20connect%20section.%20By%20default%2C%20the%20notebook%20will%20look-back%203%20days%2C%20but%20this%20can%20be%20easily%20expanded.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBelow%20is%20an%20example%20of%20the%20summary%20report%20the%20notebook%20generated%20about%20the%20attacker.%20We%20can%20see%20that%20prior%20to%20their%20first%20web%20shell%20access%20they%20had%20made%20a%20request%20to%20%E2%80%9CPicker.aspx%E2%80%9D.%20This%20file%20is%20strongly%20associated%20with%20the%20patched%20SharePoint%20vulnerability%20-ERR%3AREF-NOT-FOUND-CVE-2019-0604.%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20575px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197248iB2B81196D23ACD53%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20scenario%20we%20have%20taken%20multiple%20alerts%20from%20MDATP%20and%20provided%20enrichments%20from%20W3CIIS%20Logging%20to%20identify%20the%20attackers%20IP%20and%20user%20agent%2C%20these%20can%20now%20be%20used%20to%20further%20investigate%20the%20attackers%20actions%20on%20the%20server.%20We%20have%20been%20able%20to%20automate%20components%20of%20that%20investigation%20in%20a%20notebook%20and%20have%20provided%20a%20workflow%20that%20analysts%20and%20responders%20can%20use.%20The%20notebook%20also%20provides%20a%20foundation%20that%20can%20be%20built%20upon%2C%20with%20some%20knowledge%20of%20Kusto%20and%20Python%20it%E2%80%99s%20possible%20for%20security%20teams%20to%20tailor%20the%20notebook%20to%20their%20environment.%20We%E2%80%99ll%20explore%20such%20an%20expansion%20next%20and%20look%20at%20how%20we%20can%20communicate%20our%20findings%20back%20to%20MDATP.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1940679717%22%20id%3D%22toc-hId-1940679717%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-133225254%22%20id%3D%22toc-hId-133225254%22%3EProviding%20insights%20back%20to%20MDATP%3C%2FH2%3E%0A%3CP%3EBy%20writing%20an%20analytic%20query%20in%20Azure%20Sentinel%20we%20can%20automate%20the%20generation%20of%20some%20of%20these%20insights.%20When%20written%20as%20an%20analytic%2C%20the%20query%20below%20can%20be%20scheduled%20to%20run%20periodically.%20It%20extracts%20web%20shell%20files%20from%20MDATP%20alerts%20over%20the%20last%20hour%2C%20correlates%20them%20with%20historic%20data%20from%20the%20W3CIIS%20log%20and%20creates%20a%20new%20incident%2C%20enriched%20with%20the%20details%20of%20attacks%20leveraging%20the%20shell%20including%20the%20IP%20address%20of%20the%20attacker.%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-csharp%22%3E%3CCODE%3Elet%20alertTimeWindow%20%3D%201h%3B%0Alet%20logTimeWindow%20%3D%207d%3B%0A%2F%2F%20Define%20script%20extensions%20that%20suit%20your%20web%20application%20environment%20-%20a%20sample%20are%20provided%20below%0Alet%20scriptExtensions%20%3D%20dynamic(%5B%22.php%22%2C%20%22.jsp%22%2C%20%22.js%22%2C%20%22.aspx%22%2C%20%22.asmx%22%2C%20%22.asax%22%2C%20%22.cfm%22%2C%20%22.shtml%22%5D)%3B%20%0Alet%20alertData%20%3D%20SecurityAlert%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(alertTimeWindow)%20%0A%7C%20where%20ProviderName%20%3D%3D%20%22MDATP%22%20%0A%2F%2F%20Parse%20and%20expand%20the%20alert%20JSON%20%0A%7C%20extend%20alertData%20%3D%20parse_json(Entities)%20%0A%7C%20mvexpand%20alertData%3B%0Alet%20fileData%20%3D%20alertData%0A%2F%2F%20Extract%20web%20script%20files%20from%20MDATP%20alerts%20-%20our%20malicious%20web%20scripts%20-%20candidate%20web%20shells%0A%7C%20where%20alertData.Type%20%3D~%20%22file%22%20%0A%7C%20where%20alertData.Name%20has_any(scriptExtensions)%20%0A%7C%20extend%20FileName%20%3D%20tostring(alertData.Name)%2C%20Directory%20%3D%20tostring(alertData.Directory)%3B%0Alet%20hostData%20%3D%20alertData%0A%2F%2F%20Extract%20server%20details%20from%20alerts%20and%20map%20to%20alert%20id%0A%7C%20where%20alertData.Type%20%3D~%20%22host%22%0A%7C%20project%20HostName%20%3D%20tostring(alertData.HostName)%2C%20DnsDomain%20%3D%20tostring(alertData.DnsDomain)%2C%20SystemAlertId%0A%7C%20distinct%20HostName%2C%20DnsDomain%2C%20SystemAlertId%3B%0A%2F%2F%20Join%20the%20files%20on%20their%20impacted%20servers%0Alet%20webshellData%20%3D%20fileData%0A%7C%20join%20kind%3Dinner%20(hostData)%20on%20SystemAlertId%20%0A%7C%20project%20TimeGenerated%2C%20FileName%2C%20Directory%2C%20HostName%2C%20DnsDomain%3B%0AwebshellData%0A%7C%20join%20(%20%0A%2F%2F%20Find%20requests%20that%20were%20made%20to%20this%20file%20on%20the%20impacted%20server%20in%20the%20W3CIISLog%20table%20%0AW3CIISLog%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(logTimeWindow)%20%0A%2F%2F%20Restrict%20to%20accesses%20to%20script%20extensions%20%0A%7C%20where%20csUriStem%20has_any(scriptExtensions)%0A%7C%20extend%20splitUriStem%20%3D%20split(csUriStem%2C%20%22%2F%22)%20%0A%7C%20extend%20FileName%20%3D%20splitUriStem%5B-1%5D%2C%20HostName%20%3D%20sComputerName%0A%2F%2F%20Summarize%20potential%20attacker%20activity%0A%7C%20summarize%20count()%2C%20StartTime%3Dmin(TimeGenerated)%2C%20EndTime%3Dmax(TimeGenerated)%2C%20RequestUserAgents%3Dmake_set(csUserAgent)%2C%20ReqestMethods%3Dmake_set(csMethod)%2C%20RequestStatusCodes%3Dmake_set(scStatus)%2C%20RequestCookies%3Dmake_set(csCookie)%2C%20RequestReferers%3Dmake_set(csReferer)%2C%20RequestQueryStrings%3Dmake_set(csUriQuery)%20by%20AttackerIP%3DcIP%2C%20SiteName%3DsSiteName%2C%20ShellLocation%3DcsUriStem%2C%20tostring(FileName)%2C%20HostName%20%0A)%20on%20FileName%2C%20HostName%0A%7C%20project%20StartTime%2C%20EndTime%2C%20AttackerIP%2C%20RequestUserAgents%2C%20SiteName%2C%20ShellLocation%2C%20ReqestMethods%2C%20RequestStatusCodes%2C%20RequestCookies%2C%20RequestReferers%2C%20RequestQueryStrings%2C%20RequestCount%20%3D%20count_%0A%2F%2F%20Expose%20the%20attacker%20ip%20address%20as%20a%20custom%20entity%0A%7C%20extend%20timestamp%3DStartTime%2C%20IPCustomEntity%20%3D%20AttackerIP%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20creating%20the%20analytic%2C%20as%20part%20of%20Azure%20Sentinel%E2%80%99s%20Security%20Orchestration%20Automation%20and%20Response%20(SOAR)%20capabilities%20we%20can%20also%20specify%20an%20automated%20response%20-%20A%20playbook%20to%20run%20when%20incidents%20are%20generated.%20In%20the%20below%20example%20we%20have%20selected%20the%20Playbook%20%E2%80%98-ERR%3AREF-NOT-FOUND-Restrict-MDATPIPAddress%E2%80%99%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%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20480px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197249i421065A87ADD3AE2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22Selecting%20the%20Playbook%20%E2%80%98Restrict-MDATPIPAddress'.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESelecting%20the%20Playbook%20%E2%80%98Restrict-MDATPIPAddress'.%3C%2FSPAN%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%3EThis%20playbook%20extracts%20IP%20Address%20information%20from%20the%20enriched%20incidents%20created%20by%20our%20analytic%2C%20calls%20the%20%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-MDATP%20indicator%20API%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%20and%20submits%20them%20as%20custom%20IoCs%20for%20%E2%80%98AlertAndBlock%E2%80%99.%20Once%20submitted%2C%20MDATP%20will%20create%20new%20alerts%20where%20this%20IP%20address%20is%20observed%20in%20the%20environment%20and%20block%20endpoints%20from%20connecting%20to%20it%20for%2090%20days.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20similar%20analytic%20and%20automated%20response%20could%20also%20be%20configured%20for%20the%20scenario%20where%20we%20link%20suspicious%20commands%20to%20web%20shells%20based%20on%20a%20time%20key.%20Playbooks%20can%20also%20be%20triggered%20manually%2C%20if%20preferred%20through%20the%20incident%20investigation%20experience.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1674229209%22%20id%3D%22toc-hId--1674229209%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-813283624%22%20id%3D%22toc-hId-813283624%22%3EEnriching%20the%20Incident%3C%2FH2%3E%0A%3CP%3E-ERR%3AREF-NOT-FOUND-Microsoft%20Threat%20Protection%20(MTP)%20orchestrates%20across%20endpoint%2C%20identity%2C%20email%20and%20applications%20to%20stop%20attack%20sprawl%20and%20auto-heal%20enterprise%20assets.%26nbsp%3B%20Its%20built-in%20intelligence%20and%20automation%20combine%20signals%20across%20Microsoft%20ATP%20products%20into%20prioritized%20incidents%20enabling%20security%20professionals%20to%20determine%20the%20full%20scope%20and%20impact%20of%20the%20threat.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20installation%20and%20usage%20of%20a%20web%20shell%20is%20often%20only%20a%20small%20part%20of%20the%20overall%20attack.%20Web%20shells%20are%20used%20as%20beachheads%20to%20perform%20follow%20on%20actions%20such%20as%20credential%20theft%2C%20lateral%20movement%20and%20data%20exfiltration.%20Each%20of%20these%20actions%20may%20generate%20signal%20in%20other%20Microsoft%20products%20such%20as%20Azure%20ATP%20or%20Microsoft%20Cloud%20App%20Security%20and%20MTP%20will%20create%20an%20incident%20that%20covers%20them%20all.%20As%20well%20as%20web%20shell%20artifacts%20from%20MDATP%20this%20might%20include%20compromised%20identities%2C%20or%20details%20of%20cloud%20applications%20such%20as%20OneDrive%20that%20were%20used%20to%20exfiltrate%20sensitive%20data%20from%20the%20network.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20enriching%20individual%20MDATP%20alerts%20with%20Azure%20Sentinel%20log%20sources%20we%20have%20shown%20that%20we%20can%20build%20out%20the%20picture%20of%20the%20intrusion%20with%20details%20of%20the%20attacker%20and%20their%20infrastructure.%20Extending%20this%20enrichment%20to%20an%20MTP%20incident%20allows%20us%20to%20take%20this%20further%20and%20perform%20compound%20enrichments%20based%20upon%20the%20full%20scope%20of%20the%20attack.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWorking%20with%20an%20incident%20involving%20a%20web%20shell%20we%20can%20enrich%20endpoint%20alerts%20with%20the%20IP%20address%20and%20user%20agent%20from%20web%20server%20logs%20as%20before.%20With%20the%20incident%20we%20might%20also%20get%20compromised%20identities%20used%20in%20the%20attack%20from%20Azure%20ATP.%20We%20can%20combine%20these%20identities%20with%20the%20IP%20address%20and%20user%20agent%20insights%20to%20fingerprint%20attacker%20activity%20inside%20other%20Azure%20Sentinel%20logs%20sources%20%E2%80%93%20such%20as%20the%20SignIn%20logs%20or%20OfficeActivity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20a%20follow%20up%20post%20we%20will%20describe%20how%20upcoming%20integration%20between%20MTP%20and%20Azure%20Sentinel%20will%20allow%20us%20to%20enrich%20based%20upon%20the%20incident%20rather%20than%20individual%20alerts%20and%20explore%20new%20scenarios%20that%20demonstrate%20the%20power%20of%20this%20combination.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--994170839%22%20id%3D%22toc-hId--994170839%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1493341994%22%20id%3D%22toc-hId-1493341994%22%3E%3CSPAN%3ESummary%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3EBy%20connecting%20MDATP%20alerts%20and%20relevant%20log%20sources%20to%20Azure%20Sentinel%20we%20combined%20signals%20to%20further%20investigate%20web%20shell%20installation%20and%20activity%20alerts%20and%20gained%20additional%20high%20value%20insights%20%E2%80%93%20the%20attacker%20IP%20address%20and%20user%20agent.%20Using%20Jupyter%20notebooks%20we%20performed%20an%20investigation%20based%20upon%20these%20insights%20to%20build%20out%20the%20big%20picture%20of%20the%20intrusion%20and%20identify%20the%20vulnerability%20that%20allowed%20the%20web%20shell%20to%20be%20installed.%20Using%20Sentinel%E2%80%99s%20SOAR%20capabilities%2C%20we%20went%20further%20and%20automated%20the%20generation%20of%20these%20insights%2C%20sharing%20them%20back%20with%20MDATP%20through%20the%20indicator%20API%20for%20further%20action%20%E2%80%93%20such%20as%20new%20alerting%20and%20blocking.%20A%20number%20of%20resources%20relevant%20to%20the%20blog%20were%20added%20to%20the%20Azure%20Sentinel%20github%20and%20can%20be%20found%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FHunting%2520Queries%2FSecurityAlert%2FWebShellFileAlertEnrich.yaml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EKusto%20Query%3A%3C%2FSTRONG%3E%20Web%20shell%20file%20enrichment%20query%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FHunting%2520Queries%2FSecurityAlert%2FWebShellCommandAlertEnrich.yaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EKusto%20Query%3A%3C%2FSTRONG%3E%20Web%20shell%20command%20enrichment%20query%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FW3CIISLog%2FMaliciousAlertLinkedWebRequests.yaml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EKusto%20Detection%3A%3C%2FSTRONG%3E%20Malicious%20alert%20linked%20we%20request%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel-Notebooks%2Fblob%2Fmaster%2FGuided%2520Investigation%2520-%2520MDATP%2520Webshell%2520Alerts.ipynb%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EJupyter%20Notebook%3A%3C%2FSTRONG%3E%20Web%20shell%20investigations%20using%20MDATP%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1448065%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20600px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197280i96D19A9AD4ACCF85%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExplore%20Microsoft%20Defender%20ATP%20web%20shell%20alerts%20in%20Azure%20sentinel%2C%20identify%20attacker%20details%20from%20network%20logging%2C%20automate%20the%20investigation%20with%20a%20Jupyter%20notebook%2C%20and%20feed%20indicators%20back%20to%20Microsoft%20Defender%20ATP%20for%20blocking.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1448065%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Sentinel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EInvestigation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Tom McElroy, Rob Mead  – Microsoft Threat Intelligence Center 

 

In this blog we use Azure Sentinel to enrich the investigation of endpoint web shell alerts from Microsoft Defender Advanced Threat Protection (MDATP) by correlating with additional data sourcessuch as W3CIIS log. We then show how Azure Sentinel’s Security Orchestration Automation and Response (SOAR) capabilities can be used to automatically develop and share new insights from these logs back with MDATP, triggered by one of its own alerts. 

 

web shell is a persistence mechanism and backdoor often leveraged by attackers on web servers. Usually this involves an attacker writing a script to a web application directory and using it to execute commands from a remote location. In the last 18 months the profile of web shell based attacks has increased, due in part to a number of vulnerabilities reported in web applications such as CVE-2019-0604 or CVE-2019-16759. Multiple threat actors have also been seen to leverage web shells in recent campaigns, Microsoft has reported on GALLIUM and other groups earlier in the year. Web shells are an attractive remote access method for attackers since they often sit on internet facing infrastructure and their short content length can make writing anti-virus signatures for them difficult. 

 

The scenario below has been created tform the basis of our investigation and enrichment. An attacker will first exploit CVE-2019-0604, a patched SharePoint vulnerability, to place a web shell file on the server. The attacker will then leverage the shell to copy itself into another directory to provide a redundant backdoor.

Diagram showing where MDATP alerts trigger during our investigation.Diagram showing where MDATP alerts trigger during our investigation.

 

 

We will focus our investigation on two areas:

 

Web shell installation: A web shell file is placed on the server and the code it contains or the behaviours it exhibits result in an MDATP alert. In this scenario the alert will contain details of the potential shell (e.g. c:\mywebapp\webshell.aspx). 

 

Web shell activity: The web server executes a series of suspicious commands that look like they might be web shell activity, and result in an MDATP alert. In this scenario the alert will contain details of the suspicious processes executed. 

 

Example EDR alert for web shell installation in the MDATP Security Center.Example EDR alert for web shell installation in the MDATP Security Center.

Connecting the data sources

MDATP alerts can be connected to Azure Sentinel using the built in connector. Once enabled, alerts are written to the SecurityAlert table.

 

Example of an MDATP alert in Azure Sentinel.Example of an MDATP alert in Azure Sentinel.

 

The evidence associated with an alert in this table can be found in the ‘Entities’ field. This is where we’ll need to look to extract the details of suspicious files and processes.

 

Additional visibility into web servers can be enabled by configuring collection of web server logs in Azure Sentinel. Although in this example we discuss collection from IIS web servers, data could also be collected from other server technologies such as Apache or Tomcat to enable similar investigations. For more detail on configuring IIS log collection for Azure Sentinel see here.

 

In Azure Sentinel, the W3CIIS table contains details of requests made to the web server, including the source IP, the request page and the user agent used.

 

Azure Sentinel's W3CIIS log table.Azure Sentinel's W3CIIS log table.

Investigating the alerts and generating new insights

By connecting MDATP alerts and relevant data sources to Azure Sentinel, we can gain additional insights and enrich our investigation. In the case of a web shell, we want to be able to answer questions such as how it got there and where the attack came from.

 

Acting against the web shell alone may provide a highly motivated attacker with a window of opportunity to start diversifying their access, but by acting against the web shell with MDATP in parallel to identifying the attacker’s IP and user agent in Azure Sentinel a more developed picture of the attacks can be formed.

 

Web shell installation

In the attack scenario there are two instances where a web shell file is placed onto the server; when the attacker uses Picker.aspx to deploy the initial shell and when the attacker copies the file into a new directory. Both actions trigger MDATP alerts for the web shell file which contain a filename for the shell that we can further investigate. The diagram below highlights where in the example scenario this activity takes place.

 

MDATP alerts when files are written to the system.MDATP alerts when files are written to the system.

 

The first step is to extract web script filenames from alerts in the Azure Sentinel SecurityAlerts table. The information is stored in a JSON entity, we need to parse that to extract its name and location. The query below will perform the extraction and display the time the event was generated, the filename which is the name of the shell and the directory that the shell is in.

 

Web shell file query, Part 1/2

 

let timeWindow = 3d;
//Script file extensions to match on, can be expanded for your environment
let scriptExtensions = dynamic([".php", ".jsp", ".js", ".aspx", ".asmx", ".asax", ".cfm", ".shtml"]);
SecurityAlert
| where TimeGenerated > ago(timeWindow)
| where ProviderName == "MDATP"
//Parse and expand the alert JSON
| extend alertData = parse_json(Entities)
| mvexpand alertData
| where alertData.Type == "file"
//This can be expanded to include more file types
| where alertData.Name has_any(scriptExtensions)
| extend FileName = tostring(alertData.Name), Directory = tostring(alertData.Directory)
| project TimeGenerated, FileName, Directory

 

 

The alert has been parsed to provide the file name that triggered the alert, ‘fonts.aspx’, and the location of the file. The web shell has been installed on a SharePoint server and written to the publicly accessible ‘Template\Layouts’  directory.

 

Parsed alert showing web shell location.Parsed alert showing web shell location.

 

We can now expand our Kusto query to join the extracted file with the W3CIISLog table and find detail about web requests that were made to it. This is easy to do as we have the filename and the time the alert was generated.

 

Web shell file query, Part 2/2

 

| join ( 
W3CIISLog 
| where TimeGenerated > ago(timeWindow) 
| where csUriStem has_any(scriptExtensions) 
| extend splitUriStem = split(csUriStem, "/") 
| extend FileName = splitUriStem[-1]
| summarize StartTime=min(TimeGenerated), EndTime=max(TimeGenerated) by AttackerIP=cIP, AttackerUserAgent=csUserAgent, SiteName=sSiteName, ShellLocation=csUriStem, tostring(FileName) 
) on FileName
| project StartTime, EndTime, AttackerIP, AttackerUserAgent, SiteName, ShellLocation

 

 

Because only the attacker knows the location of the web shell, we can be confident that requests for it in W3CIIS log are malicious. The results of the query above will provide indicators for the potential attacker - The attacker IP address and user agent.

 

Potential attacker IP and user agent identified.Potential attacker IP and user agent identified.

 

Using these indicators we can investigate other actions the attacker has taken on the webserver. Some of these follow-on queries have been automated in a Notebook covered later in the post, but first we will explore what can be achieved if the alert doesn't provide the web shell filename. 

 

Web shell activity

In the example scenario the attacker uses the web shell to execute a command that copies itself to a backup location. In this case we can investigate with Azure Sentinel based upon the suspicious command execution alerts from MDATP. The diagram below highlights where in the example scenario this activity takes place.

 

Suspicious command execution stage.Suspicious command execution stage.

 

Multiple MDATP alerts may be received when suspicious commands are executed by an attacker through their web shell. In order to capture all alerts for web shell activity we will look for those that implicate the IIS worker process – w3wp.exe, by searching the evidence in the ‘Entities’ field. For the purposes of our investigation, we can be confident that alerts involving w3wp.exe are related to web shells.

 

Command execution query, Part 1/4

 

let timeRange = 3d;
let alerts = SecurityAlert 
| where TimeGenerated > ago(timeRange)
| extend alertData = parse_json(Entities), recordGuid = new_guid();
let shellAlerts = alerts
| where ProviderName == "MDATP" 
| mvexpand alertData
| where alertData.Type == "file" and alertData.Name == "w3wp.exe"
| distinct SystemAlertId
| join kind=inner (alerts) on SystemAlertId;

 

 

Due to the behavioural nature of the detection, the alerts do not provide the web shell file name, we need to consider another method of correlating them with the W3CIISLog table. Here we will use the time of command execution in the SecurityAlert table to collect linked web request events from W3CIISLog table, this will give us some candidate files to investigate.

Before linking events we extend the query to extract the suspicious command, the time it was executed and the host it was executed on.

 

Command execution query, Part 2/4

 

//Script file extensions to match on, can be expanded for your environment
let scriptExtensions = dynamic([".php", ".jsp", ".js", ".aspx", ".asmx", ".asax", ".cfm", ".shtml"]);
let alldata = shellAlerts 
| mvexpand alertData
| extend Type = alertData.Type;
//Collect alerts that match our shell criteria
let filedata = alldata 
| extend id = tostring(alertData.$id) 
| extend ImageName = alertData.Name 
| where Type == "file" and ImageName != "w3wp.exe"
| extend imagefileref = id;
//Collect commandline and execution data from the alert
let commanddata = alldata
| extend CommandLine = tostring(alertData.CommandLine) 
| extend creationtime = tostring(alertData.CreationTimeUtc) 
| where Type =~ "process" 
| where isnotempty(CommandLine) 
| extend imagefileref = tostring(alertData.ImageFile.$ref);
//Collect information about the host where the command was executed
let hostdata = alldata
| where Type =~ "host"
| project HostName = tostring(alertData.HostName), DnsDomain = tostring(alertData.DnsDomain), SystemAlertId
| distinct HostName, DnsDomain, SystemAlertId;
//Now we have extracted the file and command line information from the MDATP JSON object, re-combine them
filedata 
| join kind=inner ( 
commanddata 
) on imagefileref
| join kind=inner (hostdata) on SystemAlertId
| project DisplayName, recordGuid, TimeGenerated, ImageName, CommandLine, HostName, DnsDomain

 

 

When attackers gain initial access, they often propagate their web shells into other directories, for redundancy and/or to bypass restrictions the web server implements on code executing from the IIS web root. If they do this via a shell command, the name of the shell will appear on the command line. We can extract this value and place it in a column “PossibleShell”.

 

Command execution query, Part 3/4

 

| extend PossibleShell = iff(CommandLine has_any(scriptExtensions), extract(@'([a-zA-Z0-9\-\_]+\.[php|jsp|js|aspx|asmx|asax|cfm|shtml]+)(?:\s|"|$)', 1, CommandLine) , "n/a" ) 

 

 

In the output below, we can see the extracted commands and time created.

 

image.png

We can now expand the query to find the IP address and user agent of our attacker based upon the time of the suspicious command execution. By generating a time key we can join the SecurityAlert and W3CIISLog tables. This join will allow us to extract access to script files on the server during a 1 minute window of the command executing – this will provide us with possible web shell files and which client IP’s and user agents were accessing them at the time. On busy web servers large numbers of scripts will be accessed throughout the day increasing the chances of a false positive. To help mitigate this the query will only present scripts that have had less than 3 distinct client IP addresses visit them.

 

Command execution query, Part 4/4

 

let lookupWindow = 1m;
let lookupBin = lookupWindow / 2.0;
let distinctIpThreshold = 3;
let commandKeyedData = filedata
//Time key the command line ready for join with web log
| join kind=inner ( 
commanddata 
) on imagefileref
| join kind=inner (hostdata) on SystemAlertId
| project recordGuid, TimeGenerated, ImageName, CommandLine, TimeKey = bin(TimeGenerated, lookupBin), HostName, DnsDomain
| extend Start = TimeGenerated;
//Baseline page access by unique IP to later limit results
let baseline = W3CIISLog 
| where TimeGenerated > ago(timeRange)
| project-rename SourceIP=cIP, PageAccessed=csUriStem
| summarize dcount(SourceIP) by PageAccessed
| where dcount_SourceIP <= distinctIpThreshold;
// Time key join malicious command with web log to find correlated events
commandKeyedData
| join kind=inner (
W3CIISLog 
| where TimeGenerated > ago(timeRange)
| where csUriStem has_any(scriptExtensions) 
| extend splitUriStem = split(csUriStem, "/") 
| extend FileName = splitUriStem[-1] | extend firstDir = splitUriStem[-2] | extend TimeKey = range(bin(TimeGenerated-lookupWindow, lookupBin), bin(TimeGenerated, lookupBin),lookupBin) 
| mv-expand TimeKey to typeof(datetime) 
| summarize StartTime=min(TimeGenerated), EndTime=max(TimeGenerated) by Site=sSiteName, HostName=sComputerName, AttackerIP=cIP, AttackerUserAgent=csUserAgent, csUriStem, filename=tostring(FileName), tostring(firstDir), TimeKey
) on TimeKey, HostName
| where (StartTime - EndTime) between (0min .. lookupWindow)
| extend attackerP = pack(AttackerIP, AttackerUserAgent) 
| summarize Site=makeset(Site), Attacker=make_bag(attackerP) by csUriStem, filename, tostring(ImageName), CommandLine, HostName
| project Site, ShellLocation=csUriStem, ShellName=filename, ParentProcess=ImageName, CommandLine, Attacker, HostName
| join kind=inner (baseline) on $left.ShellLocation == $right.PageAccessed

 

 

As we can see in the image below the query was able to successfully link the commands that were executed through a potential web shell on the server, this allows us to get the attackers IP address and their user agent for follow on queries.

 

Attacker IP and user agent for follow-on queries.Attacker IP and user agent for follow-on queries.

 

 

We will take these new insights on the attack and use them to identify other activity on the compromised web server. We could do this through additional queries, but to help speed the process up we have created a notebook that automatically enriches and reports interesting attacker activity.

Building out the investigation using Jupyter Notebooks

Jupyter notebooks are a great way to pull these investigation steps together in one place for analysis. If you are new to Jupyter notebooks and would like to understand how it can help with Azure Sentinel investigations Ian Hellen wrote a series of blogs covering the topic.

 

In the example below we built a notebook wrapping each of these steps into a single analysis flow and have added some additional analytics to help understand what the attacker may have been doing on your server.

 

The notebook uses the Kusto client built into MSTICPy to enable it to communicate directly with your LogAnalytics server, we also use other MSTICPy dependencies to manipulate and investigate the data we recover. If you do not have MSTICPy configured in your environment already then go ahead and “pip install msticpy”. More detailed instructions about installation and setup can be found in the documentation.

 

Upon loading into the notebook you will see a number of instructions that cover its use, begin by importing dependencies. Then configure, connect and authenticate with your LogAnalytics instance.

Once configured the notebook provides two different investigations to choose from, these match the two scenarios we discussed earlier in the post. You can investigate alerts that are based on a web shell file being detected or you can begin an investigation into alerts where suspicious command execution from a likely web shell have been detected. Each investigation will automate the previous queries and prepare the data for further enrichment in the notebook.

 

To investigate a suspicious file alert, you will start with the cell “Begin File Investigation” to be presented with the option to choose which potential web shell file you would like to investigate. The cell will automatically retrieve MDATP alert entities from your server, automating the manual hunting queries we executed earlier.

 

You can see in the image below that a web shell called “fonts.aspx” was dropped to the server, matching the output of our manual hunting queries.

 

image.png

 

To investigate a suspicious command execution alert, you must first select the command you wish to investigate. Running the “Begin Command Investigation” cell will produce a list of suspicious commands detected by MDATP for you to choose from, again this information will be pulled directly from your server. You will need to select a GUID associated with the command you wish to investigate.  As we discovered earlier in our investigation while running manual hunting queries, you can see in the image below that commands have been executed to copy a web shell file into different locations.

 

image.png

 

While this is similar to the Kusto query we wrote earlier, this time the script will perform a check to see if the file has only been accessed by a single client IP, this is a further step to help narrow down candidate web shell files. The web shell files will often only be accessed by an attacker and no other users on the server, therefore the number of IP addresses accessing them will often be a single IP. If the attacker is rotating their infrastructure regularly you can change the threshold at the top of the cell by changing the variable named “access_threshold”. The higher you increase this number the higher the risk of false positives, but on a production server this threshold can likely be raised quite high.

 

Regardless of the type of alert you chose to investigate (file or command) we now have candidate files to investigate, we can enrich them with access information to provide us with a potential attacker IP and user agent. In the below image you can see that we have processed the candidate files and found potential attacker IP’s and user agents. If the “access_threshold” has been increased you may see files that have been accessed by legitimate users at a similar time as the command was executed, especially if the server is busy or the attack happens during core working hours.

 

image.png

 

Here you can choose the attacker IP or user agent you want to investigate, or you can choose to investigate both. You will also need to specify a look-back file access time window as the notebook will try to determine which files the attacker accessed immediately before the web shell. By default it will look-back over 30 minutes of data before the suspected web shell execution. Once we have chosen these parameters it is time to continue executing the notebook to generate a report.

 

We have successfully taken an MDATP alert and enriched it with information that has allowed us to find both the web shell location and the attacker's information.

 

When dealing with a rapidly evolving incident, security teams can now act not only against the web shell, but the IP and user agent selectors generated that can be used to block or further investigate the attacker.

 

We are in a position where we can choose to remove the attacker’s access in parallel to the web shell removal. This effectively switches the focus of our investigation to the attacker and not the tools they have used. When countering hands on keyboard attacks from both advanced persistent threats and sophisticated cybercrime groups, understanding the attacker and their behavior is critical to successful eviction from the network. Removing the attacker's ability to communicate with their tools also removes any early warning the attacker may see and will hamper their ability to persist. The notebook contains a file history analytic that will allow the identification of files that may have been used to compromise the server so the entry point can also be investigated.

 

The notebook provides two built-in analytics to help get your investigation started. As well as reporting the attacker IP, user agent, the location of the shell and the website impacted, the notebook contains two analytics that it will generate a report on the following:

 

  • File History: This is a list of the files on the server accessed immediately before the web shell file was placed by the attacker. The option “previous file access window” can be used to configure how far the script looks back through the logs. These files are good leads to continue your investigation, in a scenario where a malicious web shell file was detected on the server you may be able to use this analytic to identify the page that was exploited immediately before the web shell is deployed by the actor.
  • Earliest Server Access: This analytic looks back across your server logs and determines the earliest point that the attacker IP and/or user agent accessed your server, this is limited by a time range and is configurable in the initial config & connect section. By default, the notebook will look-back 3 days, but this can be easily expanded.

Below is an example of the summary report the notebook generated about the attacker. We can see that prior to their first web shell access they had made a request to “Picker.aspx”. This file is strongly associated with the patched SharePoint vulnerability CVE-2019-0604.

 

image.png

 

In this scenario we have taken multiple alerts from MDATP and provided enrichments from W3CIIS Logging to identify the attackers IP and user agent, these can now be used to further investigate the attackers actions on the server. We have been able to automate components of that investigation in a notebook and have provided a workflow that analysts and responders can use. The notebook also provides a foundation that can be built upon, with some knowledge of Kusto and Python it’s possible for security teams to tailor the notebook to their environment. We’ll explore such an expansion next and look at how we can communicate our findings back to MDATP.

 

Providing insights back to MDATP

By writing an analytic query in Azure Sentinel we can automate the generation of some of these insights. When written as an analytic, the query below can be scheduled to run periodically. It extracts web shell files from MDATP alerts over the last hour, correlates them with historic data from the W3CIIS log and creates a new incident, enriched with the details of attacks leveraging the shell including the IP address of the attacker.

 

 

let alertTimeWindow = 1h;
let logTimeWindow = 7d;
// Define script extensions that suit your web application environment - a sample are provided below
let scriptExtensions = dynamic([".php", ".jsp", ".js", ".aspx", ".asmx", ".asax", ".cfm", ".shtml"]); 
let alertData = SecurityAlert 
| where TimeGenerated > ago(alertTimeWindow) 
| where ProviderName == "MDATP" 
// Parse and expand the alert JSON 
| extend alertData = parse_json(Entities) 
| mvexpand alertData;
let fileData = alertData
// Extract web script files from MDATP alerts - our malicious web scripts - candidate web shells
| where alertData.Type =~ "file" 
| where alertData.Name has_any(scriptExtensions) 
| extend FileName = tostring(alertData.Name), Directory = tostring(alertData.Directory);
let hostData = alertData
// Extract server details from alerts and map to alert id
| where alertData.Type =~ "host"
| project HostName = tostring(alertData.HostName), DnsDomain = tostring(alertData.DnsDomain), SystemAlertId
| distinct HostName, DnsDomain, SystemAlertId;
// Join the files on their impacted servers
let webshellData = fileData
| join kind=inner (hostData) on SystemAlertId 
| project TimeGenerated, FileName, Directory, HostName, DnsDomain;
webshellData
| join ( 
// Find requests that were made to this file on the impacted server in the W3CIISLog table 
W3CIISLog 
| where TimeGenerated > ago(logTimeWindow) 
// Restrict to accesses to script extensions 
| where csUriStem has_any(scriptExtensions)
| extend splitUriStem = split(csUriStem, "/") 
| extend FileName = splitUriStem[-1], HostName = sComputerName
// Summarize potential attacker activity
| summarize count(), StartTime=min(TimeGenerated), EndTime=max(TimeGenerated), RequestUserAgents=make_set(csUserAgent), ReqestMethods=make_set(csMethod), RequestStatusCodes=make_set(scStatus), RequestCookies=make_set(csCookie), RequestReferers=make_set(csReferer), RequestQueryStrings=make_set(csUriQuery) by AttackerIP=cIP, SiteName=sSiteName, ShellLocation=csUriStem, tostring(FileName), HostName 
) on FileName, HostName
| project StartTime, EndTime, AttackerIP, RequestUserAgents, SiteName, ShellLocation, ReqestMethods, RequestStatusCodes, RequestCookies, RequestReferers, RequestQueryStrings, RequestCount = count_
// Expose the attacker ip address as a custom entity
| extend timestamp=StartTime, IPCustomEntity = AttackerIP

 

 

When creating the analytic, as part of Azure Sentinel’s Security Orchestration Automation and Response (SOAR) capabilities we can also specify an automated response - A playbook to run when incidents are generated. In the below example we have selected the Playbook ‘Restrict-MDATPIPAddress

 

Selecting the Playbook ‘Restrict-MDATPIPAddress'.Selecting the Playbook ‘Restrict-MDATPIPAddress'.

 

This playbook extracts IP Address information from the enriched incidents created by our analytic, calls the MDATP indicator API and submits them as custom IoCs for ‘AlertAndBlock’. Once submitted, MDATP will create new alerts where this IP address is observed in the environment and block endpoints from connecting to it for 90 days.

 

A similar analytic and automated response could also be configured for the scenario where we link suspicious commands to web shells based on a time key. Playbooks can also be triggered manually, if preferred through the incident investigation experience.

 

Enriching the Incident

Microsoft Threat Protection (MTP) orchestrates across endpoint, identity, email and applications to stop attack sprawl and auto-heal enterprise assets.  Its built-in intelligence and automation combine signals across Microsoft ATP products into prioritized incidents enabling security professionals to determine the full scope and impact of the threat.

 

The installation and usage of a web shell is often only a small part of the overall attack. Web shells are used as beachheads to perform follow on actions such as credential theft, lateral movement and data exfiltration. Each of these actions may generate signal in other Microsoft products such as Azure ATP or Microsoft Cloud App Security and MTP will create an incident that covers them all. As well as web shell artifacts from MDATP this might include compromised identities, or details of cloud applications such as OneDrive that were used to exfiltrate sensitive data from the network.

 

By enriching individual MDATP alerts with Azure Sentinel log sources we have shown that we can build out the picture of the intrusion with details of the attacker and their infrastructure. Extending this enrichment to an MTP incident allows us to take this further and perform compound enrichments based upon the full scope of the attack.

 

Working with an incident involving a web shell we can enrich endpoint alerts with the IP address and user agent from web server logs as before. With the incident we might also get compromised identities used in the attack from Azure ATP. We can combine these identities with the IP address and user agent insights to fingerprint attacker activity inside other Azure Sentinel logs sources – such as the SignIn logs or OfficeActivity.

 

In a follow up post we will describe how upcoming integration between MTP and Azure Sentinel will allow us to enrich based upon the incident rather than individual alerts and explore new scenarios that demonstrate the power of this combination.

 

Summary

By connecting MDATP alerts and relevant log sources to Azure Sentinel we combined signals to further investigate web shell installation and activity alerts and gained additional high value insights – the attacker IP address and user agent. Using Jupyter notebooks we performed an investigation based upon these insights to build out the big picture of the intrusion and identify the vulnerability that allowed the web shell to be installed. Using Sentinel’s SOAR capabilities, we went further and automated the generation of these insights, sharing them back with MDATP through the indicator API for further action – such as new alerting and blocking. A number of resources relevant to the blog were added to the Azure Sentinel github and can be found below:

 

Kusto Query: Web shell file enrichment query

Kusto Query: Web shell command enrichment query

Kusto Detection: Malicious alert linked we request 

Jupyter Notebook: Web shell investigations using MDATP

 

1 Comment

Awesome Blogpost ! Thanks for sharing with the community :cool: