Skip to content

Instantly share code, notes, and snippets.

/code_help.rb Secret

Created May 11, 2016 21:09
Show Gist options
  • Save anonymous/864553fae701df583e24fbeefc170b1c to your computer and use it in GitHub Desktop.
Save anonymous/864553fae701df583e24fbeefc170b1c to your computer and use it in GitHub Desktop.
## My ruby code:
require 'pp'
require 'censys'
require 'pry'
api = CenSys::API.new
ipresponse = api.ipv4.search(query: 'dropbox.com')
ipresponse.each_page do |page|
puts ">>> Page ##{page.metadata.page} / #{page.metadata.pages} ..."
page.each do |result|
puts result
end
end
### My Goal
I want this code to print the following
"IP Address: <IP> Ports: <port/proto>"
### The Data
ipresponse = #<CenSys::Search::Response:0x00000004b17340
@api=
#<CenSys::API:0x00000004afbbe0
@certificates=
#<CenSys::API::Resource:0x00000004afba50
#<CenSys::API::Resource:0x00000004afba50
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:certificates>,
@id="1f02fd16-393d-47e1-93d2-5a7df893ec9f",
@ipv4=
#<CenSys::API::Resource:0x00000004afbaa0
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:ipv4>,
@secret="Igf4RCRdUNloYX5Sii47jCv3fyf7owhw",
@websites=
#<CenSys::API::Resource:0x00000004afba78
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:websites>>,
@metadata=
#<CenSys::Search::Metadata:0x00000004b17318
@backend_time=19,
@count=914,
@page=1,
@pages=10,
@query="dropbox.com">,
@params={:query=>"dropbox.com"},
@result_type=:ipv4,
@results=
[#<CenSys::Search::IPv4:0x00000004b172c8
@api=
#<CenSys::API:0x00000004afbbe0
@certificates=
#<CenSys::API::Resource:0x00000004afba50
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:certificates>,
@id="1f02fd16-393d-47e1-93d2-5a7df893ec9f",
@ipv4=
#<CenSys::API::Resource:0x00000004afbaa0
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:ipv4>,
@secret="Igf4RCRdUNloYX5Sii47jCv3fyf7owhw",
@websites=
#<CenSys::API::Resource:0x00000004afba78
@api=#<CenSys::API:0x00000004afbbe0 ...>,
@type=:websites>>,
@attributes={"ip"=>"108.160.172.205", "protocols"=>["443/https"]}>,
.
.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment