示例#1
0
 def scanMovieDb(sectionNumber=0):
     global AmountOfMediasInDatabase
     global mediasFromDB
     global statusMsg
     global runningState
     try:
         Log.Debug('Starting scanMovieDb for section %s' %
                   (sectionNumber))
         runningState = -1
         statusMsg = 'Starting to scan database for section %s' % (
             sectionNumber)
         # Start by getting the totals of this section
         totalSize = XML.ElementFromURL(
             self.CoreUrl + sectionNumber +
             '/all?X-Plex-Container-Start=1&X-Plex-Container-Size=0'
         ).get('totalSize')
         AmountOfMediasInDatabase = totalSize
         Log.Debug('Total size of medias are %s' % (totalSize))
         iStart = 0
         iCount = 0
         statusMsg = 'Scanning database item %s of %s : Working' % (
             iCount, totalSize)
         # So let's walk the library
         while True:
             # Grap a chunk from the server
             medias = XML.ElementFromURL(
                 self.CoreUrl + sectionNumber +
                 '/all?X-Plex-Container-Start=' + str(iStart) +
                 '&X-Plex-Container-Size=' + str(self.MediaChuncks) +
                 '&excludeElements=' + excludeElements +
                 '&excludeFields=' + excludeFields).xpath('//Part')
             # Walk the chunk
             for part in medias:
                 if bAbort:
                     raise ValueError('Aborted')
                 iCount += 1
                 filename = part.get('file')
                 filename = unicode(misc().Unicodize(
                     part.get('file')).encode('utf8', 'ignore'))
                 mediasFromDB.append(filename)
                 statusMsg = 'Scanning database: item %s of %s : Working' % (
                     iCount, totalSize)
             iStart += self.MediaChuncks
             if len(medias) == 0:
                 statusMsg = 'Scanning database: %s : Done' % (
                     totalSize)
                 Log.Debug('***** Done scanning the database *****')
                 if DEBUGMODE:
                     Log.Debug(mediasFromDB)
                 runningState = 1
                 break
         return
     except Exception, e:
         Log.Exception('Fatal error in scanMovieDb: ' + str(e))
         runningState = 99
示例#2
0
文件: update.py 项目: ingramali/ith
 def update_dorks(self, db, lastDorkIdInDb):    
     # Update parameters
     urlGhdb = "http://www.exploit-db.com/ghdb/"
     nbOfFailure = 0
     i = lastDorkIdInDb[0]
     isUpdated = 0
     
     db_cur = db.cursor()
     misc_instance = misc()
     title_dork = ""
     link_dork = ""
     nbhits_dork = ""
     dateSubmission_dork = ""
     description_dork = ""
     
     link_dork = "" # Initialisation de link_dork
     
     # Initialization of browser
     browsing = mechanize.Browser()
     browsing.set_handle_robots(False)   # ignore robots
     browsing.set_handle_refresh(False)  # can sometimes hang without this
     browsing.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.0; rv:30.0) Gecko/20100101 Firefox/30.0')]
     
     while nbOfFailure < 5:  # For update
     
         i = i + 1 
         print "    Element N° %s" % i
         urlDork = "%s%s/" % (urlGhdb, i)
         
         # Check internet conectivity
         is_connected = misc.check_Internet_connectivity(misc_instance)
         if is_connected:
             print "    Opening: %s" % urlDork            
             error_Http = 0
             try:
                 response_browsing = browsing.open(urlDork)
             except Exception as e:
                 if e.code == 503:
                     print bcolors.WARNING+"[-] Service unavailable. Could be a Captcha. Pass to next dork!"+bcolors.ENDC
                     error_Http = 1
                     
             if error_Http == 0:
                 response_browsing.encoding = "UTF-8"            
                 if response_browsing.code == 200:
                     try:        
                         title_dork = browsing.title()
                     except:
                         print "["+bcolors.FAIL+"x"+bcolors.ENDC+"] Title parsing error!"
                     else:
                         
                         if "Page not found" in str(title_dork):
                             nbOfFailure = nbOfFailure + 1
                         else:    
                             if title_dork != None and title_dork != "":                         
                                 print "Title : %s" % title_dork
                             for link in browsing.links():
                                 
                                 links_dork = link.url
                                 
                                 if links_dork[0:29] == "http://www.google.com/search?":
                                     id_dork = i
                                     dork = link.text
                                     link_dork = link.url
                                     
                                     print "Dork Id = %s " % i
                                     
                                     if link.text != "":
                                         print "Dork text = %s " % link.text #Dork
                                     
                                     if link.url != "":
                                         print "Dork link = %s " % link.url
                             
                             # Using BSoup to search the page
                             soup = BeautifulSoup(browsing.response().read())
                             all_paragraphs = soup.find_all('p')
                             for paragraph in all_paragraphs:
                                 str_paragraph = str(paragraph)
                                 
                                 # Get number of hits
                                 if str_paragraph[0:8] == "<p>Hits:":
                                     nbhits_dork = str_paragraph[9:len(str_paragraph)-4]
                                     if nbhits_dork != "0":
                                         print "Dork Hits = %s" % nbhits_dork
                                 
                                 # Get date of submission
                                 if str_paragraph[0:12] == "<p>Submited:":
                                     dateSubmission_dork = str_paragraph[13:len(str_paragraph)-4]
                                     if dateSubmission_dork != "":
                                         print "Dork date submission  = %s" % dateSubmission_dork
                                     
                                 # GET DESCRIPTION
                                 
                                 if str_paragraph[0:16] == "<p class=\"text\">":
                                     description_dork = str_paragraph[16:len(str_paragraph)-4]
                                     if description_dork != "":
                                         print "Dork description  = %s" % description_dork
                                     
                                         
                             # bDD INSERT
                             if link_dork == "" or nbhits_dork == 0: #TODO: And Id dont exist
                                 #print "No insertion"
                                 nbOfFailure = nbOfFailure + 1
                             else:
                                 data = db_cur.execute("SELECT * FROM dorks WHERE dork_id = %s", id_dork) # Changed from id_dork to i for updates
                                 if data == 0 :
                                     db_cur.execute ("INSERT INTO dorks (dork_id, title, link, hits, date, description) values (%s, %s, %s, %s, %s, %s)",(id_dork, title_dork, link_dork, nbhits_dork, dateSubmission_dork, description_dork));
                                     # Changed id_dork to i
                                     # Adding .strip() for spaces
                                     db.commit()
                                     isUpdated = 1
                                 else:
                                     print "Existing dork. No insertion"
                             
                             #Reinitialisation des parametres
                             title_dork = ""
                             link_dork = ""
                             nbhits_dork = ""
                             dateSubmission_dork = ""
                             description_dork = ""
                             
                             
                             #print "-------------------"
                         
                 else:
                         print "Dork introuvable ..."
     return isUpdated
     
                 
示例#3
0
文件: update.py 项目: it-solunium/ith
 def update_dorks(self, db, lastDorkIdInDb):    
     # Update parameters
     urlGhdb = "http://www.exploit-db.com/ghdb/"
     nbOfFailure = 0
     i = lastDorkIdInDb[0]
     isUpdated = 0
     
     db_cur = db.cursor()
     misc_instance = misc()
     title_dork = ""
     link_dork = ""
     nbhits_dork = ""
     dateSubmission_dork = ""
     description_dork = ""
     
     link_dork = "" # Initialisation de link_dork
     
     # Initialization of browser
     browsing = mechanize.Browser()
     browsing.set_handle_robots(False)   # ignore robots
     browsing.set_handle_refresh(False)  # can sometimes hang without this
     browsing.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.0; rv:30.0) Gecko/20100101 Firefox/30.0')]
     
     while nbOfFailure < 5:  # For update
     
         i = i + 1 
         print "    Element N° %s" % i
         urlDork = "%s%s/" % (urlGhdb, i)
         
         # Check internet conectivity
         is_connected = misc.check_Internet_connectivity(misc_instance)
         if is_connected:
             print "    Opening: %s" % urlDork            
             error_Http = 0
             try:
                 response_browsing = browsing.open(urlDork)
             except Exception as e:
                 if e.code == 503:
                     print bcolors.WARNING+"[-] Service unavailable. Could be a Captcha. Pass to next dork!"+bcolors.ENDC
                     error_Http = 1
                     
             if error_Http == 0:
                 response_browsing.encoding = "UTF-8"            
                 if response_browsing.code == 200:
                     try:        
                         title_dork = browsing.title()
                     except:
                         print "["+bcolors.FAIL+"x"+bcolors.ENDC+"] Title parsing error!"
                     else:
                         
                         if "Page not found" in str(title_dork):
                             nbOfFailure = nbOfFailure + 1
                         else:    
                             if title_dork != None and title_dork != "":                         
                                 print "Title : %s" % title_dork
                             for link in browsing.links():
                                 
                                 links_dork = link.url
                                 
                                 if links_dork[0:29] == "http://www.google.com/search?":
                                     id_dork = i
                                     dork = link.text
                                     link_dork = link.url
                                     
                                     print "Dork Id = %s " % i
                                     
                                     if link.text != "":
                                         print "Dork text = %s " % link.text #Dork
                                     
                                     if link.url != "":
                                         print "Dork link = %s " % link.url
                             
                             # Using BSoup to search the page
                             soup = BeautifulSoup(browsing.response().read())
                             all_paragraphs = soup.find_all('p')
                             for paragraph in all_paragraphs:
                                 str_paragraph = str(paragraph)
                                 
                                 # Get number of hits
                                 if str_paragraph[0:8] == "<p>Hits:":
                                     nbhits_dork = str_paragraph[9:len(str_paragraph)-4]
                                     if nbhits_dork != "0":
                                         print "Dork Hits = %s" % nbhits_dork
                                 
                                 # Get date of submission
                                 if str_paragraph[0:12] == "<p>Submited:":
                                     dateSubmission_dork = str_paragraph[13:len(str_paragraph)-4]
                                     if dateSubmission_dork != "":
                                         print "Dork date submission  = %s" % dateSubmission_dork
                                     
                                 # GET DESCRIPTION
                                 
                                 if str_paragraph[0:16] == "<p class=\"text\">":
                                     description_dork = str_paragraph[16:len(str_paragraph)-4]
                                     if description_dork != "":
                                         print "Dork description  = %s" % description_dork
                                     
                                         
                             # bDD INSERT
                             if link_dork == "" or nbhits_dork == 0: #TODO: And Id dont exist
                                 #print "No insertion"
                                 nbOfFailure = nbOfFailure + 1
                             else:
                                 data = db_cur.execute("SELECT * FROM dorks WHERE dork_id = %s", id_dork) # Changed from id_dork to i for updates
                                 if data == 0 :
                                     db_cur.execute ("INSERT INTO dorks (dork_id, title, link, hits, date, description) values (%s, %s, %s, %s, %s, %s)",(id_dork, title_dork, link_dork, nbhits_dork, dateSubmission_dork, description_dork));
                                     # Changed id_dork to i
                                     # Adding .strip() for spaces
                                     db.commit()
                                     isUpdated = 1
                                 else:
                                     print "Existing dork. No insertion"
                             
                             #Reinitialisation des parametres
                             title_dork = ""
                             link_dork = ""
                             nbhits_dork = ""
                             dateSubmission_dork = ""
                             description_dork = ""
                             
                             
                             #print "-------------------"
                         
                 else:
                         print "Dork introuvable ..."
     return isUpdated
示例#4
0
文件: ith.py 项目: ingramali/ith
from update import update

import signal


def exitHandler(signum, frame):
    # Deconnexion from database
    db_manager.deconnexion(db_manager_instance, db)
    print "[" + bcolors.OKBLUE + ">" + bcolors.ENDC + "] Thank you for using ITH. See you soon!"
    exit()


signal.signal(signal.SIGINT, exitHandler)

# Get connexion parameters from config.py section bdd
misc_instance = misc()
# Clear screen
misc.clearScreen(misc_instance)
print "Initialisation :"

connexionParameters = []
connexionParameters = misc.readConfFile(misc_instance, "BddConfig")

# Connexion to database
db_manager_instance = db_manager()
db = db_manager.connexion(db_manager_instance, connexionParameters)
db_cur = db.cursor()

# Pentest instantiation
pentest_instance = pentest()
update_instance = update()
示例#5
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-


from misc import bcolors, misc
from config import bddConfiguration
import os

misc_instance = misc()
connexionParameters = []
connexionParameters = misc.readConfFile(misc_instance, "BddConfig")

# Create database
print "["+bcolors.OKBLUE+"-"+bcolors.ENDC+"] Creating database %s" % bddConfiguration.db
cmd_create_db = 'echo "create database %s" | mysql -u%s -p%s' % (bddConfiguration.db, bddConfiguration.user, bddConfiguration.passwd)
os.system(cmd_create_db)

# Import dump file : google_dorks.sql
print "["+bcolors.OKBLUE+"-"+bcolors.ENDC+"] Importing dorks from dump."
cmd_import_dump = "mysql -u%s -p%s %s < ./google_dorks.sql" % (bddConfiguration.user, bddConfiguration.passwd, bddConfiguration.db)
os.system(cmd_import_dump)

示例#6
0
 def getFiles(filePath):
     global mediasFromFileSystem
     global runningState
     global statusMsg
     try:
         runningState = -1
         Log.Debug(
             "*********************** FileSystem scan Paths: *****************************************"
         )
         bScanStatusCount = 0
         # Wondering why I do below. Part of find-unmatched, and forgot....SIGH
         files = str(filePath)[2:-2].replace("'", "").split(', ')
         #for filePath in files:
         for filePath in filePath:
             # Decode filePath
             bScanStatusCount += 1
             filePath2 = urllib.unquote(filePath).decode('utf8')
             filePath2 = misc().Unicodize(filePath2)
             Log.Debug(
                 "Handling filepath #%s: %s" %
                 (bScanStatusCount, filePath2.encode('utf8', 'ignore')))
             for root, subdirs, files in os.walk(filePath2):
                 # Need to check if directory in ignore list?
                 if os.path.basename(
                         root) in Dict['findMedia']['IGNORED_DIRS']:
                     continue
                 # Lets look at the file
                 for file in files:
                     file = misc().Unicodize(file).encode('utf8')
                     if bAbort:
                         Log.Info('Aborted in getFiles')
                         raise ValueError('Aborted')
                     if os.path.splitext(file)[1].lower(
                     )[1:] in Dict['findMedia']['VALID_EXTENSIONS']:
                         # File has a valid extention
                         if file.startswith('.') and Dict['findMedia'][
                                 'IGNORE_HIDDEN']:
                             continue
                         # Filter out local extras
                         if '-' in file:
                             if os.path.splitext(
                                     os.path.basename(file))[0].rsplit(
                                         '-', 1)[1].lower() in Extras:
                                 continue
                         # filter out local extras directories
                         if os.path.basename(os.path.normpath(
                                 root)).lower() in ExtrasDirs:
                             continue
                         composed_file = misc().Unicodize(
                             Core.storage.join_path(root, file))
                         if Platform.OS == 'Windows':
                             # I hate windows
                             pos = composed_file.find(':') - 1
                             #composed_file = composed_file[4:]
                             composed_file = composed_file[pos:]
                         mediasFromFileSystem.append(composed_file)
                         statusMsg = 'Scanning file: ' + file
             Log.Debug('***** Finished scanning filesystem *****')
             if DEBUGMODE:
                 Log.Debug(mediasFromFileSystem)
             runningState = 2
     except ValueError:
         statusMsg = 'Idle'
         runningState = 99
         Log.Info('Aborted in getFiles')
     except Exception, e:
         Log.Exception('Exception happend in getFiles: ' + str(e))
         runningState = 99
示例#7
0
import application
import weather
import news
import misc

if __name__ == '__main__':
    voice.speak(wish.wish())
    while True:
        query = voice.takeCommand()

        if 'open' in query.lower():
            websites.open_website(query)

        elif 'wikipedia' in query.lower():
            wiki.search(query)

        elif 'play' in query.lower() and 'music' in query.lower():
            song.play()

        elif 'start' in query.lower():
            application.start(query)

        elif 'weather' in query.lower():
            weather.fetch_weather()

        elif 'news' in query.lower():
            news.get_news()

        elif 'None' not in query:
            misc.misc(query)