Esempio n. 1
0
    def run(self):

        while self.processing == True:
            self.sleep(1)  # effectively a semaphore

        self.processing = True

        for i in range(0, len(self.urls)):
            try:
                url = self.urls.pop(0)
                outputfile = getTimestamp() + '-screenshot-' + url.replace(
                    ':', '-') + '.png'
                ip = url.split(':')[0]
                port = url.split(':')[1]

                if isHttps(ip, port):
                    self.save("https://" + url, ip, port, outputfile)
                else:
                    self.save("http://" + url, ip, port, outputfile)

            except Exception as e:
                self.tsLog('Unable to take the screenshot. Moving on..')
                self.tsLog(e)
                continue

        self.processing = False

        if not len(
                self.urls
        ) == 0:  # if meanwhile urls were added to the queue, start over unless we are in pause mode
            self.run()

        self.tsLog('Finished.')
Esempio n. 2
0
    def run(self):
        while self.processing == True:
            self.sleep(1)  # effectively a semaphore

        self.processing = True
        for i in range(0, len(self.urls)):
            try:
                url = self.urls.pop(0)
                self.tsLog('Opening url in browser: ' + url)
                if isHttps(url.split(':')[0], url.split(':')[1]):
                    webbrowser.open_new_tab('https://' + url)
                else:
                    webbrowser.open_new_tab('http://' + url)
                if i == 0:
                    self.sleep(
                        3
                    )  # fixes bug in Kali. have to sleep on first url so the next ones don't open a new browser instead of adding a new tab
                else:
                    self.sleep(
                        1
                    )  # fixes bug when several calls to urllib occur too fast (interrupted system call)

            except:
                self.tsLog('Problem while opening url in browser. Moving on..')
                continue

        self.processing = False
        if not len(
                self.urls
        ) == 0:  # if meanwhile urls were added to the queue, start over
            self.run()
        else:
            self.done.emit()
Esempio n. 3
0
 def test_isHttps_GivenAnIpAddrAndPortThatIsHttps_ReturnsTrue(self):
     with patch("urllib.request.urlopen") as urlopen, patch("urllib.request.Request") as Request:
         expectedUserAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0 Iceweasel/22.0'
         from app.http.isHttps import isHttps
         mockOpenedUrl = MagicMock()
         Request.return_value = MagicMock()
         urlopen.return_value.read.return_value = mockOpenedUrl
         self.assertTrue(isHttps("some-ip", "8080"))
         Request.assert_called_with("https://some-ip:8080", headers={"User-Agent": expectedUserAgent})