socialinvestigator 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/socialinvestigator/cli/net.rb +10 -1
- data/lib/socialinvestigator/client/net.rb +132 -94
- data/lib/socialinvestigator/client/standalone_net.rb +37 -2
- data/lib/socialinvestigator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13d1c86f7088d598bb4c4b81b1ce4a5d1c9344ee
|
4
|
+
data.tar.gz: 2c6385e6b65ea955f39647849c072d4212d40c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1540385a853c75ce6b0d47146412048022f2f0ba1175f90415168ea970d7257d4b312a38cd04138c2f6709da4de97b9c9e7e58028d2d7a3a3179a6f1b6f9872
|
7
|
+
data.tar.gz: c311cba9fb6267e86b5218fc699734f533edeff2394ff32cb185a0e102be3d873f6db740a604a62f3ecf9b0c101c8802053d4cbb178854edaf7912eb3db98459
|
data/README.md
CHANGED
@@ -4,8 +4,17 @@ module Socialinvestigator
|
|
4
4
|
module CLI
|
5
5
|
class Net < Thor
|
6
6
|
desc "page_info URL", "Looks at a page to see what social links it finds"
|
7
|
+
options [:noreverse, :debug]
|
8
|
+
long_desc <<-PAGE_INFO
|
9
|
+
page_info URL
|
10
|
+
|
11
|
+
Looks at a page to see what social links it finds
|
12
|
+
|
13
|
+
--noreverse skips the reverse ip lookup and associate whois call
|
14
|
+
--debug prints out every fact that is discovered
|
15
|
+
PAGE_INFO
|
7
16
|
def page_info( url )
|
8
|
-
knowledge = client.get_knowledge( url )
|
17
|
+
knowledge = client.get_knowledge( url, options[:noreverse], options[:debug] )
|
9
18
|
knowledge.print
|
10
19
|
end
|
11
20
|
|
@@ -3,118 +3,139 @@ require 'httparty'
|
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'dnsruby'
|
5
5
|
require 'whois'
|
6
|
+
require 'whois/record/parser/blank'
|
7
|
+
require 'whois/record/contact'
|
6
8
|
|
7
9
|
module Socialinvestigator
|
8
10
|
module Client
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
module Net
|
12
|
+
class PageKnowledge
|
13
|
+
@debug = false
|
14
|
+
TEMPLATE = "%20s: %s\n"
|
15
|
+
|
16
|
+
def initialize( debug = false )
|
17
|
+
@debug = debug
|
18
|
+
@knowledge = {}
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
def remember( key, value )
|
22
|
+
return if value.nil?
|
23
|
+
p key, value if @debug
|
18
24
|
|
19
|
-
|
20
|
-
|
25
|
+
@knowledge[key] = value
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
def another( key, value )
|
29
|
+
return if value.nil?
|
30
|
+
p key, value if @debug
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
@knowledge[key] ||= []
|
33
|
+
@knowledge[key] << value
|
34
|
+
@knowledge[key] = @knowledge[key].uniq
|
35
|
+
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
37
|
+
def print
|
38
|
+
p :domain
|
39
|
+
p :created_on
|
40
|
+
p :expires_on
|
41
|
+
p :updated_on
|
42
|
+
p :registrar_name
|
43
|
+
p :registrar_url
|
44
|
+
p :registrant_contact
|
45
|
+
p :admin_contact
|
46
|
+
p :technical_contact
|
47
|
+
|
48
|
+
p :server_name
|
49
|
+
p :server_country
|
50
|
+
p :server_location
|
51
|
+
p :server_latitude
|
52
|
+
p :server_longitude
|
53
|
+
p :server_ip_owner
|
54
|
+
|
55
|
+
p :emails
|
56
|
+
p :title, title
|
57
|
+
p :description, description
|
58
|
+
p :twitter_author, twitter_author
|
59
|
+
p :twitter_ids
|
60
|
+
p :image, image
|
61
|
+
p :responsive
|
62
|
+
p :rss_feed
|
63
|
+
p :atom_feed
|
64
|
+
|
65
|
+
p :twitter_links
|
66
|
+
p :linkedin_links
|
67
|
+
p :instagram_links
|
68
|
+
p :facebook_links
|
69
|
+
p :googleplus_links
|
70
|
+
p :github_links
|
71
|
+
p :technologies
|
72
|
+
end
|
59
73
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
74
|
+
def p( key, val = nil )
|
75
|
+
val = @knowledge[key] if val.nil?
|
76
|
+
if val.is_a?( Array )
|
77
|
+
printf TEMPLATE, key, val.join( ", ") if val.size > 0
|
78
|
+
elsif val.is_a?( Whois::Record::Contact )
|
79
|
+
printf TEMPLATE, key, ""
|
80
|
+
[:name, :organization, :address, :city, :zip, :state, :country, :country_code, :phone, :fax, :email, :url, :created_on, :updated_on].each do |key|
|
81
|
+
out = val.send( key )
|
82
|
+
printf "%25s: %s\n", key, out if out && out != ""
|
83
|
+
end
|
84
|
+
else
|
85
|
+
printf TEMPLATE, key, val if val
|
69
86
|
end
|
70
|
-
else
|
71
|
-
printf TEMPLATE, key, val if val
|
72
87
|
end
|
73
|
-
end
|
74
88
|
|
75
|
-
|
76
|
-
|
77
|
-
|
89
|
+
def title
|
90
|
+
@knowledge[:twitter_title] || @knowledge[:og_title] || @knowledge[:page_title]
|
91
|
+
end
|
78
92
|
|
79
|
-
|
80
|
-
|
81
|
-
|
93
|
+
def twitter_author
|
94
|
+
@knowledge[:twitter_creator] || @knowledge[:twitter_by] || @knowledge[:twitter_site_author] || (@knowledge[:twitter_ids] || []).first
|
95
|
+
end
|
82
96
|
|
83
|
-
|
84
|
-
|
85
|
-
|
97
|
+
def description
|
98
|
+
@knowledge[:twitter_description] || @knowledge[:og_description] || @knowledge[:description]
|
99
|
+
end
|
86
100
|
|
87
|
-
|
88
|
-
|
101
|
+
def image
|
102
|
+
@knowledge[:twitter_image] || @knowledge[:og_image]
|
103
|
+
end
|
89
104
|
end
|
90
|
-
end
|
91
105
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
def find_domain( hostname )
|
96
|
-
# puts "Looking for SOA of #{hostname}"
|
97
|
-
dns = Dnsruby::Resolver.new
|
98
|
-
soa = dns.query( hostname, "SOA" ).answer.select do |rr|
|
99
|
-
rr.is_a? Dnsruby::RR::IN::SOA
|
106
|
+
class DNS
|
107
|
+
def initialize
|
108
|
+
@resolv = Dnsruby::Resolver.new
|
100
109
|
end
|
101
110
|
|
102
|
-
|
111
|
+
def find_domain( hostname )
|
112
|
+
# puts "Looking for SOA of #{hostname}"
|
113
|
+
soa = @resolv.query( hostname, "SOA" ).answer.select do |rr|
|
114
|
+
rr.is_a? Dnsruby::RR::IN::SOA
|
115
|
+
end
|
116
|
+
|
117
|
+
return hostname if soa.length > 0
|
103
118
|
|
104
|
-
|
105
|
-
|
119
|
+
parts = hostname.split( /\./ )
|
120
|
+
return nil if parts.length <= 2
|
106
121
|
|
107
|
-
|
122
|
+
find_domain( parts.slice(1,100).join( "." ) )
|
123
|
+
end
|
108
124
|
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class NetClient
|
128
|
+
# Look up the domain
|
109
129
|
|
110
|
-
def get_knowledge( url )
|
111
|
-
data = PageKnowledge.new
|
130
|
+
def get_knowledge( url, noreverse = false, debug = false )
|
131
|
+
data = Socialinvestigator::Client::Net::PageKnowledge.new( debug )
|
132
|
+
dns = Socialinvestigator::Client::Net::DNS.new
|
112
133
|
|
113
134
|
uri = URI( url )
|
114
135
|
|
115
136
|
data.remember( :hostname, uri.hostname )
|
116
137
|
|
117
|
-
domain = find_domain(uri.hostname)
|
138
|
+
domain = dns.find_domain(uri.hostname)
|
118
139
|
|
119
140
|
data.remember( :domain, domain )
|
120
141
|
|
@@ -143,16 +164,7 @@ module Socialinvestigator
|
|
143
164
|
data.remember( :technical_contact, c )
|
144
165
|
end
|
145
166
|
end
|
146
|
-
|
147
|
-
# :name,:organization,:address,:city,
|
148
|
-
# :zip,:state,:country,:country_code,
|
149
|
-
# :phone,:fax,:email,:url].each do |k|
|
150
|
-
# val = c.send(k)
|
151
|
-
# printf "%15s : %s\n", k.to_s, val if !val.nil?
|
152
|
-
# end
|
153
|
-
# end
|
154
|
-
|
155
|
-
require 'whois/record/parser/blank'
|
167
|
+
|
156
168
|
whois.parts.each do |p|
|
157
169
|
if Whois::Record::Parser.parser_for(p).is_a? Whois::Record::Parser::Blank
|
158
170
|
puts "Couldn't find a parser for #{p.host}:"
|
@@ -161,7 +173,33 @@ module Socialinvestigator
|
|
161
173
|
end
|
162
174
|
|
163
175
|
|
176
|
+
if !noreverse
|
177
|
+
ip_address = Dnsruby::Resolv.getaddress uri.host
|
178
|
+
|
179
|
+
if ip_address
|
180
|
+
data.remember :ip_address, ip_address
|
181
|
+
begin
|
182
|
+
data.remember :server_name, Dnsruby::Resolv.getname( ip_address )
|
183
|
+
rescue Dnsruby::NXDomain
|
184
|
+
# Couldn't do the reverse lookup
|
185
|
+
end
|
186
|
+
|
187
|
+
location_info = HTTParty.get('http://freegeoip.net/json/' + ip_address)
|
188
|
+
|
189
|
+
data.remember :server_country, location_info['country_name']
|
190
|
+
data.remember :server_location, [location_info['city'], location_info['region_name']].collect { |x| (x != nil && x != "") ? x : nil }.select { |x| x }.join( ", ")
|
191
|
+
data.remember :server_latitude, location_info['latitude']
|
192
|
+
data.remember :server_longitude, location_info['longitude']
|
164
193
|
|
194
|
+
ip_whois = Whois.lookup ip_address
|
195
|
+
|
196
|
+
ip_whois.to_s.each_line.select { |x| x=~/Organization/ }.each do |org|
|
197
|
+
if org =~ /Organization:\s*(.*)\n/
|
198
|
+
data.another :server_ip_owner, $1
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
165
203
|
|
166
204
|
# Load up the response
|
167
205
|
|
@@ -4,10 +4,13 @@ require 'nokogiri'
|
|
4
4
|
require 'dnsruby'
|
5
5
|
require 'whois'
|
6
6
|
|
7
|
+
require 'whois/record/parser/blank'
|
8
|
+
require 'whois/record/contact'
|
9
|
+
|
7
10
|
url = ARGV[0] || "http://www.fastcolabs.com/3038014/product-bootcamp-week-six-worth-it"
|
8
11
|
|
9
12
|
class PageKnowledge
|
10
|
-
DEBUG =
|
13
|
+
DEBUG = true
|
11
14
|
TEMPLATE = "%20s: %s\n"
|
12
15
|
|
13
16
|
def initialize; @knowledge = {} end
|
@@ -38,6 +41,13 @@ class PageKnowledge
|
|
38
41
|
p :registrant_contact
|
39
42
|
p :admin_contact
|
40
43
|
p :technical_contact
|
44
|
+
p :server_name
|
45
|
+
p :server_country
|
46
|
+
p :server_location
|
47
|
+
p :server_latitude
|
48
|
+
p :server_longitude
|
49
|
+
p :server_ip_owner
|
50
|
+
|
41
51
|
p :emails
|
42
52
|
p :title, title
|
43
53
|
p :description, description
|
@@ -153,7 +163,6 @@ end
|
|
153
163
|
# end
|
154
164
|
# end
|
155
165
|
|
156
|
-
require 'whois/record/parser/blank'
|
157
166
|
whois.parts.each do |p|
|
158
167
|
if Whois::Record::Parser.parser_for(p).is_a? Whois::Record::Parser::Blank
|
159
168
|
puts "Couldn't find a parser for #{p.host}:"
|
@@ -161,7 +170,33 @@ whois.parts.each do |p|
|
|
161
170
|
end
|
162
171
|
end
|
163
172
|
|
173
|
+
# Lookup IP Address info
|
174
|
+
|
175
|
+
ip_address = Dnsruby::Resolv.getaddress uri.host
|
176
|
+
|
177
|
+
if ip_address
|
178
|
+
data.remember :ip_address, ip_address
|
179
|
+
begin
|
180
|
+
data.remember :server_name, Dnsruby::Resolv.getname( ip_address )
|
181
|
+
rescue Dnsruby::NXDomain
|
182
|
+
# Couldn't do the reverse lookup
|
183
|
+
end
|
164
184
|
|
185
|
+
location_info = HTTParty.get('http://freegeoip.net/json/' + ip_address)
|
186
|
+
|
187
|
+
data.remember :server_country, location_info['country']
|
188
|
+
data.remember :server_location, [location_info['city'], location_info['region_name']].select { |x| x }.join( ", ")
|
189
|
+
data.remember :server_latitude, location_info['latitude']
|
190
|
+
data.remember :server_longitude, location_info['longitude']
|
191
|
+
|
192
|
+
ip_whois = Whois.lookup ip_address
|
193
|
+
|
194
|
+
ip_whois.to_s.each_line.select { |x| x=~/Organization/ }.each do |org|
|
195
|
+
if org =~ /Organization:\s*(.*)\n/
|
196
|
+
data.another :server_ip_owner, $1
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
165
200
|
|
166
201
|
|
167
202
|
# Load up the response
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialinvestigator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Schenk
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.2.
|
171
|
+
rubygems_version: 2.2.1
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Simple command line tool to look at urls.
|