Home
%3CLINGO-SUB%20id%3D%22lingo-sub-705972%22%20slang%3D%22en-US%22%3ERe%3A%20msticpy%20-%20Python%20Defender%20Tools%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-705972%22%20slang%3D%22en-US%22%3E%3CP%3ESuggestion%3A%3C%2FP%3E%3CP%3EFor%20those%20running%20both%20python%202%20and%203%20maybe%20add%20the%20following%20to%20install%3F%3C%2FP%3E%3CP%3Epip3%20install%26nbsp%3B%3CSPAN%3Emsticpy%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-725251%22%20slang%3D%22en-US%22%3ERe%3A%20msticpy%20-%20Python%20Defender%20Tools%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-725251%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F362757%22%20target%3D%22_blank%22%3E%40Louis_Bernardo%3C%2FA%3E%26nbsp%3Bfor%20suggestion.%3C%2FP%3E%0A%3CP%3EWe%20will%20add%20notes%20in%20the%20installation%20section%20of%20Readme%20in%20case%20both%20python2%20and%20python3%20is%20installed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-648929%22%20slang%3D%22en-US%22%3Emsticpy%20-%20Python%20Defender%20Tools%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-648929%22%20slang%3D%22en-US%22%3E%3CH1%20id%3D%22toc-hId-1963060040%22%20id%3D%22toc-hId-1963060040%22%3EIntroduction%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Emsticpy%3C%2FEM%3E%3C%2FSTRONG%3E%20is%20a%20package%20of%20python%20tools%20intended%20to%20be%20used%20for%20security%20investigations%20and%20hunting%20(primarily%20in%20Jupyter%20notebooks).%20Most%20of%20the%20tools%20originated%20from%20code%20written%20in%20Jupyter%20notebooks%20which%20was%20tidied%20up%20and%20re-packaged%20into%20python%20modules.%20I%E2%80%99ve%20added%20some%20references%20to%20other%20blogs%20in%20the%20%3CA%20href%3D%22%23references%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReferences%3C%2FA%3E%20section%2C%20where%20I%20describe%20some%20of%20these%20notebooks%20in%20more%20detail.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20goals%20of%20the%20package%20are%20twofold%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EReduce%20the%20clutter%20of%20code%20in%20notebooks%20making%20them%20easier%20to%20use%20and%20read.%3C%2FLI%3E%0A%3CLI%3EProvide%20building-blocks%20for%20future%20notebooks%20to%20make%20authoring%20them%20simpler%20and%20quicker.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThere%20are%20some%20side%20benefits%20from%20this%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20functions%20and%20classes%20are%20easier%20to%20test%20when%20extracted%20into%20standalone%20modules%2C%20so%20(hopefully)%20they%20are%20more%20robust.%3C%2FLI%3E%0A%3CLI%3EThe%20code%20is%20easier%20to%20document%2C%20and%20the%20functionality%20is%20more%20discoverable%20than%20having%20to%20wade%20through%20old%20notebooks%20and%20copy%20and%20paste%20the%20desired%20functions.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWhile%20much%20of%20the%20functionality%20is%20only%20useful%20in%20Jupyter%20notebooks%20(e.g.%20much%20of%20the%20%3CEM%3Enbtools%3C%2FEM%3E%20sub-package)%2C%20there%20are%20several%20modules%20that%20are%20usable%20in%20any%20python%20application%20-%20most%20of%20the%20modules%20in%20the%20%3CEM%3Esectools%3C%2FEM%3E%20sub-package%20fall%20into%20this%20category.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Emsticpy%3C%2FEM%3E%3C%2FSTRONG%3E%20is%20organized%20into%20three%20main%20sub-packages%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3Esectools%3C%2FEM%3E%20-%20python%20security%20tools%20to%20help%20with%20data%20analysis%20or%20investigation.%20These%20are%20all%20focused%20on%20data%20transformation%2C%20data%20analysis%20or%20data%20enrichment.%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Enbtools%3C%2FEM%3E%20-%20Jupyter-specific%20UI%20tools%20such%20as%20widgets%20and%20data%20display.%20These%20are%20mostly%20presentation-layer%20tools%20concentrating%20on%20how%20to%20view%20or%20interact%20with%20the%20data.%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Edata%3C%2FEM%3E%20-%20data%20interfaces%20and%20query%20library%20for%20log%20and%20alert%20APIs%20including%20Azure%20Sentinel%2FLog%20Analytics%2C%20Microsoft%20Graph%20Security%20API%20and%20Microsoft%20Defender%20Advanced%20Threat%20Protection%20(MDATP).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20package%20is%20still%20in%20an%20early%20preview%20mode%20so%20there%20are%20likely%20to%20be%20bugs%2C%20possible%20API%20changes%20and%20much%20is%20not%20yet%20optimized%20for%20performance.%20We%20welcome%20feedback%2C%20bug%20reports%20and%20suggestions%20for%20new%20or%20improved%20features%20as%20well%20as%20%3CA%20href%3D%22%23contributing%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Econtributions%3C%2FA%3E%20directly%20to%20the%20package.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20article%20I'll%20give%20a%20brief%20overview%20of%20the%20main%20components.%20This%20is%20intended%20as%20an%20overview%20of%20some%20of%20the%20features%20rather%20than%20a%20full%20user%20guide.%20Although%20the%20modules%2Ffunctions%2Fclasses%20are%20documented%20at%20the%20API%20level%2C%20we%20are%20still%20missing%20more%20detailed%20user%20guidance.%20In%20future%20blogs%20I%20will%20drill%20down%20into%20some%20of%20the%20specific%20components%20to%20describe%20their%20use%20(and%20limitations)%20in%20more%20detail%2C%20which%20will%20help%20fill%20some%20of%20this%20gap.%20Some%20of%20the%20modules%20have%20user%20document%20notebooks%2C%20which%20are%20listed%20in%20the%20%3CA%20href%3D%22%23references%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReferences%3C%2FA%3E%20section%20at%20the%20end%20of%20the%20document.%20The%20API%20documentation%20is%20available%20on%20%3CA%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Foverview.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emstipy%20ReadTheDocs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--589096921%22%20id%3D%22toc-hId--589096921%22%3ERequest%20for%20Comments%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20would%20really%20appreciate%20suggestions%20for%20future%20or%20better%20features.%20You%20can%20add%20these%20in%20comments%20to%20this%20doc%20or%20directly%20as%20issues%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Emsticpy%20GitHub%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1153713414%22%20id%3D%22toc-hId-1153713414%22%3EInstalling%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20package%20requires%20Python%203.6%20or%20later%20(see%20%3CA%20href%3D%22%23supported_platforms%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESupported%20Platforms%3C%2FA%3E%20for%20more%20details).%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Epip%20install%20msticpy%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3Eor%20for%20the%20latest%20dev%20build%20(although%20usually%20we%20publish%20direct%20to%20PyPi)%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Epip%20install%20git%2B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%3C%2FA%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EA%20conda%20recipe%20and%20package%20is%20in%20the%20works%20but%20not%20yet%20available.%3C%2FP%3E%0A%3CP%3EInstalling%20the%20package%20will%20also%20install%20dependencies%20if%20required%20versions%20of%20these%20are%20not%20already%20installed.%20If%20you%20are%20installing%20into%20an%20environment%20where%20you%20are%20using%20some%20of%20these%20dependencies%20(especially%20if%20you%20are%20using%20conflicting%20versions)%2C%20you%20should%20to%20create%20a%20python%20or%20conda%20virtual%20environment%20and%20use%20your%20notebooks%20from%20within%20that.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1398443547%22%20id%3D%22toc-hId--1398443547%22%3ESecurity%20Tools%20Sub-package%20-%20%3CEM%3Esectools%3C%2FEM%3E%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20sub-package%20contains%20several%20modules%20helpful%20for%20working%20on%20security%20investigations%20and%20hunting.%20These%20are%20mostly%20data%20processing%20modules%20and%20classes%20and%20usually%20not%20restricted%20to%20use%20in%20a%20Jupyter%2FIPython%20environment%20(some%20of%20the%20modules%20have%20a%20visualization%20component%20that%20may%20not%20work%20outside%20a%20notebook%20environment).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Ebase64unpack%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20Base64%20and%20archive%20(gz%2C%20zip%2C%20tar)%20extractor%20intended%20to%20help%20decode%20obfuscated%20attack%20command%20lines%20and%20http%20request%20strings.%20Input%20can%20either%20be%20a%20single%20string%20or%20a%20specified%20column%20of%20a%20pandas%20dataframe.%20The%20module%20will%20try%20to%20identify%20any%20base64%20encoded%20strings%20and%20decode%20them.%20If%20the%20result%20of%20a%20decoding%20looks%20like%20one%20of%20the%20supported%20archive%20types%2C%20it%20will%20try%20to%20unpack%20the%20contents.%20The%20results%20of%20each%20decode%2Funpack%20are%20rechecked%20for%20further%20base64%20content%20and%20it%20will%20recurse%20down%20up%20to%2020%20levels%20(the%20default%20can%20be%20overridden%2C%20but%20if%20you%20need%20more%20than%2020%20levels%2C%20there%20is%20probably%20something%20wrong!).%20Output%20is%20to%20a%20decoded%20string%20(for%20single%20string%20input)%20or%20a%20DataFrame%20(for%20dataframe%20input).%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117700iC4D3BDE1C0EBF94E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Base64unpack.png%22%20title%3D%22Base64unpack.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eiocextract%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20uses%20a%20set%20of%20built-in%20regular%20expressions%20to%20look%20for%20Indicator%20of%20Compromise%20(IoC)%20patterns.%20Input%20can%20be%20a%20single%20string%20or%20a%20pandas%20dataframe%20with%20one%20or%20more%20columns%20specified%20as%20input.%20You%20can%20add%20additional%20patterns%20and%20override%20built-in%20patterns.%3C%2FP%3E%0A%3CP%3EThe%20following%20types%20are%20built-in%3A%20IPv4%20and%20IPv6%2C%20URLs%2C%20DNS%20domains%2C%20Hashes%20(MD5%2C%20SHA1%2C%20SHA256)%2C%20Windows%20file%20paths%20and%20Linux%20file%20paths%20(this%20latter%20regex%20is%20kind%20of%20noisy%20because%20a%20legal%20linux%20file%20path%20can%20have%20almost%20any%20character).%20The%20two%20path%20regexes%20are%20not%20run%20by%20default.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOutput%20is%20a%20dictionary%20of%20matches%20(for%20single%20string%20input)%20or%20a%20DataFrame%20(for%20dataframe%20input).%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117701i541F550E8CDA07AD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ioc_extract.png%22%20title%3D%22ioc_extract.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Evtlookup%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWrapper%20class%20around%20%3CA%20href%3D%22https%3A%2F%2Fwww.virustotal.com%2Fen%2Fdocumentation%2Fpublic-api%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVirus%20Total%20API%3C%2FA%3E.%20Input%20can%20be%20a%20single%20IoC%20observable%20or%20a%20pandas%20DataFrame%20containing%20multiple%20observables.%20Processing%20requires%20a%20Virus%20Total%20account%20and%20API%20key%20and%20processing%20performance%20is%20limited%20to%20the%20number%20of%20requests%20per%20minute%20for%20the%20account%20type%20that%20you%20have.%20For%20example%20a%20VirusTotal%20free%20account%20is%20limited%20to%204%20requests%20per%20minute.%20Supported%20IoC%20types%20are%3A%20Filehash%20(MD5%2C%20SHA1%2C%20SHA256)%2C%20URL%2C%20DNS%20Domain%2C%20IPv4%20Address.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117975i7675BF0AA91CBCCE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22vt_lookup.png%22%20title%3D%22vt_lookup.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Egeoip%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EGeographic%20location%20lookup%20for%20IP%20addresses%20is%20implemented%20as%20generic%20class%20with%20support%20for%20different%20data%20providers.%20The%20shipped%20module%20has%20two%20data%20providers%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGeoLiteLookup%20-%20Maxmind%20Geolite%20(see%20%3CA%20href%3D%22https%3A%2F%2Fwww.maxmind.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.maxmind.com%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EIPStackLookup%20-%20IPStack%20(see%20%3CA%20href%3D%22https%3A%2F%2Fipstack.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fipstack.com%3C%2FA%3E)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBoth%20services%20offer%20a%20free%20tier%20for%20non-commercial%20use.%20However%2C%20a%20paid%20tier%20will%20normally%20get%20you%20more%20accuracy%2C%20more%20detail%20and%20a%20higher%20throughput%20rate.%20Maxmind%20geolite%20uses%20a%20downloadable%20database%2C%20while%20IPStack%20is%20an%20online%20lookup%20(an%20account%20and%20API%20key%20are%20required).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20screen%20shot%20shows%20both%20the%20use%20of%20the%20GeoIP%20lookup%20classes%20and%20map%20display%20with%20another%20msticpy%20module%20using%20folium%20(a%20python%20package%20using%20leaflet.js)%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117703i6150A010D07A1F71%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22geo_ip.png%22%20title%3D%22geo_ip.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eeventcluster%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20module%20is%20intended%20to%20be%20used%20to%20summarize%20large%20numbers%20of%20events%20into%20clusters%20of%20different%20patterns.%20High%20volume%20repeating%20events%20can%20often%20make%20it%20difficult%20to%20see%20unique%20and%20interesting%20items.%3C%2FP%3E%0A%3CP%3EThe%20module%20contains%20functions%20to%20generate%20clusterable%20features%20from%20string%20data.%20For%20example%2C%20an%20administration%20command%20that%20does%20some%20maintenance%20on%20thousands%20of%20servers%20with%20a%20commandline%20such%20as%3A%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Einstall-update%20-hostname%20%7B%3CEM%3Ehost.fqdn%3C%2FEM%3E%7D%20-tmp%3A%2Ftmp%2F%7B%3CEM%3Esome_GUID%3C%2FEM%3E%7D%2Frollback%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EThese%20repetitions%20can%20be%20collapsed%20into%20a%20single%20cluster%20pattern%20by%20ignoring%20the%20character%20values%20in%20the%20string%20and%20using%20delimiters%20or%20tokens%20to%20group%20the%20values.%3C%2FP%3E%0A%3CP%3EThis%20module%20uses%20an%20unsupervised%20learning%20module%20implemented%20using%20SciKit%20Learn%20DBScan.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117704i1FA3D3D62F3A4B07%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22event_cluster.png%22%20title%3D%22event_cluster.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eoutliers%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ESimilar%20to%20the%20eventcluster%20module%20but%20a%20little%20bit%20more%20experimental%20(read%20'less%20tested').%20It%20uses%20SciKit%20Learn%20Isolation%20Forest%20to%20identify%20outlier%20events%20in%20a%20single%20data%20set%20or%20using%20one%20data%20set%20as%20training%20data%20and%20another%20on%20which%20to%20predict%20outliers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eauditdextract%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EModule%20to%20load%20and%20decode%20Linux%20audit%20logs.%20It%20collapses%20messages%20sharing%20the%20same%20message%20ID%20into%20single%20events%2C%20decodes%20hex-encoded%20data%20fields%20and%20performs%20some%20event-specific%20formatting%20and%20normalization%20(e.g.%20for%20process%20start%20events%20it%20will%20re-assemble%20the%20process%20command%20line%20arguments%20into%20a%20single%20string).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20figures%20shows%20examples%20of%20raw%20audit%20messages%20and%20converted%20messages%20(these%20are%20two%20different%20event%20sets%2C%20so%20don%E2%80%99t%20show%20the%20same%20messages).%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117705iCE9F8A6200DF2E72%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22auditd_raw.png%22%20title%3D%22auditd_raw.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117706iEE59EF75E0925A2A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22auditd_processed.png%22%20title%3D%22auditd_processed.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-344366788%22%20id%3D%22toc-hId-344366788%22%3ENotebook%20tools%20sub-package%20-%20%3CEM%3Enbtools%3C%2FEM%3E%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20collection%20of%20display%20and%20utility%20modules%20designed%20to%20make%20working%20with%20security%20data%20in%20Jupyter%20notebooks%20quicker%20and%20easier.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Enbwidgets%20-%20groups%20common%20functionality%20such%20as%20list%20pickers%2C%20time%20boundary%20settings%2C%20saving%20and%20retrieving%20environment%20variables%20into%20a%20single%20line%20callable%20command.%20In%20most%20cases%20these%20are%20simple%20wrappers%20and%20collections%20of%20the%20standard%20IPyWidgets.%3C%2FLI%3E%0A%3CLI%3Enbdisplay%20-%20functions%20that%20implement%20common%20display%20of%20things%20like%20alerts%2C%20events%20in%20a%20slightly%20prettier%20and%20more%20consumable%20way%20than%20print().%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-1890663618%22%20id%3D%22toc-hId-1890663618%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--661493343%22%20id%3D%22toc-hId--661493343%22%3Enbwidgets%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuery%20time%20selector%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117707i0704C4253B5B576E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22query_time_widget.png%22%20title%3D%22query_time_widget.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ESession%20browser%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117708i51C145201541ACBC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22session_browser.png%22%20title%3D%22session_browser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlert%20browser%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117709i19B4ACC200F39754%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22alert_selector.png%22%20title%3D%22alert_selector.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1081316992%22%20id%3D%22toc-hId-1081316992%22%3Enbdisplay%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEvent%20timeline%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117710i0984F906D2E1C924%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22event_timeline.png%22%20title%3D%22event_timeline.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELogon%20display%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117711i91228A2F98BAA36D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22logon_display.png%22%20title%3D%22logon_display.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EProcess%20Tree%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117712iCB521AA8FFEF4693%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22process_tree.png%22%20title%3D%22process_tree.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1274326464%22%20id%3D%22toc-hId--1274326464%22%3EData%20sub-package%20-%20%3CEM%3Edata%3C%2FEM%3E%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20of%20these%20components%20are%20currently%20part%20of%20the%20nbtools%20sub-package%20but%20will%20be%20migrated%20to%20the%20data%20sub-package.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-271970366%22%20id%3D%22toc-hId-271970366%22%3EParameterized%20query%20manager%3C%2FH2%3E%0A%3CP%3EThis%20is%20a%20collection%20of%20modules%20that%20includes%20a%20set%20of%20commonly%20used%20queries%20and%20can%20be%20supplemented%20by%20user-defined%20queries%20supplied%20in%20yaml%20files.%20The%20purpose%20of%20these%20is%20to%20give%20you%20quick%20access%20to%20commonly%20used-queries%20in%20a%20way%20that%20allows%20easy%20substitution%20of%20parameter%20values%20such%20as%20date%20range%2C%20host%20name%2C%20account%20name%2C%20etc.%20The%20package%20current%20supports%20Kusto%20query%20language%20(KQL)%20queries%20targeted%20at%20Log%20Analytics%20and%20OData%20queries%20targeted%20at%20Microsoft%20Graph%20Security%20API.%20We%20are%20building%20driver%20modules%20to%20work%20with%20Microsoft%20Defender%20Advanced%20Threat%20Protection%20API%20and%2C%20in%20principle%20could%20be%20extended%20to%20cover%20queries%20expresses%20as%20a%20simple%20string%20expression.%20The%20architecture%20and%20yaml%20format%20was%20inspired%20by%20the%20Intake%20package%20%E2%80%93%20although%20some%20of%20the%20parameter%20substitution%20gymnastics%20meant%20that%20I%20was%20not%20able%20to%20use%20this%20package%20directly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESample%20query%20definition%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117713i4D6F48A5C2E86C42%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22yaml_query_definition.png%22%20title%3D%22yaml_query_definition.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuery%20provider%20setup%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117714i28C76C820BF2BCF2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22query_provider_setup.png%22%20title%3D%22query_provider_setup.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERunning%20a%20query%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117715i55F6975CADC23A59%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22running_query.png%22%20title%3D%22running_query.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENote%3A%20the%20parameters%20for%20the%20query%20are%20auto-extracted%20from%20the%20%3CEM%3Equery_times%3C%2FEM%3E%20date%20widget%20object.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1394910030%22%20id%3D%22toc-hId--1394910030%22%3EOther%20Modules%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Esecurity_alert%20%3C%2FSTRONG%3Eand%20%3CSTRONG%3Esecurity_event%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThese%20are%20encapsulation%20classes%20for%20alerts%20and%20events.%20Each%20has%20a%20standard%20'entities'%20property%20reflecting%20the%20entities%20found%20in%20the%20alert%20or%20event.%20These%20can%20also%20be%20used%20as%20meta-parameters%20for%20many%20of%20the%20queries.%20For%20example%2C%20the%20query%3A%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Eqry.list_host_logons(query_times%2C%20alert)%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3Ewill%20extract%20the%20value%20for%20the%20%3CEM%3Ehostname%3C%2FEM%3E%20query%20parameter%20from%20the%20alert.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eentityschema%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20module%20implements%20entity%20classes%20(e.g.%20Host%2C%20Account%2C%20IPAddress%2C%20etc.)%20used%20in%20Log%20Analytics%20alerts%20and%20in%20many%20of%20these%20modules.%20Each%20entity%20encapsulates%20one%20or%20more%20properties%20related%20to%20the%20entity.%20This%20example%20shows%20a%20Linux%20alert%20with%20the%20related%20entities.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117716i347D33BA403FB14C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22entity_view.png%22%20title%3D%22entity_view.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-2144851664%22%20id%3D%22toc-hId-2144851664%22%3ETo-Do%20Items%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20of%20the%20items%20on%20our%20to-do%20list%20are%20shown%20below.%20However%2C%20other%20things%20requested%20by%20popular%20demand%20or%20contributed%20by%20others%20can%20certainly%20change%20this.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECreate%20generic%20Threat%20Intel%20lookup%20interface%20supporting%20multiple%20providers.%3C%2FLI%3E%0A%3CLI%3EAdd%20additional%20modules%20for%20host-to-ip%20and%20ip-to-host%20resolution.%3C%2FLI%3E%0A%3CLI%3EAdd%20syslog%20queries%2C%20processing%20and%20visualizations.%3C%2FLI%3E%0A%3CLI%3EAdd%20network%20queries%2C%20processing%20and%20visualizations.%3C%2FLI%3E%0A%3CLI%3EAdd%20additional%20notebooks%20to%20document%20use%20of%20the%20tools.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--407305297%22%20id%3D%22toc-hId--407305297%22%3E%3CA%20id%3D%22supported_platforms%22%20target%3D%22_blank%22%3E%3C%2FA%3ESupported%20Platforms%20and%20Packages%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Emsticpy%20is%20OS-independent%3C%2FLI%3E%0A%3CLI%3ERequires%20Python%203.6%20or%20later%3C%2FLI%3E%0A%3CLI%3ERequires%20the%20following%20python%20packages%3A%20pandas%2C%20bokeh%2C%20matplotlib%2C%20seaborn%2C%20setuptools%2C%20urllib3%2C%20ipywidgets%2C%20numpy%2C%20attrs%2C%20requests%2C%20networkx%2C%20ipython%2C%20scikit_learn%2C%20typing%3C%2FLI%3E%0A%3CLI%3EThe%20following%20packages%20are%20recommended%20and%20needed%20for%20some%20specific%20functionality%3A%20Kqlmagic%2C%20maxminddb_geolite2%2C%20folium%2C%20dnspython%2C%20ipwhois%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH1%20id%3D%22toc-hId-1335505038%22%20id%3D%22toc-hId-1335505038%22%3E%3CA%20id%3D%22contributing%22%20target%3D%22_blank%22%3E%3C%2FA%3EContributing%20to%20msticpy%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Emsticpy%3C%2FSTRONG%3E%20is%20intentionally%20an%20open%20source%20package%20so%20that%20it%20is%20available%20to%20be%20used%20as-is%20or%20in%20modified%20form%20by%20anyone%20who%20wants%20to.%20We%20also%20welcome%20contributions%20%E2%80%93%20whether%20these%20are%20whole%20features%2C%20extensions%20of%20existing%20features%2C%20bug-fixes%20or%20additional%20documentation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20a%20little%20finicky%20about%20code%20hygiene%20so%20I%20would%20(politely)%20ask%20the%20following%20for%20potential%20contributors%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EInclude%20doc%20comments%20in%20all%20modules%2C%20classes%2C%20public%20functions%20and%20public%20methods.%20Please%20use%20%3CA%20href%3D%22https%3A%2F%2Fnumpydoc.readthedocs.io%2Fen%2Flatest%2Fformat.html%23class-docstring%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enumpy%20docstring%20standard%3C%2FA%3E%20for%20consistency%20and%20to%20allow%20our%20auto-documentation%20to%20work%20well.%3C%2FLI%3E%0A%3CLI%3EWe%20are%20converting%20to%20%3CA%20href%3D%22https%3A%2F%2Fblack.readthedocs.io%2Fen%2Fstable%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EBlack%3C%2FSTRONG%3E%3C%2FA%3E%20code%20formatting%20throughout%20the%20project.%20This%20will%20happen%20whether%20you%20format%20your%20code%20like%20this%20or%20not.%20%3Asmiling_face_with_smiling_eyes%3A%3C%2FLI%3E%0A%3CLI%3EType%20annotations%20are%20a%20great%20thing.%20History%20and%20I%20will%20thank%20you%20for%20adding%20type%20annotations.%20See%20%3CA%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fapi-how-to-read.html%23type-annotations%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20section%3C%2FA%3E%20of%20the%20docs%20for%20more%20information.%3C%2FLI%3E%0A%3CLI%3EWe%20write%20unit%20tests%20using%20Python%20%3CSTRONG%3Eunitest%3C%2FSTRONG%3E%20format%20but%20run%20these%20with%20%3CSTRONG%3Epytest%3C%2FSTRONG%3E.%20Please%20add%20unit%20tests%20for%20any%20substantial%20PRs%20%E2%80%93%20and%20please%20make%20sure%20that%20the%20existing%20unit%20tests%20complete%20successfully.%3C%2FLI%3E%0A%3CLI%3ELinters%20and%20other%20stuff.%20Committed%20branches%20will%20kick%20of%20tests%20and%20linting%20in%20the%20Azure%20build%20pipeline.%20Many%20of%20these%20are%20none-breaking%20(i.e.%20your%20build%20will%20complete%20with%20warnings)%20but%20please%20try%20to%20avoid%20introducing%20any%20new%20warnings%20(I%E2%80%99m%20having%20a%20hard-enough%20time%20fixing%20my%20own%20warnings!).%20Using%20%3CSTRONG%3Epylint%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Eprospector%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Emypy%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Epydocstyle%3C%2FSTRONG%3E%20is%20a%20good%20minimum%20combination.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1216651923%22%20id%3D%22toc-hId--1216651923%22%3E%3CA%20id%3D%22references%22%20target%3D%22_blank%22%3E%3C%2FA%3EReferences%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENotebook%20blogs%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FWhy-Use-Jupyter-for-Security-Investigations%2Fba-p%2F475729%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EWhy%20use%20Jupyter%20for%20Security%20Investigations%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EHunting%20with%20Jupyter%20Notebooks%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F432921%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EPart%201%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F483466%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EPart%202%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FSecurity-Investigation-with-Azure-Sentinel-and-Jupyter-Notebooks%2Fba-p%2F561413%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EPart%203%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ENotebooks%20illustrating%20uses%20of%20msticpy%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWindows%20Alert%20Investigation%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Investigation%2520-%2520Process-Alerts.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%3C%2FEM%3E%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Investigation%2520-%2520Process-Alerts.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EWindows%20Host%20Explorer%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Windows-Host-Explorer.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%3C%2FEM%3E%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Windows-Host-Explorer.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EOffice%20365%20Exploration%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Office365-Exploring.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%3C%2FEM%3E%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Office365-Exploring.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECross-Network%20Hunting%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Linux-Windows-Office.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Egithub%3C%2FEM%3E%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnbviewer.jupyter.org%2Fgithub%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FNotebooks%2FSample-Notebooks%2FExample%2520-%2520Guided%2520Hunting%2520-%2520Linux-Windows-Office.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ENbViewer%3C%2FEM%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3EUser%20Documentation%20notebooks%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FBase64Unpack.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBase64Upack%20Notebook%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FGeoIPLookups.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGeoIPLookups%20Notebook%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FIoCExtract.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIoCExtract%20Notebook%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FNotebookWidgets.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWidgets%20Notebook%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FVirusTotalLookup.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVirusTotal%20Lookup%20Notebook%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-648929%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CEM%3Emsticpy%3C%2FEM%3E%3C%2FSTRONG%3E%20is%20a%20package%20of%20python%20tools%20intended%20to%20be%20used%20for%20security%20investigations%20and%20hunting%20(primarily%20in%20Jupyter%20notebooks).%20The%20article%20gives%20an%20overview%20of%20many%20of%20the%20modules%20and%20classes%20in%20%3CEM%3E%3CSTRONG%3Emsticpy%3C%2FSTRONG%3E%20%3C%2FEM%3Ewith%20illustrations%20of%20how%20they%20are%20used.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117717i61C6AC6BFB7C0A20%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22splash_image.png%22%20title%3D%22splash_image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-648929%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EInvestigation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Enotebooks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Introduction

 

msticpy is a package of python tools intended to be used for security investigations and hunting (primarily in Jupyter notebooks). Most of the tools originated from code written in Jupyter notebooks which was tidied up and re-packaged into python modules. I’ve added some references to other blogs in the References section, where I describe some of these notebooks in more detail.

 

The goals of the package are twofold:

  1. Reduce the clutter of code in notebooks making them easier to use and read.
  2. Provide building-blocks for future notebooks to make authoring them simpler and quicker.

There are some side benefits from this:

  • The functions and classes are easier to test when extracted into standalone modules, so (hopefully) they are more robust.
  • The code is easier to document, and the functionality is more discoverable than having to wade through old notebooks and copy and paste the desired functions.

While much of the functionality is only useful in Jupyter notebooks (e.g. much of the nbtools sub-package), there are several modules that are usable in any python application - most of the modules in the sectools sub-package fall into this category.

 

msticpy is organized into three main sub-packages:

  • sectools - python security tools to help with data analysis or investigation. These are all focused on data transformation, data analysis or data enrichment.
  • nbtools - Jupyter-specific UI tools such as widgets and data display. These are mostly presentation-layer tools concentrating on how to view or interact with the data.
  • data - data interfaces and query library for log and alert APIs including Azure Sentinel/Log Analytics, Microsoft Graph Security API and Microsoft Defender Advanced Threat Protection (MDATP).

The package is still in an early preview mode so there are likely to be bugs, possible API changes and much is not yet optimized for performance. We welcome feedback, bug reports and suggestions for new or improved features as well as contributions directly to the package.

 

In this article I'll give a brief overview of the main components. This is intended as an overview of some of the features rather than a full user guide. Although the modules/functions/classes are documented at the API level, we are still missing more detailed user guidance. In future blogs I will drill down into some of the specific components to describe their use (and limitations) in more detail, which will help fill some of this gap. Some of the modules have user document notebooks, which are listed in the References section at the end of the document. The API documentation is available on mstipy ReadTheDocs.

 

Request for Comments

 

We would really appreciate suggestions for future or better features. You can add these in comments to this doc or directly as issues on the msticpy GitHub.

 

Installing

 

The package requires Python 3.6 or later (see Supported Platforms for more details).

pip install msticpy

or for the latest dev build (although usually we publish direct to PyPi)

pip install git+https://github.com/microsoft/msticpy

A conda recipe and package is in the works but not yet available.

Installing the package will also install dependencies if required versions of these are not already installed. If you are installing into an environment where you are using some of these dependencies (especially if you are using conflicting versions), you should to create a python or conda virtual environment and use your notebooks from within that.

 

Security Tools Sub-package - sectools

 

This sub-package contains several modules helpful for working on security investigations and hunting. These are mostly data processing modules and classes and usually not restricted to use in a Jupyter/IPython environment (some of the modules have a visualization component that may not work outside a notebook environment).

 

base64unpack

This is a Base64 and archive (gz, zip, tar) extractor intended to help decode obfuscated attack command lines and http request strings. Input can either be a single string or a specified column of a pandas dataframe. The module will try to identify any base64 encoded strings and decode them. If the result of a decoding looks like one of the supported archive types, it will try to unpack the contents. The results of each decode/unpack are rechecked for further base64 content and it will recurse down up to 20 levels (the default can be overridden, but if you need more than 20 levels, there is probably something wrong!). Output is to a decoded string (for single string input) or a DataFrame (for dataframe input).Base64unpack.png

 

iocextract

This uses a set of built-in regular expressions to look for Indicator of Compromise (IoC) patterns. Input can be a single string or a pandas dataframe with one or more columns specified as input. You can add additional patterns and override built-in patterns.

The following types are built-in: IPv4 and IPv6, URLs, DNS domains, Hashes (MD5, SHA1, SHA256), Windows file paths and Linux file paths (this latter regex is kind of noisy because a legal linux file path can have almost any character). The two path regexes are not run by default.

 

Output is a dictionary of matches (for single string input) or a DataFrame (for dataframe input).ioc_extract.png

 

vtlookup

Wrapper class around Virus Total API. Input can be a single IoC observable or a pandas DataFrame containing multiple observables. Processing requires a Virus Total account and API key and processing performance is limited to the number of requests per minute for the account type that you have. For example a VirusTotal free account is limited to 4 requests per minute. Supported IoC types are: Filehash (MD5, SHA1, SHA256), URL, DNS Domain, IPv4 Address.vt_lookup.png

 

geoip

Geographic location lookup for IP addresses is implemented as generic class with support for different data providers. The shipped module has two data providers:

Both services offer a free tier for non-commercial use. However, a paid tier will normally get you more accuracy, more detail and a higher throughput rate. Maxmind geolite uses a downloadable database, while IPStack is an online lookup (an account and API key are required).

 

The following screen shot shows both the use of the GeoIP lookup classes and map display with another msticpy module using folium (a python package using leaflet.js)geo_ip.png

 

eventcluster

This module is intended to be used to summarize large numbers of events into clusters of different patterns. High volume repeating events can often make it difficult to see unique and interesting items.

The module contains functions to generate clusterable features from string data. For example, an administration command that does some maintenance on thousands of servers with a commandline such as:

install-update -hostname {host.fqdn} -tmp:/tmp/{some_GUID}/rollback

These repetitions can be collapsed into a single cluster pattern by ignoring the character values in the string and using delimiters or tokens to group the values.

This module uses an unsupervised learning module implemented using SciKit Learn DBScan.event_cluster.png

 

outliers

Similar to the eventcluster module but a little bit more experimental (read 'less tested'). It uses SciKit Learn Isolation Forest to identify outlier events in a single data set or using one data set as training data and another on which to predict outliers.

 

auditdextract

Module to load and decode Linux audit logs. It collapses messages sharing the same message ID into single events, decodes hex-encoded data fields and performs some event-specific formatting and normalization (e.g. for process start events it will re-assemble the process command line arguments into a single string).

 

The following figures shows examples of raw audit messages and converted messages (these are two different event sets, so don’t show the same messages).auditd_raw.png

 

auditd_processed.png

 

 

Notebook tools sub-package - nbtools

 

This is a collection of display and utility modules designed to make working with security data in Jupyter notebooks quicker and easier.

  • nbwidgets - groups common functionality such as list pickers, time boundary settings, saving and retrieving environment variables into a single line callable command. In most cases these are simple wrappers and collections of the standard IPyWidgets.
  • nbdisplay - functions that implement common display of things like alerts, events in a slightly prettier and more consumable way than print().

 

nbwidgets

 

Query time selector

 

query_time_widget.png

Session browser

 

session_browser.png

 

Alert browser

alert_selector.png

 

nbdisplay

 

Event timeline

 

event_timeline.png

 

Logon display

 

logon_display.png

 

Process Tree

 

process_tree.png

 

Data sub-package - data

 

Some of these components are currently part of the nbtools sub-package but will be migrated to the data sub-package.

 

Parameterized query manager

This is a collection of modules that includes a set of commonly used queries and can be supplemented by user-defined queries supplied in yaml files. The purpose of these is to give you quick access to commonly used-queries in a way that allows easy substitution of parameter values such as date range, host name, account name, etc. The package current supports Kusto query language (KQL) queries targeted at Log Analytics and OData queries targeted at Microsoft Graph Security API. We are building driver modules to work with Microsoft Defender Advanced Threat Protection API and, in principle could be extended to cover queries expresses as a simple string expression. The architecture and yaml format was inspired by the Intake package – although some of the parameter substitution gymnastics meant that I was not able to use this package directly.

 

Sample query definition

 

yaml_query_definition.png

 

Query provider setup

 

query_provider_setup.png

 

Running a query

 

running_query.png

 

Note: the parameters for the query are auto-extracted from the query_times date widget object.

 

Other Modules

 

security_alert and security_event

These are encapsulation classes for alerts and events. Each has a standard 'entities' property reflecting the entities found in the alert or event. These can also be used as meta-parameters for many of the queries. For example, the query:

qry.list_host_logons(query_times, alert)

will extract the value for the hostname query parameter from the alert.

 

entityschema

This module implements entity classes (e.g. Host, Account, IPAddress, etc.) used in Log Analytics alerts and in many of these modules. Each entity encapsulates one or more properties related to the entity. This example shows a Linux alert with the related entities.entity_view.png

 

To-Do Items

 

Some of the items on our to-do list are shown below. However, other things requested by popular demand or contributed by others can certainly change this.

  • Create generic Threat Intel lookup interface supporting multiple providers.
  • Add additional modules for host-to-ip and ip-to-host resolution.
  • Add syslog queries, processing and visualizations.
  • Add network queries, processing and visualizations.
  • Add additional notebooks to document use of the tools.

 

Supported Platforms and Packages

 

  • msticpy is OS-independent
  • Requires Python 3.6 or later
  • Requires the following python packages: pandas, bokeh, matplotlib, seaborn, setuptools, urllib3, ipywidgets, numpy, attrs, requests, networkx, ipython, scikit_learn, typing
  • The following packages are recommended and needed for some specific functionality: Kqlmagic, maxminddb_geolite2, folium, dnspython, ipwhois

Contributing to msticpy

 

msticpy is intentionally an open source package so that it is available to be used as-is or in modified form by anyone who wants to. We also welcome contributions – whether these are whole features, extensions of existing features, bug-fixes or additional documentation.

 

I’m a little finicky about code hygiene so I would (politely) ask the following for potential contributors:

  • Include doc comments in all modules, classes, public functions and public methods. Please use numpy docstring standard for consistency and to allow our auto-documentation to work well.
  • We are converting to Black code formatting throughout the project. This will happen whether you format your code like this or not. :smiling_face_with_smiling_eyes:
  • Type annotations are a great thing. History and I will thank you for adding type annotations. See this section of the docs for more information.
  • We write unit tests using Python unitest format but run these with pytest. Please add unit tests for any substantial PRs – and please make sure that the existing unit tests complete successfully.
  • Linters and other stuff. Committed branches will kick of tests and linting in the Azure build pipeline. Many of these are none-breaking (i.e. your build will complete with warnings) but please try to avoid introducing any new warnings (I’m having a hard-enough time fixing my own warnings!). Using pylint, prospector, mypy and pydocstyle is a good minimum combination.

 

References

 

Notebook blogs

Notebooks illustrating uses of msticpy:

User Documentation notebooks

 

2 Comments
Occasional Visitor

Suggestion:

For those running both python 2 and 3 maybe add the following to install?

pip3 install msticpy

Microsoft

Thanks @Louis_Bernardo for suggestion.

We will add notes in the installation section of Readme in case both python2 and python3 is installed.