Author: wind Ze [EST] Created: 2004-9-2 If you are a network administrator security very seriously, if you manage a computer network installed is WINDOWS 2000 system, I believe that when the security settings on the system Do your duplicate action will make you feel depressed, have you expect to let the program help you complete these duplicate work? In fact, most of the system is in operation registry, so the program can be easily implemented, and a single program that is simple allows you to easily. Today I will simply implement a security setup program. Operating System: Windows 2000 Pro Experimental Purpose: Optimize operating system: Operation through the API function to operate the system's registry, call the System () function to perform some system commands. First introduce several functions: No.1System (Char * Command) Description: Send a DOS command No.2long RegopenkeyEx (HKEY HKEY, LPCTSTR LPSUBKEY, DWORD ULOPTIONS, Regsam Samdesired, phkey phkresult) Opens an existing item. Under Win32, use this function HKEY handle, or specify a standard item name lpsubkey to open the name Uloptions of the registry key UlOptions is unused, set to zero SamDesired with one or more constants of the prefix key_ ??. Their combination describes a variable that allows for this operation phkResult to load an open item NO.3long RegSetValueex (Heky HKEY, LPCTSTSTSTSTVALUENA, DWORD RESERVED, DWORD DWTYPE, CONST BYTE * LPDATA, DWORD CBDATA) Description Settings The value of the specified item HKEY is a handle of the open item, or specifies a standard item name LPVALUENAME to set the name reserved unused, set to zero Dwtype to set the number of types of LPData to set the first byte of the buffer containing the data. The length of the CBDATA buffer No. 4REGCLOSEKEY (HKEY) Description Close a item in the system registry (or key) HKEY To close the item, look at the above function, I have a probably understanding, we Let's take a look at how to write this program. First we have to turn off the default sharing of the system, use the System function to execute system commands, of course, this method is relatively stupid, but it is relatively simple to achieve, feel suitable for our programming rookie. Void delshare () {system ("@ Net Share C $ / DEL"); System ("@ Net Share D $ / DEL"); / * Most computers are 4 partitions, if you manage a computer, there are many partitions, SYSTEM ("@NET Share E $ / DEL"); you can add it yourself, if you want to write AZ: p * / system ("@ Net Share F $ / DEL"); system ("@ net share admin $ / DEL ");} If you still have any commands that need to be executed, add it, such as shutting down the service, building a user.
What is the registry? Simplely said that the registry is a huge database that stores various configuration data for computer software and hardware. Modifying the registry is equal to modifying the configuration of the computer, so many security settings are working on the registry, let's take a specific look at the function of the registry. Bool regset () {HKEY HKRESULT1; HKEY HKRESULT2; DWORD CBDATA = 4; Char LPDA [4]; char LPDB [4]; lpctstr data1 = "system // currentcontrolset // services // NetBt // parameters"; // Setting to open position LPCTSTR data2 = "SYSTEM // CurrentControlSet // Control // Lsa"; RegOpenKeyEx (HKEY_LOCAL_MACHINE, // open the registry [HKEY_LOCAL_MACHINE / data1, SYSTEM / CurrentControlSet / Services / NetBT / Parameters] 0, KEY_ALL_ACCESS, & hkresult1) RegopenKeyEx (HKEY_LOCAL_MACHINE, / / Open Registry [HKEY_LOCAL_MACHINE / DATA2, System / CurrentControlset / Control / LSA] 0, Key_all_Access, & HKRESULT2); LPDA [0] = 1; LPDA [1] = 0; LPDA [2] = 0 ; LPDA [3] = 0; // Defines the modified value LPDB [0] = 0; LPDB [1] = 0; LPDB [2] = 0; LPDB [3] = 0; RegSetValueex (HkResult1, "SMBDeviceEnable, / / Set the registry, this setting is to close 445 port 0, REG_DWORD, (Con St UNIGNED Char *) LPDB, CBDATA); RegSetValueex (HKRESULT1, "Restrictanonymous", / / This setting is forbidden to disable IPC $ Empty connection 0, REG_DWORD, (Const unsigned char *) LPDA, CBDATA); RegcloseKey (HKRESULT1); // Turn off Registry RegcloseKey (HKRESULT2); this function we implemented 2 settings, if you need more settings, you can add it yourself, or call RegcreateKeyex to create a new item, is it simple? If you want to set hundreds of machines or more machines, you will not feel too tired. If the above code understands, I think you write a tool that fixes malicious web pages illegally modifying the registry should be easy.