001.
<?php
002.
003.
004.
$root
= dirname(
__FILE__
);
005.
$exts
=
array
(
'.html'
,
'.htm'
,
'.php'
,
'.inc'
,
'.shtml'
,
'.js'
);
006.
$words
=
array
(
'iframe'
,
'unescape'
,
'eval'
,
'script'
,
'base64_decode'
);
007.
008.
define(
'SORT_BY'
,
'dir'
);
009.
define(
'SHOW_SKIP_FILE'
,false);
010.
define(
'SHOW_NON_DETECTED_FILE'
,false);
011.
define(
'SHOW_ONLY_HIDDEN_IFRAME'
,true);
012.
define(
'SHOW_DIR'
,false);
013.
ini_set
(
"max_execution_time"
,
"150"
);
014.
015.
if
(isset(
$_POST
[
'showfile'
])){
016.
$f
=
$_POST
[
'file'
];
017.
$data
= htmlspecialchars(
file_get_contents
(
$f
));
018.
foreach
(
$words
as
$w
){
019.
$data
=
str_ireplace
(
$w
,
'<span style="color:blue">'
.
$w
.
'</span>'
,
$data
);
020.
}
021.
$data
=
str_ireplace
(
'iframe'
,
'<span style="color:red">iframe</span>'
,
$data
);
022.
header(
'Content-type:text/html;charset=tis-620'
);
023.
echo
'<div>'
,
$data
,
'</div>'
;
024.
die
();
025.
}
026.
if
(isset(
$_POST
[
'savefile'
])){
027.
$f
=
$_POST
[
'file'
];
028.
$data
=
file_get_contents
(
$f
);
029.
030.
die
();
031.
}
032.
033.
?>
036.
<head>
037.
<meta http-equiv=
"content-type"
content=
"text/html; charset=tis-620"
/>
038.
<title>virus iframe detection version 1.0a</title>
040.
<script type=
"text/javascript"
>
041.
042.
$(
function
(){
043.
$(
'a[title]'
).click(
function
(e){
044.
var
title=$(this).attr(
'title'
);
045.
var
alink=$(this);
046.
$(
'#file_content'
).load(
047.
'?'
,
048.
{showfile:
''
,file:title},
049.
function
(){
050.
var
ofs = alink.offset();
051.
$(
'#file_name'
).text(title);
052.
$(
'#file_info'
).css(
'top'
,ofs.top+20).show(
'slow'
);
053.
}
054.
);
055.
e.preventDefault();
056.
});
057.
$(
'#close'
).click(
function
(e){
058.
$(
'#file_info'
).hide(
'slow'
);
059.
e.preventDefault();
060.
});
061.
062.
});
063.
064.
</script>
065.
</head>
066.
067.
<body>
068.
<div id=
"file_info"
style=
"position:absolute;border:solid green 1px;background:lavender;display:none;"
>
069.
<div ><a href=
"#"
id=
"close"
>[close]</a></div>
070.
<div id=
"file_name"
style=
"border-bottom:solid green 2px;"
></div>
071.
<div style=
"background:ghostwhite;overflow:scroll;height:435px;width:970px;"
><pre id=
"file_content"
></pre></div>
072.
</div>
073.
<?php
074.
075.
076.
077.
$fs
=
array
();
078.
files(
$root
);
079.
080.
081.
foreach
(
$fs
as
$key
=>
$row
) {
082.
$modified
[
$key
] =
$row
[SORT_BY];
083.
}
084.
array_multisort
(
$modified
, SORT_DESC,
$fs
);
085.
unset(
$modifed
);
086.
087.
088.
foreach
(
$fs
as
$row
){
089.
extract(
$row
);
090.
$full
=
$dir
.DIRECTORY_SEPARATOR.
$name
;
091.
$report
=
'<br />'
.
$modified
.
' : '
.
$full
;
092.
if
(
$type
==
'd'
) {
093.
if
(SHOW_DIR){
094.
echo
$report
.
', <b>DIRECTORY</b>'
;
095.
}
096.
}
else
{
097.
if
(!in_array(getExt(
$name
),
$exts
,true)){
098.
if
(SHOW_SKIP_FILE){
099.
echo
$report
.
'<span style="color:blue"> SKIP</span>'
;
100.
}
101.
}
else
{
102.
$s
=
file_get_contents
(
$full
);
103.
$x
=
''
;
104.
foreach
(
$words
as
$w
){
105.
if
(SHOW_ONLY_HIDDEN_IFRAME){
106.
if
(
stripos
(
$s
,
'hidden'
) &&
stripos
(
$s
,
$w
)){
107.
$x
.= (
$w
==
'iframe'
) ?
'<b>:IFRAME</b>'
:
" :$w "
;
108.
}
109.
}
else
{
110.
if
(
stripos
(
$s
,
$w
)){
111.
$x
.= (
$w
==
'iframe'
) ?
'<b>:IFRAME</b>'
:
" :$w "
;
112.
}
113.
}
114.
}
115.
if
(
empty
(
$x
)){
116.
if
(SHOW_NON_DETECTED_FILE){
117.
echo
$report
;
118.
}
119.
}
else
{
120.
echo
$report
.
121.
'<a href="#" title="'
.htmlspecialchars(
$full
).
122.
'"><span style="color:red">'
.
$x
.
'</span></a>'
;
123.
}
124.
}
125.
}
126.
}
127.
128.
129.
130.
131.
function
files(
$dir
) {
132.
global
$fs
;
133.
$d
= dir(
$dir
);
134.
while
(false !== (
$entry
=
$d
->read())) {
135.
$f
=
$d
->path.DIRECTORY_SEPARATOR.
$entry
;
136.
if
(!(
$entry
==
'.'
||
$entry
==
'..'
)){
137.
$type
=
is_dir
(
$f
)?
'd'
:
'f'
;
138.
$fs
[] =
array
(
139.
'type'
=>
$type
,
140.
'name'
=>
$entry
,
141.
'modified'
=>
date
(
"Y-m-d H:i:s."
,
filemtime
(
$f
)),
142.
'dir'
=>
$d
->path
143.
);
144.
if
(
$type
==
'd'
){
145.
files(
$f
);
146.
}
147.
}
148.
}
149.
$d
->close();
150.
}
151.
152.
function
getExt(
$file_name
) {
153.
return
'.'
.
substr
(
strrchr
(
$file_name
,
'.'
),1);
154.
}
155.
156.
?>
157.
158.
</body>
159.
</html>