Home
%3CLINGO-SUB%20id%3D%22lingo-sub-860239%22%20slang%3D%22en-US%22%3EUsing%20Threat%20Intelligence%20in%20your%20Jupyter%20Notebooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-860239%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId-1821959866%22%20id%3D%22toc-hId-1821959866%22%3EIntroduction%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsing%20threat%20intelligence%20(TI)%20is%20vital%20part%20of%20most%20hunts%20and%20investigations.%20You%20see%20a%20suspicious%20IP%20address%20in%20your%20logs%20and%20you%20want%20to%20check%20its%20reputation%3A%20is%20it%20a%20known%20C2%20(Command%20and%20Control)%20address%3F%20is%20it%20associated%20with%20malware%20drops%3F%20You%20want%20to%20check%20a%20file%20hash%20to%20see%20if%20it%20is%20known%20malware.%20In%20many%20cases%2C%20getting%20a%20confirmation%20that%20your%20suspected%20IoC%20(indicator%20of%20compromise)%20is%20known%20to%20be%20bad%20can%20shortcut%20hours%20of%20investigation%20time.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESince%20its%20early%20days%20the%20msticpy%20package%20has%20had%20a%20module%20to%20perform%20look-ups%20at%20the%20popular%20VirusTotal%20service.%20We've%20recently%20released%20an%20update%20that%20gives%20you%20a%20generic%20TI%20lookup%20capability.%20You%20can%20configure%20multiple%20TI%20providers%20and%20submit%20one%20or%20more%20IoCs%20to%20them%20in%20a%20single%20function%20call.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20first%20set%20of%20providers%20is%20for%20Azure%20Sentinel%20TI.%20If%20you%20have%20set%20up%20a%20TI%20feed%20from%20the%20%3CA%20title%3D%22Microsoft%20Graph%20Security%20API%20Threat%20Indicators%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fresources%2Fsecurity-api-overview%3Fview%3Dgraph-rest-beta%23threat-indicators-preview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft%20Graph%20Security%20API%3C%2FA%3E%2C%20the%20indicators%20are%20made%20available%20as%20a%20table%20in%20Azure%20Sentinel%20Log%20Analytics%20store%20(see%20more%20about%20this%20%3CA%20title%3D%22Azure%20Sentinel%20TI%22%20href%3D%22%23h_944510181421568931743053%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ebelow%3C%2FA%3E).%20This%20can%20be%20queried%20using%20the%20msticpy%20TILookup%20class%20alongside%20other%20providers%20such%20as%20VirusTotal%2C%20AlienVault%20OTX%2C%20and%20IBM%20XForce.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere's%20an%20example%2C%20looking%20up%20a%20single%20observable.%20In%20the%20remainder%20of%20the%20article%20we'll%20take%20you%20through%20setting%20up%20your%20TI%20providers%2C%20querying%20IoCs%20and%20interpreting%20the%20results.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20712px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132277iB0E99D50FE568BCA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22OTXLookup.png%22%20title%3D%22OTXLookup.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--926710600%22%20id%3D%22toc-hId--926710600%22%3EA%20Note%20on%20Terminology%3C%2FH3%3E%0A%3CP%3EThe%20terms%20%3CEM%3Eobservable%3C%2FEM%3E%2C%20%3CEM%3Eindicator%3C%2FEM%3E%2C%20%3CEM%3Eindicator%20of%20compromise%3C%2FEM%3E%26nbsp%3B(%3CEM%3EIoC%3C%2FEM%3E)%20are%20almost%20interchangeable.%20Strictly%20speaking%2C%20an%20%3CEM%3Eobservable%3C%2FEM%3E%20is%20an%20identifier%20such%20as%20a%20domain%20name%2C%20IP%20address%20or%20filehash%20before%20you%20have%20done%20any%20determination%20on%20whether%20it%20is%20bad%20or%20not.%20%3CEM%3EIndicator%3C%2FEM%3E%2F%3CEM%3EIoC%3C%2FEM%3E%20are%20%3CEM%3Eobservables%3C%2FEM%3E%20that%20have%20a%20known%20bad%20determination%20-%20i.e.%20what%20you%20get%20back%20from%20a%20TI%20provider%20along%20with%20data%20describing%20its%20context.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-816099735%22%20id%3D%22toc-hId-816099735%22%3EWhy%20have%20we%20built%20TILookup%3F%3C%2FH3%3E%0A%3CP%3EMany%20TI%20providers%20offer%20sophisticated%20libraries%20to%20perform%20look-ups%20against%20their%20APIs.%20We%20are%20not%20trying%20to%20compete%20with%20these.%20In%20fact%2C%20for%20detailed%20examination%20of%20the%20results%20from%20a%20specific%20provider%2C%20you%20should%20consider%20using%20their%20client%20libraries.%20%3CEM%3ETILookup%3C%2FEM%3E%20is%20specifically%20designed%20to%20allow%20look-ups%20against%20multiple%20providers%2C%20minimizing%20your%20need%20to%20worry%20about%20the%20specifics%20of%20each.%20It%20was%20built%20to%20quickly%20answer%20the%20question%20%22is%20there%20anything%20suspicious%20about%20this%20item%3F%22.%20As%20such%2C%20we%20try%20to%20return%20raw%20data%20and%20a%20quick%20verdict%20rather%20than%20attempt%20to%20render%20the%20details%20of%20the%20provider%20results%20in%20high%20fidelity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22h_944510181421568931743053%22%20id%3D%22toc-hId--1736057226%22%20id%3D%22toc-hId--1736057226%22%3EAzure%20Sentinel%20and%20Threat%20Indicators%20from%20the%20Microsoft%20Graph%20Security%20API%3C%2FH3%3E%0A%3CP%3EAs%20mentioned%20above%2C%20Microsoft%20recently%20announced%20the%20ability%20to%20pipe%20TI%20from%20the%20MS%20Graph%20Security%20API%20into%20Azure%20Sentinel.%20%3CSPAN%3EYou%20can%20stream%20logs%20from%20Threat%20intelligence%20providers%20into%20Azure%20Sentinel%20using%20the%20new%20%3CSTRONG%3EThreat%20Intelligence%3C%2FSTRONG%3E%20data%20connector.%20Read%20more%20about%20how%20to%20set%20this%20up%20%3CA%20title%3D%22Azure%20Sentinel%20Threat%20Intelligence%20Data%20Connector%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsentinel%2Fconnect-threat-intelligence%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3Emsticpy%3C%2FSTRONG%3E%20%3CEM%3ETILookup%3C%2FEM%3E%20class%20is%20provider-independent%20but%20works%20really%20well%20with%20TI%20data%20stored%20in%20Azure%20Sentinel.%20This%20is%20especially%20true%20for%20bulk%20look-ups%2C%20because%20of%20the%20high-performance%20Log%20Analytics%20data%20store%20that%20backs%20the%20underlying%20searches.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-203266614%22%20id%3D%22toc-hId-203266614%22%3ESample%20Notebook%20and%20Documentation%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20follow%20along%20with%20real%20code%20examples%2C%20there%20is%20a%20sample%20notebook%20showing%20more%20extended%20usage%20of%20%3CEM%3ETILookup%3C%2FEM%3E%20%3CA%20title%3D%22TI%20Providers%20Notebook%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%2Fblob%2Fmaster%2Fdocs%2Fnotebooks%2FTIProviders.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EDocumentation%20based%20on%20this%20notebook%20is%20also%20available%20%3CA%20title%3D%22MSTICPY%20TI%20Providers%20documenation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2FTIProviders.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EThe%20full%20API%20documents%20can%20be%20found%20on%26nbsp%3B%3CA%20title%3D%22MSTICPY%20TILookup%20module%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23module-msticpy.sectools.tilookup%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReadTheDocs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22h_3465877812261568935344674%22%20id%3D%22toc-hId-1946076949%22%20id%3D%22toc-hId-1946076949%22%3ESetting%20up%20Your%20Providers%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20check%20which%20providers%20are%20currently%20supported%20by%20%3CSTRONG%3Emsticpy%3C%2FSTRONG%3E%20(we%20intend%20to%20add%20more%20as%20time%20goes%20on)%20you%20need%20to%20create%20an%20instance%20of%20the%20%3CEM%3ETILookup%3C%2FEM%3E%20class.%20The%20%3CA%20title%3D%22Available_providers%20documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.available_providers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Eavailable_providers%3C%2FEM%3E%3C%2FA%3E%20property%20will%20return%20a%20list%20of%20the%20providers%20that%20you%20can%20use.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20571px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132722i5976DA8678995E25%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22AvailableProviders.png%22%20title%3D%22AvailableProviders.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENone%20of%20these%20are%20yet%20configured%20so%20you%20won't%20be%20able%20to%20do%20anything%20with%20them%20just%20yet.%20For%20most%20providers%2C%20you%20will%20need%20to%20create%20an%20account%20at%20the%20TI%20provider%20site%20and%20obtain%20an%20API%20key%20that%20authorizes%20you%20to%20query%20the%20data.%20The%20Azure%20Sentinel%20provider%20uses%20your%20existing%20workspace%20credentials%2C%20so%20you%20do%20not%20need%20additional%20credentials%20for%20this.%20Once%20you%20have%20these%20you%20can%20enter%20the%20details%20in%20a%20configuration%20file%20to%20be%20read%20by%20the%20respective%20provider.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--802593517%22%20id%3D%22toc-hId--802593517%22%3ETI%20Providers%20-%20Where%20to%20sign%20up%3C%2FH3%3E%0A%3CP%3EIf%20you%20do%20not%20have%20accounts%20with%20these%20TI%20providers%2C%20go%20here%20to%20create%20them.%20Be%20sure%20to%20save%20your%20API%20keys%20somewhere%20safe.%20Please%20read%20and%20abide%20by%20the%20Terms%20of%20Use%20of%20each%20provider.%3C%2FP%3E%0A%3CP%3EVirusTotal%20-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdevelopers.virustotal.com%2Freference%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdevelopers.virustotal.com%2Freference%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EAlienVault%20Open%20Threat%20Exchange%20-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fotx.alienvault.com%2Fapi%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fotx.alienvault.com%2Fapi%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EIBM%20XForce%20-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fapi.xforce.ibmcloud.com%2Fdoc%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fapi.xforce.ibmcloud.com%2Fdoc%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-940216818%22%20id%3D%22toc-hId-940216818%22%3EConfiguring%20your%20API%20keys%20-%20%3CEM%3Emsticpyconfig.yaml%3C%2FEM%3E%3C%2FH3%3E%0A%3CP%3EThe%20%3CEM%3Emsticpyconfig.yaml%3C%2FEM%3E%20file%20is%20read%20from%20the%20current%20directory%20or%20its%20location%20can%20be%20specified%20with%20an%20environment%20variable%20%3CEM%3EMSTICPYCONFIG%3C%2FEM%3E.%20The%20former%20method%20is%20useful%20if%20you%20want%20to%20vary%20the%20configuration%20for%20different%20investigation%20patterns%20(e.g.%20use%20a%20different%20set%20of%20providers).%20The%20latter%20is%20more%20useful%20if%20you%20want%20to%20keep%20a%20single%20configuration%20and%20use%20it%20everywhere.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20620px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132286i1C53AE69BD8F6F54%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22msticpyconfig.yaml.png%22%20title%3D%22msticpyconfig.yaml.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlthough%20other%20things%20can%20be%20specified%20in%20the%20file%2C%20you%20only%20need%20the%20%3CSTRONG%3ETIProviders%3C%2FSTRONG%3E%20section.%20You%20can%20put%20the%20values%20directly%20into%20the%20file%20or%20give%20the%20name%20of%20an%20environment%20variable%20to%20fetch%20the%20value%20from%20(this%20is%20shown%20in%20the%20XForce%20example%20above)%20.%3C%2FP%3E%0A%3CP%3ENote%2C%20that%20the%20guids%20shown%20here%20are%20all%20dummy%20values%2C%20so%20don't%20try%20to%20use%20them.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEach%20provider%20section%20has%20a%20name%20(you%20can%20use%20whatever%20you%20like%20for%20this)%20and%20an%20number%20of%20configuration%20options%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EArgs%3C%2FSTRONG%3E%3CUL%3E%0A%3CLI%3EFor%20HTTP%2FRESTful%20providers%20the%20values%20here%20are%20usually%20%3CSTRONG%3EAuthKey%3C%2FSTRONG%3E%20(often%20referred%20to%20as%20%3CEM%3EApiKey%3C%2FEM%3E).%20Some%20providers%2C%20such%20as%20XForce%2C%20also%20require%20an%20account%20ID%20value%20-%20%3CSTRONG%3EApiID%3C%2FSTRONG%3E.%20Do%20not%20confuse%20these.%20If%20you%20are%20only%20given%20one%20key%20when%20you%20create%20the%20TI%20provider%20account%20it%20is%20almost%20certainly%20the%20%3CSTRONG%3EAuthKey%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3EFor%20the%20AzureSentinel%20provider%2C%20it%20requires%20the%20workspace%20and%20tenant%20IDs%20for%20the%20workspace%20where%20your%20TI%20table%20is%20stored.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EProvider%3C%2FSTRONG%3E%20-%20normally%20you%20should%20not%20alter%20this%20value%20since%20it%20tells%20%3CEM%3ETILookup%3C%2FEM%3E%20which%20class%20to%20load.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EPrimary%3C%2FSTRONG%3E%20-%20if%20this%20is%20True%20the%20provider%20will%20be%20used%20by%20default%20on%20all%20look-ups.%20You%20can%20override%20this%20setting%20by%20explicitly%20naming%20the%20provider%20when%20you%20do%20a%20lookup%20or%20passing%20the%20prov_scope%20parameter%20(valid%20values%20are%20%22primary%22%2C%20%22secondary%22%20or%20%22all%22).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EOnce%20you%20have%20your%20configuration%20set%20up%20you%20are%20ready%20to%20use%20the%20library.%20Reloading%20the%20new%20settings%20as%20shown%20below%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20632px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132288i845F82B9F1A7BB3D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ReloadProviders.png%22%20title%3D%22ReloadProviders.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CA%20title%3D%22Provider_status%20documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.provider_status%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Eprovider_status%3C%2FEM%3E%3C%2FA%3E%20property%20will%20list%20the%20currently%20loaded%20providers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22h_3104631481621568920278127%22%20id%3D%22toc-hId--1415426638%22%20id%3D%22toc-hId--1415426638%22%3ELooking%20up%20a%20Single%20IoC%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20method%20to%20lookup%20a%20single%20IoC%20is%20%3CEM%3E%3CA%20title%3D%22lookup_ioc%20Documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.lookup_ioc%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elookup_ioc%3C%2FA%3E()%3C%2FEM%3E.%20Let's%20have%20a%20look%20at%20the%20parameters%20(you%20can%20type%20ti_lookup.lookup_ioc%3F%20in%20a%20Jupyter%20cell%20and%20execute%20it%20to%20get%20help%20for%20the%20method).%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20784px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132289i1B6D748BC2204D1E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22LookupIoCAPISig.png%22%20title%3D%22LookupIoCAPISig.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CEM%3Eobservable%3C%2FEM%3E%20parameter%20is%20the%20only%20required%20parameter%20-%20this%20is%20the%20suspected%20IoC%20that%20you%20want%20to%20look%20up.%20If%20you%20do%20not%20specify%20an%20%3CEM%3Eioc_type%3C%2FEM%3E%20the%20type%20will%20be%20inferred.%20This%20inference%20uses%20the%20%3CSTRONG%3Emsticpy%3C%2FSTRONG%3E%20%3CA%20title%3D%22IoCExtract%20documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23module-msticpy.sectools.iocextract%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EIoCExtract%3C%2FEM%3E%3C%2FA%3E%20class%20to%20try%20to%20determine%20the%20IoC%20type%20using%20regular%20expressions.%20This%20is%20not%20foolproof%20though%2C%20so%20if%20you%20know%20the%20IoC%20type%2C%20it%20is%20always%20better%20and%20more%20efficient%20to%20specify%20it%20explicitly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20raw%20output%20from%20%3CEM%3Elookup_ioc%3C%2FEM%3E%20is%20a%20little%20terse%20so%20it's%20better%20to%20transform%20it%20into%20a%20more%20readable%20format.%20There%20is%20a%20built-in%20method%20called%20%3CA%20title%3D%22result_to_df%20documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.result_to_df%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Eresult_to_df%3C%2FEM%3E%3C%2FA%3E%20that%20will%20convert%20the%20output%20into%20a%20%3CA%20title%3D%22Pandas%22%20href%3D%22https%3A%2F%2Fpandas.pydata.org%2Fpandas-docs%2Fstable%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epandas%3C%2FA%3E%20%3CEM%3EDataFrame%3C%2FEM%3E.%20The%20number%20of%20rows%20in%20the%20%3CEM%3EDataFrame%3C%2FEM%3E%20will%20depend%20on%20how%20many%20providers%20you%20have%20configured.%20In%20the%20example%20below%2C%20we've%20converted%20to%20a%20%3CEM%3EDataFrame%3C%2FEM%3E%20and%20also%20flipped%20the%20frame%20using%20the%20%3CEM%3Edataframe.%3C%2FEM%3E%3CEM%3ET%3C%2FEM%3E%20(matrix%20transform)%20property%20to%20show%20the%20results%20from%20each%20provider%20in%20columns.%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%2F132290iF3492D7FFD86FA40%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22LookupIoCMulti.png%22%20title%3D%22LookupIoCMulti.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20fields%20returned%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EIoc%3C%2FSTRONG%3E%20-%20the%20original%20observable%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EIocType%3C%2FSTRONG%3E%20-%20the%20supplied%20or%20inferred%20type%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EQuerySubtype%3C%2FSTRONG%3E%20-%20see%20more%20about%20this%20below%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EResult%3C%2FSTRONG%3E%20-%20True%20if%20we%20got%20a%20response%20of%20any%20kind%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESeverity%3C%2FSTRONG%3E%20-%20an%20assessment%20of%20the%20severity%20of%20the%20TI%20data.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EDetails%3C%2FSTRONG%3E%20-%20some%20extracted%20details%20from%20the%20report%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ERawResult%3C%2FSTRONG%3E%20-%20the%20full%20response%20from%20the%20provider.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EReference%3C%2FSTRONG%3E%20-%20this%20is%20either%20the%20original%20URL%20requested%20(in%20the%20case%20of%20HTTP%20providers)%20or%20the%20KQL%20query%20used%20(in%20the%20case%20of%20LogAnalytics%20providers)%20to%20retrieve%20data%20for%20this%20IoC.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EStatus%3C%2FSTRONG%3E%20-%3CUL%3E%0A%3CLI%3Eif%20this%20is%20an%20HTTP%2FRESTful%20provider%3A%3CUL%3E%0A%3CLI%3E200%20means%20success%3C%2FLI%3E%0A%3CLI%3E404%20means%20not%20found%20-%20many%20providers%20use%20this%20to%20indicate%20that%20no%20information%20was%20found%20for%20the%20observable%3C%2FLI%3E%0A%3CLI%3EAny%20other%20code%20means%20some%20error%20occurred%20403%20probably%20means%20that%20you%20are%20using%20the%20wrong%20key%2C%20401%20probably%20means%20that%20you%20have%20exceeded%20your%20lookup%20quota.%20However%20this%20varies%20by%20provider.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3Eif%20it%20is%20a%20LogAnalytics%20provider%20a%20status%20of%200%20means%20success%20and%20-1%20means%20failure.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%20due%20to%20the%20complexities%20of%20parsing%20data%20across%20different%20providers%20the%20accuracy%20of%20the%26nbsp%3B%3CEM%3ESeverity%3C%2FEM%3E%20and%20%3CEM%3EDetails%3C%2FEM%3E%26nbsp%3Bmay%20vary.%20You%20will%20normally%20want%20to%20check%20the%20full%20RawResult%20field%20for%20details%20about%20the%20IoC.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20the%20curious%20the%20raw%20output%20from%20%3CEM%3Elookup_ioc%3C%2FEM%3E%20has%20the%20following%20format%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3Etuple%3C%2FEM%3E(overall_success%2C%20%3CEM%3Elist%3C%2FEM%3E%5Bprov_results%5D).%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Elist%3C%2FEM%3E%5Bprov_results%5D%20is%20a%20list%20of%20responses%20from%20each%20provider.%3C%2FLI%3E%0A%3CLI%3Eprov_results%20is%20itself%20a%20%3CEM%3Etuple%3C%2FEM%3E(provider_id%2C%20%3CA%20title%3D%22LookupResult%20documention%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tiproviders.ti_provider_base.LookupResult%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3ELookupResult%3C%2FSTRONG%3E%3C%2FA%3E).%3C%2FLI%3E%0A%3CLI%3EFinally%2C%20%3CSTRONG%3ELookupResult%3C%2FSTRONG%3E%20is%20a%20class%20that%20contains%20all%20of%20the%20fields%20described%20in%20the%20previous%20paragraph.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-130870192%22%20id%3D%22toc-hId-130870192%22%3EQuerying%20a%20subset%20of%20providers%3C%2FH3%3E%0A%3CP%3EYou%20can%20use%20the%20%3CEM%3Eproviders%3C%2FEM%3E%20parameter%20of%20%3CEM%3Elookup_ioc%3C%2FEM%3E%20to%20supply%20a%20list%20of%20providers%20to%20use.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20829px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132713i55C78B5337D37898%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Multi-providers.png%22%20title%3D%22Multi-providers.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--1339496699%22%20id%3D%22toc-hId--1339496699%22%3EWhat%20Types%20of%20IoCs%20does%20a%20Provider%20Support%3F%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMost%20providers%20support%20multiple%20IoC%20types.%20Many%20providers%20also%20offer%20different%20types%20of%20sub-query%20associated%20with%20some%20of%20the%20types.%20For%20example%2C%20GeoIP%2C%20Whois%20and%20Passive%20DNS%20are%20commonly%20provided%20for%20IP%20addresses%2C%20even%20though%20they%20are%20not%20strictly%20TI%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20view%20the%20supported%20types%20for%20a%20single%20provider%2C%20you%20first%20need%20to%20know%20the%20provider%20short%20name%20-%20you%20can%20get%20this%20from%20%3CEM%3Eti_lookup.%3CA%20title%3D%22provider_status%20Documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.provider_status%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eprovider_status%3C%2FA%3E%3C%2FEM%3E.%20Using%20the%20short%20name%20type%20the%20following%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20663px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132292i49C85A242891AC5F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ProviderUsage.png%22%20title%3D%22ProviderUsage.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20just%20list%20the%20usage%20for%20all%20loaded%20providers%20more%20simply%20using%20%3CEM%3Eprovider_usage()%3C%2FEM%3E.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20768px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132293i7A3EFD55A27DB0ED%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ProviderUsageAll.png%22%20title%3D%22ProviderUsageAll.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20last%20example%20you%20can%20see%20some%20IoC%20types%20that%20have%20%3CEM%3Eioc_query_type%3C%2FEM%3E%20entries.%20Where%20sub-query%20types%20are%20supported%20you%20can%20chose%20to%20lookup%20just%20the%20data%20of%20this%20type%20for%20an%20IoC.%20The%20string%20shown%20here%20(e.g.%20%22passivedns%22%2C%20%22geo%22%2C%20etc.)%20is%20value%20that%20you%20supply%20for%20the%20optional%20%3CEM%3Eioc_query_type%3C%2FEM%3E%20parameter%20mentioned%20above.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere's%20an%20example%20with%20a%20query%20type%20requesting%20passive%20DNS%20data.%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%2F132294i82A8E7A3A42E753B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22PassiveDns.png%22%20title%3D%22PassiveDns.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1393637723%22%20id%3D%22toc-hId--1393637723%22%3ESome%20Defensive%20Optimizations%3C%2FH3%3E%0A%3CP%3ETILookup%20contains%20a%20couple%20of%20optimizations%20to%20prevent%20needlessly%20performing%20expensive%20lookups%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20least-recently-used%20(LRU)%20cache%20is%20kept%20per-provider.%20This%20avoids%20looking%20up%20the%20same%20observable%20multiple%20times%20-%20it%20will%20just%20return%20the%20first%20result%20for%20subsequent%20queries.%20This%20is%20a%20memory%20cache%20only%2C%20so%20disappears%20when%20you%20reset%20the%20Jupyter%20kernel.%20It%20is%20not%20shared%20between%20multiple%20instances%20of%20TILookup.%3C%2FLI%3E%0A%3CLI%3EIoC%20sanitization%20tries%20to%20weed%20out%20observables%20that%20are%20never%20going%20to%20appear%20in%20TI.%20Examples%20include%20loopback%20and%20private%20IP%20addresses%20and%20URLs%20with%20an%20unqualified%20domain%20name.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2146123971%22%20id%3D%22toc-hId-2146123971%22%3ELooking%20up%20Multiple%20IoCs%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESometimes%20you%20will%20want%20to%20lookup%20sets%20of%20IoCs.%20You%20can%20do%20this%20with%20the%20%3CEM%3E%3CA%20title%3D%22lookup_iocs%20documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%2Fen%2Flatest%2Fmsticpy.sectools.html%23msticpy.sectools.tilookup.TILookup.lookup_iocs%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elookup_iocs%3C%2FA%3E()%3C%2FEM%3E%20method.%20This%20is%20similar%20to%20the%20method%20to%20lookup%20a%20single%20IoC%20but%20takes%20a%20data%20parameter%20which%20holds%20the%20collection%20of%20IoCs%20to%20search%20for.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20653px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132295i0D0496F6365BA49A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22LookupIocsAPISig.png%22%20title%3D%22LookupIocsAPISig.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20input%20can%20be%20a%20pandas%20%3CEM%3EDataFrame%3C%2FEM%3E%2C%20a%20python%20%3CEM%3Edict%3C%2FEM%3E%20or%20a%20python%20%3CEM%3Eiterable%3C%2FEM%3E%20(such%20as%20a%20list).%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIn%20the%20case%20of%20a%20%3CEM%3EDataFrame%3C%2FEM%3E%20you%20must%20also%20supply%20the%20%3CEM%3Eobs_col%3C%2FEM%3E%20parameter%20-%20the%20DataFrame%20column%20containing%20the%20observable%20to%20look%20up%20-%20and%2C%20optionally%2C%20the%20%3CEM%3Eioc_type_col%3C%2FEM%3E%20-%20the%20column%20holding%20the%20IoC%20type.%3C%2FLI%3E%0A%3CLI%3EFor%20a%20%3CEM%3Edict%2C%3C%2FEM%3E%20the%20format%20is%20%7Bioc%3A%20ioc_type%7D%3C%2FLI%3E%0A%3CLI%3EAn%20%3CEM%3EIterable%3C%2FEM%3E%20is%20just%20a%20collection%20of%20IoCs.%20This%20could%20be%20a%20%3CEM%3Elist%2C%20tuple%3C%2FEM%3E%20or%20any%20data%20type%20that%20supports%20the%20python%20%3CEM%3Eiterable%3C%2FEM%3E%20interface.%20IoC%20Type%20is%20always%20inferred%20in%20this%20case.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EYou%20can%20specify%20a%20sub-query%20type%20(this%20will%20apply%20to%20all%20look-ups)%2C%20a%20provider%20list%20and%20a%20provider%20scope.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-2091982947%22%20id%3D%22toc-hId-2091982947%22%3E%3CFONT%20color%3D%22%23FF0000%22%3EIMPORTANT%3C%2FFONT%3E%20-%20Multiple%20Look-ups%20Caveats%3C%2FH3%3E%0A%3CP%3EMost%20HTTP%20TI%20providers%20have%20throttle%20limits%20for%20data%20queries.%20If%20you%20are%20using%20a%20free%20tier%20account%20from%20these%20providers%2C%20these%20limits%20can%20be%20easily%20exceeded%20if%20you%20submit%20large%20collections%20of%20IoCs.%20There%20is%20currently%20no%20throttling%20mechanism%20in%20%3CEM%3ETILookup%3C%2FEM%3E.%20As%20long%20as%20there%20are%20things%20in%20the%20queue%20it%20will%20keep%20submitting%20them.%20So%20please%2C%20do%20yourself%20and%20your%20TI%20provider%20a%20favor%20and%20be%20mindful%20of%20these%20limits%20when%20performing%20bulk%20look-ups.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20good%20strategy%20may%20be%20restricting%20the%20provider%20list%20you%20use%20to%20providers%20where%20you%20have%20a%20paid%20tier%20supporting%20high%20lookup%20rates%20when%20querying%20large%20data%20sets.%20You%20can%20do%20this%20using%20the%20%3CEM%3Eproviders%3D%5B%22prov1%22%2C%20%22prov2%22%5D%3C%2FEM%3E%20parameter.%20Once%20you%20have%20done%20the%20initial%20lookup%2C%20you%20can%20submit%20smaller%20numbers%20to%20other%20providers%20with%20lower%20limits%20for%20a%20second%20opinion.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20primary%20use%20case%20for%20the%20%3CEM%3EPrimary%3C%2FEM%3E%20configuration%20parameter%20in%20the%20%3CEM%3Emsticpyconfig.yaml%3C%2FEM%3E%20file%20(see%20%3CA%20title%3D%22Setting%20up%20Your%20Providers%22%20href%3D%22%23h_3465877812261568935344674%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESetting%20up%20Your%20Providers%3C%2FA%3E%26nbsp%3Bearlier%20in%20the%20article).%20Set%20your%20high-bandwidth%20providers%20as%20Primary%3DTrue%20and%20the%20remainder%20as%20Primary%3DFalse.%20You%20can%20then%20perform%20secondary%20look-ups%20on%20a%20subset%20of%20your%20suspected%20IoCs%20to%20get%20more%20detail.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20second%20caveat%20is%20performance-related.%20The%20HTTP%20requests%20are%20currently%20not%20implemented%20as%20asynchronous%20calls%20(although%20we%20plan%20to%20change%20this).%20All%20requests%20are%20submitted%20in%20sequence%2C%20blocking%20until%20each%20one%20returns.%20While%20this%20is%20not%20a%20huge%20problem%20for%20a%20few%20tens%20of%20look-ups%20and%20small%20numbers%20of%20providers%2C%20it%20will%20be%20an%20issue%20if%20you%20are%20searching%20for%20very%20large%20sets%20(provider%20throttling%20limits%2C%20notwithstanding).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20performance%20optimization%20that%20we%20have%20built%20for%20the%20HTTP%20provider%20lookup%20is%20to%20add%20a%20Least-recently-used%20cache%20to%20the%20look-ups.%20This%20means%20that%20you%20can%20freely%20re-run%20the%20same%20query%20and%20it%20will%20return%20the%20result%20without%20hitting%20the%20provider%20site.%20The%20cache%20size%20is%201024%20entries%20and%20is%20maintained%20per-provider.%20It%20is%20a%20memory-only%20cache%2C%20so%20will%20disappear%20if%20you%20reset%20your%20kernel%20and%20is%20not%20shared%20across%20notebooks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--460174014%22%20id%3D%22toc-hId--460174014%22%3ERunning%20a%20Query%20for%20Multiple%20IoCs%3C%2FH3%3E%0A%3CP%3E%3CEM%3Elookup_iocs%3C%2FEM%3E%20always%20returns%20a%20%3CEM%3EDataFrame%3C%2FEM%3E.%20This%20has%20the%20same%20schema%20as%20the%20individual%20IoC%20lookups%20(see%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3Ethe%20section%20%3CA%20title%3D%22Looking%20up%20an%20single%20IoC%22%20href%3D%22%23h_3104631481621568920278127%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3ELooking%20Up%20a%20Single%20IoC%3C%2FEM%3E%3C%2FA%3E%20earlier%20in%20the%20article).%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%3EThe%20following%20are%20a%20set%20of%20examples%20of%20using%20the%20multi%20IoC%20lookup.%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3EAlthough%20I'm%20disobeying%20my%20earlier%20rule%20about%20specifying%20the%20IoC%20types%20explicitly%2C%20the%20type%20inference%20usually%20works%20and%20makes%20the%20examples%20a%20bit%20easier%20to%20read.%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EHere%20is%20an%20example%20using%20multiple%20IP%20addresses%20with%20a%20single%20provider%20-%20Azure%20Sentinel%20TI.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20796px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132516iC7FFF883597E5669%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MultipleIPs.png%22%20title%3D%22MultipleIPs.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CSPAN%3EThis%20example%20shows%20multiple%20URLs%20using%20all%20configured%20providers.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20943px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132517iA1E15402819DEABE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MultiIoCMultiProvider.png%22%20title%3D%22MultiIoCMultiProvider.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3CSPAN%3EThe%20final%20example%20shows%20that%20you%20can%20send%20a%20mixed%20set%20of%20IoCs%20at%20once.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20850px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132518i14137AEAF0E79C1E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MixedIocs.png%22%20title%3D%22MixedIocs.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20inherit%3B%20font-size%3A%2024px%3B%22%3EConclusion%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EOver%20the%20next%20few%20months%20we%20plan%20to%20add%20additional%20providers.%20These%20include%20some%20simple%2C%20non-standard%20data%20sources%20such%20as%20Tor%20exit%20nodes%20and%20Open%20Page%20Rank%20domain%20popularity.%20Feel%20free%20to%20request%20others%20that%20you%20think%20would%20be%20useful.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EFor%20now%2C%20I%20hope%20you%20have%20been%20able%20to%20see%20how%20to%20make%20use%20of%20the%20%3CEM%3ETILookup%3C%2FEM%3E%20class%20in%20your%20own%20notebooks%20(or%20actually%2C%20in%20any%20Python%20code).%20Although%20the%20library%20is%20not%20that%20refined%2C%20it%20is%20effective%20at%20being%20able%20to%20pull%20in%20broad%20sweeps%20of%20data%20from%20multiple%20TI%20providers%20with%20minimal%20effort.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EPlease%20visit%20the%20msticpy%20%3CA%20title%3D%22MSTICPY%20GitHub%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmsticpy%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%3C%2FA%3E%26nbsp%3Bto%20submit%20issues%20and%20requests%2C%20and%20read%20the%20documentation%20on%20%3CA%20title%3D%22MSTICPY%20Documentation%22%20href%3D%22https%3A%2F%2Fmsticpy.readthedocs.io%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EReadTheDocs%3C%2FA%3E%26nbsp%3Bto%20find%20out%20more%20about%20the%20package%20and%20its%20other%20features.%20Follow%20me%20on%20twitter%20at%26nbsp%3B%3CA%20title%3D%22Ian%20Hellen%20Twitter%22%20href%3D%22https%3A%2F%2Ftwitter.com%2Fianhellen%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%40ianhellen%3C%2FA%3E%20for%20news%20about%20updates%20to%20our%20Notebooks%2C%20Python%20packages%20and%20related%20items.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EHappy%20hunting!%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CH2%20id%3D%22toc-hId--1215379616%22%20id%3D%22toc-hId--1215379616%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-860239%22%20slang%3D%22en-US%22%3E%3CP%3EUse%20Threat%20Intelligence%20in%20your%20hunting%2Finvestigation%20notebooks%3F%20Ever%20wanted%20to%20lookup%20an%20IoC%20in%20multiple%20TI%20providers%20without%20installing%20a%20bunch%20of%20packages%20or%20hand-crafting%20HTTP%20requests%3F%20TILookup%20is%20a%20multi-provider%20TI%20query%20module.%20It%20supports%20multiple%20providers%20like%20OTX%2C%20VirusTotal%2C%20Azure%20Sentinel%20and%20XForce%20(others%20in%20the%20pipeline%20and%20you%20can%20add%20your%20own).%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%2F132290iF3492D7FFD86FA40%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22LookupIoCMulti.png%22%20title%3D%22LookupIoCMulti.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

Introduction

 

Using threat intelligence (TI) is vital part of most hunts and investigations. You see a suspicious IP address in your logs and you want to check its reputation: is it a known C2 (Command and Control) address? is it associated with malware drops? You want to check a file hash to see if it is known malware. In many cases, getting a confirmation that your suspected IoC (indicator of compromise) is known to be bad can shortcut hours of investigation time.

 

Since its early days the msticpy package has had a module to perform look-ups at the popular VirusTotal service. We've recently released an update that gives you a generic TI lookup capability. You can configure multiple TI providers and submit one or more IoCs to them in a single function call.

 

One of the first set of providers is for Azure Sentinel TI. If you have set up a TI feed from the Microsoft Graph Security API, the indicators are made available as a table in Azure Sentinel Log Analytics store (see more about this below). This can be queried using the msticpy TILookup class alongside other providers such as VirusTotal, AlienVault OTX, and IBM XForce.

 

Here's an example, looking up a single observable. In the remainder of the article we'll take you through setting up your TI providers, querying IoCs and interpreting the results.

OTXLookup.png

 

A Note on Terminology

The terms observable, indicator, indicator of compromise (IoC) are almost interchangeable. Strictly speaking, an observable is an identifier such as a domain name, IP address or filehash before you have done any determination on whether it is bad or not. Indicator/IoC are observables that have a known bad determination - i.e. what you get back from a TI provider along with data describing its context.

 

Why have we built TILookup?

Many TI providers offer sophisticated libraries to perform look-ups against their APIs. We are not trying to compete with these. In fact, for detailed examination of the results from a specific provider, you should consider using their client libraries. TILookup is specifically designed to allow look-ups against multiple providers, minimizing your need to worry about the specifics of each. It was built to quickly answer the question "is there anything suspicious about this item?". As such, we try to return raw data and a quick verdict rather than attempt to render the details of the provider results in high fidelity.

 

Azure Sentinel and Threat Indicators from the Microsoft Graph Security API

As mentioned above, Microsoft recently announced the ability to pipe TI from the MS Graph Security API into Azure Sentinel. You can stream logs from Threat intelligence providers into Azure Sentinel using the new Threat Intelligence data connector. Read more about how to set this up here.

 

The msticpy TILookup class is provider-independent but works really well with TI data stored in Azure Sentinel. This is especially true for bulk look-ups, because of the high-performance Log Analytics data store that backs the underlying searches.

 

Sample Notebook and Documentation

 

If you want to follow along with real code examples, there is a sample notebook showing more extended usage of TILookup here.

Documentation based on this notebook is also available here.

The full API documents can be found on ReadTheDocs.

 

Setting up Your Providers

 

To check which providers are currently supported by msticpy (we intend to add more as time goes on) you need to create an instance of the TILookup class. The available_providers property will return a list of the providers that you can use.

AvailableProviders.png

 

None of these are yet configured so you won't be able to do anything with them just yet. For most providers, you will need to create an account at the TI provider site and obtain an API key that authorizes you to query the data. The Azure Sentinel provider uses your existing workspace credentials, so you do not need additional credentials for this. Once you have these you can enter the details in a configuration file to be read by the respective provider.

 

TI Providers - Where to sign up

If you do not have accounts with these TI providers, go here to create them. Be sure to save your API keys somewhere safe. Please read and abide by the Terms of Use of each provider.

VirusTotal - https://developers.virustotal.com/reference

AlienVault Open Threat Exchange - https://otx.alienvault.com/api

IBM XForce - https://api.xforce.ibmcloud.com/doc/

 

Configuring your API keys - msticpyconfig.yaml

The msticpyconfig.yaml file is read from the current directory or its location can be specified with an environment variable MSTICPYCONFIG. The former method is useful if you want to vary the configuration for different investigation patterns (e.g. use a different set of providers). The latter is more useful if you want to keep a single configuration and use it everywhere.

msticpyconfig.yaml.png

 

Although other things can be specified in the file, you only need the TIProviders section. You can put the values directly into the file or give the name of an environment variable to fetch the value from (this is shown in the XForce example above) .

Note, that the guids shown here are all dummy values, so don't try to use them. 

 

Each provider section has a name (you can use whatever you like for this) and an number of configuration options:

  • Args
    • For HTTP/RESTful providers the values here are usually AuthKey (often referred to as ApiKey). Some providers, such as XForce, also require an account ID value - ApiID. Do not confuse these. If you are only given one key when you create the TI provider account it is almost certainly the AuthKey.
    • For the AzureSentinel provider, it requires the workspace and tenant IDs for the workspace where your TI table is stored.
  • Provider - normally you should not alter this value since it tells TILookup which class to load.
  • Primary - if this is True the provider will be used by default on all look-ups. You can override this setting by explicitly naming the provider when you do a lookup or passing the prov_scope parameter (valid values are "primary", "secondary" or "all").

Once you have your configuration set up you are ready to use the library. Reloading the new settings as shown below:

ReloadProviders.png

 

The provider_status property will list the currently loaded providers.

 

Looking up a Single IoC

 

The method to lookup a single IoC is lookup_ioc(). Let's have a look at the parameters (you can type ti_lookup.lookup_ioc? in a Jupyter cell and execute it to get help for the method).

LookupIoCAPISig.png

 

The observable parameter is the only required parameter - this is the suspected IoC that you want to look up. If you do not specify an ioc_type the type will be inferred. This inference uses the msticpy IoCExtract class to try to determine the IoC type using regular expressions. This is not foolproof though, so if you know the IoC type, it is always better and more efficient to specify it explicitly.

 

The raw output from lookup_ioc is a little terse so it's better to transform it into a more readable format. There is a built-in method called result_to_df that will convert the output into a pandas DataFrame. The number of rows in the DataFrame will depend on how many providers you have configured. In the example below, we've converted to a DataFrame and also flipped the frame using the dataframe.T (matrix transform) property to show the results from each provider in columns.

LookupIoCMulti.png

 

The fields returned are:

  • Ioc - the original observable
  • IocType - the supplied or inferred type
  • QuerySubtype - see more about this below
  • Result - True if we got a response of any kind
  • Severity - an assessment of the severity of the TI data.
  • Details - some extracted details from the report
  • RawResult - the full response from the provider.
  • Reference - this is either the original URL requested (in the case of HTTP providers) or the KQL query used (in the case of LogAnalytics providers) to retrieve data for this IoC.
  • Status -
    • if this is an HTTP/RESTful provider:
      • 200 means success
      • 404 means not found - many providers use this to indicate that no information was found for the observable
      • Any other code means some error occurred 403 probably means that you are using the wrong key, 401 probably means that you have exceeded your lookup quota. However this varies by provider.
    • if it is a LogAnalytics provider a status of 0 means success and -1 means failure.

Note: due to the complexities of parsing data across different providers the accuracy of the Severity and Details may vary. You will normally want to check the full RawResult field for details about the IoC.

 

For the curious the raw output from lookup_ioc has the following format:

  • tuple(overall_success, list[prov_results]).
  • list[prov_results] is a list of responses from each provider.
  • prov_results is itself a tuple(provider_id, LookupResult).
  • Finally, LookupResult is a class that contains all of the fields described in the previous paragraph.

 

Querying a subset of providers

You can use the providers parameter of lookup_ioc to supply a list of providers to use.

Multi-providers.png

 

What Types of IoCs does a Provider Support?

 

Most providers support multiple IoC types. Many providers also offer different types of sub-query associated with some of the types. For example, GeoIP, Whois and Passive DNS are commonly provided for IP addresses, even though they are not strictly TI data.

 

To view the supported types for a single provider, you first need to know the provider short name - you can get this from ti_lookup.provider_status. Using the short name type the following:

ProviderUsage.png

 

You can also just list the usage for all loaded providers more simply using provider_usage().

ProviderUsageAll.png

 

In this last example you can see some IoC types that have ioc_query_type entries. Where sub-query types are supported you can chose to lookup just the data of this type for an IoC. The string shown here (e.g. "passivedns", "geo", etc.) is value that you supply for the optional ioc_query_type parameter mentioned above.

 

Here's an example with a query type requesting passive DNS data.

PassiveDns.png

 

Some Defensive Optimizations

TILookup contains a couple of optimizations to prevent needlessly performing expensive lookups:

  • A least-recently-used (LRU) cache is kept per-provider. This avoids looking up the same observable multiple times - it will just return the first result for subsequent queries. This is a memory cache only, so disappears when you reset the Jupyter kernel. It is not shared between multiple instances of TILookup.
  • IoC sanitization tries to weed out observables that are never going to appear in TI. Examples include loopback and private IP addresses and URLs with an unqualified domain name.

 

Looking up Multiple IoCs

 

Sometimes you will want to lookup sets of IoCs. You can do this with the lookup_iocs() method. This is similar to the method to lookup a single IoC but takes a data parameter which holds the collection of IoCs to search for.

LookupIocsAPISig.png

The input can be a pandas DataFrame, a python dict or a python iterable (such as a list).

  • In the case of a DataFrame you must also supply the obs_col parameter - the DataFrame column containing the observable to look up - and, optionally, the ioc_type_col - the column holding the IoC type.
  • For a dict, the format is {ioc: ioc_type}
  • An Iterable is just a collection of IoCs. This could be a list, tuple or any data type that supports the python iterable interface. IoC Type is always inferred in this case.

You can specify a sub-query type (this will apply to all look-ups), a provider list and a provider scope.

 

IMPORTANT - Multiple Look-ups Caveats

Most HTTP TI providers have throttle limits for data queries. If you are using a free tier account from these providers, these limits can be easily exceeded if you submit large collections of IoCs. There is currently no throttling mechanism in TILookup. As long as there are things in the queue it will keep submitting them. So please, do yourself and your TI provider a favor and be mindful of these limits when performing bulk look-ups.

 

A good strategy may be restricting the provider list you use to providers where you have a paid tier supporting high lookup rates when querying large data sets. You can do this using the providers=["prov1", "prov2"] parameter. Once you have done the initial lookup, you can submit smaller numbers to other providers with lower limits for a second opinion.

 

This is the primary use case for the Primary configuration parameter in the msticpyconfig.yaml file (see Setting up Your Providers earlier in the article). Set your high-bandwidth providers as Primary=True and the remainder as Primary=False. You can then perform secondary look-ups on a subset of your suspected IoCs to get more detail.

 

The second caveat is performance-related. The HTTP requests are currently not implemented as asynchronous calls (although we plan to change this). All requests are submitted in sequence, blocking until each one returns. While this is not a huge problem for a few tens of look-ups and small numbers of providers, it will be an issue if you are searching for very large sets (provider throttling limits, notwithstanding).

 

One performance optimization that we have built for the HTTP provider lookup is to add a Least-recently-used cache to the look-ups. This means that you can freely re-run the same query and it will return the result without hitting the provider site. The cache size is 1024 entries and is maintained per-provider. It is a memory-only cache, so will disappear if you reset your kernel and is not shared across notebooks.

 

Running a Query for Multiple IoCs

lookup_iocs always returns a DataFrame. This has the same schema as the individual IoC lookups (see 

the section Looking Up a Single IoC earlier in the article).
 
The following are a set of examples of using the multi IoC lookup. Although I'm disobeying my earlier rule about specifying the IoC types explicitly, the type inference usually works and makes the examples a bit easier to read.

 

Here is an example using multiple IP addresses with a single provider - Azure Sentinel TI.
MultipleIPs.png

 

This example shows multiple URLs using all configured providers.
MultiIoCMultiProvider.png

 

 

The final example shows that you can send a mixed set of IoCs at once.
MixedIocs.png

 

 

Conclusion

 

Over the next few months we plan to add additional providers. These include some simple, non-standard data sources such as Tor exit nodes and Open Page Rank domain popularity. Feel free to request others that you think would be useful.
 
For now, I hope you have been able to see how to make use of the TILookup class in your own notebooks (or actually, in any Python code). Although the library is not that refined, it is effective at being able to pull in broad sweeps of data from multiple TI providers with minimal effort.
 
Please visit the msticpy GitHub to submit issues and requests, and read the documentation on ReadTheDocs to find out more about the package and its other features. Follow me on twitter at @ianhellen for news about updates to our Notebooks, Python packages and related items.
 
Happy hunting!