23 thg 3, 2007

Các phương pháp can thiệp vào Registry

Registry là gì?
Registry là một dạng cơ sở dữ liệu được tổ chức theo cấu trúc hình cây để lưu giữ hầu hết các thông số kỹ thuật của hệ thống windows nó ghi nhận và lưu giữ tất cả các hành động thay đổi của người dùng tác động lên hệ thống thông qua việc thiết lập chỉnh sửa và cấu hình hệ thống từ phần cứng cho đến phần mềm để từ đó windows vận hành hệ thống thông qua những thiết lập được lưu trữ sẵn trong registry. Và một khi có một thông số nào đó được thay đổi trong Registry thì hệ thống cũng sẽ ảnh hưởng.
Chính vì vậy có thể xem Registry giống như là trái tim của hệ thống. vì thế việc kiểm soát được nội dung của Registry là yêu cầu tất yếu để bạn sử dụng máy tính một cách khoa học, hiểu sâu hơn về môi trường làm vịệc của Windows. Và nhất là trong lĩnh vực lập trình, bảo mật, bẻ khóa cũng như là thâm nhập thì ít nhiều bạn cũng phải biết về Registry.
Can thiệp trực tiếp vào Registry giúp cho bạn đỡ tốn thời gian hơn rất nhiều thay vì phải sử dụng các công cụ của windows để thiết lập các thông số nhằm tối ưu hệ thống và sử dụng Registry một cách hiệu quả chẳng những giúp cho hệ thống của bạn chạy nhanh hơn mà còn tăng thêm tính bảo mật cho cả hệ thống vì vậy những ai chuyên nghiên cứu về thâm nhập một hệ thống Windows rất thích thao tác trực tiếp lên hệ thống thông qua Registry nhằm bẻ gãy các thiết lập trên làm cho việc thâm nhập trở nên dễ dàng hơn.
Ví dụ như cách thức cho chương trình bất kỳ tự khởi động, cách bật tắt các service của hệ thống hay làm rối loạn cả hệ thống theo ý của người thâm nhập… Vì vậy việc tìm hiểu về Registry là một việc tối quan trọng nếu như bạn muốn làm chủ hệ thống của bạn.
Ở bài viết này tôi chỉ đề cập đến cách thức để can thiệp vào Registry chứ không đi sâu vào công dụng của từng key như thế nào vì những cái đó các bạn có thể tìm trên Internet và cũng có rất nhiều bài viết giới thiệu về các thủ thuật của Registry nhằm không mất thời gian.
Cấu trúc của Registry:
Registry có cấu trúc hình cây, tương tự như cấu trúc của cây thư mục với rất nhiều nhánh con tỏa ra tùy theo cấu trúc ứng dụng. Thông thường Registry của Windows có 5 nhánh chính, mỗi nhánh đảm nhận viện lưu trữ những thông tin riêng biệt. Mỗi nhánh chính tỏa ra rất nhiều nhánh con và những nhánh con này cũng lưu trữ vô số thông tin đặc thù về mọi thứ có trong Windows.
Năm nhánh chính như sau:
1/HKEY_CLASSES_ROOT: Lưu những thông tin dùng chung cho toàn bộ hệ thống.2/HKEY_CURRENT_USER: Lưu những thông tin được thiết lập cho người dùng đang sử dụng hoặc đăng nhập vào Windows.3/HKEY_LOCAL_MACHINE: Lưu những thông tin được thiết lập về hệ thống, phần cứng, phần mềm…4/HKEY_USERS: Lưu những thông tin của tất cả các User (người dùng), mỗi user là một nhánh với tên là số ID định dạng của user đó.5/HKEY_CURRENT_CONFIG: Lưu thông tin về cấu hình
Và trong mỗi nhánh chính bao gồm nhiều Key và trong mỗi Key cũng gồm nhiều Key con tùy theo mỗi thiết lập cụ thể mà các key này nhiều hay ít.
Và cuối cùng là mỗi Key có thể chứa nhiều dữ liệu nhưng chỉ gồm 5 kiểu dữ liệu dạng sau đây:-String Value-Binary Value-DWORD Value-Muti-String Value-Expandable String Value
Thao tác lên Registry.
Có nhiều cách thao tác lên Registry gồm các cách sau:
Cách thông thường nhất là sử dụng chương trình Registry Edit có sẵn trong Window: => vào start ==> Run ==> Regedit (dành cho người sử dụng window).
Trong các ngôn ngữ lập trình ứng dụng với window đều có tích hợp sẵng những hàm để can thiệp vào Registry (dành cho lập trình)
Nhưng không phải lúc nào bạn cũng có thể can thiệp được vào Registry một khi người quản trị hệ thống đã khóa chức năng soạn thảo Registry (trong những lúc bạn sử dụng máy ở ngoài tiệm internet hay trong văn phòng…) để tránh trường hợp người không có kinh nghiệm sửa đổi sẽ làm cho hệ thống mất ổn định.
Vậy nếu như bạn gặp trường hợp đó chẳng lẽ phải bó tay sao và nhất là với những ai chuyên nghiên cứu về thâm nhập chẳng hạn.
Ví dụ như người quản trị ẩn hết tất cả các menu Run, các items trong Control Panel, tắt các service quan trọng,… và ẩn cả những chức năng và các biểu tượng trên desktop… Và sau đó không cho mở trình truy cập vào Registry. Vậy làm sao bạn có thể thao tác và sửa đổi khi mà Registry Editor không thể sử dụng được?
Trong bài viết này tôi sẽ chủ yếu đi vào cách can thiệp vào Registry một cách đơn giản nhất bằng những công cụ có sẵn và chắc chắn là ít bao giờ bị khóa đó là sử dụng chương trình NotePad để can thiệp và có thể sử dụng cả command line.
Cách thứ nhất: tạo ra file thuần text có đuôi .reg và đơn giản là chạy nó để tạo key trong Registry
File .reg có cấu trúc như sau:===========================Windows Registry Editor Version 5.00(Khoảng trống)(Key cần tạo)=================================
Ví dụ: Tạo một Registry có chức năng cấm hiển thị Task Manager (Ctrl + Alt + Del)
Lưu ý: nếu bạn cắt dán đoạn code nhớ lưu ý đổi lại dấu “ngoắc đôi” cho đúng vì wordpress đã thay đổi dấu “ngoắc đôi”
Bạn mở notepad dán đoạn code dưới vào sau đó lưu với têndisTaskManager.reg==========================Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]“DisableTaskMgr”=dword:00000001==========================
Chạy thử nó và nhấn yes để chấp nhận sau đó nhấn thử (Ctrl + Alt + Del) thì Task Manager sẽ không được phép thực thi.
Để bật lại chỉ cần thay giá trị dword:00000001 ==> dword:00000000 và chạy lại lần nữa. Sau đó để hiển thị được Task Manager bạn chỉ cần cho chạy file này:
enableTaskManager.reg===========================Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]“DisableTaskMgr”=dword:00000000===========================
Để thực thi được file .reg với điều kiện là chức năng này được cho phép, Vậy trong trường hợp bị khóa thì sao ???
Ví dụ: Bạn tạo thử một file .reg có tên là LockRegistry.reg sau đó chạy thử xem chuyện gì sẽ xảy ra nha
LockRegistry.reg=============================Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]“DisableRegistryTools”=dword:00000001=============================
Khi chạy file LockRegistry.reg rồi bạn thử vào start ==> run ==> regedit thì một dòng thông báo sẽ hiện ra như sau: “Registry Editing have been disabled by your administrator” và bạn tạo file
unLockRegistry.reg ==================Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]“DisableRegistryTools”=dword:00000000===================
và khi thực thi nó thì dòng thông báo trên cũng vẫn xuất hiện và không cho phép tiếp tục thực thi file unLockRegistry.reg.
2/Cách thứ hai
Vậy làm cách nào để bật Registry edit lên lại?? xin thưa bạn hãy xem qua bài chạy chương trình bất kỳ dưới quyền hệ thống thì sẽ có cách giải quyết ngay thôi.
Bạn sẽ làm như sau: ví dụ giờ của hệ thống đang là 10:30AM_Mở Start ==> Run ==> cmd_Từ dấu nhắc dos gõ lệnh: At 10:31AM /interactive Registry _Sau đó ngồi chờ đúng 10:31 thì Registry Editor sẽ hiện lên._Vào HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Systemvà đổi giá trị cho key “DisableRegistryTools ==> dword=00000000” thế là xong, quá đơn giản phải không?
Cách thứ 3: sử dụng command lineĐó là bạn sử dụng lệnh Reg (để nghiên cứu thêm về lệnh reg các bạn có thể ra Mở Run =>cmd=>reg/help để biết thêm chi tiết.
Trở lại ví dụ lúc nãy để enable lại Registry edit gõ lệnh như sau:
REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f
Vậy như đặt trường hợp lỡ hợp thoại Run cũng bị khóa và Hệ thống không cho truy cập Dos thì sao ??
Cách thứ 4: Thế là lại nhờ tới anh NotePad và biết một chút về lập trình với VBScript là xong, còn nếu không biết về VBScript thì cứ copy và dán đoạn Script sau vào và đặt tên là EnableRegistry.vbs và chỉ cần nhấn đúp để chạy nó thì Registry Edit sẽ hết bị khóa.
EnableRegistry.vbs======================================‘@Author: L0ng3ta@hotmail.com
Option ExplicitDim WSHShell: Set WSHShell = WScript.CreateObject(”WScript.Shell”)Dim Root: Root = “HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\”Dim Key: Key = “DisableRegistryTools”Dim ItemType: ItemType = “REG_DWORD”‘0:Enable , 1:DisableDim Value: Value = 0On Error Resume NextWSHShell.RegWrite Root & Key, Value, ItemTypeMybox = MsgBox(”Registry Enabled”, 4096, “Success”)=====================================
Ngoài ra VBscript cũng cung cấp sẵn các hàm để tạo Key, Xóa Key, Đọc Key các bạn tự tham khảo._Đọc Key: n = WSHShell.RegRead (Root & Key) đưa ra giá trị n-Xóa Key: WSHShell.RegDelete (Root & Key)
Ví dụ: Tạo một file VBScript có tác dụng tắt và mở chức năng của Registry (File này tự động dò tìm nếu trường hợp Registry đang bị Disable thì Enable lên và ngược lại:
AutoRegistry.vbs=========================================‘@Author: L0ng3ta@hotmail.comOption Explicit
Dim WSHShell: Set WSHShell = WScript.CreateObject(”WScript.Shell”)‘Khai bao keyDim Root: Root = “HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\”Dim Key: Key = “DisableRegistryTools”Dim ItemType: ItemType = “REG_DWORD”
‘0:Enable , 1:DisableDim enaValue: enaValue = 0Dim disValue: disValue = 1
‘Cac cau thong baoDim enaMes: enaMes=”Enabled !”Dim disMes: disMes=”Disabled !”Dim mainMes: MainMes=”Registry Editor is “
Err.Clear
On Error Resume Next‘lay va kiem tra gia tri cua Key xem dang Enable hay DisableDim valueGet: valueGet = WSHShell.RegRead (Root & Key)Dim errNum: errNum = Err.Number
‘Neu khong co key thi tao keyOn Error Goto 0if errNum <> 0 then WSHShell.RegWrite Root & Key , disValue, itemtypeEnd If‘Neu co key kiem tra gia tri key n neu dang enable thi disable va nguoc laiDim MyBoxIf valueGet = enaValue Then WSHShell.RegWrite Root & Key , disValue, itemtype MyBox = MsgBox(MainMes & disMes, 4096, “Susscess”)ElseIf valueGet = disValue then WSHShell.RegWrite Root & Key, enaValue, itemtype MyBox = MsgBox(MainMes & enaMes, 4096, “Susscess”) End If=========================================
Nói chung là còn rất nhiều cách nhưng vấn đề ở đây là cốt lõi và bạn phải nắm được căn bản về Registry và phải biết “Tùy cơ ứng biến”.
Sau đây là các Thủ thuật về Registry cần thiết cho việc thâm nhập:
1/Enable Remote Assistance (Windows XP)Registry SettingsSystem Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]Value Name: AllowTSConnections, fDenyTSConnections, fAllowToGetHelpData Type: REG_DWORD (DWORD Value)
Tạo hoặc sửa các Giá trị DWORD:Giá trị REG_SZ mặt địnhAllowTSConnections REG_DWORD 0×00000001 (1) sửa thành ==>0fDenyTSConnections REG_DWORD 0×00000000 (0) sửa thành ==>1fAllowToGetHelp REG_DWORD 0×00000001 (1) sửa thành ==>0
2/Bật hoặc tắt các Service khác
Các giá trị của dword được hiểu như sau:dword:00000002 Automaticdword:00000003 Manualdword:00000004 Disabled
Để bật Service nào đó bạn chỉ cần đổi giá trị về dword:00000002 và khởi động lại
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Alerter]“Description”=”Allows alert messages to be sent to W2K servers.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ALG]“Description”=”Allows you to use the built-in firewall.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AppMgmt]“Description”=”Allows programs to use the add/remove control panel”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BITS]“Description”=”Allows you to resume file transfers on slow connections.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser]“Description”=”Used to show a list of computers on a local network.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ClipSrv]“Description”=”Permits you to cut and paste text and graphics over the network.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\COMSysApp]“Description”=”Allows COM-aware software components to communicate with each other.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CryptSvc]“Description”=”Allows for authentication, encoding and encryption to verify software signatures.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ERSvc]“Description”=”Allows applications to send error reports to Microsoft if/when they crash.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventSystem]“Description”=”A method for allowing software compenents to communicate with each other.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\FastUserSwitchingCompatibility]“Description”=”Allows for multiple users on a single machine without requiring you to log out.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\helpsvc]“Description”=”Allows the XP Built-in Help and Support Center to run.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ICFS]“Description”=”Enables the built-in Microsoft firewall.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation]“Description”=”The Workstation service enables a computer to connect to and use network resources.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LmHosts]“Description”=”Enables NetBIOS over TCP/IP (NetBT) services.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger]“Description”=”Despite its best efforts, it’s an evil service that has massive security flaws.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mnmsrvc]“Description”=”Allows NetMeeting programs to access the local computer.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSDTC]“Description”=”Provides data replication between a client and multiple Windows servers.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSIServer]“Description”=”Allows for programs to be installed. Enough said.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Nla]“Description”=”Useful if you have a multihomed or multiple-network connected computer.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent]“Description”=”Provides IPSEC capabilities (secure TCP/IP).”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ProtectedStorage]“Description”=”Allows the local computer to save passwords.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RDSessMgr]“Description”=”Allows remote access and control of the local computer.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RemoteRegistry]“Description”=”Allows remote access and control of the Windows registry.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RSVP]“Description”=”See MS-Technet Q316666 for vague details.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RPCLocator]“Description”=”Allows distributed applications to use the Microsoft RPC name service.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\seclogon]“Description”=”Enables starting processes under alternate credentials.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SENS]“Description”=”Allows the computer to be aware of network connectivty interruptions.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Spooler]“Description”=”Loads files to memory for faster printing.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\srservice]“Description”=”System Restore BloatWare ™. Just say no.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Schedule]“Description”=”Start programs at specified times.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SSDPSRV]“Description”=”An often unused discovery protocol that has yet to catch on.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService]“Description”=”Used mainly to allow for fast user switching.”“Start”=dword:00000004
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Themes]“Description”=”Applies visual styles to the user interface via ComCtl32.dll.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TrkWks]“Description”=”Updates the location of links that are moved on NTFS volumes.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\upnphost]“Description”=”Essentially a networkable version of Plug and Play that never really caught on.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UPS]“Description”=”Uninterruptible Power Supply service Manager.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time]“Description”=”Allows the local computer to synchronize its clock with an Internet Time Server”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient]“Description”=”Enables Windows-based programs to create, access, and modify non-local files across the Internet.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\winmgmt]“Description”=”Similiar to Simple Network Management Protocol (SNMP) and Desktop Management Interface (DMI).”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WmdmPmSp]“Description”=”Allows your portable music player to be tracked by serial number.”“Start”=dword:00000003
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Wmi]“Description”=”Essentially an XML encoder for representing network services.”“Start”=dword:00000002
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv]“Description”=”Allows you to use the WindowsUpdate website.”“Start”=dword:00000002
Ngoài ra các bạn có thể tham khảo thêm về các thủ thuật về Registry chủ yếu là công dụng của từng key có rất nhiều trêncác website bài viết này tôi chỉ giới thiệu một vài key cần thiết và làm cách nào để can thiệp vào Registry mà thôi công việc tìm công năng của từng key các bạn hãy tự tìm (ví dụ như tắt Firewall, Tắt chương trình cảnh báo của Microsoft, tắt các chương trình Antivirus …)
Thân chào L0ng3ta.
NẾU BẠN MUỐN COPY BÀI VIẾT XIN VUI LÒNG TÔN TRỌNG QUYỀN TÁC GIẢ
Các bạn có thể tham khảo các Key tại địa chỉ:http://www.kellys-korner-xp.com/xp_tweaks.htmhttp://www.pctools.com/guides/registry/

l0ng3ta.wordpress

1 nhận xét:

Nhan Dao nói...

Xin chao, chung ta co the trao doi link khong nhi? http://giangdaytructuyen.blogspot.com. Moi ban ghe xem nhe! Blog cua minh moi vua thanh lap chua day thang!!!