def makebooster(self, irc, msg, args, text): reload(pbj) nick = msg.nick channell = msg.args[0] if nick in irc.state.channels[channell].halfops: capability='halfops' if not ircdb.checkCapability(msg.prefix, capability): irc.errorNoCapability(capability, Raise=True) irc.reply('Booster is on its way!') req = urllib2.Request(url % text) responselol = urllib2.urlopen(req) contentsz = responselol.read() rawr = pbj.pastehtml(contentsz) rawr = rawr.replace('/view/', '/raw/') irc.reply(rawr)
def scan(text): # if errno == "1": # irc.error("One Nmap scan is already running", Raise=True) # else: # errno = "1" print text processname = "/usr/local/bin/nmap -T4 -A -v -Pn" for line in os.popen("ps xa"): fields = line.split() pid = fields[0] process = fields[4] if process.find(processname) > 0: irc.error("Nmap is already running!", Raise=True) else: result = pbj.pastehtml(os.system("/usr/local/bin/nmap -T4 -A -v -Pn %s" % text)) result = result.replace('/view/', '/raw/') # errno = "0" return result
import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks from supybot.i18n import PluginInternationalization, internationalizeDocstring import supybot.ircmsgs as ircmsgs import os, pbj, signal, urllib2 def scan(text): try: inst = subprocess.Popen(text, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=file(os.devnull)) except OSError, e: irc.error('It seems the requested command was ' 'not available (%s).' % e, Raise=True) result = inst.communicate() if result[1]: # stderr irc.error(' '.join(result[1].split())) if result[0]: # stdout response = result[0].split("\n"); response = [l for l in response if l] result = pbj.pastehtml(response).replace('/view', '/raw/') #result = result.replace('/view/', '/raw/') if not "Starting Nmap" in urllib2.urlopen(result): result = "Error, I returned %r instead of a true scan." return result