1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | <?php
/**
* Parse URLs from Firefox SessionStore.js
*
* Copyright(c)2012 Markus Diersbock. All Rights Reserved.
*
* Terms: You may freely use this source code in both
* commercial and non-commercial applications, provided
* all copyright notices remain intact.
*
* Author: Markus Diersbock <markus@swingnote.com>
* Revisions: 2012/11/16 Created
*
* Purpose: The sessionstore.js file may be become
* corrupt, making JSON editors useless. This
* script parses URLs and returns links.
*
* Notes: Script returns all included URLs, even garbage
* links to trackers, ads, et al.
*/
error_reporting(E_ALL);
// to ignore "url":" chars
define("PREFIX_CHARS", 7);
// Firefox Session file
$session_file = "sessionstore.js";
// Grab session contents
$session_data = file_get_contents($session_file);
// Pattern to match only URLs
$pattern_match = '/"url":"[^"]*/';
preg_match_all($pattern_match, $session_data, $matches, PREG_PATTERN_ORDER);
?>
<html>
<body>
<h2>Parsed URLs from Firefox SessionStore</h2>
<?php
// If URLs exist, get'r done...
if (count($matches)):
// The array of full pattern matches is in [0]
// Iterate and echo page of links
foreach ($matches[0] as $url):
$url = substr($url, PREFIX_CHARS);
echo "<a href=".$url." target='_blank'>".$url."</a><br /><hr />";
endforeach;
else:
echo "Error: urls are not found in file";
endif;
?>
</body>
</html>
|