Monday, September 2, 2013

Get Website Source + Source

Just a simple source, I would like to share. It can output the IP Addresses of as many websites as you pass through the command line.

Code:
#include <iostream>
#include <windows.h>
#pragma comment(lib, "ws2_32.lib")

int main(int argc, char *argv[])
{
    WSADATA wsData;
    if(WSAStartup(MAKEWORD(2, 2), &wsData) != 0)
    {
        std::cout << "Cannot WSAStartup\n";
        WSACleanup();
    }
    else
    {
        for(int i = 1; i < argc; i++)
            std::cout << argv[i] << " : " << inet_ntoa(*(in_addr*)*gethostbyname(argv[i])->h_addr_list) << std::endl;
    }
    std::cin.get();
    return 0;
}

Command-line:
Code:
Directory>GetWebAddress www.hackforums.net www.google.com www.youtube.com
www.hackforums.net : 69.162.82.251
www.google.com : 72.14.204.99
www.youtube.com : 74.125.113.92

No comments:

Post a Comment