def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.debug('Monitoring...') pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[]) slexy_thread = threading.Thread(target=Slexy().monitor, args=[]) pastie_thead = threading.Thread(target=Pastie().monitor, args=[]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() # Let threads run try: while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument( "-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() rotate() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig( format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.info('Monitoring...') bot = Twitter( auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET) ) # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() pastebin_thread = threading.Thread( target=Pastebin().monitor, args=[bot, tweet_lock]) slexy_thread = threading.Thread( target=Slexy().monitor, args=[bot, tweet_lock]) pastie_thead = threading.Thread( target=Pastie().monitor, args=[bot, tweet_lock]) pastebin_ru_thread = threading.Thread( target=Pastebin_ru().monitor, args=[bot, tweet_lock]) nopaste_thread = threading.Thread( target=Nopaste().monitor, args=[bot, tweet_lock]) safebin_thread = threading.Thread( target=Safebin().monitor, args=[bot, tweet_lock]) """for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread, safebin_thread): thread.daemon = True thread.start()""" for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread, safebin_thread): thread.daemon = True thread.start() # Let threads run try: # i = 0 while(1): # i += 1 sleep(5) # if i == 6: # for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread): # if not thread.isAlive: # thread.daemon = True # thread.start() except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument( "-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig( format='%(asctime)s [%(levelname)s] %(message)s', datefmt="%d-%m-%Y %H:%M:%S", filename=log_file, level=level) logging.info('Monitoring...') ### To enable tweets, uncomment the following lines ### '''bot = Twitter( auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET) )''' ### And delete the next ones ### bot = None ########## # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() if not os.path.isdir("saves"): try: os.makedirs("saves") except Exception: logging.error("Failed to create the 'saves' directory") sys.exit() pastebin_thread = threading.Thread( target=Pastebin().monitor, args=[bot, tweet_lock]) slexy_thread = threading.Thread( target=Slexy().monitor, args=[bot, tweet_lock]) pastie_thead = threading.Thread( target=Pastie().monitor, args=[bot, tweet_lock]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() # Let threads run try: while(1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): setLog() check_req() pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[]) slexy_thread = threading.Thread(target=Slexy().monitor, args=[]) pastie_thead = threading.Thread(target=Pastie().monitor, args=[]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() try: while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): #while (True): # print("running sleep permanently") # sleep(20) #return 0; ''' monitor() - Main function... creates and starts threads ''' parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() # Configure logging level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.info('Monitoring...') # Create lock for both output log log_lock = threading.Lock() tweet_lock = threading.Lock( ) # TODO: should be removed to simplify to simplify pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[tweet_lock]) slexy_thread = threading.Thread(target=Slexy().monitor, args=[tweet_lock]) for thread in (pastebin_thread, slexy_thread): thread.daemon = True thread.start() # Let threads run try: while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG #logging to both stdout and file file_handler = logging.FileHandler(log_file) handlers = [file_handler] if PRINT_LOG: stdout_handler = logging.StreamHandler(sys.stdout) handlers.append(stdout_handler) logging.basicConfig(level=level, format='%(asctime)s [%(levelname)s] %(message)s', handlers=handlers) logging.info('Monitoring...') paste_lock = threading.Lock() pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[paste_lock]) # changed threading to not be in a for loop # we're only monitoring one site now - Moe pastebin_thread.daemon = True pastebin_thread.start() # Let threads run try: while (1): sleep(5) except KeyboardInterrupt: logging.warning('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG #logging to both stdout and file file_handler = logging.FileHandler(log_file) handlers = [file_handler] if PRINT_LOG: stdout_handler = logging.StreamHandler(sys.stdout) handlers.append(stdout_handler) logging.basicConfig(level=level, format='%(asctime)s [%(levelname)s] %(message)s', handlers=handlers) db_client = sqlite3.connect(DB_DB, check_same_thread=False) c = db_client.cursor() c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?;", (DB_DUMP_TABLE, )) if c.fetchone() is None: c.execute('''CREATE TABLE %s( pk INTEGER PRIMARY KEY, text CLOB, emails CLOB, passwords CLOB, num_emails INTEGER, num_passwords INTEGER, type VARCHAR(10), db_keywords FLOAT, url VARCHAR(60), author VARCHAR(30) );''' % (DB_DUMP_TABLE)) db_client.commit() c.close() logging.info('Monitoring...') paste_lock = threading.Lock() db_lock = threading.Lock() pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[paste_lock, db_lock, db_client]) # changed threading to not be in a for loop # we're only monitoring one site now - Moe pastebin_thread.daemon = True pastebin_thread.start() # Let threads run try: while (1): sleep(5) except KeyboardInterrupt: logging.warning('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") parser.add_argument("-t", "--test", help="test a plugin") args = parser.parse_args() if not args.test: rotate() # do not rotate in test mode level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.info('Monitoring...') if USE_TWITTER: bot = Twitter(auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET)) else: bot = None # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() threads = [] if args.test: # test mode if args.test == 'pastebin': Pastebin().monitor(bot, tweet_lock, False) if args.test == 'pastebin_ru': Pastebin_ru().monitor(bot, tweet_lock, False) logging.info('Test finished') sys.exit(0) else: if USE_PASTEBIN: threads.append( threading.Thread(target=Pastebin().monitor, args=[bot, tweet_lock])) if USE_SLEXY: threads.append( threading.Thread(target=Slexy().monitor, args=[bot, tweet_lock])) if USE_PASTIE: threads.append( threading.Thread(target=Pastie().monitor, args=[bot, tweet_lock])) if USE_PASTEBIN_RU: threads.append( threading.Thread(target=Pastebin_ru().monitor, args=[bot, tweet_lock])) if USE_NOPASTE: threads.append( threading.Thread(target=Nopaste().monitor, args=[bot, tweet_lock])) if USE_SAFEBIN: threads.append( threading.Thread(target=Safebin().monitor, args=[bot, tweet_lock])) for thread in threads: thread.daemon = True thread.start() # Let threads run try: # i = 0 while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')