Пример #1
0
    def collectLinks(self, img_url):
        l_unreal = []
        console.task('New Image: {0}'.format(img_url.strip()[:90]))
        driver = self.driver
        driver.get("https://www.yandex.com/images/")
        console.subtask('Inserting Image URL')
        elems = driver.find_elements_by_xpath(
            '/html/body/div[1]/div/div[1]/div[2]/form/div[1]/span/span/table/tbody/tr/td[2]/div/button'
        )[0]
        elems.click()
        input = driver.find_elements_by_xpath(
            '/html/body/div[3]/div/div[1]/div/form[2]/span/span/input')[0]
        input.clear()
        input.send_keys(img_url)
        input.send_keys(Keys.RETURN)
        console.subtask('Searching for Image...')
        time.sleep(cfg.timeout())
        link_name = driver.find_elements_by_xpath(
            '/html/body/div[6]/div[1]/div[1]/div[3]/ul/li/div/a[2]')
        console.subtask("Collecting Links...")
        for link in link_name:
            href = link.get_attribute('href')
            l_unreal.append(href)

        console.subtask("Getting real links from Yandex ShortURLs")
        l_real = []
        for l_u in l_unreal:
            driver.get(l_u)
            if (filterLink(driver.current_url)):
                l_real.append(driver.current_url)
                console.subtask('Added verified {0}'.format(
                    driver.current_url.strip()[:90]))
        self.links = l_real
Пример #2
0
 def getLinks(self):
     try:
         link_name = self.driver.find_elements_by_tag_name('a')
         links = []
         for l in link_name:
             link = l.get_attribute('href')
             if not link == None:
                 if filterLink(link):
                     if (not "https://www.google.com/imgres?imgurl"
                             in link) or (not "translate" in link) or (
                                 not "cdninstagram" in link):
                         links.append(link)
         links = list(set(links))
         print(len(links))
         print(links)
         for link in links:
             if "url?" in link:
                 self.driver.execute_script('''window.open("''' + link +
                                            '''","_blank");''')
                 time.sleep(2)
                 #switch to tab
                 self.driver.switch_to.window(self.driver.window_handles[1])
                 time.sleep(1)
                 url = self.driver.current_url
                 self.driver.close()
                 time.sleep(1)
                 self.driver.switch_to.window(self.driver.window_handles[0])
                 time.sleep(1)
                 self.links.append(url)
                 console.subtask("Added {}".format(url))
             else:
                 console.subtask("Skipping {}".format(link))
                 self.links.append(link)
     except:
         pass
Пример #3
0
 def collectAges(self, img_url):
     if not self.driver:
         self.driver = cfg.getWebDriver()
     console.task('New Image: {0}'.format(img_url.strip()[:90]))
     driver = self.driver
     driver.get("http://www.pictriev.com/?lang=en")
     console.subtask('Inserting Image URL')
     input = driver.find_elements_by_xpath('//*[@id="urltext"]')[0]
     input.clear()
     input.send_keys(img_url)
     btn = driver.find_elements_by_xpath('//*[@id="submit-url"]')[0]
     btn.click()
     console.subtask('Searching for Image...')
     time.sleep(cfg.timeout() * 3)
     try:
         age = driver.find_elements_by_css_selector(
             '#age-gauge > svg:nth-child(1) > text:nth-child(6) > tspan:nth-child(1)'
         )
     except:
         age = driver.find_elements_by_css_selector(
             '#age-gauge > svg:nth-child(1) > text:nth-child(6) > tspan:nth-child(1)'
         )
     if len(age) == 1:
         age = age[0].text
     else:
         age = 0
     self.ages.append(int(age))
 def insertImageLinks(self, images):
     self.driver.get("https://www.imageraider.com/")
     input = self.driver.find_elements_by_xpath('//*[@id="topurllist"]')[0]
     for i in images:
         console.subtask('Inserting {0}'.format(i))
         input.send_keys(i)
         input.send_keys(Keys.RETURN)
     console.subtask('Submitting...')
     btn = self.driver.find_elements_by_xpath('/html/body/div[3]/div/div/article/div/div[1]/form/span/input')[0]
     btn.click()
Пример #5
0
 def loadKnown(self, label):
     console.task('Loading known faces')
     pathlist = Path('./known').glob('**/*.jpg')
     for path in pathlist:
         p_str = str(path)
         console.subtask('Loading {0}'.format(p_str.split('/')[1]))
         im = face_recognition.load_image_file(p_str)
         encoding = face_recognition.face_encodings(
             im, num_jitters=self.num_jitters)
         for e in encoding:
             self.known_face_encodings.append(e)
             self.known_face_names.append(label)
Пример #6
0
def getInstaLinks(username):
    looter = InstaLooter(profile=username)
    images = []
    i = 0
    for media in looter.medias():
        if i > cfg.instaLimit():
            break
        if not media['is_video']:
            console.subtask("Got Image: {0}".format(media['display_src'].strip()[:90]))
            images.append(media['display_src'])
            i = i + 1
    return images
Пример #7
0
    def collectLinks(self, img_url):
        console.task('New Image: {0}'.format(img_url.strip()[:90]))
        driver = self.driver
        driver.get("https://www.google.com/imghp")
        console.subtask('Inserting Image URL')
        console.task("Please agree to google's stuff in the browser")
        time.sleep(10)
        elems = driver.find_elements_by_xpath(self.PHOTO_XPATH)[0]
        elems.click()
        time.sleep(1)
        input = driver.find_elements_by_xpath('//*[@id="Ycyxxc"]')[0]
        input.clear()
        input.send_keys(img_url)
        input.send_keys(Keys.RETURN)
        console.subtask('Searching for Image...')
        time.sleep(cfg.timeout() * 2)
        pred_error = False
        try:
            pred = driver.find_element_by_xpath(self.PRED_XPATH)
        except NoSuchElementException:
            console.subfailure('No Prediction given sry...')
            pred = None
            pred_error = True
        except BrokenPipeError:
            #just try again...
            try:
                pred = driver.find_element_by_xpath(self.PRED_XPATH)
            except NoSuchElementException:
                console.subfailure(
                    'Broken pipe Error. This is not a Problem...moving on!')
                console.subfailure('No Prediction given sry...')
                pred = None
                pred_error = True

        if not pred_error:
            pred = pred.text
        self.predictions.append(pred)

        console.subtask("Collecting Links...(Page 1)")
        self.getLinks()

        for num in range(2, self.max_pages + 1):
            console.subtask("Switching to Page {0}".format(num))
            try:
                page_n = driver.find_element_by_link_text(str(num))
                page_n.click()
                time.sleep(cfg.timeout())
                console.subtask("Collecting Links...(Page {0})".format(num))
                self.getLinks()
            except NoSuchElementException:
                console.subfailure('No more pages...')
                break
Пример #8
0
 def processCSV(self):
     time.sleep(2)
     p = os.path.join(tempfile.gettempdir(), 'imageraider')
     pathlist = Path(p).glob('**/*')
     links = []
     for path in pathlist:
         path = str(path)
         with open(path, 'r') as csvfile:
             reader = csv.DictReader(csvfile)
             for row in reader:
                 if filterLink(row['Discovered Page URL']):
                     console.subtask('Added {0}'.format(
                         row['Discovered Page URL']))
                     links.append(row['Discovered Page URL'])
     return links
Пример #9
0
    def grabData(self):
        console.task('Opening Webdriver')
        driver = cfg.getWebDriver()
        driver.get(self.url)
        self.profile_list = []
        self.profile_img = []

        console.task("Please agree to facebook's stuff in the browser")
        time.sleep(10)

        #get all profile image links
        profile_img_links = driver.find_elements_by_xpath(
            "//a[@class='_2ial']")
        console.subtask('Collecting Image URLs...(Page 1)')

        if len(profile_img_links) <= 0:
            console.subfailure('No FB Links found')
        else:
            for e in profile_img_links:
                href = e.get_attribute("href")
                image = e.find_element_by_tag_name("img")
                img_src = image.get_attribute("src")
                self.profile_list.append(href)
                self.profile_img.append(img_src)

        pages = driver.find_elements_by_xpath("//a")
        pages_links = []
        for e in pages:
            link = e.get_attribute('href')
            if "&page" in link:
                pages_links.append(link)
        pages_links = list(set(pages_links))

        for page in pages_links:
            driver.get(page)
            profile_img_links = driver.find_elements_by_xpath(
                "//a[@class='_2ial']")
            page_num = page[-1:]
            console.subtask(
                'Collecting Images URLs...(Page {0})'.format(page_num))
            for e in profile_img_links:
                href = e.get_attribute("href")
                image = e.find_element_by_tag_name("img")
                img_src = image.get_attribute("src")
                self.profile_list.append(href)
                self.profile_img.append(img_src)
            time.sleep(1)
        driver.close()
Пример #10
0
    def collectLinksLocal(self):
        l_unreal = []
        console.task('Uploading Local Images')
        driver = self.driver
        driver.get("https://www.yandex.com/images/")
        pa_g = Path('./known')
        pathlist = []
        for ext in [
                '.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.bmp',
                '.BMP'
        ]:
            tmp_pl = pa_g.glob('**/*{}'.format(ext))
            for t in tmp_pl:
                pathlist.append(t)
        for p in pathlist:
            str_p = str(p)
            console.subtask('Inserting Image URL')
            time.sleep(5)
            elems = driver.find_elements_by_xpath(
                '/html/body/div[1]/div[2]/div[1]/div[1]/div[1]/div/div/div/div[1]/div[2]/form/div[1]/span/span[2]'
            )[0]
            elems.click()
            input = driver.find_elements_by_xpath(
                '/html/body/div[1]/div[2]/div[1]/div[1]/div[1]/div/div/div/div[4]/div/div[1]/div/form[1]/input'
            )[0]
            input.clear()
            p_i = os.path.join(os.getcwd(), str_p)
            input.send_keys(p_i)
            console.subtask('Searching for Image...')
            time.sleep(cfg.timeout())
            link_name = driver.find_elements_by_xpath(
                '/html/body/div[6]/div[1]/div[1]/div[3]/ul/li/div/a[2]')

            console.subtask("Collecting Links...")
            for link in link_name:
                href = link.get_attribute('href')
                l_unreal.append(href)

        console.subtask("Getting real links from Yandex ShortURLs")
        l_real = []
        for l_u in l_unreal:
            driver.get(l_u)
            if (filterLink(driver.current_url)):
                l_real.append(driver.current_url)
                console.subtask('Added verified {0}'.format(
                    driver.current_url.strip()[:90]))
        for l in l_real:
            self.links.append(l)
Пример #11
0
 def loadKnown(self, label):    
     console.task('Loading known faces')
     pa_g = Path('./known')
     pathlist = []
     for ext in ['.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.bmp', '.BMP']:
         tmp_pl = pa_g.glob('**/*{}'.format(ext))
         for t in tmp_pl:
             pathlist.append(t)
     for path in pathlist:
         p_str = str(path)
         delim = '/'
         if platform == "win32":
             delim = '\\'
         console.subtask('Loading {0}'.format(p_str.split(delim)[1]))
         im = face_recognition.load_image_file(p_str)
         encoding = face_recognition.face_encodings(im, num_jitters=self.num_jitters)
         for e in encoding:
             self.known_face_encodings.append(e)
             self.known_face_names.append(label)
Пример #12
0
    def grabData(self):
        console.task('Opening Webdriver')
        driver = cfg.getWebDriver()
        driver.get(self.url)
        self.profile_list = []
        self.profile_img = []

        #get all profile image links
        profile_img_links = driver.find_elements_by_xpath(
            "//a[@class='_2ial _8o _8s lfloat _ohe']")
        console.subtask('Collecting Image URLs...(Page 1)')

        for e in profile_img_links:
            href = e.get_attribute("href")
            image = e.find_element_by_tag_name("img")
            img_src = image.get_attribute("src")
            self.profile_list.append(href)
            self.profile_img.append(img_src)

        pages = driver.find_elements_by_xpath("//a")
        pages_links = []
        for e in pages:
            link = e.get_attribute('href')
            if "&page" in link:
                pages_links.append(link)
        pages_links = list(set(pages_links))

        for page in pages_links:
            driver.get(page)
            profile_img_links = driver.find_elements_by_xpath(
                "//a[@class='_2ial _8o _8s lfloat _ohe']")
            page_num = page[-1:]
            console.subtask(
                'Collecting Images URLs...(Page {0})'.format(page_num))
            for e in profile_img_links:
                href = e.get_attribute("href")
                image = e.find_element_by_tag_name("img")
                img_src = image.get_attribute("src")
                self.profile_list.append(href)
                self.profile_img.append(img_src)
            time.sleep(1)
        driver.close()
Пример #13
0
    def collectLinksLocal(self):
        driver = self.driver
        console.section("Uploading Local Known Images")
        pa_g = Path('./known')
        pathlist = []
        for ext in [
                '.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.bmp',
                '.BMP'
        ]:
            tmp_pl = pa_g.glob('**/*{}'.format(ext))
            for t in tmp_pl:
                pathlist.append(t)
        for p in pathlist:
            str_p = str(p)
            driver.get("https://www.google.com/imghp")
            elems = driver.find_elements_by_xpath(self.PHOTO_XPATH)[0]
            elems.click()
            time.sleep(1)
            elems = driver.find_element_by_xpath(self.PHOTO_UPLOAD_XPATH)

            elems.click()
            time.sleep(1)
            console.subtask("Inserting Path")
            input_box = driver.find_element_by_xpath('//*[@id="qbfile"]')
            p_i = os.path.join(os.getcwd(), str_p)
            input_box.send_keys(p_i)
            time.sleep(cfg.timeout() * 2)
            pred_error = False
            try:
                pred = driver.find_element_by_xpath(self.PRED_XPATH)
            except NoSuchElementException:
                console.subfailure('No Prediction given sry...')
                pred = None
                pred_error = True
            except BrokenPipeError:
                #just try again...
                try:
                    pred = driver.find_element_by_xpath(self.PRED_XPATH)
                except NoSuchElementException:
                    console.subfailure(
                        'Broken pipe Error. This is not a Problem...moving on!'
                    )
                    console.subfailure('No Prediction given sry...')
                    pred = None
                    pred_error = True

            if not pred_error:
                pred = pred.text
            self.predictions.append(pred)
            console.subtask("Collecting Links...(Page 1)")
            self.getLinks()

            for num in range(2, self.max_pages + 1):
                console.subtask("Switching to Page {0}".format(num))
                try:
                    page_n = driver.find_element_by_link_text(str(num))
                    page_n.click()
                    time.sleep(cfg.timeout())
                    console.subtask(
                        "Collecting Links...(Page {0})".format(num))
                    self.getLinks()
                except NoSuchElementException:
                    console.subfailure('No more pages...')
                    break
Пример #14
0
    def collectLinks(self, img_url):
        console.task('New Image: {0}'.format(img_url.strip()[:90]))
        driver = self.driver
        driver.get("https://www.google.com/imghp")
        console.subtask('Inserting Image URL')
        elems = driver.find_elements_by_xpath(
            '/html/body/div/div[3]/div[3]/form/div[2]/div/div[1]/div/div[2]/div'
        )[0]
        #elems = driver.find_elements_by_xpath('//*[@id="qbi"]')[0]
        elems.click()
        time.sleep(1)
        input = driver.find_elements_by_xpath('//*[@id="qbui"]')[0]
        input.clear()
        input.send_keys(img_url)
        input.send_keys(Keys.RETURN)
        console.subtask('Searching for Image...')
        time.sleep(cfg.timeout() * 2)
        pred_error = False
        try:
            pred = driver.find_element_by_xpath(
                "/html/body/div[6]/div[3]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[2]/a"
            )
        except NoSuchElementException:
            console.subfailure('No Prediction given sry...')
            pred = None
            pred_error = True
        except BrokenPipeError:
            #just try again...
            try:
                pred = driver.find_element_by_xpath(
                    "/html/body/div[6]/div[3]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[2]/a"
                )
            except NoSuchElementException:
                console.subfailure(
                    'Broken pipe Error. This is not a Problem...moving on!')
                console.subfailure('No Prediction given sry...')
                pred = None
                pred_error = True

        if not pred_error:
            pred = pred.text
        self.predictions.append(pred)

        try:

            link_name = driver.find_elements_by_xpath("//*[@class='iUh30']")
            #link_name=driver.find_elements_by_xpath(".//h3[@class='r']/a")
        except BrokenPipeError:
            link_name = driver.find_elements_by_xpath("//*[@class='iUh30']")
            #link_name=driver.find_elements_by_xpath(".//h3[@class='r']/a")
        console.subtask("Collecting Links...(Page 1)")
        for link in link_name:
            #href = link.get_attribute('href')
            href = link.text
            if filterLink(href):
                console.subtask('Added {0}'.format(href))
                self.links.append(href)

        for num in range(2, self.max_pages + 1):
            console.subtask("Switching to Page {0}".format(num))
            try:
                page_n = driver.find_element_by_link_text(str(num))
                page_n.click()
                time.sleep(cfg.timeout())
                console.subtask("Collecting Links...(Page {0})".format(num))
                try:
                    link_name = driver.find_elements_by_xpath(
                        "//*[@class='iUh30']")
                except BrokenPipeError:
                    link_name = driver.find_elements_by_xpath(
                        "//*[@class='iUh30']")
                for link in link_name:
                    href = link.get_attribute('href')
                    if filterLink(href):
                        console.subtask('Added {0}'.format(href))
                        self.links.append(href)
            except NoSuchElementException:
                console.subfailure('No more pages...')
                break
Пример #15
0
def main(skipFB=False, skipY=False, FBUrls=[], jsonRep=None):
    if not skipFB:
        # collect user input
        console.prompt('Enter the persons name to find on FB: ')
        name = input('')
        while not name:
            console.prompt('Enter the persons name to find on FB: ')
            name = input('')
    else:
        console.task('Skipping FB Search')
        name = "Unknown"

    console.prompt(
        'How many jitters, higher is better [max 100] (default=70): ')
    num_jitters = input('')
    if not num_jitters:
        console.task('Settings jitters to 70')
        num_jitters = 70
    num_jitters = int(num_jitters)
    if num_jitters > 100:
        console.subfailure('Dude wtf?!')
        num_jitters = 100
        console.subfailure('Using 100 jitters...')

    if not skipFB:
        # grab profile urls
        f = FBGrabber(name)
        f.grabData()
        # do face recognition on those profile images
        r = FaceRecog(f.getProfileLinks(),
                      f.getProfileImages(),
                      num_jitters=num_jitters)
        r.loadKnown(name)
        profile_links, profile_imgs = r.getValidLinksAndImg(name)
        console.section('Result')
        console.task('Found the following Profiles:')
        for i in range(len(profile_links)):
            console.subtask(profile_links[i])
    else:
        if len(FBUrls) > 0:
            f = FBProfileGrabber(FBUrls)
            img_urls = f.grabLinks()
            #FBURLS are our profile links synchron with img_urls
            # so FBURLS[0] <=> img_urls[0]
            r = FaceRecog(FBUrls, img_urls, num_jitters=num_jitters)
            r.loadKnown(name)
            profile_links, profile_imgs = r.getValidLinksAndImg(name)
            console.section('Result')
            console.task('Found the following Profiles:')
            for i in range(len(profile_links)):
                console.subtask(profile_links[i])
        else:
            profile_links = []
            profile_imgs = []

    # google reverse image search on profile pics
    g = GoogleGrabber()
    for img in profile_imgs:
        g.collectLinks(img)

    # google reverse image search on reference pic
    g.collectLinksLocal()
    rev_links, predictions = g.finish()

    #TODO: Fix yandex search
    #if not skipY:
    if False:
        yandex = YandexGrabber()
        for img in profile_imgs:
            yandex.collectLinks(img)
        yandex.collectLinksLocal()
        #add to rev_links
        for e in yandex.finish():
            rev_links.append(e)
    else:
        console.task('Skipping Yandex Search')
    rev_links = list(set(rev_links))

    instaNames = parseInstaUsername(filterInstaLinks(rev_links))
    validatedInstaNames = []
    console.section("Validating Instagram Profiles")
    for un in instaNames:
        console.task("Validating Profile: '{0}'".format(un))
        if validateInstaUser(un, num_jitters):
            validatedInstaNames.append(un)

    raider_img_list = profile_imgs
    for v in validatedInstaNames:
        l = getInstaLinks(v)

        for li in l:
            raider_img_list.append(li)

    if len(raider_img_list) <= 0:
        console.failure('No Links found...')
    else:
        console.task('RIP Imageraider')

    rev_links = list(set(rev_links))
    predictions = list(set(predictions))
    console.section('Links')
    print(rev_links)
    console.section('Predictions')
    try:
        predictions = [x.lower() for x in predictions]
    except:
        predictions = []
    print(predictions)
    presentResult(predictions)

    for pl in profile_links:
        rev_links.append(pl)
    rev_links = list(set(rev_links))

    #estimate age
    ageEstimator = PictrievGrabber()
    if len(validatedInstaNames) > 0:
        for v in validatedInstaNames:
            l = getInstaLinks(v)
            if len(l) >= cfg.instaLimit():
                l = l[:cfg.instaLimit()]
            for li in l:
                ageEstimator.collectAges(li)
        age = ageEstimator.finish()
    else:
        console.failure('No Instagram Images to upload...')
        #ageEstimator.finish()
        age = "Unknown"

    if jsonRep:
        console.section("Dumping JSON Report")
        makeJSONReport(name, rev_links, predictions, validatedInstaNames, age,
                       jsonRep)
    else:
        console.section("Creating PDF Report")
        makeReport(name, rev_links, predictions, validatedInstaNames, age)

    p = os.path.join(tempfile.gettempdir(), 'imageraider')
    if os.path.isdir(p):
        pathlist = Path(p).glob('**/*')
        for path in pathlist:
            s_p = str(path)
            os.remove(s_p)
    console.task("KTHXBYE")
Пример #16
0
    def collectLinksLocal(self):
        driver = self.driver
        console.section("Uploading Local Known Images")
        pa_g = Path('./known')
        pathlist = []
        for ext in [
                '.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.bmp',
                '.BMP'
        ]:
            tmp_pl = pa_g.glob('**/*{}'.format(ext))
            for t in tmp_pl:
                pathlist.append(t)
        for p in pathlist:
            str_p = str(p)
            driver.get("https://www.google.com/imghp")
            elems = driver.find_elements_by_xpath('//*[@id="qbi"]')[0]
            elems.click()
            time.sleep(1)
            elems = driver.find_element_by_xpath(
                '/html/body/div[1]/div[3]/div[3]/div/div[2]/form/div[1]/div/a')
            elems.click()
            time.sleep(1)
            console.subtask("Inserting Path")
            input_box = driver.find_element_by_xpath('//*[@id="qbfile"]')
            p_i = os.path.join(os.getcwd(), str_p)
            input_box.send_keys(p_i)
            time.sleep(cfg.timeout() * 2)
            try:
                pred = driver.find_element_by_xpath(
                    "/html/body/div[6]/div[3]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[2]/a"
                )
                pred = pred.text
            except NoSuchElementException:
                console.subfailure('No Prediction given sry...')
                pred = None
            self.predictions.append(pred)
            link_name = driver.find_elements_by_xpath(".//h3[@class='r']/a")
            console.subtask("Collecting Links...(Page 1)")
            for link in link_name:
                href = link.get_attribute('href')
                if filterLink(href):
                    console.subtask('Added {0}'.format(href))
                    self.links.append(href)

            for num in range(2, self.max_pages + 1):
                console.subtask("Switching to Page {0}".format(num))
                try:
                    page_n = driver.find_element_by_link_text(str(num))
                    page_n.click()
                    time.sleep(cfg.timeout())
                    console.subtask(
                        "Collecting Links...(Page {0})".format(num))
                    link_name = driver.find_elements_by_xpath(
                        ".//h3[@class='r']/a")
                    for link in link_name:
                        href = link.get_attribute('href')
                        if filterLink(href):
                            console.subtask('Added {0}'.format(href))
                            self.links.append(href)
                except NoSuchElementException:
                    console.subfailure('No more pages...')
                    break
Пример #17
0
    def collectLinksLocal(self):
        driver = self.driver
        console.section("Uploading Local Known Images")
        pa_g = Path('./known')
        pathlist = []
        for ext in [
                '.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.bmp',
                '.BMP'
        ]:
            tmp_pl = pa_g.glob('**/*{}'.format(ext))
            for t in tmp_pl:
                pathlist.append(t)
        for p in pathlist:
            str_p = str(p)
            driver.get("https://www.google.com/imghp")
            elems = driver.find_elements_by_xpath(
                '/html/body/div/div[3]/div[3]/form/div[2]/div/div[1]/div/div[2]/div'
            )[0]
            elems.click()
            time.sleep(1)
            elems = driver.find_element_by_xpath(
                '/html/body/div[1]/div[3]/div[3]/div/div[2]/form/div[1]/div/a')

            elems.click()
            time.sleep(1)
            console.subtask("Inserting Path")
            input_box = driver.find_element_by_xpath('//*[@id="qbfile"]')
            p_i = os.path.join(os.getcwd(), str_p)
            input_box.send_keys(p_i)
            time.sleep(cfg.timeout() * 2)
            pred_error = False
            try:
                pred = driver.find_element_by_xpath(
                    "/html/body/div[5]/div[3]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[2]/a"
                )
            except NoSuchElementException:
                console.subfailure('No Prediction given sry...')
                pred = None
                pred_error = True
            except BrokenPipeError:
                #just try again...
                try:
                    pred = driver.find_element_by_xpath(
                        "/html/body/div[5]/div[3]/div[3]/div[1]/div[2]/div/div[2]/div[1]/div/div[2]/a"
                    )
                except NoSuchElementException:
                    console.subfailure(
                        'Broken pipe Error. This is not a Problem...moving on!'
                    )
                    console.subfailure('No Prediction given sry...')
                    pred = None
                    pred_error = True

            if not pred_error:
                pred = pred.text
            self.predictions.append(pred)
            try:
                link_name = driver.find_elements_by_xpath(
                    "//*[@class='iUh30']")
            except BrokenPipeError:
                link_name = driver.find_elements_by_xpath(
                    "//*[@class='iUh30']")
            console.subtask("Collecting Links...(Page 1)")
            if len(link_name) <= 0:
                console.subfailure('No Links found')
            else:
                for link in link_name:
                    if link != None:
                        href = link.text
                        if filterLink(href):
                            console.subtask('Added {0}'.format(href))
                            self.links.append(href)

            for num in range(2, self.max_pages + 1):
                console.subtask("Switching to Page {0}".format(num))
                try:
                    page_n = driver.find_element_by_link_text(str(num))
                    page_n.click()
                    time.sleep(cfg.timeout())
                    console.subtask(
                        "Collecting Links...(Page {0})".format(num))
                    try:
                        link_name = driver.find_elements_by_xpath(
                            "//*[@class='iUh30']")
                    except BrokenPipeError:
                        link_name = driver.find_elements_by_xpath(
                            "//*[@class='iUh30']")
                    for link in link_name:
                        href = link.text
                        if filterLink(href):
                            console.subtask('Added {0}'.format(href))
                            self.links.append(href)
                except NoSuchElementException:
                    console.subfailure('No more pages...')
                    break
Пример #18
0
def main():
    # collect user input
    console.prompt('Enter the persons name to find on FB: ')
    name = input('')

    console.prompt('How many jitters, higher is better [max 100]: ')
    num_jitters = input('')
    num_jitters = int(num_jitters)
    if num_jitters > 100:
        console.subfailure('Dude wtf?!')
        num_jitters = 100
        console.subfailure('Using 100 jitters...')

    # grab profile urls
    f = FBGrabber(name)
    f.grabData()

    # do face recognition on those profile images
    r = FaceRecog(f.getProfileLinks(), f.getProfileImages(), num_jitters=num_jitters)
    r.loadKnown(name)

    profile_links, profile_imgs = r.getValidLinksAndImg(name)
    console.section('Result')
    console.task('Found the following Profiles:')
    for i in range(len(profile_links)):
        console.subtask(profile_links[i])

    # google reverse image search on profile pics
    g = GoogleGrabber()
    for img in profile_imgs:
        g.collectLinks(img)

    # google reverse image search on reference pic
    g.collectLinksLocal()
    rev_links, predictions = g.finish()

    yandex = YandexGrabber()
    for img in profile_imgs:
        yandex.collectLinks(img)
    
    #add to rev_links
    for e in yandex.finish():
        rev_links.append(e)
    rev_links = list(set(rev_links))

    instaNames = parseInstaUsername(filterInstaLinks(rev_links))
    validatedInstaNames = []
    console.section("Validating Instagram Profiles")
    for un in instaNames:
        console.task("Validating Profile: '{0}'".format(un))
        if validateInstaUser(un, num_jitters):
            validatedInstaNames.append(un)
    

    raider_img_list = profile_imgs
    for v in validatedInstaNames:
        l = getInstaLinks(v)
        for li in l:
            raider_img_list.append(li)

    if len(raider_img_list) <= 0:
        console.failure('No Links founds...')
    else:
        raider = ImageRaiderGrabber()
        raider.insertImageLinks(raider_img_list)
        raider.downloadCSV()
        raider_links = raider.processCSV()
        for raider_link in raider_links:
            rev_links.append(raider_link)


    rev_links = list(set(rev_links))
    predictions = list(set(predictions))
    console.section('Links')
    print(rev_links)
    console.section('Predictions')
    try:
        predictions = [x.lower() for x in predictions]
    except:
        predictions = []
    print(predictions)
    presentResult(predictions)
    

    console.section("Creating PDF Report")
    makeReport(name, rev_links, predictions, validatedInstaNames)


    p = os.path.join(tempfile.gettempdir(), 'imageraider')
    if os.path.isdir(p):
        pathlist = Path(p).glob('**/*')
        for path in pathlist:
            s_p = str(path)
            os.remove(s_p)
    console.task("KTHXBYE")