grinch-identify 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +61 -0
  4. data/lib/cinch/plugins/identify.rb +117 -0
  5. metadata +62 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af84c50edd0bda9b174b3439184668c2b93d12c1013aaed0d7284c9cbf42ca04
4
+ data.tar.gz: dc508374a5dddc19f2536088efc434aa2b3308542b368da7798b4d71fd536522
5
+ SHA512:
6
+ metadata.gz: b9131dda43dc450aa0328d026c4a1fde9b0e6596d0cae21bc62ee2593e71d3920a71fa0705a80528693541732cb0e5791109ee9f6203fbc5ab5ca7542a3e71da
7
+ data.tar.gz: 7926476e05c31352006b43c1a0585194face6cf5309ac8440628365e8beaa89ea089f1eb90c003d2bd7b32599541fe781e9e2689a7a31065f2938366a9b64f1c
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2011 by Dominik Honnef
2
+ Copyright (C) 2019 by William Woodruff
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Identify plugin
2
+
3
+ This plugin allows Grinch to automatically identify with services.
4
+ Currently, DALnet, QuakeNet, KreyNet and all networks using NickServ are
5
+ supported.
6
+
7
+ For QuakeNet, both the normal _auth_ and the more secure
8
+ _challengeauth_ commands are supported.
9
+
10
+ ## Installation
11
+ First install the gem by running:
12
+ [sudo] gem install cinch-identify
13
+
14
+ Then load it in your bot:
15
+
16
+ require "cinch"
17
+ require "cinch/plugins/identify"
18
+
19
+ bot = Cinch::Bot.new do
20
+ configure do |c|
21
+ # add all required options here
22
+ c.plugins.plugins = [Cinch::Plugins::Identify] # optionally add more plugins
23
+ c.plugins.options[Cinch::Plugins::Identify] = {
24
+ :username => "my_username",
25
+ :password => "my secret password",
26
+ :type => :nickserv,
27
+ }
28
+ end
29
+ end
30
+
31
+ bot.start
32
+
33
+ ## Commands
34
+ None.
35
+
36
+ ## Options
37
+ ### :type
38
+ The type of authentication. `:nickserv` for NickServ, `:userserv` for
39
+ UserServ, `:dalnet` for DALnet, `:quakenet` for the insecure _auth_ command on QuakeNet and
40
+ `:secure_quakenet` or `:challengeauth` for the more secure
41
+ _challengeauth_. `:kreynet` for KreyNet.
42
+
43
+ ### :username
44
+ The username to use for authentication. Do not set this when using
45
+ NickServ on a network that only supports identifying as the current
46
+ nick (e.g. dancer-ircd.)
47
+
48
+ ### :password
49
+ The password to use for authentication
50
+
51
+ ### :service_name
52
+ The nick name of the service to send the identification message to.
53
+ This option is currently only being used for `:userserv` and defaults
54
+ to `"UserServ"`.
55
+
56
+ ### Example configuration
57
+ Check the install instructions for an example configuration.
58
+
59
+ ## Warning
60
+ Be warned that, when using the `:nickserv`, `:dalnet`, `:userserv`, `:quakenet`
61
+ or `:kreynet` types, the password will show up in the logs.
@@ -0,0 +1,117 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "openssl"
3
+
4
+ module Cinch
5
+ module Plugins
6
+ class Identify
7
+ include Cinch::Plugin
8
+
9
+ listen_to :connect, method: :identify
10
+ def identify(m)
11
+ case config[:type]
12
+ when :quakenet
13
+ debug "Identifying with Q"
14
+ identify_quakenet
15
+ when :dalnet
16
+ debug "Identifying with Nickserv on DALnet"
17
+ identify_dalnet
18
+ when :secure_quakenet, :challengeauth
19
+ debug "Identifying with Q, using CHALLENGEAUTH"
20
+ identify_secure_quakenet
21
+ when :nickserv
22
+ debug "Identifying with NickServ"
23
+ identify_nickserv
24
+ when :kreynet
25
+ debug "Identifying with K on KreyNet"
26
+ identify_kreynet
27
+ when :userserv
28
+ debug "Identifying with UserServ"
29
+ identify_userserv
30
+ else
31
+ debug "Not going to identify with unknown type #{config[:type].inspect}"
32
+ end
33
+ end
34
+
35
+ match(/^You are successfully identified as/, use_prefix: false, use_suffix: false, react_on: :private, method: :identified_nickserv)
36
+ match(/^You are now identified for/, use_prefix: false, use_suffix: false, react_on: :private, method: :identified_nickserv)
37
+ match(/^Password accepted - you are now recognized\./, use_prefix: false, use_suffix: false, react_on: :private, method: :identified_nickserv)
38
+ match(/^Hasło przyjęte - jesteś zidentyfikowany/, use_prefix: false, use_suffix: false, react_on: :private, method: :identified_nickserv)
39
+ def identified_nickserv(m)
40
+ service_name = config[:service_name] || "nickserv"
41
+ if m.user == User(service_name) && config[:type] == :nickserv
42
+ debug "Identified with NickServ"
43
+ @bot.handlers.dispatch :identified, m
44
+ end
45
+ end
46
+
47
+ match(/^CHALLENGE (.+?) (.+)$/, use_prefix: false, use_suffix: false, react_on: :notice, method: :challengeauth)
48
+ def challengeauth(m)
49
+ return unless m.user && m.user.nick == "Q"
50
+ return unless [:secure_quakenet, :challengeauth].include?(config[:type])
51
+
52
+ if match = m.message.match(/^CHALLENGE (.+?) (.+)$/)
53
+ challenge = match[1]
54
+ @bot.debug "Received challenge '#{challenge}'"
55
+
56
+ username = config[:username].irc_downcase(:rfc1459)
57
+ password = config[:password][0,10]
58
+
59
+ key = OpenSSL::Digest::SHA256.hexdigest(username + ":" + OpenSSL::Digest::SHA256.hexdigest(password))
60
+ response = OpenSSL::HMAC.hexdigest("SHA256", key, challenge)
61
+ User("Q@CServe.quakenet.org").send("CHALLENGEAUTH #{username} #{response} HMAC-SHA-256")
62
+ end
63
+ end
64
+
65
+ match(/^You are now logged in as/, use_prefix: false, use_suffix: false, react_on: :notice, method: :identified_quakenet)
66
+ def identified_quakenet(m)
67
+ if m.user == User("q") && [:quakenet, :secure_quakenet, :challengeauth].include?(config[:type])
68
+ debug "Identified with Q"
69
+ @bot.handlers.dispatch(:identified, m)
70
+ end
71
+ end
72
+
73
+ match(/^You are now logged in as/, use_prefix: false, use_suffix: false, react_on: :notice, method: :identified_userserv)
74
+ def identified_userserv(m)
75
+ service_name = config[:service_name] || "UserServ"
76
+ service_name = service_name.split("@").first
77
+ if m.user == User(service_name) && config[:type] == :userserv
78
+ debug "Identified with UserServ"
79
+ @bot.handlers.dispatch :identified, m
80
+ end
81
+ end
82
+
83
+ private
84
+ def identify_dalnet
85
+ User("Nickserv@services.dal.net").send("identify %s" % [config[:password]])
86
+ end
87
+
88
+ def identify_quakenet
89
+ User("Q@CServe.quakenet.org").send("auth %s %s" % [config[:username], config[:password]])
90
+ end
91
+
92
+ def identify_secure_quakenet
93
+ User("Q@CServe.quakenet.org").send("CHALLENGE")
94
+ end
95
+
96
+ def identify_nickserv
97
+ service_name = config[:service_name] || "nickserv"
98
+ service_name = service_name.split("@").first
99
+ if config[:username]
100
+ cmd = "identify %s %s" % [config[:username], config[:password]]
101
+ else
102
+ cmd = "identify %s" % [config[:password]]
103
+ end
104
+ User(service_name).send(cmd)
105
+ end
106
+
107
+ def identify_kreynet
108
+ User("K!k@krey.net").send("LOGIN %s %s" % [config[:username], config[:password]])
109
+ end
110
+
111
+ def identify_userserv
112
+ service_name = config[:service_name] || "UserServ"
113
+ User(service_name).send("LOGIN %s %s" % [config[:username], config[:password]])
114
+ end
115
+ end
116
+ end
117
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grinch-identify
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.7.0
5
+ platform: ruby
6
+ authors:
7
+ - William Woodruff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: grinch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ description: |
28
+ A plugin allowing Grinch bots to automatically identify with services.
29
+ NickServ, QuakeNet and KreyNet are supported.
30
+ email:
31
+ - william@yossarian.net
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - LICENSE
37
+ - README.md
38
+ - lib/cinch/plugins/identify.rb
39
+ homepage: http://rubydoc.info/github/cinchrb/cinch-identify
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '2.4'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.0.3
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A plugin allowing Grinch bots to automatically identify with services.
62
+ test_files: []