浅谈NT的ACL,令牌,权限与安全性问题
“冰箱有电”通过精心收集,向本站投稿了7篇浅谈NT的ACL,令牌,权限与安全性问题,下面是小编给大家带来浅谈NT的ACL,令牌,权限与安全性问题,一起来阅读吧,希望对您有所帮助。
篇1:浅谈NT的ACL,令牌,权限与安全性问题另一种克隆帐号的途径
-----另一种克隆帐号的途径
作者:刺(aXis)
来源:www.3389.net
摘要:关于nt的acl,token,and privilege的,以及通过privilege绕过acl,达到访问文件的目的,可以说是另一种克隆administrator的方法,不过更隐蔽,利用起来难度较大,需要绕过检测才行,目前取的的突破是利用权限绕过acl。
关键字:ACL,ACE,DACL,TOKEN,SID,PRIVILEGE
申明:谨以此文,献给陈静。
一.基本概念(这部分介绍的是令牌,ACL等基本概念,是为第二部分做准备,如果你已经了解其内容,请跳过这一部分)
1.什么是令牌(TOKEN)
当用户登录到Windows NT//XP,同时通过了身份认证,此时将会由系统为该用户分配一个令牌。令牌是一个数据结构,用于由所有该用户激活的进程和线程。令牌的结构如下图:
Token source
Impersonation Type
Token ID
Authentication ID
Modified ID
Expiration Time
Default Primary Group
Default DACL
User Account SID
Group 1 SID
......
Group n SID
Restricted SID 1
......
Restricted SID n
Privilege 1
......
Prililege n
这样看不太容易理解。我们来看一个实例,使用win2000 resource kit中的whoami.exe来查看当前用户的访问令牌(Access Token)中的详细信息
C:\\\\>whoami /all
[User] = \\\“DARKDEAMON\\\\Administrator\\\” S-1-5-21-1409082233-1957994488-47230797
1-500
[Group 1] = \\\“DARKDEAMON\\\\None\\\” S-1-5-21-1409082233-1957994488-472307971-513
[Group 2] = \\\“Everyone\\\” S-1-1-0
[Group 3] = \\\“BUILTIN\\\\Administrators\\\” S-1-5-32-544
[Group 4] = \\\“BUILTIN\\\\Users\\\” S-1-5-32-545
[Group 5] = \\\“NT AUTHORITY\\\\INTERACTIVE\\\” S-1-5-4
[Group 6] = \\\“NT AUTHORITY\\\\Authenticated Users\\\” S-1-5-11
[Group 7] = \\\“LOCAL\\\” S-1-2-0
(X) SeChangeNotifyPrivilege =
(O) SeSecurityPrivilege =
(O) SeBackupPrivilege =
(O) SeRestorePrivilege =
(O) SeSystemtimePrivilege =
(O) SeShutdownPrivilege =
(O) SeRemoteShutdownPrivilege =
(O) SeTakeOwnershipPrivilege =
(O) SeDebugPrivilege =
(O) SeSystemEnvironmentPrivilege =
(O) SeSystemProfilePrivilege =
(O) SeProfileSingleProcessPrivilege =
(O) SeIncreaseBasePriorityPrivilege =
(X) SeLoadDriverPrivilege =
(O) SeCreatePagefilePrivilege =
(O) SeIncreaseQuotaPrivilege =
(X) SeUndockPrivilege =
(O) SeTcbPrivilege =
C:\\\\>
这就是我的令牌中的信息,它包括我的SID,属于的组,具有的权限的详细列表等信息。所以可见,令牌决定了一个用户在一台计算机上所具有的能力。
2.安全性标志符(SID)
SID是在创建一个用户或组的时候由系统分配的,是唯一的。当一个本地用户登录时,SID将由系统从SAM中的用户数据库中取出。
关于SID的结构可以参照《INSIDE WINDOWS2000》里的一段:
A SID is a variable-length numeric value that consists of a SID structure revision number, a 48-bit identifier authority value, and a variable number of 32-bit subauthority or relative identifier (RID) values.
下面是一些系统内置的SID
Well-Known SIDs
SID
Group
Use
S-1-1-0
Everyone
A group that includes all users.
S-1-2-0
Local
Users who log on to terminals locally (physically) connected to the system.
S-1-3-0
Creator Owner ID
A security identifier to be replaced by the security identifier of the user who created a new object. This SID is used in inheritable access-control entries (ACEs).
S-1-3-1
Creator Group ID
Identifies a security identifier to be replaced by the primary-group SID of the user who created a new object. Use this SID in inheritable ACEs.
SID结尾的数字是RID(relative identifier)。500表示是管理员组,GUEST组的是501
ADAM提出的克隆管理员帐号就是在SID上做手脚,把一个帐号的SID的RID克隆成500,这样系统就会认为是管理员了。
一个完整的SID的结构可以参看上面令牌中的SID。
S-1-5-21-1409082233-1957994488-472307971-500
3.什么是访问控制列表(ACL)
ACL(access control list)从字面的意思很好理解。一个系统通过ACL来判断用户对资源的何种程度的访问。由两种类型的ACL:DACL(Discretionary Access Control List)和SACL(System Access Control List)。DACL包括户和组的列表,以及相应的权限,允许或是拒绝,用来确定对资源的访问权限。SACL则用来确定安全资源的审核策略。ACL由零个或多个ACE(Access Control Entries)组成,一个ACE包括一个SID和该SID可访问资源的描述,比如允许和拒绝,拒绝优先于允许。
在win2000 resource kit中有几个工具是关于acl的,较为典型的是xcacls。下面是一个用xcacls查看acl的例子
C:\\\\Program Files\\\\Resource Kit>xcacls whoami.exe
C:\\\\Program Files\\\\Resource Kit\\\\whoami.exe BUILTIN\\\\Users:R
BUILTIN\\\\Power Users:C
BUILTIN\\\\Administrators:F
NT AUTHORITY\\\\SYSTEM:F
NT AUTHORITY\\\\TERMINAL SERVER USER:C
C:\\\\Program Files\\\\Resource Kit>
其他的关于acl的工具还有svcacls.exe,showacls以及subinacl.exe等。这里不再一一赘述。
4.权限(privilege)
简单来说,权限是系统赋予用户的一定的权力,它们允许或者不允许某些影响整个计算机系统而非某一对象的特权操作。下面的表格列出了系统的一些权限和功能。
Privilege
Windows Privilege
Description
SeTcbPrivilege
Act as part of the operating system
Allows a process to authenticate like a user and thus gain access to the same resources as a user. Only low-level authentication services should require this privilege.
SeMachineAccountPrivilege
Add computers to a domain
Allows the user to add a computer to a specific domain. For the privilege to be effective, it must be assigned to the user as part of local security policy for domain controllers in the domain.
SeBackupPrivilege
Back up files and directories
Allows the user to circumvent file and directory permissions to back up the system. The privilege is checked only when an application attempts access through the NTFS backup application programming interface (API). Otherwise, normal file and directory permissions apply.
By default, this privilege is assigned to Administrators and Backup Operators. See also Restore files and directories in this table.
SeChangeNotifyPrivilege
Bypass traverse checking
Allows the user to pass through folders to which the user otherwise has no access while navigating an object path in any Windows file system or in the registry. This privilege does not allow the user to list the contents of a folder; it allows the user only to traverse its directories.
By default, this privilege is assigned to Administrators, Backup Operators, Power Users, Users, and Everyone.
SeSystemTimePrivilege
Change the system time
Allows the user to set the time for the internal clock of the computer.
By default, this privilege is assigned to Administrators and Power Users.
SeCreatePagefilePrivilege
Create a page filepagefile
Allows the user to create and change the size of a page file.
By default, this privilege is assigned to Administrators.
SeCreateTokenPrivilege
Create a token object
Allows a process to create an access token by calling NtCreateToken or other token-creating APIs.
SeCreatePermanentPrivilege
Create permanent shared objects
Allows a process to create a directory object in the Windows 2000 object manager.
SeDebugPrivilege
Debug programs
Allows the user to attach a debugger to any process.
By default, this privilege is assigned to Administrators.
SeEnableDelegationPrivilege
Enable computer and user accounts to be trusted for delegation
Allows the user to change the Trusted for Delegation setting on a User or Computer object in Active Directory. The user or computer that is granted this privilege must also have write access to the account control flags on the object.
SeRemoteShutdownPrivilege
Force shutdown from a remote system
Allows a user to shut down a computer from a remote location on the network. See also Shut down the system in this table.
By default, this privilege is assigned to Administrators.
SeAuditPrivilege
Generate security audits
Allows a process to create, generate, and add entries in the security log. The security log is used to trace unauthorized system access. See also Manage auditing and security log in this table.
SeIncreaseQuotaPrivilege
Increase quotas
Allows a process that has Write Property access to another process to increase the processor quota that is assigned to the other process. This privilege is useful for system tuning, but it can be abused, as in a denial of service attack.
By default, this privilege is assigned to Administrators.
SeIncreaseBasePriorityPrivilege
Increase scheduling priority
Allows a process that has Write Property access to another process to increase the execution priority of the other process. A user with this privilege can change the scheduling priority of a process in the Task Manager dialog box.
By default, this privilege is assigned to Administrators.
SeLoadDriverPrivilege
Load and unload device drivers
Allows a user to install and uninstall Plug and Play device drivers. Device drivers that are not Plug and Play are not affected by this privilege and can be installed only by Administrators. Because device drivers run as trusted (highly privileged) programs, this privilege can be misused to install hostile programs and give them destructive access to resources.
By default, this privilege is assigned to Administrators.
SeLockMemoryPrivilege
Lock pages in memory
Allows a process to keep data in physical memory, which prevents the system from paging the data to virtual memory on disk. Exercising this privilege can significantly degrade system performance. This privilege is obsolete and is therefore never selected.
SeSecurityPrivilege
Manage auditing and security log
Allows a user to specify object access auditing options for individual resources such as files, Active Directory objects, and registry keys. Object access auditing is not actually performed unless you have enabled it in Audit Policy (under Security Settings, Local Policies). A user who has this privilege can also view and clear the security log from Event Viewer.
By default, this privilege is assigned to Administrators.
SeSystemEnvironmentPrivilege
Modify firmware environment values
Allows modification of system environment variables either by a process through an API or by a user through System Properties.
By default, this privilege is assigned to Administrators.
SeProfileSingleProcessPrivilege
Profile a single process
Allows a user to run Microsoft® Windows NT® and Microsoft® Windows® 2000 performance-monitoring tools to monitor the performance of nonsystem processes.
By default, this privilege is assigned to Administrators and Power Users.
SeSystemProfilePrivilege
Profile system performance
Allows a user to run Windows NT and Windows 2000 performance-monitoring tools to monitor the performance of system processes.
By default, this privilege is assigned to Administrators.
SeUndockPrivilege
Remove computer from docking station
Allows the user of a portable computer to undock the computer by clicking Eject PC on the Start menu.
By default, this privilege is assigned to Administrators, Power Users, and Users.
SeAssignPrimaryTokenPrivilege
Replace a process-level token
Allows a parent process to replace the access token associated with a child process.
SeRestorePrivilege
Restore files and directories
Allows a user to circumvent file and directory permissions when restoring backed-up files and directories and to set any valid security principal as the owner of an object. See also Back up files and directories in this table.
By default, this privilege is assigned to Administrators and Backup Operators.
SeShutdownPrivilege
Shut down the system
Allows a user to shut down the local computer. See also Force shutdown from a remote system in this table. In Windows 2000 Professional:
By default, this privilege is assigned to Administrators, Backup Operators, Power Users, and Users. In Windows 2000 Server:
By default, this privilege is not assigned to Users, only to Administrators, Backup Operators, and Power Users.
SeSynchAgentPrivilege
Synchronize directory service data
Allows a process to provide directory synchronization services. This privilege is relevant only on domain controllers.
By default, this privilege is assigned to Administrators and LocalSystem accounts on domain controllers.
SeTakeOwnershipPrivilege
Take ownership of files or other objects
Allows a user to take ownership of any securable object in the system, including Active Directory objects, files and folders, printers, registry keys, processes, and threads.
By default, this privilege is assigned to Administrators.
二.一些安全问题
1.利用备份权限绕过访问控制
系统备份员(Backup Operators)和管理员(Administrator)具有一项权限:SeBackupPrivilege
利用该权限可以访问正常情况下被拒绝访问的文件,
当在ACL中设置拒绝某帐号读取文件时,一个备份程序可以在调用Createprocess时,通过设置FILE_FLAG_BACKUP_SEMANTICS的标志来对文件进行读取。
按照《writng secure code》一书给出的代码如下
1. 假设你具有SeBackupPrivilege权限。
2. 创建一个txt文件,内容为:writings this for cj
3. 添加一个全部拒绝该用户访问的ACE。
现在,试着打开该文件,将会出现拒绝访问的提示。现在,编译下面这段代码(来自《writng secure code》)
/*
WOWAccess.cpp
*/
#include
#include
int EnablePriv (char *szPriv) {
HANDLE hToken = 0;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES,
&hToken)) {
printf(\\\“OpenProcessToken() failed ->%d\\\”, GetLastError());
return -1;
}
TOKEN_PRIVILEGES newPrivs;
if (!LookupPrivilegeValue (NULL, szPriv,
&newPrivs.Privileges[0].Luid)) {
printf(\\\“LookupPrivilegeValue() failed ->%d\\\”, GetLastError());
CloseHandle (hToken);
return -1;
}
newPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
newPrivs.PrivilegeCount = 1;
if (!AdjustTokenPrivileges(hToken, FALSE, &newPrivs, 0, NULL, NULL)) {
printf(\\\“AdjustTokenPrivileges() failed ->%d\\\”, GetLastError());
CloseHandle (hToken);
return -1;
}
CloseHandle (hToken);
return 0;
}
void DoIt(char *szFileName, DWORD dwFlags) {
printf(\\\“\\\\n\\\\nAttempting to read %s, with 0x%x flags\\\\n\\\”,
szFileName, dwFlags);
HANDLE hFile = CreateFile(szFileName,
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING,
dwFlags,
NULL);
if (hFile == INVALID_HANDLE_VALUE) {
printf(\\\“CreateFile() failed ->%d\\\”, GetLastError());
return;
}
char buff[128];
DWORD cbRead=0, cbBuff = sizeof buff;
ZeroMemory(buff, sizeof buff);
if (ReadFile(hFile, buff, cbBuff, &cbRead, NULL)) {
printf(\\\“Success, read %d bytes\\\\n\\\\nText is: %s\\\”,
cbRead, buff);
} else {
printf(\\\“ReadFile() failed ->%d\\\”, GetLastError());
}
CloseHandle(hFile);
}
void main(int argc, char* argv[]) {
if (argc < 2) {
printf(\\\“Usage: %s \\\”, argv[0]);
return;
}
// Need to enable backup priv first.
if (EnablePriv(SE_BACKUP_NAME) == -1)
return;
// Try with no backup flag - should get access denied.
DoIt(argv[1], FILE_ATTRIBUTE_NORMAL);
// Try with backup flag - should work!
DoIt(argv[1], FILE_ATTRIBUTE_NORMAL │ FILE_FLAG_BACKUP_SEMANTICS);
}
运行情况如下
C:\\\\>bkp
Usage: bkp
C:\\\\>bkp test.txt
Attempting to read test.txt, with 0x80 flags
CreateFile() failed ->5
Attempting to read test.txt, with 0x2000080 flags
Success, read 20 bytes
Text is: writings this for cj
C:\\\\>
如上,使用了备份的标志后(with 0x2000080 flags)就可以访问开始拒绝访问的文件了。
2.利用SeTakeOwnershipPrivilege权限绕过访问控制
在我的计算机上,tt是一个普通的user帐号,当给他添加上SeTakeOwnershipPrivilege后,就可以绕过原来的访问控制,比如,对system32目录下就可以添加完全控制的ACE,从而可以任意复制文件。对Document and Settings目录下也可以如法炮制,那么,给管理员下个套就是很简单的事情了。下面是实现过程
首先看下tt所具有的权限
C:\\\\>whoami /all
[User] = \\\“DARKDEAMON\\\\tt\\\” S-1-5-21-1409082233-1957994488-472307971-1013
[Group 1] = \\\“DARKDEAMON\\\\None\\\” S-1-5-21-1409082233-1957994488-472307971-513
[Group 2] = \\\“Everyone\\\” S-1-1-0
[Group 3] = \\\“BUILTIN\\\\Users\\\” S-1-5-32-545
[Group 4] = \\\“NT AUTHORITY\\\\INTERACTIVE\\\” S-1-5-4
[Group 5] = \\\“NT AUTHORITY\\\\Authenticated Users\\\” S-1-5-11
[Group 6] = \\\“LOCAL\\\” S-1-2-0
(O) SeCreatePagefilePrivilege =
(O) SeAssignPrimaryTokenPrivilege =
(O) SeCreateTokenPrivilege =
(O) SeAuditPrivilege =
(X) SeUndockPrivilege =
(O) SeTakeOwnershipPrivilege =
(X) SeChangeNotifyPrivilege =
C:\\\\>
可以看到已经添加了SeTakeOwnershipPrivilege权限,下面,将演示如何取得对system32目录的完全控制
这是修改前的结果.
下面我们来更改目录的所有者以得到完全控制.
现在可以看到更改所有者已经激活,所以我们只需要更改所有者就可以取得完全控制了。而在这个权限添加以前是无法进行这项操作的。
3.利用SeDebugPrivilege权限来做坏事
这个权限是极为危险的。它允许用户通过调试进程来访问秘密数据。典型的例子就是findpass。利用SeDebugPrivilege调试winlogon进程来获得明文存储在里面的域名和密码。
另一个典型的例子就是LSADUMP2,通过使用CreateRemoteThread函数来在LSASS.EXE进程中读取已经经过LSA解密的私有数据代码,从而查看LSA中存储的秘密信息。
4.更进一步
管理员(Administrator)默认具有16个权限
SeChangeNotifyPrivilege
SeSecurityPrivilege
SeBackupPrivilege
SeRestorePrivilege
SeSystemtimePrivilege
SeShutdownPrivilege
SeRemoteShutdownPrivilege
SeTakeOwnershipPrivilege
SeDebugPrivilege
SeSystemEnvironmentPrivilege
SeSystemProfilePrivilege
SeProfileSingleProcessPrivilege
SeIncreaseBasePriorityPrivilege
然而,SeTcbPrivilege和SeCreateTokenPrivilege两个权限管理员缺省是没有的. SeTcbPrivilege是具有操作系统的一部分来工作的权限,,SeCreateTokenPrivilege更为任意令牌创建权限!拥有了这两个权限,用Lu0的话来说,就是可以超越administrator!
从而提出另一种克隆管理员帐号的途径:克隆管理员的权限,甚至包括SeTcbPrivilege和SeCreateTokenPrivilege两个权限!
在这里使用到RESOURCE KIT中的一个工具:ntrights.exe
通过这个工具可以给指定帐号和组添加权限。
下面是ntrights.exe的说明
ntrights {-r Right │ +r Right} -u UserOrGroup [-m \\\\\\\\Computer] [-e Entry] [-?]
Where:
-r Right
revokes Right from specified user or group. For a full list, see Windows 2000 Rights.
+r Right
grants Right to specified user or group. For a full list, see Windows 2000 Rights.
-u UserOrGroup
specifies the user or group for whom rights are to be granted or revoked.
-m \\\\\\\\Computer
specifies the computer (machine) on which to perform. the operation. The default is the local computer.
-e Entry
adds a text string Entry to the computer\\\s event log.
-?
displays a syntax screen at the command prompt.
下面是使用实例,
C:\\\\>ntrights +r SeDebugPrivilege -u tt
Granting SeDebugPrivilege to tt ... successful
C:\\\\>
这样就成功给tt添加了SeDebugPrivilege的权限,其他权限也可以照样添加。如果是去除权限,则只需把+r变成-r就可以了。
这样就实现了另一种意义上的克隆帐号,不过这样得到权限后仍然不能启动服务或添加帐号,比如net user ttt /add时发生拒绝错误,不知道这条命令是否会检查当前用户的SID,所以产生失败,还请高手指示。
三.后记
罗嗦写了这么多,是出于学习的目的,用wawa的话来说就是在写的过程中获益不少。由于水平有限,内容不免有错误之处,还请高手指正。
相关工具下载:
whoami: www.3389.net/download/whoami.exe
xcacls: www.3389.net/download/xcacl.exe
bkp: www.3389.net/download/bkp.exe
ntrights: www.3389.net/download/ntrights.exe
findpass: www.3389.net/download/findpass.zip
lsadump2: www.3389.net/download/lsadump2.zip
篇2:LINUX文件安全与权限
当你创建一个文件的时候,系统保存了有关该文件的全部信息,包括:
? 文件的位置,
? 文件类型。
? 文件长度。
? 哪位用户拥有该文件,哪些用户可以访问该文件。
? i节点。
? 文件的修改时间。
? 文件的权限位。
让我们使用ls -l命令,来看一个典型的文件:
root@ubuntu:~/resource/mini2440/file-system# ls -l
total 11488
drwxr-xr-x 33 root root 4096 -04-17 04:29 busybox-1.17.3
-rwxrw-rw- 1 root root 2094550 2013-04-17 03:03 busybox-1.17.3.tar.bz2
-rw------- 1 root root 9660288 2013-04-17 04:30 haitao.img
我们现在看到的上面的打印信息,分析如下:
total 11488:这一行告诉我们该目录中所有文件所占的空间。
d rwx r-x r-x:这是该文件的权限位。这里一共是 10个字符,除了第一位他们分别对应9个权限位。通过这些权限位,可以设定用户对文件的访问权限。这 9个字符可以分
为三组:
rwx:文件属主权限 这是前面三位
r-x :同组用户权限 这是中间三位
r-x :其他用户权限 这是最后三位
后面我们还将对这些权限位作更详细的介绍。出现在 r、w、x位置上的横杠表示相应的访问权限被禁止
33表示该文件硬链接的数目
root 文件的属主
root 文件的属主root所在的缺省组
4096 用字节来表示的文件长度,记住,不是 K字节!
busybox-1.17.3 文件名(这里其实是一个目录名)
文件类型有七种,它可以从 ls -l命令所列出的结果的第一位看出,这七种类型是:
d 目录
l 符号链接(指向另一个文件)。
s 套接字文件。
b 块设备文件。
c 字符设备文件。
p 命名管道文件。
- 普通文件,或者更准确地说,不属于以上几种类型的文件。
所以说上面的busybox-1.17.3是一个目录的名字
文件权限
root@ubuntu:~/resource/study/shell# touch test
root@ubuntu:~/resource/study/shell# ls
test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-rw-r--r-- 1 root root 0 2013-04-18 22:26 test
上面我们用touch新建了一个空文件,可以看到他是一个普通文件,属主权限为可读可写不可执行,用户组权限为可读,不可写,不可执行,其他组权限为可读,不可写,不可执行
我们要做的就是试着去改变这些权限,达到我们想要设定的权限,我们是通过chmod实现的
chmod命令的一般格式为:
chmod [who] operator [permission] filename
w h o的含义是:
u 文件属主权限。
g 同组用户权限。
o 其他用户权限。
a 所有用户(文件属主、同组用户及其他用户 )。
o p e r a t o r的含义:
+ 增加权限。
- 取消权限。
= 设定权限。
p e r m i s s i o n的含义:
r 读权限。
w 写权限。
x 执行权限。
s 文件属主和组s e t - I D。
t 粘性位*。
l 给文件加锁,使其他用户无法访问。
u,g,o 针对文件属主、同组用户及其他用户的操作。
在列文件或目录时,有时会遇到“ t”位。“t”代表了粘性位。如果在一个目录上出现“t”位,这就意味着该目录中的文件只有其属主才可以删除,即使某个同组用户具有和属主同等的权限。不过有的系统在这一规则上并不十分严格。如果在文件列表时看到“ t”,那么这就意味着该脚本或程序在执行时会被放在交换区 (虚
存)。不过由于当今的内存价格如此之低,大可不必理会文件的“ t”的使用
看看实例吧
root@ubuntu:~/resource/study/shell# chmod u+x test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-rwxr--r-- 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod g+x test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-rwxr-xr-- 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod o+x test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-rwxr-xr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod a-x test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-rw-r--r-- 1 root root 0 2013-04-18 22:26 test
我们首先吧属主,用户组,其他用户组的权限都加上了可指向权限,然后又一并去掉了他们的可指行权限
当然还有另外一种方法来更改权限
chmd命令绝对模式的一般形式为:
chmod [mode] file
其中mode是一个八进制数
r w x
4 2 1
上面就是对应关系,说明如下:
可读,可写,可执行:4+2+1=7
可读,不可写,可执行:4+1=5
可读,可写,吧可执行:4+2=6
可读,不可写,不可执行:4
就是通过累加方式实现的
下面说说目录的访问权限
目录的权限位和文件有所不同。现在我们来看看其中的区别。目录的读权限位意味着可以列出其中的内容。
写权限位意味着可以在该目录中创建文件,如果不希望其他用户在你的目录中创建文件,可以取消相应的写权限位。执行权限位则意味着搜索和访问该目录
如果把同组用户或其他用户针对某一目录的权限设置为 - - x,那么他们将无法列出该目录中的文件。如果该目录中有一个执行位置位的脚本或程序,只要用户知道它的路径和文件名,仍然可以执行它。用户不能够进入该目录并不妨碍他的执行。
suid和guid的设置
这里有一个很好的例子。我管理着几个大型的数据库系统,而对它们进行备份需要有系统管理权限。我写了几个脚本,并设置了它们的 g u i d,这样我指定的一些用户只要执行这些脚本就能够完成相应的工作,而无须以数据库管理员的身份登录,以免不小心破坏了数据库服务器。通过执行这些脚本,他们可以完成数据库备份及其他管理任务,但是在这些脚本运行结束之后,他们就又回复到他们作为普通用户的权限。有相当一些U N I X命令也设置了s u i d和g u i d,
如果想找出这些命令,可以进入 / b i n或/ s b i n目录,执行下面的命令:
$ ls -l | grep '^...s'
上面的命令是用来查找 s u i d文件的;
$ ls -l | grep '^...s..s'
上面的命令是用来查找 suid和guid的。
现在我们明白了什么是 suid,可是如何设置它呢?下面就来介绍这个问题。如果希望设置s u i d,那么就将相应的权限位之前的那一位设置为 4;如果希望设置g u i d,那么就将相应的权限位之前的那一位设置为2;如果希望两者都置位,那么将相应的权限位之前的那一位设置为4+2。一旦设置了这一位,一个 s将出现在 x的位置上。记住:在设置 s u i d或g u i d的同时,相应的执行权限位必须要被设置。例如,如果希望设置 g u i d,那么必须要让该用户组具有执行权限。
看看下面的例子
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-xr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod 4555 test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-sr-xr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod 555 test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-xr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod 2555 test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-sr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod 555 test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-xr-x 1 root root 0 2013-04-18 22:26 test
root@ubuntu:~/resource/study/shell# chmod 6555 test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-sr-sr-x 1 root root 0 2013-04-18 22:26 test
下面我们看一下chowm这个命令,这个命令用来改变文件的属主
chown命令的一般形式为:
chown -R -h owner file
- R选项意味着对所有子目录下的文件也都进行同样的操作。 - h选项意味着在改变符号链接文件的属主时不影响该链接所指向的目标文件。
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-xr-x 1 hai-tao root 0 2013-04-18 22:26 test
-rw-r--r-- 1 root root 0 2013-04-18 23:20 test1
root@ubuntu:~/resource/study/shell# cd ..
root@ubuntu:~/resource/study# chown -R root shell
root@ubuntu:~/resource/study# ls -l shell
total 0
-r-xr-xr-x 1 root root 0 2013-04-18 22:26 test
-rw-r--r-- 1 root root 0 2013-04-18 23:20 test1
root@ubuntu:~/resource/study# cd ..
root@ubuntu:~/resource# cd study/shell
root@ubuntu:~/resource/study/shell# chown hai-tao test
root@ubuntu:~/resource/study/shell# ls -l
total 0
-r-xr-xr-x 1 hai-tao root 0 2013-04-18 22:26 test
-rw-r--r-- 1 root root 0 2013-04-18 23:20 test1
文件test的所有权现在由用户root交给了用户hai-tao了
chgrp命令和chown命令的格式差不多,他用来改变用户所属的组
找出自己所属的用户组,书上说通过group获得,我使用的时候出现错,使用groups是ok的
root@ubuntu:~/resource/study/shell# groups
root
root@ubuntu:~/resource/study/shell# groups hai-tao
hai-tao : hai-tao adm dialout cdrom plugdev lpadmin admin sambashare
上面的命令告诉我们用户hai-tao属于后面的那么多用户组
umask的讲解
当最初登录到系统中时, umask命令确定了你创建文件的缺省模式。这一命令实际上和chmod命令正好相反。你的系统管理员必须要为你设置一个合理的umask值,以确保你创建的
文件具有所希望的缺省权限,防止其他非同组用户对你的文件具有写权限。在已经登录之后,可以按照个人的偏好使用umask命令来改变文件创建的缺省权限。相应的改变直到退出该shell或使用另外的umask命令之前一直有效。
一般来说,umask命令是在/etc/profile文件中设置的,每个用户在登录时都会引用这个文件,所以如果希望改变所有用户的umask,可以在该文件中加入相应的条目。如果希望永久性地设置自己的umask值,那么就把它放在自己 $HOME目录下的. profile或. bash_profile文件中。
如何计算umask值
umask命令允许你设定文件创建时的缺省模式,对应每一类用户 (文件属主、同组用户、其他用户)存在一个相应的umask值中的数字。对于文件来说,这一数字的最大值分别是 6。系统不允许你在创建一个文本文件时就赋予它执行权限,必须在创建后用chmod命令增加这一权限。目录则允许设置执行权限,这样针对目录来说, u m a s k中各个数字最大可以到 7。
该命令的一般形式为:
umask nnn,其中nnn为umask置000-777。
列出了与权限位相对应的umask值。
umask值与权限
umask 文件 目录
0 6 7
1 6 6
2 4 5
3 4 4
4 2 3
5 2 2
6 0 1
7 0 0
在计算umask值时,可以针对各类用户分别在这张表中按照所需要的文件 /目录创建缺省权限查找对应的umask值。
例如,umask值002 所对应的文件和目录创建缺省权限分别为 6 6 4和7 7 5。
还有另外一种计算umask值的方法。我们只要记住umask是从权限中“拿走”相应的位即例如,对于umask值0 0 2,相应的文件和目录缺省创建权限是什么呢?
篇3:WordPress 文件权限与安全
三两饭在之前的文章中曾经提到过 WordPress 的安全问题,并提出了十条安全建议,其中有一条是有关于 WordPress 文件权限的,那么到底哪些文件和文件夹需要将权限设置为只读,怎么设置?
需要设置只读权限的文件和文件夹:
wp-config.php 是肯定需要设置的,它包含了你的数据库信息非常重要;
index.php 博客主索引文件,不是一般的重要;
wp-setting.php 你的 wordpress 设置文件,非常重要;
Theme directory 目录也需要设置为已读,防止别人篡改你的主题文件,
将文件(夹)权限设置为只读文件:
可能还是有很多朋友不太明白文件权限,所谓文件权限通常表现为一个三位的数字,比如777就表示最高权限,任何人可以对该文件做任何想做的事。
那么777是怎么算出来的呢?通常有三种用户,他们分别是 owner 、group 、others 。每种用户类型有三种权限,分别为 read 、write 、execute 。
系统会为 read 权限标记4, write 权限标记2, execute 权限标记1,所以三种权限相加就是7(4+2+1=7)。777就代表 owner 、group 、others 三种用户都具有最高权限。
所以,为了别人不会任意篡改你的程序文件,将重要的文件设置成只读,那么就是444了。
篇4:了解Windows权限 认识局域网共享与安全
说起Windows的局域网共享时,就提到了IPC(InternetProcessConnection),IPC是NT以上的系统为了让进程间通信而开放的命名管道,可以通过验证用户名和密码获得相应的权限,在远程管理计算机和查看计算机的共享资源时使用,微软把它用于局域网功能的实现,如果它被关闭,计算机就会出现“无法访问网络邻居”的故障,
在WindowsNT以后的系统里,IPC是依赖于Server服务运行的,一些习惯了单机环境的用户可能会关闭这个服务,这样的后果就是系统将无法提供与局域网有关的操作,用户无法查看别人的计算机,也无法为自己发布任何共享。
要确认IPC和Server服务是否正常,可以在命令提示符里输入命令netshare,如果Server服务未开启,系统会提示“没有启动Server服务。是否可以启动?(Y/N)[Y]:”,回车即可以启动Server服务。如果Server服务已开启,系统会列出当前的所有共享资源列表,其中少要有名为“IPC$”的共享,否则用户依然无法正常使用共享资源。
除了Server服务以外,还有两个服务会对共享造成影响,分别是“ComputerBrowser”和“TCP/IPNetBIOSHelperService”,前者用于保存和交换局域网内计算机的NetBIOS名称和共享资源列表,当一个程序需要访问另一台计算机的共享资源时,它会从这个列表里查询目标计算机,一旦该服务被禁止,IPC就认定当前没有可供访问的共享资源,用户自然就没法访问其他计算机的共享资源了;后者主要用于在TCP/IP上传输的NetBIOS协议(NetBT)和NetBIOS名称解析工作,NetBT协议为跨网段实现NetBIOS命令传输提供了载体,正因如此,早期的 入侵教材里“关于139端口的远程入侵”才能实现,因为NetBIOS协议被TCP封装起来通过Internet传输到对方机器里处理了,同样对方也是用相同途径实现数据传输的,否则 们根本无法跨网段使用网络资源映射指令“netuse”。对于本地局域网来说,NetBT是SMB协议依赖的传输媒体,也是相当重要的。
如果这两个服务异常终止,局域网内的共享可能就无法正常使用,这时候我们可以通过执行程序“services.msc”打开服务管理器,在里面查找“ComputerBrowser”和“TCP/IPNetBIOSHelperService”服务并点击“启动”即可。
熟悉Windows系统的用户或多或少都会接触到“组策略”(gpedit.msc),这里实际上是提供了一个比手工修改注册表更直观的操作方法来设置系统的一些功能和用户权限,但是这里的设置失误也会影响到局域网共享资源的使用,
由于IPC本身就是用于身份验证的,因此它对计算机账户的配置特别敏感,而组策略里偏偏就有很多方面的设置是针对计算机账户的,其中影响最大的要数“计算机配置CWindows配置C安全设置C本地策略C用户权利指派”里的“拒绝从网络访问这台计算机”,在Windows系统里默认是不做任何限制的,可是自从XP出现后,这个部分就默认多了两个帐户,一个是用于远程协助(也就是被简化过的终端服务)身份登录的3389用户名,另一个则是我们局域网共享的基本成员guest!
许多使用XP系统的用户无法正常开启共享资源的访问权限,正是这个项目的限制,解决方法也很容易,只要从列表里移除“Guest”帐户就可以了。
除了与帐户相关的策略,这里还有几个与NetBIOS和IPC相关的组策略设置,它们是位于“计算机配置CWindows配置C安全设置C本地策略C安全选项”里的“对匿名连接的额外限制”(默认为“无”),对于XP以上的系统,这里还有“不允许SAM账户和共享的匿名枚举”(默认为“已停用”)、“本地账户的共享和安全模式”(默认为“仅来宾”),其中“对匿名连接的额外限制”的设置是可以直接扼杀共享功能的,当它被设置为“不允许枚举”时,其他计算机就无法获取共享资源列表,如果它被设置为“没有显式匿名权限就无法访问”的话,这台计算机就与共享功能彻底告别了,所以有时候实在找不出故障,不妨检查一下该项目。
一些刚接触NTFS分区的用户经常会发现,自己机器的共享和来宾帐户都开了,但是别人无论怎么访问都提示“权限不足”,即使给共享权限里添加了来宾帐户甚至管理员帐户也无效,这是为什么?归根究底还是因为在NTFS这部分被拦截了,用户必须理清一个概念,那就是如果你对某个共享目录的访问权限做了什么设置,例如添加删除访问成员,其相应的NTFS权限成员也要做出相应的修改,即共享权限成员和NTFS权限成员必须一致或者为“Everyone”成员,在XP/系统里出于安全因素,文件夹时常会缺少Everyone权限,因此,即使你的共享权限里设置了Everyone或Guest,它仍然会被NTFS权限因素阻止访问;如果NTFS权限成员里有共享权限成员的存在,那么访问的权限就在共享权限里匹配,例如一个目录的共享权限里打开了Everyone只读访问权限,那么即使在NTFS权限里设置了Everyone的完全控制权限,通过共享途径访问的用户依然只有“只读”的权限,但是如果在NTFS权限成员或共享权限成员里缺少Everyone的话,这个目录就无法被访问了。因此要获得正常的访问权限,除了做好共享目录的权限设置工作以外,还在共享目录上单击右键―属性―-安全,在里面添加Guest和Everyone权限并设置相应的访问规则(完全控制、可修改、可读取等),如果没有其他故障因素,你就会发现共享正常开启访问了。
篇5:IIS6和IIS7.5网站权限配置与区别WEB安全
IIS6网站权限,通常配置IUSR_计算机名和NETWORK SERVICE两个用户权限即可:
其中IUSR_计算机名是网站匿名访问帐户,NETWORK SERVICE是网站应用程序池安全帐户:
然而,同样的权限配置,测试发现IIS7.5网站动态页面打开会出错,比较发现IIS7.5应用程序池安全帐户除了本地系统、网络服务和本地服务外,比IIS6多了一个ApplicationPoolIdentity,并且它是默认安全帐户:
这就解释了为什么网站动态页面打开会出错,然而,在Windows 用户或组中并没有ApplicationPoolIdentity这么一个用户,这权限要怎么配置?百度后有网友说它对应的用户为“IIS AppPool\应用程序池名”,加入后网站访问正常:
看下任务管理器中的变化:
这样相当于是有了多个NETWORK SERVICE用户,能大大降低网站被旁注的风险,
当然了,也可以将IIS7.5应用程序池安全帐户设置为网络服务,这样和IIS6.0一样配置即可,但不推荐这么做。此外,若想简单配置,只赋于网站Authenticated Users组权限也是可以的(代替匿名帐户+安全帐户,但比Everyone安全)。
篇6:转基因生物存在的安全性问题与管理对策研究
转基因生物存在的安全性问题与管理对策研究
概述了转基因生物的`历史和现状,介绍了转基因生物存在的安全性问题,并对其潜在的风险和危害进行了分析,并结合实际提出了对我国转基因生物进行科学管理的应对措施.
作 者:赵安芳 刘瑞芳 陈兰英 ZHAO An-fang LIU Rui-fang CHEN Lan-ying 作者单位:平顶山工学院,生物工程系,河南,平顶山,467001 刊 名:河南师范大学学报(自然科学版) ISTIC PKU英文刊名:JOURNAL OF HENAN NORMAL UNIVERSITY (NATURAL SCIENCE) 年,卷(期): 34(3) 分类号:Q788 关键词:转基因生物 安全性 对策 风险篇7:设网站文件目录与数据库权限拒绝安全入侵
网站目录权限的设置方法
大多数网站都是采用程序搭建,对于系统管理的目录,可以将其设置为可读也可执行脚本,但不可写入的权限;但是对于放置网页静态文件的目录,以及放置图片文件、模板文件的目录,就可以将其设置为可读写但不可执行的系统权限,在权限分配明确之后,即使系统被入侵,也只能浏览而无法对文件进行直接的操作。
对于能够执行脚本的文件,最好设置只能读而不能写的权限,而需要写入的文件则将其设置为不能执行脚本,目录权限这样配置下来,网站系统的安全性会大大提高。
数据库权限也要仔细设置
对于网站来说,数据库可以说是站点的核心,所有网站的内容都存储在数据库中。所以说数据库安全也是需要注意的地方。对于MySQL数据库来说,最好不要对网站直接使用root管理用户的权限,而要专门为每个站点开通一个数据库账号,而且将账户的权限设置仅限于操作当前数据库目录,并且对这些单独的MYSQL账号去掉file和EXECUTE的执行权限,这样一来,即使数据库被SQL注入,也只能到数据库一级,而无法拿到整个数据库服务器的权限,
这样一来,只要经常对网站的数据库进行备份,就很少会出现数据库被入侵的情况。
另外需要注意的是,由于很多建站系统并没有使用数据库的存储过程,因此最好禁用FILE、EXECUTE 等执行存储过程或文件操作的权限。
小提示:对于Access的数据库来说,可以将数据库的存放位置进行修改,最好是较为隐蔽的目录,这样会避免数据库文件被恶意探测下载。另外,一些程序也支持修改后缀,比如可以将。mdb的数据库文件修改为。asa等后缀名,同样可以有效地保护数据库安全。
删除不需要的文件
很多内容管理系统中,都会在空间中存在很多以后并不需要的文件,最普遍的可能就属于系统安装文件了,这类文件通常被命名为install.php或者install.asp,如果你的空间中存在类似的文件,现在就赶快删除吧。
另外,一些CMS也会存在很多功能,如问答系统等等,但是往往这些功能在网站中都不会用到,这时候就建议将这些功能的目录删除,或者仅保留Html静态页面,然后将目录设置为可读写但不可执行的权限。
【浅谈NT的ACL,令牌,权限与安全性问题】相关文章:
1.职责权限
4.权限申请范文
10.董事会职责和权限






文档为doc格式