Monday, January 2, 2012

How 'main(int argc, char ** argv)' is implemented?

The declaration of main looks like this:
int main(int argc, char *argv[]);
This indicates that main is a function returning an integer. In hosted environments such as DOS or UNIX, this value or exit status is passed back to the command line interpreter.Typically, this facility is used to direct the way the program goes about its task. It's particularly common to provide file names to a program through its arguments.
There are two arguments to main: argc and argv. The first of these is a count of the arguments supplied to the program and the second is an array of pointers to the strings which are those arguments—which are passed to the main function in the form of pointer to an array. These arguments are passed to the program by the host system's command line interpreter.



Here's an example to explain the concept:-
#include
#include
using namespace std;

int main( int argc, char* argv[] )
{
cout << "The name used to start the program: " << argv[ 0 ]<< "\nArguments are:\n"; 

 for (int n = 1; n < argc; n++) 
cout << setw( 2 ) << n << ": " << argv[ n ] << '\n'; 
 return 0; 
}  


Compile it, then from the command-prompt try running it different ways:- 
 If the program name is "a" and it has arguments hello,world when it is run, the state of the arguments and the value of argv can be illustrated like this: 


 D:\prog\test> a Hello world!
The name used to start the program: a
Arguments are:
1: Hello
2: world!

Each time that argv is incremented, it is stepped one item further along the array of arguments. Thus after the first iteration of the loop, argv will point to the pointer which in turn points to the world! argument.

This is another way of giving arguments:-

D:\prog\test> cd ..

D:\prog> test\a.exe "Peter Piper" picked a peck of "pickled peppers"
The name used to start the program: test\a.exe
Arguments are:
1: Peter Piper
2: picked
3: a
4: peck
5: of
6: pickled peppers

I guess this one is self explanatory..:)



Tuesday, December 6, 2011

How to unblock blocked sites in your network?

This post will teach you 5 possible ways to bypass the web filter.Some methods work only work with certain filter configurations so you may have to experiment with several methods to find the best one for your situation.We will also look into some of the technical details of it.

What is a DNS?


An often-used analogy to explain the Domain Name System(DNS) is that it serves as the phone book for the Internet by translating human-friendly computer hostnames into IP addresses. For example, the domain name www.example.com translates to the addresses 192.0.32.10 (IPv4) and 2620:0:2d0:200::10 (IPv6).In other words the DNS is a database keeping records of which IP belongs to which site.That means when you type in an URL in your browser the browser connects to the DNS server through your ISP and asks for the corresponding IP address,when the DNS server provides the IP of that site the connection is made between your browser and the site.

How blocking is implemented?


OpenDNS, or any DNS based filtering/blocking service for that matter blocks sites by returning fake information when your computer requests the IP address of a blocked domain. If you were to visit Google.com then OpenDNS would return the genuine IP address, but if you tried to access a blocked domain like Facebook.com then OpenDNS will return modified/fake data which will redirect you to block.opendns.com.



How to access blocked sites?


#1)Web Proxy


You can use a web proxy service like the one offered by Freeproxyserver.net. When surfing a blocked site like Facebook through a web proxy, your computer and DNS provider will think you're simply browsing freeproxyserver.net because freeproxy will be making all the connections to Facebook for you. There are thousands of free web proxies out there but you should ideally use one that's hosted in the same country as you for the best speed results.

#2)HOST file modification


Although this method is slightly more technical than simply using a web proxy, it should be within the capabilities of most users. This method involves making a temporary modification to your computers HOST file. The HOST file can be used to store the real IP address of a website that you want to visit. So when you try to visit a blocked domain, for example Facebook.com, your computer will already know the real IP address for that domain and won't waste time querying OpenDNS. Since no query is sent to OpenDNS, your computer won't receive any false data which is used to prevent your computer from accessing that domain.
You can visit http://www.fpweb.net/support/managed-hosting/hostfile-editing-support.asp if you don't know how to edit hosts file.This is the best method as far as the speed is concerned.But it takes a lot of time to find the ip's of all the URL's that a particular site uses,you can search for the list of ip's under that site.

#3)Using different DNS server


This method was working fine for me but few days back my network admin restricted access to any other DNS server.Now all my DNS requests route through OpenDNS.It is quite easy. You can use OpenDNS servers or Google Public DNS servers. If you are using Windows then go to Control Panel > Network and Internet Connections > Network Connections and then right click on connection status icon which you are using to access internet. Now chose “Properties” and then Internet Protocol(TCP/IP). Put any one of the following values in the DNS server address OpenDNS server address: 208.67.222.222 208.67.220.220 Google DNS server address 8.8.8.8 8.8.4.4.Now open up command prompt and type the following c:\>ipconfig /flushdns
If it does not work then make sure to revert the settings to previous one and again type in the same command in command prompt to flush off the DNS cache.

#4)Using https:// instead of http://


This came to my notice recently when my college ISP blocked http://facebook.com but when i tried https://facebook.com
the site was loaded.This works with many DNS blocking systems and for many sites.It works because the URL blocklist works by inspecting HTTP packets sent out on TCP port 80 and checking the host header to see what URL they're requesting. When using HTTPS the host header is encrypted along with the body, so the router can't read it. The router can see that it's a HTTPS request going to a certain IP address on TCP port 443, but nothing else.

#5)Using translation services


Translation services like Google Translate , translate a website from one language to another and display the translated results on their own page .You can access the blocked website by re-translating blocked url using such online translation services.


That's it these were 5 easy ways to get access to any blocked sites blocked by your network provider.But be sure to know what the consequences of doing this is before attempting it.This is classified as computer tampering and is most likely against your organisations rules, if caught you can get into serious trouble, if you are sure that you are not being watched tracked or know that there are not serious consequences for doing this then you should only do the above.

Thanks for reading,do leave a comment. :)