-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_lnkdecoder.php
98 lines (83 loc) · 2.65 KB
/
test_lnkdecoder.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @desc simple test script for lnkdecoder.class.php
*
*/
require 'lnkdecoder.class.php';
// http://www.php.net/manual/en/function.chr.php#89488
function echocolor($text,$color="normal",$back=0)
{
$colors = array('light_red' => "[1;31m", 'light_green' => "[1;32m", 'yellow' => "[1;33m",
'light_blue' => "[1;34m", 'magenta' => "[1;35m", 'light_cyan' => "[1;36m",
'white' => "[1;37m", 'normal' => "[0m", 'black' => "[0;30m",
'red' => "[0;31m", 'green' => "[0;32m", 'brown' => "[0;33m",
'blue' => "[0;34m", 'cyan' => "[0;36m", 'bold' => "[1m",
'underscore' => "[4m", 'reverse' => "[7m" );
$out = $colors["$color"];
$ech = chr(27)."$out"."$text".chr(27)."[0m";
if($back)
{
return $ech;
}
else
{
echo $ech . PHP_EOL;
}
}
function failed ()
{
echocolor(" FAILED",$color="red",$back=0);
}
function passed ()
{
echocolor(" PASSED",$color="green",$back=0);
}
function separator ()
{
echocolor (" =====", $color="magenta",$back=0);
}
$msshlnk = array();
$FOLDER = 'samples';
$test_files = new DirectoryIterator($FOLDER);
echo "=======================================" . PHP_EOL;
echo "======== Test Suite for MSSHLNK =======" . PHP_EOL;
echo "=======================================" . PHP_EOL;
echo " Opening Files" . PHP_EOL;
echo "=======================================" . PHP_EOL;
foreach ($test_files as $file)
{
if (!$test_files->isDot()) {
$f = $file->getFilename();
echo 'Opening lnk file "' . $f . '"... ' ;
//var_dump($file);
$msshlnk[$f] = new MSshlnk();
if (!$msshlnk[$f]->open($file->getPathname())) {
failed() . PHP_EOL;
echo ' errno='
. $msshlnk[$file_fixed]->errno
. ' errstring="'
. $msshlnk[$file_fixed]->errstring
. '"' . PHP_EOL;
unset($msshlnk[$f]);
} else {
passed() . PHP_EOL;
}
echo PHP_EOL;
}
}
foreach($msshlnk as $key => $lnk) {
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo "=======================================" . PHP_EOL;
echo " =================== " . PHP_EOL;
echo " parse_LinkInfo for $key" . PHP_EOL;
echo " =================== " . PHP_EOL;
$lnk->parse();
// echo "LinkFlags= "; print_r($lnk->LinkFlags);
// echo "StructSize= "; print_r($lnk->StructSize);
echo "ParsedInfo= "; @print_r($lnk->ParsedInfo);
echo "=======================================" . PHP_EOL;
}
//print_r( str_split($msshlnk[$key]->lnk_bin));
echo "========== End of test suite ==========" . PHP_EOL;