SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
Laura García @ RootedCON2019
SHODANAPIand CODINGSKILLS
$ whoami
I am Laura García
Computer Engineer & Cybersec Master @Polytechnic_University_of_Madrid
Security Architect / Pentester @Deloitte_Hack_Team
Speaker at RootedCON Madrid 2016 and MalCon 2016
The large
number of
assets
published
on the
Internet,
increase
the
probability
of services
exposed
that could
put them
at risk.
country:"ES"+port:"3389"
3094 resultscountry:"US"+port:"445"
411.012 results
country:"JP"+port:"137"
28.574 results
country:"BR"+port:"500"
39.106 results
country:"TH"+port:"1900"
54.312 results
SHODAN SEEKER
Business Logic Fully
Customizable
Reporting Python
Official Shodan
Library for
Python
REST API
STREAMING
API
LogsMailing list
shodan-seeker $ ./shodanseeker
Usage: python shodanseeker [options]
Options:
-h, --help show this help message and exit
--mail=MAIL Send email with results and alerts
-a Attach csv results to an email
Scanning Options:
--si=SCANINPUT Scan an IP/netblock
--sf=SCANFILE Scan an IP/netblock from file
--force Force Shodan to re-scan the provided IPs
-l List previously submitted scans
Searching Options:
-i GETINFO Get all information of an IP/netblock
-f GETINFOFROMFILE Get all information of an IP/netblock from file
--history Get all Historical Banners
--diff Detect New Services Published
--output=OUTPUT Output results in csv format
Monitoring in Real-Time:
--ca=ADDALERT Create network alerts for the IP/netblock
--cf=ADDALERTFILE Create network alerts from file
--la List of all the network alerts activated
--da=DELALERT Remove the specified network alert
--subs=SUBSALERTS Subscribe to the Private Horse Streaming
--monport=MONPORT Monitoring for High Risk Services
--mondiff Monitoring for New Services Published
--montag=MONTAG Tags (ex: compromised, doublepulsar, self-signed,...)
--get=GET Protocols, services, ports and tags supported
EXAMPLES:
./shodanseeker --si 'X.X.X.X Y.Y.Y.Y/24' # Scan IPs/netblocks
./shodanseeker --sf 'pathfilename' # Scan IPs/netblocks from a file
./shodanseeker -l # List previously submitted scans
./shodanseeker -i 'X.X.X.X Y.Y.Y.Y/24 Z.Z.Z.Z' # Get all information of IP/netblocks
./shodanseeker -f 'pathfilename' # Get all information from a file of IPs/netblocks
./shodanseeker -i 'X.X.X.X' --history # Get all historical banners
./shodanseeker -i 'X.X.X.X' --diff # Detect new services published
./shodanseeker -f 'pathfilename' [--history|--diff] --output csv # Output results in csv format
./shodanseeker -i 'X.X.X.X' --diff --output csv --mail toaddr -a # Send email with csv results attached
./shodanseeker --ca Name 'X.X.X.X Y.Y.Y.Y/24' # Create network alerts for the IP/netblock
./shodanseeker --cf Name 'pathfilename' # Create network alerts from file
./shodanseeker --la # List of all the network alerts activated on the account
./shodanseeker --da [alertid|all] # Remove the specified network alert
./shodanseeker --subs [alertid|all] --monport '3389 22' [--mail toaddr] # Subscribe to the Streaming for high risk services
./shodanseeker --subs [alertid|all] --mondiff [--mail toaddr] # Subscribe to the Streaming for new services published
./shodanseeker --subs [alertid|all] --montag 'compromised' [--mail toaddr] # Subscribe to the Streaming and monitoring for tags
./shodanseeker --get [protocols|services|ports|tags] # List of (protocols,services,ports,tags) supported
Technical issues
● Request rate limit reached (1 request/second) in API calls.
- sleep(0.5s)
● Connection between the script and the server got broken (Streaming).
- ./sh to respawn shodan-seeker.py script.
- ChunkedEncodingError exception: call self.function.
● JSON output contains blank fields ( “ports”).
● Shodan takes a few hours, since on-demand scanning is launched, to
update its databases with the results.
● IPs found with open ports did not appear in their database.
Diffing implementation
ip port1 timestamp1
port1 timestamp2
last_update port2 timestamp3
port3 timestamp1
port3 timestamp3
GET/shodan/host/{ip}&history=true
port1 port2 port3
Request:
Response:
list_port_uniq:
timestamp1
timestamp2
timestamp3
list_timestamp_host_sort_uniq:
var list_timestamp_port:
timestamp1
timestamp3
for port in port_uniq:
for timestamp in list_timestamp_port:
if (last_update == timestamp) and (date <= timestamp_adjustment):
if (len (list_timestamp_port) == 1:
print “diff port open”
else:
next_timestamp_port = list_timestamp_port[1]
next_timestamp_host = list_timestamp_host_sort_uniq[1]
if (next_timestamp_port != next_timestamp_host):
print “diff port open”
timestamp_ajustment =
datetime.now() +
days=32
timestamp_adjustment:
Pros and Cons
● Diffing implementation for assets discovery on real-time or REST API approach.
● Getting information (History, Diffing) without consuming credits.
● Generating results on csv format without consuming credits.
● Reports easy to integrate with Business Data Analytics frameworks.
● Fully customizable:
○ Input data via console or files.
○ Different output modes.
○ Send alerts and output results to different mailing lists.
● Monitoring all tags supported by Shodan.
● Console friendly :)
● API plan subscription needed.
Downloads
Recommended clone from Git:
git clone https://github.com/laincode/shodan-seeker
cd shodan-seeker
./shodan-seeker # just run this script
$ ./shodan-seeker
Demo
Thanks!!
#hack.delite_es -=Pwn&Swag=-

Contenu connexe

Tendances

Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
RootedCON
 
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
RootedCON
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
Cyber Security Alliance
 
Wtf is happening_inside_my_android_phone_public
Wtf is happening_inside_my_android_phone_publicWtf is happening_inside_my_android_phone_public
Wtf is happening_inside_my_android_phone_public
Jaime Blasco
 
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
OpenDNS
 
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
CODE BLUE
 

Tendances (20)

Python Cryptography & Security
Python Cryptography & SecurityPython Cryptography & Security
Python Cryptography & Security
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso Remoto
 
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
 
DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...
DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...
DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...
 
NSC #2 - Challenge Solution
NSC #2 - Challenge SolutionNSC #2 - Challenge Solution
NSC #2 - Challenge Solution
 
Hacking the swisscom modem
Hacking the swisscom modemHacking the swisscom modem
Hacking the swisscom modem
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
Da APK al Golden Ticket
Da APK al Golden TicketDa APK al Golden Ticket
Da APK al Golden Ticket
 
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
Threat hunting != Throwing arrow! Hunting for adversaries in your it environmentThreat hunting != Throwing arrow! Hunting for adversaries in your it environment
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
 
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
Francisco Jesús Gómez + Carlos Juan Diaz - Cloud Malware Distribution: DNS wi...
 
Assume Compromise
Assume CompromiseAssume Compromise
Assume Compromise
 
Hunting for APT in network logs workshop presentation
Hunting for APT in network logs workshop presentationHunting for APT in network logs workshop presentation
Hunting for APT in network logs workshop presentation
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Wtf is happening_inside_my_android_phone_public
Wtf is happening_inside_my_android_phone_publicWtf is happening_inside_my_android_phone_public
Wtf is happening_inside_my_android_phone_public
 
Hiding in plain sight
Hiding in plain sightHiding in plain sight
Hiding in plain sight
 
Windows persistence presentation
Windows persistence presentationWindows persistence presentation
Windows persistence presentation
 
Rooted2020 stefano maccaglia--_the_enemy_of_my_enemy
Rooted2020 stefano maccaglia--_the_enemy_of_my_enemyRooted2020 stefano maccaglia--_the_enemy_of_my_enemy
Rooted2020 stefano maccaglia--_the_enemy_of_my_enemy
 
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
 
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
 

Similaire à Laura Garcia - Shodan API and Coding Skills [rooted2019]

Go with the Flow-v2
Go with the Flow-v2Go with the Flow-v2
Go with the Flow-v2
Zobair Khan
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale
Subbu Allamaraju
 
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docxINFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
carliotwaycave
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
Freddy Buenaño
 

Similaire à Laura Garcia - Shodan API and Coding Skills [rooted2019] (20)

Nmap scripting engine
Nmap scripting engineNmap scripting engine
Nmap scripting engine
 
Pyrax talk
Pyrax talkPyrax talk
Pyrax talk
 
Go with the Flow-v2
Go with the Flow-v2Go with the Flow-v2
Go with the Flow-v2
 
Go with the Flow
Go with the Flow Go with the Flow
Go with the Flow
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
 
Getting Data into Splunk
Getting Data into SplunkGetting Data into Splunk
Getting Data into Splunk
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docxINFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
 
Monitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachineMonitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachine
 
Incident response: Advanced Network Forensics
Incident response: Advanced Network ForensicsIncident response: Advanced Network Forensics
Incident response: Advanced Network Forensics
 
CODEONTHEBEACH_Streaming Applications with Apache Pulsar
CODEONTHEBEACH_Streaming Applications with Apache PulsarCODEONTHEBEACH_Streaming Applications with Apache Pulsar
CODEONTHEBEACH_Streaming Applications with Apache Pulsar
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
Socket programming-tutorial-sk
Socket programming-tutorial-skSocket programming-tutorial-sk
Socket programming-tutorial-sk
 
Soap Toolkit Dcphp
Soap Toolkit DcphpSoap Toolkit Dcphp
Soap Toolkit Dcphp
 
IBCAST 2021: Observations and lessons learned from the APNIC Community Honeyn...
IBCAST 2021: Observations and lessons learned from the APNIC Community Honeyn...IBCAST 2021: Observations and lessons learned from the APNIC Community Honeyn...
IBCAST 2021: Observations and lessons learned from the APNIC Community Honeyn...
 
03 sockets
03 sockets03 sockets
03 sockets
 
Approach to find critical vulnerabilities
Approach to find critical vulnerabilitiesApproach to find critical vulnerabilities
Approach to find critical vulnerabilities
 

Plus de RootedCON

Plus de RootedCON (20)

Rooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro Villaverde
Rooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro VillaverdeRooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro Villaverde
Rooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro Villaverde
 
rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...
rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...
rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...
 
Rooted2020 hunting malware-using_process_behavior-roberto_amado
Rooted2020 hunting malware-using_process_behavior-roberto_amadoRooted2020 hunting malware-using_process_behavior-roberto_amado
Rooted2020 hunting malware-using_process_behavior-roberto_amado
 
Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_
Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_
Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_
 
Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...
Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...
Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...
 
Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...
Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...
Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...
 
Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...
Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...
Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...
 
Rooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguer
Rooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguerRooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguer
Rooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguer
 
rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...
rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...
rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...
 
Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...
Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...
Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...
 
Rooted2020 virtual pwned-network_-_manel_molina
Rooted2020 virtual pwned-network_-_manel_molinaRooted2020 virtual pwned-network_-_manel_molina
Rooted2020 virtual pwned-network_-_manel_molina
 
Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...
Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...
Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...
 
Rooted2020 todo a-siem_-_marta_lopez
Rooted2020 todo a-siem_-_marta_lopezRooted2020 todo a-siem_-_marta_lopez
Rooted2020 todo a-siem_-_marta_lopez
 
Rooted2020 live coding--_jesus_jara
Rooted2020 live coding--_jesus_jaraRooted2020 live coding--_jesus_jara
Rooted2020 live coding--_jesus_jara
 
Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...
Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...
Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...
 
Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...
Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...
Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...
 
Rooted2020 evading deep-learning_malware_detectors_-_javier_yuste
Rooted2020 evading deep-learning_malware_detectors_-_javier_yusteRooted2020 evading deep-learning_malware_detectors_-_javier_yuste
Rooted2020 evading deep-learning_malware_detectors_-_javier_yuste
 
Rooted2020 encontrando 0days-en_2020_-_antonio_morales
Rooted2020 encontrando 0days-en_2020_-_antonio_moralesRooted2020 encontrando 0days-en_2020_-_antonio_morales
Rooted2020 encontrando 0days-en_2020_-_antonio_morales
 
Rooted2020 emotet is-dead_long_live_emotet_-_victor_acin
Rooted2020 emotet is-dead_long_live_emotet_-_victor_acinRooted2020 emotet is-dead_long_live_emotet_-_victor_acin
Rooted2020 emotet is-dead_long_live_emotet_-_victor_acin
 
Rooted2020 el camino-de_hacktiago_tras_los_pasos_de_14_increibles_cibersantua...
Rooted2020 el camino-de_hacktiago_tras_los_pasos_de_14_increibles_cibersantua...Rooted2020 el camino-de_hacktiago_tras_los_pasos_de_14_increibles_cibersantua...
Rooted2020 el camino-de_hacktiago_tras_los_pasos_de_14_increibles_cibersantua...
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Laura Garcia - Shodan API and Coding Skills [rooted2019]

  • 1. Laura García @ RootedCON2019 SHODANAPIand CODINGSKILLS
  • 2. $ whoami I am Laura García Computer Engineer & Cybersec Master @Polytechnic_University_of_Madrid Security Architect / Pentester @Deloitte_Hack_Team Speaker at RootedCON Madrid 2016 and MalCon 2016
  • 3. The large number of assets published on the Internet, increase the probability of services exposed that could put them at risk.
  • 4. country:"ES"+port:"3389" 3094 resultscountry:"US"+port:"445" 411.012 results country:"JP"+port:"137" 28.574 results country:"BR"+port:"500" 39.106 results country:"TH"+port:"1900" 54.312 results
  • 5. SHODAN SEEKER Business Logic Fully Customizable Reporting Python Official Shodan Library for Python REST API STREAMING API LogsMailing list
  • 6. shodan-seeker $ ./shodanseeker Usage: python shodanseeker [options] Options: -h, --help show this help message and exit --mail=MAIL Send email with results and alerts -a Attach csv results to an email Scanning Options: --si=SCANINPUT Scan an IP/netblock --sf=SCANFILE Scan an IP/netblock from file --force Force Shodan to re-scan the provided IPs -l List previously submitted scans Searching Options: -i GETINFO Get all information of an IP/netblock -f GETINFOFROMFILE Get all information of an IP/netblock from file --history Get all Historical Banners --diff Detect New Services Published --output=OUTPUT Output results in csv format Monitoring in Real-Time: --ca=ADDALERT Create network alerts for the IP/netblock --cf=ADDALERTFILE Create network alerts from file --la List of all the network alerts activated --da=DELALERT Remove the specified network alert --subs=SUBSALERTS Subscribe to the Private Horse Streaming --monport=MONPORT Monitoring for High Risk Services --mondiff Monitoring for New Services Published --montag=MONTAG Tags (ex: compromised, doublepulsar, self-signed,...) --get=GET Protocols, services, ports and tags supported
  • 7. EXAMPLES: ./shodanseeker --si 'X.X.X.X Y.Y.Y.Y/24' # Scan IPs/netblocks ./shodanseeker --sf 'pathfilename' # Scan IPs/netblocks from a file ./shodanseeker -l # List previously submitted scans ./shodanseeker -i 'X.X.X.X Y.Y.Y.Y/24 Z.Z.Z.Z' # Get all information of IP/netblocks ./shodanseeker -f 'pathfilename' # Get all information from a file of IPs/netblocks ./shodanseeker -i 'X.X.X.X' --history # Get all historical banners ./shodanseeker -i 'X.X.X.X' --diff # Detect new services published ./shodanseeker -f 'pathfilename' [--history|--diff] --output csv # Output results in csv format ./shodanseeker -i 'X.X.X.X' --diff --output csv --mail toaddr -a # Send email with csv results attached ./shodanseeker --ca Name 'X.X.X.X Y.Y.Y.Y/24' # Create network alerts for the IP/netblock ./shodanseeker --cf Name 'pathfilename' # Create network alerts from file ./shodanseeker --la # List of all the network alerts activated on the account ./shodanseeker --da [alertid|all] # Remove the specified network alert ./shodanseeker --subs [alertid|all] --monport '3389 22' [--mail toaddr] # Subscribe to the Streaming for high risk services ./shodanseeker --subs [alertid|all] --mondiff [--mail toaddr] # Subscribe to the Streaming for new services published ./shodanseeker --subs [alertid|all] --montag 'compromised' [--mail toaddr] # Subscribe to the Streaming and monitoring for tags ./shodanseeker --get [protocols|services|ports|tags] # List of (protocols,services,ports,tags) supported
  • 8. Technical issues ● Request rate limit reached (1 request/second) in API calls. - sleep(0.5s) ● Connection between the script and the server got broken (Streaming). - ./sh to respawn shodan-seeker.py script. - ChunkedEncodingError exception: call self.function. ● JSON output contains blank fields ( “ports”). ● Shodan takes a few hours, since on-demand scanning is launched, to update its databases with the results. ● IPs found with open ports did not appear in their database.
  • 9. Diffing implementation ip port1 timestamp1 port1 timestamp2 last_update port2 timestamp3 port3 timestamp1 port3 timestamp3 GET/shodan/host/{ip}&history=true port1 port2 port3 Request: Response: list_port_uniq: timestamp1 timestamp2 timestamp3 list_timestamp_host_sort_uniq: var list_timestamp_port: timestamp1 timestamp3 for port in port_uniq: for timestamp in list_timestamp_port: if (last_update == timestamp) and (date <= timestamp_adjustment): if (len (list_timestamp_port) == 1: print “diff port open” else: next_timestamp_port = list_timestamp_port[1] next_timestamp_host = list_timestamp_host_sort_uniq[1] if (next_timestamp_port != next_timestamp_host): print “diff port open” timestamp_ajustment = datetime.now() + days=32 timestamp_adjustment:
  • 10. Pros and Cons ● Diffing implementation for assets discovery on real-time or REST API approach. ● Getting information (History, Diffing) without consuming credits. ● Generating results on csv format without consuming credits. ● Reports easy to integrate with Business Data Analytics frameworks. ● Fully customizable: ○ Input data via console or files. ○ Different output modes. ○ Send alerts and output results to different mailing lists. ● Monitoring all tags supported by Shodan. ● Console friendly :) ● API plan subscription needed.
  • 11. Downloads Recommended clone from Git: git clone https://github.com/laincode/shodan-seeker cd shodan-seeker ./shodan-seeker # just run this script