SlideShare a Scribd company logo
1 of 15
Download to read offline
python-stix primer
Ben Schmoker
github.com/bschmoker
What is python-stix?
• Developer friendly
– Python objects > raw XML
• Re-usable
– Open-source libraries
• Plug-in ready
– Integrate with existing tools
github.com/STIXProject/python-stix
Let's get started!
• Install Python 2.7 and dependencies
apt-get install python-dev python-pip
apt-get install libxml2-dev libxslt-dev
apt-get install zlib1g-dev
pip install stix
github.com/STIXProject/python-stix
Create a STIX document
github.com/STIXProject/python-stix
$ cat > write.py
from stix.core import STIXPackage, STIXHeader
header = STIXHeader ()
header.title = "My first document!"
pkg = STIXPackage()
pkg.stix_header = header
print pkg.to_xml() // output XML
Generate a STIX Indicator
• The following slides will reference
this example code
github.com/STIXProject/python-stix
Create IP Address Indicator
github.com/STIXProject/python-stix
$ cat >> write.py
ind = Indicator()
ind.title="malicious IP"
ind.add_indicator_type("IP Watchlist")
// set value
addr = Address()
addr.address_value="10.0.0.0"
addr.category = 'ipv4-addr'
addr.condition = "Equals"
// add to package
ind.add_observable(addr)
stix_package.add_indicator(ind)
Add optional fields
github.com/STIXProject/python-stix
$ cat >> write.py
// add a type of malicious activity
activity = TTP(title="C2 Behavior")
stix_package.add_ttp(activity)
//link indicator to activity
ind.add_indicated_ttp(TTP(idref = activity.id_) )
Parsing STIX
• The following slides will reference
this example code
github.com/STIXProject/python-stix
Load a STIX document
$ curl http://tiny.cc/samplestix > in.xml
$ python
from stix.core import STIXPackage, STIXHeader
myfile = open('in.xml')
pkg = STIXPackage.from_xml(myfile)
github.com/STIXProject/python-stix
Access Data Elements
$cat in.xml
<stix:STIX_Package
<stix:Package_Intent>Incident
<stix:Description>Sample breach report
</>
$ cat >> read.py
print pkg.stix_header.description
github.com/STIXProject/python-stix
Iterate Lists
$cat in.xml
<stix:Incident>
<incident:Title>Breach of Cyber Tech Dynamics
</>
$ cat >> read.py
for inc in pkg.incidents:
print inc.title
github.com/STIXProject/python-stix
Parsing STIX (Advanced)
• The following slides will reference
this example code
github.com/STIXProject/python-stix
$curl http://tiny.cc/samplestixobs > in.xml
<stix:Indicator>
<indicator:Observable>
<cybox:Object>
<cybox:Properties>
<FileObj:Hashes>
<cyboxCommon:Hash>d3adb33f
</>
$ cat > read.py
for ind in pkg.indicators:
for obs in ind.observables:
for digest in obs.object_.properties.hashes:
print digest
Examine Observables
github.com/STIXProject/python-stix
Dereference Links
github.com/STIXProject/python-stix
$cat in.xml
<stix:TTPs>
<stix:TTP id="id_value">
[...]
</>
<stix:Indicator>
<indicator:Indicated_TTP>
<stixCommon:TTP idref="id_value">
</>
$ cat >> read.py
relationship_dict = {}
for ttp in package.ttps.ttps:
relationship_dict [ttp.id_] = ttp # assign object to dictionary value, with I
as key
for rel_ttp in indicator.indicated_ttps:
if rel_ttp.item.idref in ttps: # look up object by ID
print relationship_dict[rel_ttp.item.idref].title
Further Reading
• Sample code and use cases
– stixproject.github.io/documentation/idioms
• Python documentation
– stix.readthedocs.org
github.com/STIXProject/python-stix

More Related Content

What's hot

Cloud security certifications landscape
Cloud security certifications landscapeCloud security certifications landscape
Cloud security certifications landscapeMoshe Ferber
 
Secure code practices
Secure code practicesSecure code practices
Secure code practicesHina Rawal
 
Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]David Sweigert
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testingNezar Alazzabi
 
Segmenting your Network for Security - The Good, the Bad and the Ugly
Segmenting your Network for Security - The Good, the Bad and the UglySegmenting your Network for Security - The Good, the Bad and the Ugly
Segmenting your Network for Security - The Good, the Bad and the UglyAlgoSec
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & GuidelinesPrabath Siriwardena
 
Security Attacks.ppt
Security Attacks.pptSecurity Attacks.ppt
Security Attacks.pptZaheer720515
 
Presentation cisco iron port email & web security
Presentation   cisco iron port email & web securityPresentation   cisco iron port email & web security
Presentation cisco iron port email & web securityxKinAnx
 
Empire Kurulumu ve Kullanımı
Empire Kurulumu ve Kullanımı Empire Kurulumu ve Kullanımı
Empire Kurulumu ve Kullanımı BGA Cyber Security
 
Information security
Information security Information security
Information security razendar79
 

What's hot (20)

Cloud security certifications landscape
Cloud security certifications landscapeCloud security certifications landscape
Cloud security certifications landscape
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
 
CompTIA Security+.pptx
CompTIA Security+.pptxCompTIA Security+.pptx
CompTIA Security+.pptx
 
Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]
 
Endpoint Security
Endpoint SecurityEndpoint Security
Endpoint Security
 
Windows Security
Windows Security Windows Security
Windows Security
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
SOC for Cybersecurity Overview
SOC for Cybersecurity OverviewSOC for Cybersecurity Overview
SOC for Cybersecurity Overview
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
 
Segmenting your Network for Security - The Good, the Bad and the Ugly
Segmenting your Network for Security - The Good, the Bad and the UglySegmenting your Network for Security - The Good, the Bad and the Ugly
Segmenting your Network for Security - The Good, the Bad and the Ugly
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & Guidelines
 
Security Attacks.ppt
Security Attacks.pptSecurity Attacks.ppt
Security Attacks.ppt
 
Presentation cisco iron port email & web security
Presentation   cisco iron port email & web securityPresentation   cisco iron port email & web security
Presentation cisco iron port email & web security
 
Empire Kurulumu ve Kullanımı
Empire Kurulumu ve Kullanımı Empire Kurulumu ve Kullanımı
Empire Kurulumu ve Kullanımı
 
SIEM
SIEMSIEM
SIEM
 
Network Access Control (NAC)
Network Access Control (NAC)Network Access Control (NAC)
Network Access Control (NAC)
 
Information security
Information security Information security
Information security
 
Firewall
FirewallFirewall
Firewall
 
Advanced persistent threats(APT)
Advanced persistent threats(APT)Advanced persistent threats(APT)
Advanced persistent threats(APT)
 
Security Analytics with OpenSearch
Security Analytics with OpenSearchSecurity Analytics with OpenSearch
Security Analytics with OpenSearch
 

Viewers also liked

Introduction to STIX 101
Introduction to STIX 101Introduction to STIX 101
Introduction to STIX 101stixproject
 
Everything about TAXII
Everything about TAXIIEverything about TAXII
Everything about TAXIIstixproject
 
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015Priyanka Aash
 
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworks
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworksSANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworks
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworksMatthew J. Harmon
 
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築 [ISOC-JP workshop, 2016/05/20]
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築  [ISOC-JP workshop, 2016/05/20]セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築  [ISOC-JP workshop, 2016/05/20]
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築 [ISOC-JP workshop, 2016/05/20]Takeshi Takahashi
 
Network security chapter 6 and 7 internet architecture
Network security chapter  6 and 7 internet   architectureNetwork security chapter  6 and 7 internet   architecture
Network security chapter 6 and 7 internet architectureMuhammad ismail Shah
 
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)Security Strategy and Tactic with Cyber Threat Intelligence (CTI)
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)Priyanka Aash
 

Viewers also liked (8)

Introduction to STIX 101
Introduction to STIX 101Introduction to STIX 101
Introduction to STIX 101
 
Everything about TAXII
Everything about TAXIIEverything about TAXII
Everything about TAXII
 
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015
STIX, TAXII, CISA: Impact of the Cybersecurity Information Sharing Act of 2015
 
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworks
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworksSANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworks
SANS_Minneapolis_2015_ThreatIntelligence_NeighborhoodWatchForYourNetworks
 
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築 [ISOC-JP workshop, 2016/05/20]
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築  [ISOC-JP workshop, 2016/05/20]セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築  [ISOC-JP workshop, 2016/05/20]
セキュリティオペレーション自動化に向けた、基盤技術と共通インターフェースの構築 [ISOC-JP workshop, 2016/05/20]
 
מצגת החברות המשתתפות בתערוכת מיליפול 2013
מצגת החברות המשתתפות בתערוכת מיליפול 2013מצגת החברות המשתתפות בתערוכת מיליפול 2013
מצגת החברות המשתתפות בתערוכת מיליפול 2013
 
Network security chapter 6 and 7 internet architecture
Network security chapter  6 and 7 internet   architectureNetwork security chapter  6 and 7 internet   architecture
Network security chapter 6 and 7 internet architecture
 
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)Security Strategy and Tactic with Cyber Threat Intelligence (CTI)
Security Strategy and Tactic with Cyber Threat Intelligence (CTI)
 

Similar to Python + STIX = Awesome

First python project
First python projectFirst python project
First python projectNeetu Jain
 
Share your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packagesShare your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packagesHannes Hapke
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with WebhooksAnne Gentle
 
Open erp on ubuntu
Open erp on ubuntuOpen erp on ubuntu
Open erp on ubuntuIker Coranti
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Henry Schreiner
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingHenry Schreiner
 
PyCourse - Self driving python course
PyCourse - Self driving python coursePyCourse - Self driving python course
PyCourse - Self driving python courseEran Shlomo
 
Python Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtPython Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtInexture Solutions
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingHenry Schreiner
 
Hello Git
Hello GitHello Git
Hello Gitbsadd
 
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @ShanghaiLuke Han
 
Steps to install ns3
Steps to install ns3Steps to install ns3
Steps to install ns3DIGITAL PADM
 
Princeton RSE Peer network first meeting
Princeton RSE Peer network first meetingPrinceton RSE Peer network first meeting
Princeton RSE Peer network first meetingHenry Schreiner
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3Youhei Sakurai
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Henry Schreiner
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with pythonroskakori
 

Similar to Python + STIX = Awesome (20)

First python project
First python projectFirst python project
First python project
 
Share your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packagesShare your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packages
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
 
Open erp on ubuntu
Open erp on ubuntuOpen erp on ubuntu
Open erp on ubuntu
 
2016/11/05: OSWDem16 workshop
2016/11/05: OSWDem16 workshop2016/11/05: OSWDem16 workshop
2016/11/05: OSWDem16 workshop
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meeting
 
PyCourse - Self driving python course
PyCourse - Self driving python coursePyCourse - Self driving python course
PyCourse - Self driving python course
 
Python Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtPython Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txt
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance Tooling
 
SciPy 2022 Scikit-HEP
SciPy 2022 Scikit-HEPSciPy 2022 Scikit-HEP
SciPy 2022 Scikit-HEP
 
Hello Git
Hello GitHello Git
Hello Git
 
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
 
Steps to install ns3
Steps to install ns3Steps to install ns3
Steps to install ns3
 
Princeton RSE Peer network first meeting
Princeton RSE Peer network first meetingPrinceton RSE Peer network first meeting
Princeton RSE Peer network first meeting
 
Hello, Git!
Hello, Git!Hello, Git!
Hello, Git!
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with python
 
05 python.pdf
05 python.pdf05 python.pdf
05 python.pdf
 

Recently uploaded

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Python + STIX = Awesome

  • 2. What is python-stix? • Developer friendly – Python objects > raw XML • Re-usable – Open-source libraries • Plug-in ready – Integrate with existing tools github.com/STIXProject/python-stix
  • 3. Let's get started! • Install Python 2.7 and dependencies apt-get install python-dev python-pip apt-get install libxml2-dev libxslt-dev apt-get install zlib1g-dev pip install stix github.com/STIXProject/python-stix
  • 4. Create a STIX document github.com/STIXProject/python-stix $ cat > write.py from stix.core import STIXPackage, STIXHeader header = STIXHeader () header.title = "My first document!" pkg = STIXPackage() pkg.stix_header = header print pkg.to_xml() // output XML
  • 5. Generate a STIX Indicator • The following slides will reference this example code github.com/STIXProject/python-stix
  • 6. Create IP Address Indicator github.com/STIXProject/python-stix $ cat >> write.py ind = Indicator() ind.title="malicious IP" ind.add_indicator_type("IP Watchlist") // set value addr = Address() addr.address_value="10.0.0.0" addr.category = 'ipv4-addr' addr.condition = "Equals" // add to package ind.add_observable(addr) stix_package.add_indicator(ind)
  • 7. Add optional fields github.com/STIXProject/python-stix $ cat >> write.py // add a type of malicious activity activity = TTP(title="C2 Behavior") stix_package.add_ttp(activity) //link indicator to activity ind.add_indicated_ttp(TTP(idref = activity.id_) )
  • 8. Parsing STIX • The following slides will reference this example code github.com/STIXProject/python-stix
  • 9. Load a STIX document $ curl http://tiny.cc/samplestix > in.xml $ python from stix.core import STIXPackage, STIXHeader myfile = open('in.xml') pkg = STIXPackage.from_xml(myfile) github.com/STIXProject/python-stix
  • 10. Access Data Elements $cat in.xml <stix:STIX_Package <stix:Package_Intent>Incident <stix:Description>Sample breach report </> $ cat >> read.py print pkg.stix_header.description github.com/STIXProject/python-stix
  • 11. Iterate Lists $cat in.xml <stix:Incident> <incident:Title>Breach of Cyber Tech Dynamics </> $ cat >> read.py for inc in pkg.incidents: print inc.title github.com/STIXProject/python-stix
  • 12. Parsing STIX (Advanced) • The following slides will reference this example code github.com/STIXProject/python-stix
  • 13. $curl http://tiny.cc/samplestixobs > in.xml <stix:Indicator> <indicator:Observable> <cybox:Object> <cybox:Properties> <FileObj:Hashes> <cyboxCommon:Hash>d3adb33f </> $ cat > read.py for ind in pkg.indicators: for obs in ind.observables: for digest in obs.object_.properties.hashes: print digest Examine Observables github.com/STIXProject/python-stix
  • 14. Dereference Links github.com/STIXProject/python-stix $cat in.xml <stix:TTPs> <stix:TTP id="id_value"> [...] </> <stix:Indicator> <indicator:Indicated_TTP> <stixCommon:TTP idref="id_value"> </> $ cat >> read.py relationship_dict = {} for ttp in package.ttps.ttps: relationship_dict [ttp.id_] = ttp # assign object to dictionary value, with I as key for rel_ttp in indicator.indicated_ttps: if rel_ttp.item.idref in ttps: # look up object by ID print relationship_dict[rel_ttp.item.idref].title
  • 15. Further Reading • Sample code and use cases – stixproject.github.io/documentation/idioms • Python documentation – stix.readthedocs.org github.com/STIXProject/python-stix