moriarty 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3cb31914a272650d99fca4b1e85bfe4d2ab6df52329b13b9c0b539b981b3c5e0
4
+ data.tar.gz: ab6971049b411bf8631414bc886e915292308f84833c560a88cb851acc5fd149
5
+ SHA512:
6
+ metadata.gz: 3ea1fcbb4b8a05222c72fe9c3c7acea5093c969348bfe5f088b49380947fad2698a493e7c7968588d71239fcfaddc9c3e54fc2cf417fe1b6bd2a77dd2fcdef5a
7
+ data.tar.gz: d4c9374f0bc802770554902ca3079e94653971a019f67454560b2e29017dc105d0527e570218584bd67b9a17cb5d7e9130f4750dd3857abd279e36ab9652a06b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 decentralizuj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Moriarty
2
+
3
+ Tool to check social networks for available username.
4
+ _Idea from python tool - sherlock_
5
+
6
+ ---
7
+
8
+ # What it do
9
+
10
+ Search multiple social networks for free username.
11
+ It's reverse from Sherlock, so not-found username is success.
12
+ Argument `--hunt` will run search like _sherlock_ would, looking for valid users.
13
+
14
+ ---
15
+
16
+ # How to install
17
+
18
+ Clone repo and enter directory:
19
+
20
+ ```
21
+ git clone https://github.com/decentralizuj/moriarty.git && cd moriarty
22
+ ```
23
+
24
+ Install gem and it's dependecies:
25
+
26
+ ```
27
+ bundle install
28
+ ```
29
+
30
+ Moriarty depend on gems: _Rest-Client, Nokogiri and Colorize._
31
+
32
+ ---
33
+
34
+ # How to use
35
+
36
+ Run script from terminal, you will receive info about free/taken username.
37
+ To search for registered user, execute with `--hunt` as argument.
38
+
39
+ Read source-code, each method is explained with examples.
40
+
41
+ ```
42
+ # if run without arguments, or with `-h || --help`, help banner is printed
43
+
44
+ ruby bin/moriarty
45
+ # => print usage instructions
46
+
47
+ ruby bin/moriarty USERNAME1 USERNAME2 USERNAME3
48
+ # => search for free usernames ... ... ...
49
+
50
+ ruby bin/moriarty --hunt USERNAME1 USERNAME2 USERNAME3
51
+ # => hunt registered usernames ... ... ...
52
+ ```
53
+
54
+ To use *Moriarty* in your own project, available methods are:
55
+
56
+ ```ruby
57
+ @jim = Moriarty.new( 'somename', 'facebook.com' )
58
+ # => prepare request for 'https://facebook.com/somename'
59
+
60
+ @jim.go
61
+ # => check facebook for username 'somename', return true/false
62
+
63
+ @jim.go site: 'github.com'
64
+ # => search github.com, but do not change default :url
65
+
66
+ @jim.go site: 'github.com', user: 'decentralizuj'
67
+ # => search new user and site without changing defaults
68
+
69
+ @jim.url
70
+ # => 'https://facebook.com/' -> get url
71
+
72
+ @jim.user
73
+ # => 'somename' -> get user
74
+
75
+ @jim.url = 'instagram.com'
76
+ # => 'https://instagram.com/' -> set url
77
+
78
+ @jim.user = 'moriarty'
79
+ # => 'moriarti' -> set user
80
+
81
+ @jim.search
82
+ # => alias for #go
83
+ ```
84
+
85
+ `CLI` is created to test main `class Moriarty` in terminal.
86
+ Accept 3 self methods, #find!, #hunt! and #print_url
87
+
88
+ ```ruby
89
+ Moriarty.find! 'somename', 'instagram.com'
90
+ # => execute search and print colorized output
91
+
92
+ Moriarty.find! 'somename', 'github.com', :hunt
93
+ or
94
+ Moriarty.hunt! 'somename', 'github.com'
95
+ # => execute hunt and print colorized output
96
+
97
+ Moriarty.print_url 'https://www.github.com/'
98
+ # => 'github'
99
+ ```
data/bin/moriarty ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/moriarty'
4
+
5
+ # Simple way to try first version
6
+ # accept '--hunt' as argument
7
+
8
+ hunt = ARGV.include?('--hunt') ? :hunt : :search
9
+
10
+ # If no args, or include '-h' or '--help', print banner
11
+ # If use '--hunt', do not search for '--hunt' username
12
+
13
+ if ARGV.empty? or ARGV.include? '-h' or ARGV.include? '--help'
14
+
15
+ puts "\nSearch social networks for free username".yellow
16
+ puts " $ ".white + "ruby bin/moriarty sherlock watson".green
17
+ puts "\nRun with --hunt to search for registered users".yellow
18
+ puts " $ ".white + "ruby bin/moriarty sherlock watson --hunt\n".green
19
+ exit(1)
20
+
21
+ else
22
+
23
+ system 'clear' or system 'cls'
24
+ start_time = Time.now.to_i
25
+
26
+ ARGV.each do |user|
27
+ next if user == '--hunt'
28
+
29
+ print "\nStarting #{hunt} for username -> ".white.bold
30
+ puts "[".green + user.yellow + "]".green; puts ""
31
+
32
+ Moriarty.find! user, 'github.com', hunt
33
+ Moriarty.find! user, 'facebook.com', hunt
34
+ Moriarty.find! user, 'instagram.com', hunt
35
+ Moriarty.find! "@#{user}", 'dev.to', hunt
36
+ Moriarty.find! "@#{user}", 'medium.com', hunt
37
+ Moriarty.find! "/u/#{user}", 'reddit.com', hunt
38
+ Moriarty.find! "@#{user}", 'tiktok.com', hunt
39
+ end
40
+
41
+ end_time = Time.now.to_i
42
+
43
+ print "\nFinished in -> ".white.bold
44
+ print "[".green + "#{count = end_time - start_time}".yellow + "]".green
45
+ print " second".white
46
+ puts "s".white unless count.to_s.end_with?('1')
47
+ puts ""
48
+ end
data/lib/moriarty.rb ADDED
@@ -0,0 +1,89 @@
1
+ require_relative 'moriarty/cli.rb'
2
+
3
+ require 'rest-client'
4
+ require 'colorize'
5
+ require 'nokogiri'
6
+
7
+ #
8
+ # Main class to get data and execute request
9
+ #
10
+ # Methods: [ #new, #go, #success?, #make_url, #url=, #user= ]
11
+ #
12
+ # Attributes:
13
+ # :user = :moriarty => 'moriarty'
14
+ # :url = 'example.com' => 'https://example.com/'
15
+ # :response => [.code, .headers, .body] -> restclient#get
16
+ # :html => scrapped HTML if success? -> nokogiri#html
17
+ #
18
+
19
+ class Moriarty
20
+
21
+ attr_reader :url, :user, :response, :html
22
+
23
+ # Set username and site for search request
24
+ # exclude 'https', #make_url will add it for you
25
+ # To use different protocol, set it as third parameter
26
+ #
27
+ # @jim = Moriarty.new( 'moriarty', 'example.com', :http )
28
+ # => @jim.user == 'moriarty'
29
+ # => @jim.url == 'http://example.com/'
30
+
31
+ def initialize( name = '', site = 'github.com', type = :https )
32
+ @user = name.to_s
33
+ @url = make_url site, type
34
+ end
35
+
36
+ # execute request (args are optional)
37
+ # @jim.go site: 'github.com', user: 'mynickname'
38
+ # => true/false
39
+ # -> @jim.response (.code, .headers, .body)
40
+ # -> @jim.html (page HTML if request success)
41
+
42
+ def go( opt = {} )
43
+ opt[:user] ||= @user
44
+ url = opt[:site].nil? ? @url : make_url(opt[:site])
45
+ uri = url + opt[:user]
46
+ @response = RestClient.get uri
47
+ @html = Nokogiri::HTML @response
48
+ return @success = true
49
+ rescue
50
+ return @success = false
51
+ end
52
+
53
+ alias search go
54
+
55
+ # create URL from site name, add 'https' if needed
56
+ # @jim.make_url 'instagram.com'
57
+ # => 'https://instagram.com/'
58
+
59
+ def make_url( link, prot = :https )
60
+ prot = nil if link.to_s.start_with? prot.to_s
61
+ url = prot.nil? ? link.to_s : prot.to_s + '://' + link.to_s
62
+ url += '/' unless url.end_with?('/')
63
+ return url
64
+ end
65
+
66
+ # Set URL from site name and protocol(optional)
67
+ # @jim.url = 'github.com'
68
+ # => @jim.url == 'https://github.com'
69
+
70
+ def url=( link, start = :https )
71
+ @url = make_url link, start
72
+ end
73
+
74
+ # Set username from string or :symbol
75
+ # @jim.user = :moriarty
76
+ # => @jim.user == 'moriarty'
77
+
78
+ def user=( name )
79
+ @user = name.to_s
80
+ end
81
+
82
+ # Check does request succeeded or not
83
+ # @jim.success?
84
+ # => true/false
85
+
86
+ def success?
87
+ @success == true
88
+ end
89
+ end
@@ -0,0 +1,53 @@
1
+ # For CLI use, return colorized output
2
+ # Accepted args: ( name, site, type )
3
+ #
4
+ # name is required ~ (string or :symbol)
5
+ # site is optional ~ (default 'github.com')
6
+
7
+ class Moriarty
8
+
9
+ # Moriarty.find! 'smartuser'
10
+ # => [FOUND!] if username 'smartuser' is free on github
11
+ #
12
+ # Moriarty.find! :stupiduser, 'facebook.com', :hunt
13
+ # => [FREE!] if user 'stupiduser' is registered on facebook
14
+
15
+ def self.find!( name, site = 'github.com', type = :search )
16
+
17
+ @jim = Moriarty.new name.to_s, site.to_s
18
+ @jim.go
19
+
20
+ case
21
+ when type.to_sym == :hunt && @jim.success?
22
+ puts " [FOUND!]".white + " #{name} found on #{ print_url(site) }".yellow
23
+ when type.to_sym == :hunt && !@jim.success?
24
+ puts " #{name} not found on #{ print_url(site) }".red
25
+ when @jim.success?
26
+ puts " #{name} is taken on #{ print_url(site) }".red
27
+ else
28
+ puts " [FREE!]".white + " #{name} is free on #{ print_url(site) }".yellow
29
+ end
30
+ end
31
+
32
+ # #hunt! is alias for #find! with :hunt option
33
+ # Check is user 'stupiduser' registered on instagram
34
+ # -> Moriarty.hunt! 'stupiduser', 'instagram.com'
35
+
36
+ def self.hunt!( name, site = 'github.com', type = :hunt)
37
+ find! name, site, type
38
+ end
39
+
40
+ # Remove extensions from domain name
41
+ # Moriarty.print_url('https://www.github.com')
42
+ # => 'github'
43
+
44
+ def self.print_url( site )
45
+ if site.start_with?('http')
46
+ site.gsub!("https://", '') or site.gsub!("http://", '')
47
+ end
48
+ site.gsub!("www.", '') if site.start_with?('www.')
49
+ ext = site.to_s.split('.').last
50
+ return site.gsub!(".#{ext}", '') if ext.size.to_i < 5
51
+ end
52
+
53
+ end
data/moriarty.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'moriarty'
5
+ s.version = '0.1.0'
6
+ s.summary = 'Moriarty - Check social networks for available username.'
7
+ s.description = <<~DESC
8
+ Check social networks for username, and find out is it taken.
9
+ Option to run in 'hunt' mode, to confirm registered users across the networks.
10
+ DESC
11
+ s.authors = ['decentralizuj']
12
+ s.homepage = 'https://github.com/decentralizuj/moriarty'
13
+ s.license = 'MIT'
14
+
15
+ s.metadata['homepage_uri'] = 'https://github.com/decentralizuj/moriarty'
16
+ s.metadata['source_code_uri'] = 'https://github.com/decentralizuj/moriarty'
17
+ s.metadata['bug_tracker_uri'] = 'https://github.com/decentralizuj/moriarty/issues'
18
+
19
+ s.files = ['bin/moriarty', 'lib/moriarty.rb', 'lib/moriarty/cli.rb', 'moriarty.gemspec',
20
+ 'README.md', 'LICENSE']
21
+ s.bindir = 'bin'
22
+ s.executables = ['moriarty']
23
+ s.require_paths = ['lib']
24
+
25
+ s.add_runtime_dependency 'colorize', '~> 0.8.1'
26
+ s.add_runtime_dependency 'rest-client', '~> 2.1.0'
27
+ s.add_runtime_dependency 'nokogiri', '~> 1.11.2'
28
+
29
+ s.add_development_dependency 'bundler', '~> 2.2.9'
30
+ s.add_development_dependency 'rake', '~> 13.0.3'
31
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moriarty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - decentralizuj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.11.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.11.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.9
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.2.9
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 13.0.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 13.0.3
83
+ description: |
84
+ Check social networks for username, and find out is it taken.
85
+ Option to run in 'hunt' mode, to confirm registered users across the networks.
86
+ email:
87
+ executables:
88
+ - moriarty
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - LICENSE
93
+ - README.md
94
+ - bin/moriarty
95
+ - lib/moriarty.rb
96
+ - lib/moriarty/cli.rb
97
+ - moriarty.gemspec
98
+ homepage: https://github.com/decentralizuj/moriarty
99
+ licenses:
100
+ - MIT
101
+ metadata:
102
+ homepage_uri: https://github.com/decentralizuj/moriarty
103
+ source_code_uri: https://github.com/decentralizuj/moriarty
104
+ bug_tracker_uri: https://github.com/decentralizuj/moriarty/issues
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubygems_version: 3.2.3
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Moriarty - Check social networks for available username.
124
+ test_files: []