diff --git a/src-RDP_C&C/LicenseUnit.dcu b/src-RDP_C&C/LicenseUnit.dcu new file mode 100644 index 00000000..525dd652 Binary files /dev/null and b/src-RDP_C&C/LicenseUnit.dcu differ diff --git a/src-RDP_C&C/LicenseUnit.dfm b/src-RDP_C&C/LicenseUnit.dfm new file mode 100644 index 00000000..000ccb90 --- /dev/null +++ b/src-RDP_C&C/LicenseUnit.dfm @@ -0,0 +1,64 @@ +object LicenseForm: TLicenseForm + Left = 0 + Top = 0 + BorderIcons = [] + BorderStyle = bsDialog + Caption = 'License Agreement' + ClientHeight = 346 + ClientWidth = 539 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Position = poOwnerFormCenter + PixelsPerInch = 96 + TextHeight = 13 + object mText: TMemo + Left = 8 + Top = 8 + Width = 523 + Height = 297 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + WordWrap = False + end + object bAccept: TButton + Left = 91 + Top = 311 + Width = 150 + Height = 30 + Caption = '&Accept' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ModalResult = 1 + ParentFont = False + TabOrder = 1 + end + object bDecline: TButton + Left = 292 + Top = 311 + Width = 150 + Height = 30 + Caption = '&Decline' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ModalResult = 2 + ParentFont = False + TabOrder = 2 + end +end diff --git a/src-RDP_C&C/LicenseUnit.pas b/src-RDP_C&C/LicenseUnit.pas new file mode 100644 index 00000000..a44a2ad7 --- /dev/null +++ b/src-RDP_C&C/LicenseUnit.pas @@ -0,0 +1,43 @@ +{ + Copyright 2014 Stas'M Corp. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +} + +unit LicenseUnit; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls; + +type + TLicenseForm = class(TForm) + mText: TMemo; + bAccept: TButton; + bDecline: TButton; + private + { Private declarations } + public + { Public declarations } + end; + +var + LicenseForm: TLicenseForm; + +implementation + +{$R *.dfm} + +end. diff --git a/src-RDP_C&C/MainUnit.dcu b/src-RDP_C&C/MainUnit.dcu new file mode 100644 index 00000000..722aa3c2 Binary files /dev/null and b/src-RDP_C&C/MainUnit.dcu differ diff --git a/src-RDP_C&C/MainUnit.dfm b/src-RDP_C&C/MainUnit.dfm new file mode 100644 index 00000000..a7239c84 --- /dev/null +++ b/src-RDP_C&C/MainUnit.dfm @@ -0,0 +1,510 @@ +object MainForm: TMainForm + Left = 0 + Top = 0 + BorderStyle = bsDialog + Caption = 'RDP Wrapper Configuration and Check utility by sebaxakerhtc' + ClientHeight = 442 + ClientWidth = 566 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Position = poDesktopCenter + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object bOK: TButton + Left = 0 + Top = 404 + Width = 138 + Height = 30 + Caption = 'OK' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ModalResult = 1 + ParentFont = False + TabOrder = 4 + OnClick = bOKClick + end + object bCancel: TButton + Left = 150 + Top = 404 + Width = 130 + Height = 30 + Caption = 'Cancel' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ModalResult = 2 + ParentFont = False + TabOrder = 5 + OnClick = bCancelClick + end + object bApply: TButton + Left = 290 + Top = 404 + Width = 130 + Height = 30 + Caption = 'Apply' + Enabled = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 6 + OnClick = bApplyClick + end + object rgNLA: TRadioGroup + Left = 290 + Top = 195 + Width = 268 + Height = 143 + BiDiMode = bdLeftToRight + Caption = 'Authentication Mode' + DefaultHeaderFont = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + HeaderFont.Charset = DEFAULT_CHARSET + HeaderFont.Color = clWindowText + HeaderFont.Height = -13 + HeaderFont.Name = 'Tahoma' + HeaderFont.Style = [fsBold] + Items.Strings = ( + 'GUI Authentication Only' + 'Default RDP Authentication' + 'Network Level Authentication') + ParentBiDiMode = False + ParentFont = False + TabOrder = 2 + OnClick = cbAllowTSConnectionsClick + end + object rgShadow: TRadioGroup + Left = 8 + Top = 195 + Width = 272 + Height = 143 + BiDiMode = bdLeftToRight + Caption = 'Session Shadowing Mode' + DefaultHeaderFont = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + HeaderFont.Charset = DEFAULT_CHARSET + HeaderFont.Color = clWindowText + HeaderFont.Height = -13 + HeaderFont.Name = 'Tahoma' + HeaderFont.Style = [fsBold] + Items.Strings = ( + 'Disable Shadowing' + 'Full access with user'#39's permission' + 'Full access without permission' + 'View only with user'#39's permission' + 'View only without permission') + ParentBiDiMode = False + ParentFont = False + TabOrder = 3 + OnClick = cbAllowTSConnectionsClick + end + object bLicense: TButton + Left = 432 + Top = 404 + Width = 130 + Height = 30 + Caption = 'View license...' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 7 + OnClick = bLicenseClick + end + object gbDiag: TGroupBox + Left = 8 + Top = 6 + Width = 272 + Height = 183 + BiDiMode = bdLeftToRight + Caption = 'Diagnostics' + DefaultHeaderFont = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + HeaderFont.Charset = DEFAULT_CHARSET + HeaderFont.Color = clWindowText + HeaderFont.Height = -13 + HeaderFont.Name = 'Tahoma' + HeaderFont.Style = [fsBold] + ParentBiDiMode = False + ParentFont = False + TabOrder = 0 + object lListener: TLabel + Left = 7 + Top = 90 + Width = 99 + Height = 19 + Caption = 'Listener state:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object lService: TLabel + Left = 7 + Top = 68 + Width = 94 + Height = 19 + Caption = 'Service state:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object lsListener: TLabel + Left = 117 + Top = 90 + Width = 76 + Height = 19 + Caption = 'Unknown' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lsService: TLabel + Left = 117 + Top = 68 + Width = 76 + Height = 19 + Caption = 'Unknown' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lsTSVer: TLabel + Left = 117 + Top = 112 + Width = 76 + Height = 19 + Caption = 'Unknown' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lsWrapper: TLabel + Left = 117 + Top = 24 + Width = 76 + Height = 19 + Caption = 'Unknown' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lsWrapVer: TLabel + Left = 117 + Top = 46 + Width = 76 + Height = 19 + Caption = 'Unknown' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lTSVer: TLabel + Left = 7 + Top = 112 + Width = 86 + Height = 19 + Caption = 'termsrv ver.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object lWrapper: TLabel + Left = 7 + Top = 24 + Width = 104 + Height = 19 + Caption = 'Wrapper state:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object lWrapVer: TLabel + Left = 7 + Top = 46 + Width = 92 + Height = 19 + Caption = 'Wrapper ver.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object lsSuppVer: TLabel + Left = 46 + Top = 137 + Width = 155 + Height = 25 + Caption = '[support level]' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -21 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + end + object gbGeneral: TGroupBox + Left = 290 + Top = 8 + Width = 268 + Height = 181 + BiDiMode = bdLeftToRight + Caption = ' General Settings' + DefaultHeaderFont = False + HeaderFont.Charset = DEFAULT_CHARSET + HeaderFont.Color = clWindowText + HeaderFont.Height = -13 + HeaderFont.Name = 'Tahoma' + HeaderFont.Style = [fsBold] + ParentBiDiMode = False + TabOrder = 1 + object lRDPPort: TLabel + Left = 19 + Top = 29 + Width = 70 + Height = 19 + Caption = 'RDP port:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object cbAllowTSConnections: TCheckBox + Left = 16 + Top = 54 + Width = 209 + Height = 38 + Caption = 'Enable Remote Desktop' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + OnClick = cbAllowTSConnectionsClick + end + object cbSingleSessionPerUser: TCheckBox + Left = 16 + Top = 91 + Width = 209 + Height = 28 + Caption = 'Single session per user' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 2 + OnClick = cbAllowTSConnectionsClick + end + object cbHideUsers: TCheckBox + Left = 16 + Top = 114 + Width = 257 + Height = 39 + Caption = 'Hide users on logon screen' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 3 + OnClick = cbAllowTSConnectionsClick + end + object seRDPPort: TSpinEdit + Left = 108 + Top = 26 + Width = 93 + Height = 29 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + MaxValue = 65535 + MinValue = 0 + ParentFont = False + TabOrder = 1 + Value = 0 + OnChange = seRDPPortChange + end + object cbCustomPrg: TCheckBox + Left = 16 + Top = 145 + Width = 225 + Height = 36 + Caption = 'Allow unlisted RemoteApps' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 4 + OnClick = cbAllowTSConnectionsClick + end + end + object gbLocalRDPChecker: TGroupBox + Left = 8 + Top = 344 + Width = 545 + Height = 54 + Hint = + 'Choose your resolution. We prefore "mstsc" button. You can click' + + ' every button many times ;)' + Caption = ' Integrated Local RDP Checker' + DefaultHeaderFont = False + HeaderFont.Charset = DEFAULT_CHARSET + HeaderFont.Color = clWindowText + HeaderFont.Height = -13 + HeaderFont.Name = 'Tahoma' + HeaderFont.Style = [fsBold] + ParentShowHint = False + ShowHint = True + TabOrder = 8 + object bmstsc: TButton + Left = 11 + Top = 21 + Width = 100 + Height = 25 + Caption = 'mstsc' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 0 + OnClick = bmstscClick + end + object b800x600: TButton + Left = 117 + Top = 21 + Width = 100 + Height = 25 + Caption = '800x600' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 1 + OnClick = b800x600Click + end + object b1024x768: TButton + Left = 223 + Top = 21 + Width = 100 + Height = 25 + Caption = '1024x768' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 2 + OnClick = b1024x768Click + end + object b1366x768: TButton + Left = 329 + Top = 21 + Width = 100 + Height = 25 + Caption = '1366x768' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 3 + OnClick = b1366x768Click + end + object b1920x1080: TButton + Left = 435 + Top = 21 + Width = 100 + Height = 25 + Caption = '1920x1080' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 4 + OnClick = b1920x1080Click + end + end + object Timer: TTimer + Interval = 250 + OnTimer = TimerTimer + Left = 248 + Top = 27 + end +end diff --git a/src-RDP_C&C/MainUnit.pas b/src-RDP_C&C/MainUnit.pas new file mode 100644 index 00000000..c824bf29 --- /dev/null +++ b/src-RDP_C&C/MainUnit.pas @@ -0,0 +1,722 @@ +{ + Copyright 2017 Stas'M Corp. + Copyright 2021 sebaxakerhtc + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +} +unit MainUnit; +interface +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, Spin, ExtCtrls, WinSvc, MSTSCLib_TLB, Registry, ShellAPI; +type + TMainForm = class(TForm) + bOK: TButton; + bCancel: TButton; + bApply: TButton; + cbSingleSessionPerUser: TCheckBox; + rgNLA: TRadioGroup; + cbAllowTSConnections: TCheckBox; + rgShadow: TRadioGroup; + seRDPPort: TSpinEdit; + lRDPPort: TLabel; + lService: TLabel; + lListener: TLabel; + lWrapper: TLabel; + lsListener: TLabel; + lsService: TLabel; + lsWrapper: TLabel; + Timer: TTimer; + lTSVer: TLabel; + lsTSVer: TLabel; + lWrapVer: TLabel; + lsWrapVer: TLabel; + bLicense: TButton; + gbDiag: TGroupBox; + lsSuppVer: TLabel; + cbHideUsers: TCheckBox; + gbGeneral: TGroupBox; + cbCustomPrg: TCheckBox; + gbLocalRDPChecker: TGroupBox; + bmstsc: TButton; + b800x600: TButton; + b1024x768: TButton; + b1366x768: TButton; + b1920x1080: TButton; + procedure FormCreate(Sender: TObject); + procedure cbAllowTSConnectionsClick(Sender: TObject); + procedure seRDPPortChange(Sender: TObject); + procedure bApplyClick(Sender: TObject); + procedure bCancelClick(Sender: TObject); + procedure bOKClick(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure bLicenseClick(Sender: TObject); + procedure TimerTimer(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure bmstscClick(Sender: TObject); + procedure b800x600Click(Sender: TObject); + procedure b1024x768Click(Sender: TObject); + procedure b1366x768Click(Sender: TObject); + procedure b1920x1080Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + function ExecWait(Cmdline: String): Boolean; + procedure ReadSettings; + procedure WriteSettings; + end; + FILE_VERSION = record + Version: record case Boolean of + True: (dw: DWORD); + False: (w: record + Minor, Major: Word; + end;) + end; + Release, Build: Word; + bDebug, bPrerelease, bPrivate, bSpecial: Boolean; + end; + WTS_SESSION_INFOW = record + SessionId: DWORD; + Name: packed array [0..33] of WideChar; + State: DWORD; + end; + WTS_SESSION = Array[0..0] of WTS_SESSION_INFOW; + PWTS_SESSION_INFOW = ^WTS_SESSION; +const + winstadll = 'winsta.dll'; +var + MainForm: TMainForm; + Ready: Boolean = False; + Arch: Byte; + OldWow64RedirectionValue: LongBool; + OldPort: Word; + INI: String; +function WinStationEnumerateW(hServer: THandle; + var ppSessionInfo: PWTS_SESSION_INFOW; var pCount: DWORD): BOOL; stdcall; + external winstadll name 'WinStationEnumerateW'; +function WinStationFreeMemory(P: Pointer): BOOL; stdcall; external winstadll; +implementation +{$R *.dfm} +{$R resource.res} +uses + LicenseUnit, RDPUnit; +function ExpandPath(Path: String): String; +var + Str: Array[0..511] of Char; +begin + Result := ''; + FillChar(Str, 512, 0); + if Arch = 64 then + Path := StringReplace(Path, '%ProgramFiles%', '%ProgramW6432%', [rfReplaceAll, rfIgnoreCase]); + if ExpandEnvironmentStrings(PWideChar(Path), Str, 512) > 0 then + Result := Str; +end; +function DisableWowRedirection: Boolean; +type + TFunc = function(var Wow64FsEnableRedirection: LongBool): LongBool; stdcall; +var + hModule: THandle; + Wow64DisableWow64FsRedirection: TFunc; +begin + Result := False; + hModule := GetModuleHandle(kernel32); + if hModule <> 0 then + Wow64DisableWow64FsRedirection := GetProcAddress(hModule, 'Wow64DisableWow64FsRedirection') + else + Exit; + if @Wow64DisableWow64FsRedirection <> nil then + Result := Wow64DisableWow64FsRedirection(OldWow64RedirectionValue); +end; +function RevertWowRedirection: Boolean; +type + TFunc = function(var Wow64RevertWow64FsRedirection: LongBool): LongBool; stdcall; +var + hModule: THandle; + Wow64RevertWow64FsRedirection: TFunc; +begin + Result := False; + hModule := GetModuleHandle(kernel32); + if hModule <> 0 then + Wow64RevertWow64FsRedirection := GetProcAddress(hModule, 'Wow64RevertWow64FsRedirection') + else + Exit; + if @Wow64RevertWow64FsRedirection <> nil then + Result := Wow64RevertWow64FsRedirection(OldWow64RedirectionValue); +end; +function GetFileVersion(const FileName: TFileName; var FileVersion: FILE_VERSION): Boolean; +type + VS_VERSIONINFO = record + wLength, wValueLength, wType: Word; + szKey: Array[1..16] of WideChar; + Padding1: Word; + Value: VS_FIXEDFILEINFO; + Padding2, Children: Word; + end; + PVS_VERSIONINFO = ^VS_VERSIONINFO; +const + VFF_DEBUG = 1; + VFF_PRERELEASE = 2; + VFF_PRIVATE = 8; + VFF_SPECIAL = 32; +var + hFile: HMODULE; + hResourceInfo: HRSRC; + VersionInfo: PVS_VERSIONINFO; +begin + Result := False; + hFile := LoadLibraryEx(PWideChar(FileName), 0, LOAD_LIBRARY_AS_DATAFILE); + if hFile = 0 then + Exit; + hResourceInfo := FindResource(hFile, PWideChar(1), PWideChar($10)); + if hResourceInfo = 0 then + Exit; + VersionInfo := Pointer(LoadResource(hFile, hResourceInfo)); + if VersionInfo = nil then + Exit; + FileVersion.Version.dw := VersionInfo.Value.dwFileVersionMS; + FileVersion.Release := Word(VersionInfo.Value.dwFileVersionLS shr 16); + FileVersion.Build := Word(VersionInfo.Value.dwFileVersionLS); + FileVersion.bDebug := (VersionInfo.Value.dwFileFlags and VFF_DEBUG) = VFF_DEBUG; + FileVersion.bPrerelease := (VersionInfo.Value.dwFileFlags and VFF_PRERELEASE) = VFF_PRERELEASE; + FileVersion.bPrivate := (VersionInfo.Value.dwFileFlags and VFF_PRIVATE) = VFF_PRIVATE; + FileVersion.bSpecial := (VersionInfo.Value.dwFileFlags and VFF_SPECIAL) = VFF_SPECIAL; + FreeLibrary(hFile); + Result := True; +end; +function IsWrapperInstalled(var WrapperPath: String): ShortInt; +var + TermServiceHost, + TermServicePath: String; + Reg: TRegistry; +begin + Result := -1; + WrapperPath := ''; + Reg := TRegistry.Create; + Reg.RootKey := HKEY_LOCAL_MACHINE; + if not Reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Services\TermService') then begin + Reg.Free; + Exit; + end; + TermServiceHost := Reg.ReadString('ImagePath'); + Reg.CloseKey; + if Pos('svchost.exe', LowerCase(TermServiceHost)) = 0 then + begin + Result := 2; + Reg.Free; + Exit; + end; + if not Reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Services\TermService\Parameters') then + begin + Reg.Free; + Exit; + end; + TermServicePath := Reg.ReadString('ServiceDll'); + Reg.CloseKey; + Reg.Free; + if (Pos('termsrv.dll', LowerCase(TermServicePath)) = 0) + and (Pos('rdpwrap.dll', LowerCase(TermServicePath)) = 0) then + begin + Result := 2; + Exit; + end; + if Pos('rdpwrap.dll', LowerCase(TermServicePath)) > 0 then begin + WrapperPath := TermServicePath; + Result := 1; + end else + Result := 0; +end; +function GetTermSrvState: ShortInt; +type + SERVICE_STATUS_PROCESS = record + dwServiceType, + dwCurrentState, + dwControlsAccepted, + dwWin32ExitCode, + dwServiceSpecificExitCode, + dwCheckPoint, + dwWaitHint, + dwProcessId, + dwServiceFlags: DWORD; + end; + PSERVICE_STATUS_PROCESS = ^SERVICE_STATUS_PROCESS; +const + SvcName = 'TermService'; +var + hSC: SC_HANDLE; + hSvc: THandle; + lpServiceStatusProcess: PSERVICE_STATUS_PROCESS; + Buf: Pointer; + cbBufSize, pcbBytesNeeded: Cardinal; +begin + Result := -1; + hSC := OpenSCManager(nil, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CONNECT); + if hSC = 0 then + Exit; + hSvc := OpenService(hSC, PWideChar(SvcName), SERVICE_QUERY_STATUS); + if hSvc = 0 then + begin + CloseServiceHandle(hSC); + Exit; + end; + if QueryServiceStatusEx(hSvc, SC_STATUS_PROCESS_INFO, nil, 0, pcbBytesNeeded) then + Exit; + cbBufSize := pcbBytesNeeded; + GetMem(Buf, cbBufSize); + if not QueryServiceStatusEx(hSvc, SC_STATUS_PROCESS_INFO, Buf, cbBufSize, pcbBytesNeeded) then begin + FreeMem(Buf, cbBufSize); + CloseServiceHandle(hSvc); + CloseServiceHandle(hSC); + Exit; + end else begin + lpServiceStatusProcess := Buf; + Result := ShortInt(lpServiceStatusProcess^.dwCurrentState); + end; + FreeMem(Buf, cbBufSize); + CloseServiceHandle(hSvc); + CloseServiceHandle(hSC); +end; +function IsListenerWorking: Boolean; +var + pCount: DWORD; + SessionInfo: PWTS_SESSION_INFOW; + I: Integer; +begin + Result := False; + if not WinStationEnumerateW(0, SessionInfo, pCount) then + Exit; + for I := 0 to pCount - 1 do + if SessionInfo^[I].Name = 'RDP-Tcp' then begin + Result := True; + Break; + end; + WinStationFreeMemory(SessionInfo); +end; +function ExtractResText(ResName: String): String; +var + ResStream: TResourceStream; + Str: TStringList; +begin + ResStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA); + Str := TStringList.Create; + try + Str.LoadFromStream(ResStream); + except + end; + ResStream.Free; + Result := Str.Text; + Str.Free; +end; +function TMainForm.ExecWait(Cmdline: String): Boolean; +var + si: STARTUPINFO; + pi: PROCESS_INFORMATION; +begin + Result := False; + ZeroMemory(@si, sizeof(si)); + si.cb := sizeof(si); + si.dwFlags := STARTF_USESHOWWINDOW; + si.wShowWindow := SW_HIDE; + UniqueString(Cmdline); + if not CreateProcess(nil, PWideChar(Cmdline), nil, nil, True, 0, nil, nil, si, pi) then begin + MessageBox(Handle, + PWideChar('CreateProcess error (code: ' + IntToStr(GetLastError) + ').'), + 'Error', MB_ICONERROR or MB_OK); + Exit; + end; + CloseHandle(pi.hThread); + WaitForSingleObject(pi.hProcess, INFINITE); + CloseHandle(pi.hProcess); + Result := True; +end; +procedure TMainForm.ReadSettings; +var + Reg: TRegistry; + SecurityLayer, UserAuthentication: Integer; +begin + Reg := TRegistry.Create; + Reg.RootKey := HKEY_LOCAL_MACHINE; + Reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Control\Terminal Server'); + try + cbAllowTSConnections.Checked := not Reg.ReadBool('fDenyTSConnections'); + except + end; + try + cbSingleSessionPerUser.Checked := Reg.ReadBool('fSingleSessionPerUser'); + except + end; + try + cbCustomPrg.Checked := Reg.ReadBool('HonorLegacySettings'); + except + end; + Reg.CloseKey; + Reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'); + seRDPPort.Value := 3389; + try + seRDPPort.Value := Reg.ReadInteger('PortNumber'); + except + end; + OldPort := seRDPPort.Value; + SecurityLayer := 0; + UserAuthentication := 0; + try + SecurityLayer := Reg.ReadInteger('SecurityLayer'); + UserAuthentication := Reg.ReadInteger('UserAuthentication'); + except + end; + if (SecurityLayer = 0) and (UserAuthentication = 0) then + rgNLA.ItemIndex := 0; + if (SecurityLayer = 1) and (UserAuthentication = 0) then + rgNLA.ItemIndex := 1; + if (SecurityLayer = 2) and (UserAuthentication = 1) then + rgNLA.ItemIndex := 2; + try + rgShadow.ItemIndex := Reg.ReadInteger('Shadow'); + except + end; + Reg.CloseKey; + Reg.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'); + try + cbHideUsers.Checked := Reg.ReadBool('dontdisplaylastusername'); + except + end; + Reg.CloseKey; + Reg.Free; +end; +procedure TMainForm.WriteSettings; +var + Reg: TRegistry; + SecurityLayer, UserAuthentication: Integer; +begin + Reg := TRegistry.Create; + Reg.RootKey := HKEY_LOCAL_MACHINE; + Reg.OpenKey('\SYSTEM\CurrentControlSet\Control\Terminal Server', True); + try + Reg.WriteBool('fDenyTSConnections', not cbAllowTSConnections.Checked); + except + end; + try + Reg.WriteBool('fSingleSessionPerUser', cbSingleSessionPerUser.Checked); + except + end; + try + Reg.WriteBool('HonorLegacySettings', cbCustomPrg.Checked); + except + end; + Reg.CloseKey; + Reg.OpenKey('\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp', True); + try + Reg.WriteInteger('PortNumber', seRDPPort.Value); + except + end; + if OldPort <> seRDPPort.Value then + begin + OldPort := seRDPPort.Value; + ExecWait('netsh advfirewall firewall set rule name="Remote Desktop" new localport=' + IntToStr(OldPort)); + end; + case rgNLA.ItemIndex of + 0: begin + SecurityLayer := 0; + UserAuthentication := 0; + end; + 1: begin + SecurityLayer := 1; + UserAuthentication := 0; + end; + 2: begin + SecurityLayer := 2; + UserAuthentication := 1; + end; + else begin + SecurityLayer := -1; + UserAuthentication := -1; + end; + end; + if SecurityLayer >= 0 then begin + try + Reg.WriteInteger('SecurityLayer', SecurityLayer); + Reg.WriteInteger('UserAuthentication', UserAuthentication); + except + end; + end; + if rgShadow.ItemIndex >= 0 then begin + try + Reg.WriteInteger('Shadow', rgShadow.ItemIndex); + except + end; + end; + Reg.CloseKey; + Reg.OpenKey('\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services', True); + if rgShadow.ItemIndex >= 0 then begin + try + Reg.WriteInteger('Shadow', rgShadow.ItemIndex); + except + end; + end; + Reg.CloseKey; + Reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', True); + try + Reg.WriteBool('dontdisplaylastusername', cbHideUsers.Checked); + except + end; + Reg.CloseKey; + Reg.Free; +end; +function CheckSupport(FV: FILE_VERSION): Byte; +var + VerTxt: String; +begin + Result := 0; + if (FV.Version.w.Major = 6) and (FV.Version.w.Minor = 0) then + Result := 1; + if (FV.Version.w.Major = 6) and (FV.Version.w.Minor = 1) then + Result := 1; + VerTxt := Format('%d.%d.%d.%d', + [FV.Version.w.Major, FV.Version.w.Minor, FV.Release, FV.Build]); + if Pos('[' + VerTxt + ']', INI) > 0 then + Result := 2; +end; +procedure TMainForm.TimerTimer(Sender: TObject); +var + WrapperPath, INIPath: String; + FV: FILE_VERSION; + L: TStringList; + CheckSupp: Boolean; +begin + CheckSupp := False; + case IsWrapperInstalled(WrapperPath) of + -1: begin + lsWrapper.Caption := 'Unknown'; + lsWrapper.Font.Color := clGrayText; + end; + 0: begin + lsWrapper.Caption := 'Not installed'; + lsWrapper.Font.Color := clGrayText; + end; + 1: begin + lsWrapper.Caption := 'Installed'; + lsWrapper.StyleElements := lsWrapper.StyleElements - [seFont]; + lsWrapper.Font.Color := clGreen; + CheckSupp := True; + INIPath := ExtractFilePath(ExpandPath(WrapperPath)) + 'rdpwrap.ini'; + if not FileExists(INIPath) then + CheckSupp := False; + end; + 2: begin + lsWrapper.Caption := '3rd-party'; + lsWrapper.StyleElements := lsWrapper.StyleElements - [seFont]; + lsWrapper.Font.Color := clRed; + end; + end; + case GetTermSrvState of + -1, 0: begin + lsService.Caption := 'Unknown'; + lsService.Font.Color := clGrayText; + end; + SERVICE_STOPPED: begin + lsService.Caption := 'Stopped'; + lsService.StyleElements := lsService.StyleElements - [seFont]; + lsService.Font.Color := clRed; + end; + SERVICE_START_PENDING: begin + lsService.Caption := 'Starting...'; + lsService.Font.Color := clGrayText; + end; + SERVICE_STOP_PENDING: begin + lsService.Caption := 'Stopping...'; + lsService.Font.Color := clGrayText; + end; + SERVICE_RUNNING: begin + lsService.Caption := 'Running'; + lsService.StyleElements := lsService.StyleElements - [seFont]; + lsService.Font.Color := clGreen; + end; + SERVICE_CONTINUE_PENDING: begin + lsService.Caption := 'Resuming...'; + lsService.Font.Color := clGrayText; + end; + SERVICE_PAUSE_PENDING: begin + lsService.Caption := 'Suspending...'; + lsService.Font.Color := clGrayText; + end; + SERVICE_PAUSED: begin + lsService.Caption := 'Suspended'; + lsService.Font.Color := clWindowText; + end; + end; + if IsListenerWorking then begin + lsListener.Caption := 'Listening'; + lsListener.StyleElements := lsListener.StyleElements - [seFont]; + lsListener.Font.Color := clGreen; + end else begin + lsListener.Caption := 'Not listening'; + lsListener.StyleElements := lsListener.StyleElements - [seFont]; + lsListener.Font.Color := clRed; + end; + if WrapperPath = '' then begin + lsWrapVer.Caption := 'N/A'; + lsWrapVer.Font.Color := clGrayText; + end else + if not GetFileVersion(ExpandPath(WrapperPath), FV) then begin + lsWrapVer.Caption := 'N/A'; + lsWrapVer.Font.Color := clGrayText; + end else begin + lsWrapVer.Caption := + IntToStr(FV.Version.w.Major)+'.'+ + IntToStr(FV.Version.w.Minor)+'.'+ + IntToStr(FV.Release)+'.'+ + IntToStr(FV.Build); + lsWrapVer.Font.Color := clWindowText; + end; + if not GetFileVersion('termsrv.dll', FV) then begin + lsTSVer.Caption := 'N/A'; + lsTSVer.Font.Color := clGrayText; + end else begin + lsTSVer.Caption := + IntToStr(FV.Version.w.Major)+'.'+ + IntToStr(FV.Version.w.Minor)+'.'+ + IntToStr(FV.Release)+'.'+ + IntToStr(FV.Build); + lsTSVer.Font.Color := clWindowText; + lsSuppVer.Visible := CheckSupp; + if CheckSupp then begin + if INI = '' then begin + L := TStringList.Create; + try + L.LoadFromFile(INIPath); + except + end; + INI := L.Text; + L.Free; + end; + case CheckSupport(FV) of + 0: begin + lsSuppVer.Caption := '[not supported]'; + lsSuppVer.StyleElements := lsSuppVer.StyleElements - [seFont]; + lsSuppVer.Font.Color := clRed; + end; + 1: begin + lsSuppVer.Caption := '[supported partially]'; + lsSuppVer.StyleElements := lsSuppVer.StyleElements - [seFont]; + lsSuppVer.Font.Color := clOlive; + end; + 2: begin + lsSuppVer.Caption := '[fully supported]'; + lsSuppVer.StyleElements := lsSuppVer.StyleElements - [seFont]; + lsSuppVer.Font.Color := clGreen; + end; + end; + end; + end; +end; +procedure TMainForm.bLicenseClick(Sender: TObject); +begin + LicenseForm.mText.Text := ExtractResText('LICENSE'); + if LicenseForm.ShowModal <> mrOk then + Halt(0); +end; +procedure TMainForm.cbAllowTSConnectionsClick(Sender: TObject); +begin + if Ready then + bApply.Enabled := True; +end; +procedure TMainForm.seRDPPortChange(Sender: TObject); +begin + if Ready then + bApply.Enabled := True; +end; +procedure TMainForm.FormCreate(Sender: TObject); +var + SI: TSystemInfo; +begin + GetNativeSystemInfo(SI); + case SI.wProcessorArchitecture of + 0: Arch := 32; + 6: Arch := 64; // Itanium-based x64 + 9: Arch := 64; // Intel/AMD x64 + else Arch := 0; + end; + if Arch = 64 then + DisableWowRedirection; + ReadSettings; + Ready := True; +end; +procedure TMainForm.FormDestroy(Sender: TObject); +begin + if Arch = 64 then + RevertWowRedirection; +end; +procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + if bApply.Enabled then + CanClose := MessageBox(Handle, 'Settings are not saved. Do you want to exit?', + 'Warning', mb_IconWarning or mb_YesNo) = mrYes; +end; +procedure TMainForm.bOKClick(Sender: TObject); +begin + if bApply.Enabled then begin + WriteSettings; + bApply.Enabled := False; + end; + Close; +end; + +procedure TMainForm.bCancelClick(Sender: TObject); +begin + Close; +end; + +procedure TMainForm.bmstscClick(Sender: TObject); +begin + ShellExecute(0, nil, 'mstsc', '/v:127.0.0.2 /prompt', nil, SW_SHOW); +// RDPForm := TRDPForm.Create(Self); +// RDPForm.RDPmstsc.Width := 640; +// RDPForm.RDPmstsc.Height := 480; +// RDPForm.Show; +end; + +procedure TMainForm.b800x600Click(Sender: TObject); +begin + RDPForm := TRDPForm.Create(Self); + RDPForm.RDPmstsc.Width := 800; + RDPForm.RDPmstsc.Height := 600; + RDPForm.Show; +end; + +procedure TMainForm.b1024x768Click(Sender: TObject); +begin + RDPForm := TRDPForm.Create(Self); + RDPForm.RDPmstsc.Width := 1024; + RDPForm.RDPmstsc.Height := 768; + RDPForm.Show; +end; + +procedure TMainForm.b1366x768Click(Sender: TObject); +begin + RDPForm := TRDPForm.Create(Self); + RDPForm.RDPmstsc.Width := 1366; + RDPForm.RDPmstsc.Height := 768; + RDPForm.Show +end; + +procedure TMainForm.b1920x1080Click(Sender: TObject); +begin + RDPForm := TRDPForm.Create(Self); + RDPForm.RDPmstsc.Width := 1920; + RDPForm.RDPmstsc.Height := 1080; + RDPForm.Show +end; + +procedure TMainForm.bApplyClick(Sender: TObject); +begin + WriteSettings; + bApply.Enabled := False; +end; +end. diff --git a/src-RDP_C&C/RDP.ico b/src-RDP_C&C/RDP.ico new file mode 100644 index 00000000..4b6866db Binary files /dev/null and b/src-RDP_C&C/RDP.ico differ diff --git a/src-RDP_C&C/RDPConf.dpr b/src-RDP_C&C/RDPConf.dpr new file mode 100644 index 00000000..f1c36d52 --- /dev/null +++ b/src-RDP_C&C/RDPConf.dpr @@ -0,0 +1,32 @@ +{ + Copyright 2014 Stas'M Corp. + Copyright 2021 sebaxakerhtc + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +} +program RDPConf; +uses + Forms, + MainUnit in 'MainUnit.pas' {MainForm}, + LicenseUnit in 'LicenseUnit.pas' {LicenseForm}, + Vcl.Themes, + Vcl.Styles, + RDPUnit in 'RDPUnit.pas' {RDPForm}; + +{$R *.res} +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Remote Desktop Protocol Configuration'; + Application.CreateForm(TMainForm, MainForm); + Application.CreateForm(TLicenseForm, LicenseForm); + Application.CreateForm(TRDPForm, RDPForm); + Application.Run; +end. diff --git a/src-RDP_C&C/RDPConf.dproj b/src-RDP_C&C/RDPConf.dproj new file mode 100644 index 00000000..9647b26c --- /dev/null +++ b/src-RDP_C&C/RDPConf.dproj @@ -0,0 +1,1011 @@ + + + {A7CB4C30-85F5-4D96-B510-6F0CDCF7C2DA} + 19.3 + RDPConf.dpr + Release + DCC32 + VCL + True + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + ..\bin\ + ..\bin\RDPConf.exe + 00400000 + x86 + RDPConf + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;System.Win;$(DCC_Namespace) + 1033 + Carbon|VCLSTYLE|$(BDSCOMMONDIR)\Styles\Carbon.vsf;Glossy|VCLSTYLE|$(BDSCOMMONDIR)\Styles\Glossy.vsf + CompanyName=Stas'M Corp.;FileDescription=RDP Configuration Program;FileVersion=1.0.0.0;InternalName=RDPConf;LegalCopyright=Copyright © Stas'M Corp. 2014;LegalTrademarks=Stas'M Corp.;OriginalFilename=RDPConf.exe;ProductName=RDP Host Support;ProductVersion=1.4.0.0;Comments=http://stascorp.com + + + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + 1033 + $(BDS)\bin\default_app.manifest + true + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitorV2 + CompanyName=Thanks to Stas'M Corp for this project;FileDescription=RDP Wrapper Configuration and Check utility by sebaxakerhtc;FileVersion=1.8.5.0;InternalName=RDP Wrapper Configuration and Check utility by sebaxakerhtc;LegalCopyright=sebaxakerhtc;LegalTrademarks=Stas'M Corp;OriginalFilename=RDP_C&C;ProductName=RDP_C&C;ProductVersion=1.8.5.0;Comments=https://sebaxakerhtc.github.io;ProgramID=com.embarcadero.RDP_C&C + RDP.ico + requireAdministrator + true + 8 + 5 + + + DEBUG;$(DCC_Define) + + + true + PerMonitorV2 + true + 7 + 4 + CompanyName=Thanks to Stas'M Corp for this project;FileDescription=RDP Wrapper Configuration utility by sebaxakerhtc;FileVersion=1.7.4.0;InternalName=RDP Wrapper Configuration utility by sebaxakerhtc;LegalCopyright=sebaxakerhtc;LegalTrademarks=Stas'M Corp;OriginalFilename=RDPConf_B;ProductName=$(MSBuildProjectName);ProductVersion=1.7.4.0;Comments=https://sebaxakerhtc.github.io;ProgramID=io.github.sebaxakerhtc.$(MSBuildProjectName) + RDP_B.ico + requireAdministrator + + + + MainSource + + +
MainForm
+
+ +
LicenseForm
+
+ +
RDPForm
+ dfm +
+ + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + +
+ + + Delphi.Personality.12 + + + + + RDPConf.dpr + + + False + True + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1033 + 1252 + + + Stas'M Corp. + RDP Configuration Program + 1.0.0.0 + RDPConf + Copyright © Stas'M Corp. 2014 + Stas'M Corp. + RDPConf.exe + RDP Host Support + 1.4.0.0 + http://stascorp.com + + + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + + + RDPConf.exe + true + + + + + RDPConf.exe + true + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 64 + + + classes + 64 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + + + + 12 + + + +
diff --git a/src-RDP_C&C/RDPConf.res b/src-RDP_C&C/RDPConf.res new file mode 100644 index 00000000..4bf9a740 Binary files /dev/null and b/src-RDP_C&C/RDPConf.res differ diff --git a/src-RDP_C&C/RDPUnit.dcu b/src-RDP_C&C/RDPUnit.dcu new file mode 100644 index 00000000..08ceb6c5 Binary files /dev/null and b/src-RDP_C&C/RDPUnit.dcu differ diff --git a/src-RDP_C&C/RDPUnit.dfm b/src-RDP_C&C/RDPUnit.dfm new file mode 100644 index 00000000..e4cbf74d --- /dev/null +++ b/src-RDP_C&C/RDPUnit.dfm @@ -0,0 +1,26 @@ +object RDPForm: TRDPForm + Left = 0 + Top = 0 + AutoSize = True + BorderIcons = [biSystemMenu, biMinimize] + Caption = 'Integrated Local RDP Checker by sebaxakerhtc' + ClientHeight = 192 + ClientWidth = 192 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -12 + Font.Name = 'Segoe UI' + Font.Style = [] + OnCreate = FormCreate + PixelsPerInch = 96 + TextHeight = 15 + object RDPmstsc: TMsRdpClient9NotSafeForScripting + Left = 0 + Top = 0 + Width = 192 + Height = 192 + TabOrder = 0 + ControlData = {0003000008000200000000000B0000000B000000} + end +end diff --git a/src-RDP_C&C/RDPUnit.pas b/src-RDP_C&C/RDPUnit.pas new file mode 100644 index 00000000..d2aa82a9 --- /dev/null +++ b/src-RDP_C&C/RDPUnit.pas @@ -0,0 +1,129 @@ +unit RDPUnit; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, + Controls, Forms, Dialogs, OleCtrls, OleServer, MSTSCLib_TLB, Registry; + +type + TRDPForm = class(TForm) + RDPmstsc: TMsRdpClient9NotSafeForScripting; + procedure RDPDisconnected(ASender: TObject; discReason: Integer); + procedure FormCreate(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; +var + RDPForm: TRDPForm; + SecurityLayer, UserAuthentication: DWORD; +implementation +{$R *.dfm} +procedure TRDPForm.FormCreate(Sender: TObject); +var + Reg: TRegistry; +begin + RDPmstsc.DisconnectedText := 'Disconnected.'; + RDPmstsc.ConnectingText := 'Connecting...'; + RDPmstsc.ConnectedStatusText := 'Connected.'; + RDPmstsc.UserName := ''; + RDPmstsc.Server := '127.0.0.2'; + Reg := TRegistry.Create; + Reg.RootKey := HKEY_LOCAL_MACHINE; + if Reg.OpenKey('\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp', True) then + begin + try + SecurityLayer := Reg.ReadInteger('SecurityLayer'); + UserAuthentication := Reg.ReadInteger('UserAuthentication'); + Reg.WriteInteger('SecurityLayer', 0); + Reg.WriteInteger('UserAuthentication', 0); + except + end; + Reg.CloseKey; + end; + if Reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp') then begin + try + RDPmstsc.AdvancedSettings2.RDPPort := Reg.ReadInteger('PortNumber'); + except + end; + Reg.CloseKey; + end; + Reg.Free; + Sleep(1000); + RDPmstsc.Connect; +end; +procedure TRDPForm.RDPDisconnected(ASender: TObject; discReason: Integer); +var + ErrStr: String; + Reg: TRegistry; +begin + case discReason of + 1: ErrStr := 'Local disconnection.'; + 2: ErrStr := 'Disconnected by user.'; + 3: ErrStr := 'Disconnected by server.'; + $904: ErrStr := 'Socket closed.'; + $C08: ErrStr := 'Decompress error.'; + $108: ErrStr := 'Connection timed out.'; + $C06: ErrStr := 'Decryption error.'; + $104: ErrStr := 'DNS name lookup failure.'; + $508: ErrStr := 'DNS lookup failed.'; + $B06: ErrStr := 'Encryption error.'; + $604: ErrStr := 'Windows Sockets gethostbyname() call failed.'; + $208: ErrStr := 'Host not found error.'; + $408: ErrStr := 'Internal error.'; + $906: ErrStr := 'Internal security error.'; + $A06: ErrStr := 'Internal security error.'; + $506: ErrStr := 'The encryption method specified is not valid.'; + $804: ErrStr := 'Bad IP address specified.'; + $606: ErrStr := 'Server security data is not valid.'; + $406: ErrStr := 'Security data is not valid.'; + $308: ErrStr := 'The IP address specified is not valid.'; + $808: ErrStr := 'License negotiation failed.'; + $908: ErrStr := 'Licensing time-out.'; + $106: ErrStr := 'Out of memory.'; + $206: ErrStr := 'Out of memory.'; + $306: ErrStr := 'Out of memory.'; + $706: ErrStr := 'Failed to unpack server certificate.'; + $204: ErrStr := 'Socket connection failed.'; + $404: ErrStr := 'Windows Sockets recv() call failed.'; + $704: ErrStr := 'Time-out occurred.'; + $608: ErrStr := 'Internal timer error.'; + $304: ErrStr := 'Windows Sockets send() call failed.'; + $B07: ErrStr := 'The account is disabled.'; + $E07: ErrStr := 'The account is expired.'; + $D07: ErrStr := 'The account is locked out.'; + $C07: ErrStr := 'The account is restricted.'; + $1B07: ErrStr := 'The received certificate is expired.'; + $1607: ErrStr := 'The policy does not support delegation of credentials to the target server.'; + $2107: ErrStr := 'The server authentication policy does not allow connection requests using saved credentials. The user must enter new credentials.'; + $807: ErrStr := 'Login failed.'; + $1807: ErrStr := 'No authority could be contacted for authentication. The domain name of the authenticating party could be wrong, the domain could be unreachable, or there might have been a trust relationship failure.'; + $A07: ErrStr := 'The specified user has no account.'; + $F07: ErrStr := 'The password is expired.'; + $1207: ErrStr := 'The user password must be changed before logging on for the first time.'; + $1707: ErrStr := 'Delegation of credentials to the target server is not allowed unless mutual authentication has been achieved.'; + $2207: ErrStr := 'The smart card is blocked.'; + $1C07: ErrStr := 'An incorrect PIN was presented to the smart card.'; + $B09: ErrStr := 'Network Level Authentication is required, run RDPCheck as administrator.'; + $708: ErrStr := 'RDP is working, but the client doesn''t allow loopback connections. Try to connect to your PC from another device in the network.'; + else ErrStr := 'Unknown code 0x'+IntToHex(discReason, 1); + end; + if (discReason > 2) then + MessageBox(Handle, PWideChar(ErrStr), 'Disconnected', mb_Ok or mb_IconError); + Reg := TRegistry.Create; + Reg.RootKey := HKEY_LOCAL_MACHINE; + if Reg.OpenKey('\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp', True) then + begin + try + Reg.WriteInteger('SecurityLayer', SecurityLayer); + Reg.WriteInteger('UserAuthentication', UserAuthentication); + except + end; + Reg.CloseKey; + end; + Reg.Free; + Halt(0); +end; +end. diff --git a/src-RDP_C&C/RDP_B.ico b/src-RDP_C&C/RDP_B.ico new file mode 100644 index 00000000..c4cc4715 Binary files /dev/null and b/src-RDP_C&C/RDP_B.ico differ diff --git a/src-RDP_C&C/resource.res b/src-RDP_C&C/resource.res new file mode 100644 index 00000000..0c9b0fe5 Binary files /dev/null and b/src-RDP_C&C/resource.res differ