forked from nil0x42/phpsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirAccess.php
More file actions
55 lines (52 loc) · 1.27 KB
/
Copy pathdirAccess.php
File metadata and controls
55 lines (52 loc) · 1.27 KB
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
<?
// dirAccess($abspath, $mode) (type => boolean):
// Check if $abspath directory has $mode permission.
//
// $abspath (string):
// This variable must refer to an exsting directory.
// $mode (char):
// Mode should be 'r' to test read access, and 'w'
// to check write access.
//
// EXAMPLE:
// >>> dirAccess("/etc/", 'r')
// True
// >>> dirAccess("/etc/", 'w')
// False
//
// TODO: It will be smart if the function could restore atime
// (access time) on unix systems after testing for stealth purposes.
function dirAccess($abspath, $mode)
{
if ($mode == 'r')
{
if ($h = @opendir($abspath))
{
closedir($h);
return (True);
}
else
return (False);
}
elseif ($mode == 'w' || $mode == 'a')
{
$old_mtime = @filemtime($abspath);
$old_atime = @fileatime($abspath);
$rand = $abspath . uniqid('/pspapi_');
if ($h = @fopen($rand, 'a'))
{
@fclose($h);
$result = True;
}
else
{
$result = False;
}
@unlink($rand);
@touch($abspath, $old_mtime, $old_atime);
return ($result);
}
else
return (False);
}
?>