Module: PWN::Plugins::IRC
- Defined in:
- lib/pwn/plugins/irc.rb
Overview
This plugin was created to interact with IRC protocols
Constant Summary collapse
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
irc_obj = PWN::Plugins::IRC.connect( host: ‘required - host or ip (defaults to “127.0.0.1”)’, port: ‘required - host port (defaults to 6667)’, nick: ‘required - nickname’, real: ‘optional - real name (defaults to value of nick)’, tls: ‘optional - boolean connect to host socket using TLS (defaults to false)’ ).
-
.disconnect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.disconnect( irc_obj: ‘required - irc_obj returned from #connect method’ ).
-
.help ⇒ Object
Display Usage for this Module.
-
.join(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.join( irc_obj: ‘required - irc_obj returned from #connect method’, nick: ‘required - nickname’, chan: ‘required - channel to join’ ).
-
.listen(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.listen( irc_obj: ‘required - irc_obj returned from #connect method’, verbose: ‘optional - boolean to enable verbose output (defaults to false)’ ).
-
.names(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.names( irc_obj: ‘required - irc_obj returned from #connect method’, chan: ‘required - channel to list names’ ).
-
.part(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.part( irc_obj: ‘required - irc_obj returned from #connect method’, chan: ‘required - channel to part’, message: ‘optional - message to send when parting’ ).
-
.ping(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.ping( irc_obj: ‘required - irc_obj returned from #connect method’, message: ‘required - message to send’ ).
-
.pong(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.pong( irc_obj: ‘required - irc_obj returned from #connect method’, message: ‘required - message to send’ ).
-
.privmsg(opts = {}) ⇒ Object
Supported Method Parameters::.
-
.quit(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.quit( irc_obj: ‘required - irc_obj returned from #connect method’, message: ‘optional - message to send when quitting’ ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
242 243 244 245 246 |
# File 'lib/pwn/plugins/irc.rb', line 242 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
irc_obj = PWN::Plugins::IRC.connect(
host: 'required - host or ip (defaults to "127.0.0.1")', port: 'required - host port (defaults to 6667)', nick: 'required - nickname', real: 'optional - real name (defaults to value of nick)', tls: 'optional - boolean connect to host socket using TLS (defaults to false)'
)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pwn/plugins/irc.rb', line 50 public_class_method def self.connect(opts = {}) host = opts[:host] ||= '127.0.0.1' port = opts[:port] ||= 6667 nick = opts[:nick].to_s.scrub real = opts[:real] ||= nick tls = opts[:tls] || false irc_obj = PWN::Plugins::Sock.connect( target: host, port: port, tls: tls ) irc_cmd(irc_obj: irc_obj, cmd: "NICK #{nick}") irc_cmd( irc_obj: irc_obj, cmd: "USER #{nick} #{host} #{host} :#{real}", max_timeout: 0.1 ) irc_obj rescue StandardError => e irc_obj = disconnect(irc_obj: irc_obj) unless irc_obj.nil? raise e end |
.disconnect(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.disconnect(
irc_obj: 'required - irc_obj returned from #connect method'
)
233 234 235 236 237 238 |
# File 'lib/pwn/plugins/irc.rb', line 233 public_class_method def self.disconnect(opts = {}) irc_obj = opts[:irc_obj] PWN::Plugins::Sock.disconnect(sock_obj: irc_obj) unless irc_obj.nil? rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/pwn/plugins/irc.rb', line 250 public_class_method def self.help puts "USAGE: irc_obj = #{self}.connect( host: 'required - host or ip', port: 'required - host port', nick: 'required - nickname', real: 'optional - real name (defaults to value of nick)', tls: 'optional - boolean connect to host socket using TLS (defaults to false)' ) #{self}.ping( irc_obj: 'required - irc_obj returned from #connect method', message: 'required - message to send' ) #{self}.pong( irc_obj: 'required - irc_obj returned from #connect method', message: 'required - message to send' ) #{self}.privmsg( irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to send message', message: 'required - message to send' ) #{self}.join( irc_obj: 'required - irc_obj returned from #connect method', nick: 'required - nickname', chan: 'required - channel to join' ) #{self}.names( irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to list names' ) #{self}.part( irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to part', message: 'optional - message to send when parting' ) #{self}.quit( irc_obj: 'required - irc_obj returned from #connect method', message: 'optional - message to send when quitting' ) #{self}.listen( irc_obj: 'required - irc_obj returned from #connect method', verbose: 'optional - boolean to enable verbose output (defaults to false)' ) irc_obj = #{self}.disconnect( irc_obj: 'required - irc_obj returned from #connect method' ) #{self}.authors " end |
.join(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.join(
irc_obj: 'required - irc_obj returned from #connect method', nick: 'required - nickname', chan: 'required - channel to join'
)
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/pwn/plugins/irc.rb', line 82 public_class_method def self.join(opts = {}) irc_obj = opts[:irc_obj] nick = opts[:nick].to_s.scrub chan = opts[:chan].to_s.scrub irc_cmd(irc_obj: irc_obj, cmd: "JOIN #{chan}") privmsg(irc_obj: irc_obj, message: "#{nick} joined.") rescue StandardError => e raise e end |
.listen(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.listen(
irc_obj: 'required - irc_obj returned from #connect method', verbose: 'optional - boolean to enable verbose output (defaults to false)'
)
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/pwn/plugins/irc.rb', line 210 public_class_method def self.listen(opts = {}) irc_obj = opts[:irc_obj] verbose = opts[:verbose] ||= false loop do = irc_obj.gets @@logger.info(.to_s.chomp) if verbose irc_obj.flush next unless block_given? yield end rescue StandardError => e raise e ensure disconnect(irc_obj: irc_obj) end |
.names(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.names(
irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to list names'
)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pwn/plugins/irc.rb', line 98 public_class_method def self.names(opts = {}) irc_obj = opts[:irc_obj] chan = opts[:chan].to_s.scrub resp = irc_cmd(irc_obj: irc_obj, cmd: "NAMES #{chan}", max_timeout: 0.01) names = [] raw_names = resp.first.to_s.split[5..-1] # Strip out colons and @ from names names = raw_names.map { |name| name.gsub(/[@:]/, '') } if raw_names.is_a?(Array) names rescue StandardError => e raise e end |
.part(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.part(
irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to part', message: 'optional - message to send when parting'
)
178 179 180 181 182 183 184 185 186 |
# File 'lib/pwn/plugins/irc.rb', line 178 public_class_method def self.part(opts = {}) irc_obj = opts[:irc_obj] chan = opts[:chan].to_s.scrub = opts[:message].to_s.scrub irc_cmd(irc_obj: irc_obj, cmd: "PART #{chan} :#{}") rescue StandardError => e raise e end |
.ping(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.ping(
irc_obj: 'required - irc_obj returned from #connect method', message: 'required - message to send'
)
149 150 151 152 153 154 155 156 |
# File 'lib/pwn/plugins/irc.rb', line 149 public_class_method def self.ping(opts = {}) irc_obj = opts[:irc_obj] = opts[:message].to_s.scrub irc_cmd(irc_obj: irc_obj, cmd: "PING :#{}") rescue StandardError => e raise e end |
.pong(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.pong(
irc_obj: 'required - irc_obj returned from #connect method', message: 'required - message to send'
)
163 164 165 166 167 168 169 170 |
# File 'lib/pwn/plugins/irc.rb', line 163 public_class_method def self.pong(opts = {}) irc_obj = opts[:irc_obj] = opts[:message].to_s.scrub irc_cmd(irc_obj: irc_obj, cmd: "PONG :#{}") rescue StandardError => e raise e end |
.privmsg(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.privmsg(
irc_obj: 'required - irc_obj returned from #connect method', chan: 'required - channel to send message', message: 'required - message to send',
)
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/pwn/plugins/irc.rb', line 120 public_class_method def self.privmsg(opts = {}) irc_obj = opts[:irc_obj] chan = opts[:chan].to_s.scrub = opts[:message].to_s.scrub nick = opts[:nick].to_s.scrub = .split("\n").length if .positive? .split("\n") do || = "PRIVMSG #{chan} :#{}" if .length.positive? irc_cmd( irc_obj: irc_obj, cmd: ) end end else irc_cmd(irc_obj: irc_obj, cmd: "PRIVMSG #{chan} :#{}") end rescue StandardError => e raise e end |
.quit(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::IRC.quit(
irc_obj: 'required - irc_obj returned from #connect method', message: 'optional - message to send when quitting'
)
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/pwn/plugins/irc.rb', line 193 public_class_method def self.quit(opts = {}) irc_obj = opts[:irc_obj] = opts[:message].to_s.scrub irc_cmd(irc_obj: irc_obj, cmd: "QUIT :#{}") rescue StandardError => e raise e ensure disconnect(irc_obj: irc_obj) unless irc_obj.nil? end |