-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added irc action * Forgot to import pastepwn util * Fixed typo
- Loading branch information
1 parent
df37d7f
commit fc1d1ab
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
import socket | ||
|
||
from pastepwn.util import TemplatingEngine | ||
from .basicaction import BasicAction | ||
|
||
|
||
class IrcAction(BasicAction): | ||
"""Action to send an irc message to a certain channel""" | ||
name = "IrcAction" | ||
irc = socket.socket() | ||
|
||
def __init__( | ||
self=None, | ||
server=None, | ||
channel=None, | ||
port=6667, | ||
nick="pastepwn" | ||
): | ||
super().__init__() | ||
|
||
self.ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
self.server = server | ||
self.channel = channel | ||
self.port = port | ||
self.nick = nick | ||
|
||
def perform(self, paste, analyzer_name=None): | ||
"""Perform the action on the passed paste""" | ||
if self.template is None: | ||
text = "New paste matched by analyzer '{0}' - Link: {1}".format(analyzer_name, paste.full_url) | ||
else: | ||
text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template) | ||
|
||
self.ircsock.connect((self.server, self.port)) | ||
self.ircsock.send(bytes("USER " + self.nick + " " + self.nick + " " + self.nick + "n", "UTF-8")) | ||
self.ircsock.send(bytes("NICK " + self.nick + "n", "UTF-8")) | ||
self.ircsock.send(bytes("JOIN " + self.channel + "n", "UTF-8")) | ||
self.ircsock.send(bytes("PRIVMSG " + self.channel + " " + text + "n", "UTF-8")) | ||
self.ircsock.send(bytes("QUIT n", "UTF-8")) |