def testNewHistoryFile(self):
        """Tests reading of history files written by recent versions of Firefox."""
        history_file = os.path.join(self.base_path, "new_places.sqlite")
        history = firefox3_history.Firefox3History(open(history_file))
        entries = [x for x in history.Parse()]

        self.assertEquals(len(entries), 3)
        self.assertEquals(entries[1][3],
                          "Slashdot: News for nerds, stuff that matters")
        self.assertEquals(entries[2][0], 1342526323608384L)
        self.assertEquals(entries[2][1], "FIREFOX3_VISIT")
        self.assertEquals(
            entries[2][2],
            "https://blog.duosecurity.com/2012/07/exploit-mitigations"
            "-in-android-jelly-bean-4-1/")
Ejemplo n.º 2
0
 def ParseFiles(self, responses):
   """Take each file we retrieved and get the history from it."""
   if responses:
     for response in responses:
       fd = aff4.FACTORY.Open(response.stat_entry.aff4path, token=self.token)
       hist = firefox3_history.Firefox3History(fd)
       count = 0
       for epoch64, dtype, url, dat1, in hist.Parse():
         count += 1
         str_entry = "%s %s %s %s" % (
             datetime.datetime.utcfromtimestamp(epoch64 / 1e6), url,
             dat1, dtype)
         if self.runner.output is not None:
           self.runner.output.write(utils.SmartStr(str_entry) + "\n")
       self.Log("Wrote %d Firefox History entries for user %s from %s", count,
                self.args.username, response.stat_entry.pathspec.Basename())
       self.state.hist_count += count
Ejemplo n.º 3
0
 def ParseFiles(self, responses):
   """Take each file we retrieved and get the history from it."""
   if responses:
     for response in responses:
       fd = aff4.FACTORY.Open(
           response.stat_entry.AFF4Path(self.client_id), token=self.token)
       hist = firefox3_history.Firefox3History(fd)
       count = 0
       for epoch64, dtype, url, dat1, in hist.Parse():
         count += 1
         str_entry = "%s %s %s %s" % (
             datetime.datetime.utcfromtimestamp(epoch64 / 1e6), url, dat1,
             dtype)
         self.SendReply(rdfvalue.RDFString(utils.SmartStr(str_entry)))
       self.Log("Wrote %d Firefox History entries for user %s from %s", count,
                self.args.username, response.stat_entry.pathspec.Basename())
       self.state.hist_count += count
Ejemplo n.º 4
0
    def testBasicParsing(self):
        """Test we can parse a standard file."""
        history_file = os.path.join(self.base_path, "places.sqlite")
        history = firefox3_history.Firefox3History(open(history_file, "rb"))
        # Parse returns (timestamp, dtype, url, title)
        entries = [x for x in history.Parse()]

        self.assertEqual(len(entries), 1)

        try:
            dt1 = datetime.datetime(1970, 1, 1)
            dt1 += datetime.timedelta(microseconds=entries[0][0])
        except (TypeError, ValueError):
            dt1 = entries[0][0]

        self.assertEqual(str(dt1), "2011-07-01 11:16:21.371935")
        self.assertEqual(entries[0][2], "http://news.google.com/")
        self.assertEqual(entries[0][3], "Google News")