1
1
{
2
- Copyright 2017 Stas'M Corp.
2
+ Copyright 2018 Stas'M Corp.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
26
26
Classes,
27
27
WinSvc,
28
28
Registry,
29
- WinInet;
29
+ WinInet,
30
+ AccCtrl,
31
+ AclAPI;
30
32
31
33
function EnumServicesStatusEx (
32
34
hSCManager: SC_HANDLE;
@@ -41,6 +43,11 @@ function EnumServicesStatusEx(
41
43
pszGroupName: PWideChar): BOOL; stdcall;
42
44
external advapi32 name ' EnumServicesStatusExW' ;
43
45
46
+ function ConvertStringSidToSid (
47
+ StringSid: PWideChar;
48
+ var Sid: PSID): BOOL; stdcall;
49
+ external advapi32 name ' ConvertStringSidToSidW' ;
50
+
44
51
type
45
52
FILE_VERSION = record
46
53
Version: record case Boolean of
@@ -639,14 +646,57 @@ begin
639
646
Result := True;
640
647
end ;
641
648
649
+ procedure GrantSidFullAccess (Path, SID: String);
650
+ var
651
+ p_SID: PSID;
652
+ pDACL: PACL;
653
+ EA: EXPLICIT_ACCESS;
654
+ Code, Result: DWORD;
655
+ begin
656
+ p_SID := nil ;
657
+ if not ConvertStringSidToSid(PChar(SID), p_SID) then
658
+ begin
659
+ Code := GetLastError;
660
+ Writeln(' [-] ConvertStringSidToSid error (code ' , Code, ' ).' );
661
+ Exit;
662
+ end ;
663
+ EA.grfAccessPermissions := GENERIC_ALL;
664
+ EA.grfAccessMode := GRANT_ACCESS;
665
+ EA.grfInheritance := SUB_CONTAINERS_AND_OBJECTS_INHERIT;
666
+ EA.Trustee.pMultipleTrustee := nil ;
667
+ EA.Trustee.MultipleTrusteeOperation := NO_MULTIPLE_TRUSTEE;
668
+ EA.Trustee.TrusteeForm := TRUSTEE_IS_SID;
669
+ EA.Trustee.TrusteeType := TRUSTEE_IS_WELL_KNOWN_GROUP;
670
+ EA.Trustee.ptstrName := p_SID;
671
+
672
+ Result := SetEntriesInAcl(1 , @EA, nil , pDACL);
673
+ if Result = ERROR_SUCCESS then
674
+ begin
675
+ if SetNamedSecurityInfo(pchar(Path), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, nil , nil , pDACL, nil ) <> ERROR_SUCCESS then
676
+ begin
677
+ Code := GetLastError;
678
+ Writeln(' [-] SetNamedSecurityInfo error (code ' , Code, ' ).' );
679
+ end ;
680
+ LocalFree(Cardinal(pDACL));
681
+ end
682
+ else begin
683
+ Code := GetLastError;
684
+ Writeln(' [-] SetEntriesInAcl error (code ' , Code, ' ).' );
685
+ end ;
686
+ end ;
687
+
642
688
procedure ExtractFiles ;
643
689
var
644
690
RDPClipRes, RfxvmtRes, S: String;
645
691
OnlineINI: TStringList;
646
692
begin
647
693
if not DirectoryExists(ExtractFilePath(ExpandPath(WrapPath))) then
648
- if ForceDirectories(ExtractFilePath(ExpandPath(WrapPath))) then
649
- Writeln(' [+] Folder created: ' , ExtractFilePath(ExpandPath(WrapPath)))
694
+ if ForceDirectories(ExtractFilePath(ExpandPath(WrapPath))) then begin
695
+ S := ExtractFilePath(ExpandPath(WrapPath));
696
+ Writeln(' [+] Folder created: ' , S);
697
+ GrantSidFullAccess(S, ' S-1-5-18' ); // Local System account
698
+ GrantSidFullAccess(S, ' S-1-5-6' ); // Service group
699
+ end
650
700
else begin
651
701
Writeln(' [-] ForceDirectories error.' );
652
702
Writeln(' [*] Path: ' , ExtractFilePath(ExpandPath(WrapPath)));
@@ -1080,8 +1130,8 @@ var
1080
1130
I: Integer;
1081
1131
begin
1082
1132
Writeln(' RDP Wrapper Library v1.6.2' );
1083
- Writeln(' Installer v2.5 ' );
1084
- Writeln(' Copyright (C) Stas'' M Corp. 2017 ' );
1133
+ Writeln(' Installer v2.6 ' );
1134
+ Writeln(' Copyright (C) Stas'' M Corp. 2018 ' );
1085
1135
Writeln(' ' );
1086
1136
1087
1137
if (ParamCount < 1 )
0 commit comments