Wednesday, November 10, 2010

Abhimanyu Khanna

Hi everyone. This is me Abhimanyu again . I thought about writing of tearing firewalls apart.

A firewall is basically something that protects the network from the Internet. 
It is derived from the concept of 
firewalls used in vehicles which is a barrier made of fire resistant material 
protecting the vehicle in case of 
fire. Anyway a firewall is best described as a software or hardware or both 
Hardware and Software packet 
filter that allows only selected packets to pass through from the Internet to 
your private internal network. 
A firewall is a system or a group of systems which guard a trusted network( The 
Internal Private Network 
from the untrusted network (the Internet.) To understand how a firewall works, 
firstly we need to understand 
how exactly data is transferred on the Internet. 

NOTE: The following is a very weird, short and incomplete description of the 
TCP\IP protocol, I have just 
given a general idea of the whole data transmission process so that everyone can 
understand firewalls. 

The TCP\IP suite is responsible for successful transfer of data across a network 
both the Internet and the 
Intranet. The TCP\IP suite is a collection of protocols which are inter-related 
and interdependent and act as a 
set of rules according to which data is transferred across the network. A protocol 
can be defined as a language 
or a standard which is followed while transfer of data takes place. Lets go 
through a brief explanation of how 
data is transferred across a network following the various components of the 
TCP\IP suite. 
The whole process of data transmission begins when a user starts up an Internet 
application like the email 
client or a FTP client. The user types an email in his client and in this way 
provides data to be 
transferred. The email client is said to be a part of the application layer of 
the TCP\IP stack. Now this 
application layer (email client) provides data (the email itself) which has to be 
transferred to the Transmission 
control protocol or TCP which constitutes the Transfer Layer of TCP\IP. TCP breaks 
down the data i.e. the 
email into smaller chunks called packets and hands over the responsibility to the 
Internet Protocol or IP 
which forms the invisible network layer. This Internet Protocol adds some various 
info to each packet to 
ensure that the packet knows for which computer it is meant for and which port 
or application it is going to 
meet and from where it has come. An IP datagram contains: 

1. A header which contains the Source and Destination IP, Time to live info and 
also the protocol 
used. There is also a header checksum present. 
2. Remaining part contains the data to be transferred. 

You do not need to understand all this in detail but just remember that TCP 
breaks data into smaller packets 
and IP adds the source and destination IP's to the packets. When the data reaches 
the other server IP hands 
the packets to TCP again which re assembles the packets. Port numbers are also 
used to ensure that the 
packets know to which application it need to go to. So, basically we can conclude 
that a successful 
transmission of data across a network relies on the source and destination IP 
and also the ports. 

A firewall too relies on the source and destination IP and also the ports to 
control the packet transfer between 
the untrusted network and the trusted network. Firewalls can be classified into 3 
types: 

1. Packet Filter Firewalls 
2. Application proxy Firewalls 
3. Packet Inspection Firewalls 

Packet Filter Firewalls 

They are the earliest and the most criticized firewalls, which nowadays are not 
easily found. They are usually 
Hardware based i.e. Router Based (a router is a piece of device which connects two 
networks together.) 
Whenever a Packet Filter Firewall receives a packet for permission to pass 
through, it compares the header 
information i.e. the source and destination IP address, and port number with a 
table of predefined access 
control rules If the header information matches, then the packet is allowed to 
pass else the packet is 
dropped or terminated. They are not popular due to the fact that they allow 
direct contact between the 
untrusted system and the trusted private system. 
To understand such firewalls lets take the example of the secretary that sits in 
your office. This kind of 
secretary allows only those people who have an appointment to pass but if you 
convince her that her boss 
wants to meet her then she would allow you to pass. 
Such Firewalls can be fooled by using techniques like IP Spoofing in which we 
can change the source 
IP such that the firewall thinks that the packet has come from a trusted system 
which is among the list of 
systems which have access through the firewall. 

Application proxy Firewalls 

The shortcomings of the packet filter firewalls are addressed by the new type of 
firewalls developed by 
the DARPA. It was widely believed that the earlier type of firewalls were not 
secure enough as they allowed 
the untrusted systems to have a direct connection with the trusted systems. This 
problem was solved with 
the use of Proxy servers as firewalls. A proxy server which is used as a 
firewall are called application proxy 
servers. 
This kind of a proxy firewall examines what application or service (running on 
ports) a packet is meant for 
and if that particular service is available only then is the packet allowed to 
pass through and if the service is 
unavailable then the packet is discarded or dropped by the firewall. Once this 
is done, the firewall extracts 
the data and delivers it to the appropriate service. There is not direct 
connection between the untrusted 
systems with the trusted systems as the original data sent by the untrusted 
system is dropped by the firewall 
and it personally delivers the data. 

Let's again take the example of a secretary. Such a secretary would take a gift 
or something else for you 
only if you are available in the office and it would not allow the visitor to 
deliver the thing but would personally 
deliver it to you. Although they are somewhat slower, they are much more 
secure as they do not allow 
a direct contact between an untrusted network and a trusted network. 

Packet Inspection Firewalls 

It can be also known as an extension of the Packet Filter Firewall. It not only 
verifies the source and 
destination IP's and ports, it also takes into consideration or verifies that 
content of the data before passing it 
through. There are two ways in which this kind of a firewall verifies the data to 
be passed: 
State and Session. 
In case of state inspection, an incoming packet is allowed to pass through only 
if there is a matching 
outward bound request for this packet. This means that the incoming packet is 
allowed to pass through only 
if the trusted server had requested for it or had sent an invitation for it. 
In case of session filtering, the data of the incoming is not verified, but 
instead the network activity is traced 
and once a trusted system ends the session, no further packets from that system 
pertaining to that session 
are allowed to pass through. This protects against IP spoofing to a certain 
extend. 
Such firewalls can also be configured beforehand to act according to pre defined 
rules when it is attacked. It 
can also be configured to disconnect from the Internet in case of an attack. 

All along you will come across many Firewalls on various systems, basically a 
firewall can be established 
or setup in two ways: 

1. Dual-homed gateway 
2. Demilitarized zone (DMZ) 

In a dual homed gateway firewall, there is a single firewall with 2 connections, 
one for the trusted network 
and the other for the untrusted network. 
In the case of a Demilitarized Firewall or a DMZ there are two firewalls, each 
with two connections, but there 
is a slight difference in the case of a DMZ setup. 
In the case of a DMZ setup, there are two firewalls, the first having two 
connections, one leading to the 
untrusted network and the other leading to the host systems like the email 
server or the FTP server etc. 
These host systems can be accessed from the untrusted network. These host systems 
are connected with the 
internal private trusted systems through another firewall. Thus there is no 
direct contact between the 
untrusted network and the trusted internal network. The area or region between 
the two firewalls is termed as 
the demilitarized zone. 
In the case of a Dual Homed Gateway the untrusted network is connected to the 
host systems (email 
and FTP servers etc) through a firewall and these host systems are connected to 
the internal private 
network. There is no second firewall between the host systems and the internal 
private trusted network. 
The basic structure of the DMZ setup declares it to be a more secure system as 
even if an attacker gets 
through the first firewall, he just reaches the host systems, while the internal 
network is protected by another 
firewall. 

Do Firewalls provide enough Security for my Network? 

The answer is a simple no. There is no such thing that a firewall is enough to 
fulfill or satisfy all your 
security concerns. Yes it does protect the trusted systems from the untrusted 
ones, but they are definitely 
not enough for all your security needs. We need to protect our systems to secure 
the company data. The 
most common methods used to break into networks are brute force password 
cracking and social 
engineering. A firewall in no way can prevent such occurrences. 

There are other ways in which attackers can steal or destroy company data. Phone 
Tapping and the use of 
spy gadgets has become a common occurance.Although providing safety to the 
network to a large extend, a 
firewall is still not able to protect the company data from Viruses and Trojans, 
although some firewalls do 
provide for scanning everything being downloaded, the rate at which new HTML, 
Java and other viruses are 
propping up, it is becoming very difficult for firewalls to detect all 
viruses. Anyway firewalls provide no 
physical protection to the networks. It also provides no protection from fire, 
tornados etc.Yet another 
shortcoming is the fact that if the attacker is able to break into a trusted 
system which is provided access by 
the firewall, then he can easily gain access to the data at your network, as the 
firewall will think that he is 
actually the trusted party. 




Abhimanyu Khanna

Abhimanyu Khanna

Hi again guys, i decided to write about about Batch File Programming,

 Batch file programming is nothing but the Windows version of Unix Shell 
Programming. Let's start by understanding what happens when we give a DOS 
command. DOS is basically a file called command.com
It is this file (command.com) which handles all DOS commands that you give at the 
DOS prompt---such as COPY, DIR, DEL etc. These commands are built in with the 
Command.com file. (Such commands which are built in are called internal 
commands.).DOS has something called external commands too such as FORMAT, 
UNDELETE, BACKUP etc.

So whenever we give a DOS command either internal or external, command.com 
either straightaway executes the command (Internal Commands) or calls an external 
separate program which executes the command for it and returns the 
result (External Commands.)

So why do I need Batch File Programs? Say you need to execute a set of commands 
over and over again to perform a routine task like Backing up Important Files, 
Deleting temporary files(*.tmp, .bak , ~.* etc)
then it is very difficult to type the same set of commands over and over 
again. To perform a bulk set of same commands over and over again, Batch files 
are used. Batch Files are to DOS what Macros are to Microsoft Office and are used 
to perform an automated predefined set of tasks over and over again.


So how do I create batch files? To start enjoying using Batch files, you need to 
learn to create Batch files. Batch files are basically plain text files 
containing DOS commands. So the best editor to write your commands in would be 
Notepad or the DOS Editor (EDIT) All you need to remember is that a batch file 
should have the extension .BAT(dot bat)Executing a batch file is quite simple 
too. For example if you create a Batch file and save it with the filename 
batch.bat then all you need to execute the batch file is to type:

C:\windows>batch.bat

So what happens when you give a Batch file to the command.com to execute? 
Whenever command.com comes across a batch file program, it goes into batch 
mode. In the batch mode, it reads the commands from the batch file line by 
line. So basically what happens is, command.com opens the batch file and reads 
the first line, then it closes the batch file. It then executes the command and 
again reopens the batch file and reads the next line from it. Batch files are 
treated as Internal DOS commands.
********************

Hacking Truth: While creating a batch file, one thing that you need to keep in 
mind is that the filename of the batch file should not use the same name as a 
DOS command. For example, if you create a batch file by the name dir.bat and then 
try to execute it at the prompt, nothing will happen.
This is because when command.com comes across a command, it first checks to see 
if it is an internal command. If it is not then command.com checks if it a .COM, 
.EXE or .BAT file with a matching filename.
All external DOS commands use either a .COM or a .EXE extension, DOS never 
bothers to check if the batch program exits.

******************

Now let's move on to your first Batch file program. We will unlike 
always(Normally we begin with the obligatory Hello World program) first take up 
a simple batch file which executes or launches a .EXE program. Simply type the 
following in a blank text file and save it with a .BAT extension.
C:
cd windows
telnet
Now let's analyze the code, the first line tells command.com to go to the C:
Next it tells it to change the current directory to Windows. The last line tells it to 
launch the telnet client. You may contradict saying that the full filename is 
telnet.exe. Yes you are right, but the .exe extension is automatically added by 
command.com. Normally we do not need to change the drive and the directory as 
the Windows directory is the default DOS folder. So instead the bath file 
could simply contain the below and would still work.

telnet

Now let's execute this batch file and see what results it shows. Launch 
command.com (DOS) and execute the batch file by typing:

C:\WINDOWS>batch_file_name
You would get the following result:
C:\WINDOWS>scandisk
And Scandisk is launched. So now the you know the basic functioning of Batch 
files, let' move on to Batch file commands.


So thats it for now, although batch file programming is a huge topic and it really cant be covered in a single blog , but i hope you all got the idea.



Abhimanyu khanna
Hi . This is me Abhimanyu writing an blog from Akshit account as i have not been able to accept the invitation from my account . Since i have not lead a lab session till now so i  write this article about using databases in PHP



The first thing we need to do is connect to the database.
mysql_connect("somehost", "username", "password") or die ("Can't connect!");

This will try to connect to the database on somehost and login with “username” as the username and “password” as the password. If it can't, it will output an error message saying that it can't connect. For your own code be sure to change somehost to your host (most of the times it's localhost, ask your admin), username to your username (duh), and password to your password. Another way to connect to a database is to open a persistent connection. To do this, use the mysql_pconnect function and pass it the same arguments as mysql_connect. Why open a persistent connection? When you call mysql_pconnect, instead of going out and opening a connection to the database, it sees if one is already open, if it is, the script will use it. Also, when the script has finished executing, the connection to the database will not automatically be closed like it is when using mysql_connect. This way the connection can be used later on. Using a persistent connection is a good idea if your scripts constantly need to connect to the database.
After we have opened a connection to the database, we then select a database.
mysql_select_db("database_name") or die("Can't select database!");

This will try to select the database named “database_name” (for your own code change it to the name of your database). If it can't select the database, it will output and error. Once you're actually connected to a database, you will want to query a table in the database to get whatever you want done. A query looks like this:
mysql_query("Some query");

Common queries are SELECT and INSERT For full documentation go to the mysql web site (http://www.mysql.com). Another common php function is mysql_num_rows; if it isn't obvious this gets the number of rows from a query. Here is an example of how it can be used with mysql_query:
<?php

  $result= mysql_query("SELECT * FROM some_table");

  $number_of_rows= @mysql_num_rows($result);

      

  if ($number_of_rows == 0)

  {

    echo "Sorry there are no rows";

  }

  else {

    echo "Yes! we found some rows!";

  } 

?>

Now you may be wondering why I put the @ sign before mysql_num_rows. In php, the @ sign suppress errors; I put it in front of mysql_num_rows so that if there are no rows, MySQL will not output a bunch of errors. So when would mysql_num_rows be useful? Well, you could use it for an authentication script which searchs the database for a username and password and if it doesn't find any (i.e. if no rows are returned), it tells the user that the username, or password, are not correct.
Another really useful function is mysql_fetch_array, because it gets the rows and puts them in an array that contains the name of the rows. That way instead of having to access each row by number you can do it by name! For example, let's say that our database looked like this:
UserPassword
Johnafasdfadsfdsf
Billytla;jrjealjwqsldajf
Mitchpqrtupipripewir
We would use the following code to get the users' names and output them:
<?php

  echo "The users in this database are: <br>";  

  $result= mysql_query("SELECT * FROM some_table");

      

  while ($row= mysql_fetch_array($result))

  {

    $username= $row["User"]; 

    echo "$username<br>";

  } 

?>

This will output all the usernames in a database; you can add error checking if you like. The while statement is read “while there are rows that satisfy the query, put the contents of the row from the column ‘User’ into the variable ‘username,’ and print the usernames (each on a new line) to an HTML page.”
Now let's cover a couple of functions that actually work with the database. The first is mysql_create_db, don't you just love how the functions are named you can figure out what they do just by looking at the function name, this one obviously creates a database. Here's how to use it:
<?php 

  echo "I am going to try to create a database...<br>";

      

  if (mysql_create_db("test_database"))

  {

    echo "Hooray, I've created the database!<br>";

  }

  else { 

    echo "Darn couldn't create the database! because: ";

    echo "mysql_error() <br>";

  }

?>

You can see I used a new function, mysql_error, you don't really need to know too much about it, all it does is return the error string sent by MySQL. Now since we learned how to create a database, how's about we learn to delete one. To do that use the mysql_drop_db, here is how to use it:
<?php 

  echo "I am going to try to delete a database...<br>";

  $result= mysql_drop_db("test_database");

      

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!<br>";                   

  }

  else { 

    echo "Hooray, I've deleted the database<br>";   

  }

?>

You can see that the syntax is very similar to that of mysql_create_db, just pop the name of the database you want to delete into the function.
The next two items aren't functions, rather they are queries that you can use to manage an existing table. The following query will insert data into a database:
<?php 

  echo "I am going to try to insert data into a table...<br>";

  $result= mysql_query("INSERT INTO test_database (username, password) VALUES 

                (Rahim, adfjaldadfsdaf)");

      

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!<br>"; 

  }

  else { 

    echo "Hooray, I've deleted the database<br>";     

  }

?>

This query should be pretty obvious, it inserts the data defined in between the parentheses into the rows. Just a little note to remember, the order in which you write out the column names is the order your data will be entered (i.e. a row with the contents Rahim will be entered under username, not password since we wrote username then pasword, if it was reveresd Rahim would be put under password).
The next query we've already gone over, I'm just going to add to it; after I'm done you should be able to use it to help create a simple search engine (upcomming tutorial)! For the sake of brevity I'll remove all the extra php stuff and just show you the “meat” of the code.
$result= mysql_query("SELECT name FROM some_table WHERE name=Joe AND 

         lastname=Sixpack OR lastname=Becker ORDER BY lastname LIMIT 20");

Now I know that looks like a long query, but it's not really all that bad. What it's pretty much saying is: “Get me the name from some_table where the name is Joe and the lastname is Sixpack or Becker, oh and by the way while your at it, put it in alphabetical order by the lastname; oh and one last thing, just get the first 20 results please.” MySQL has lots of other filters that you can add on to the SELECT statement, I highly suggest you download the MySQL documentation and give it a perusing.




Abhimanyu khanna

Being a teacher for the first time!!

Well, Leading a lab session was not an easy task.
I did the lab leading with Anulima Chaudhary.
Now we realized that how difficult it is for our TAs to tech us during labs.

The first most difficult task for us was to decide the sequence in which the topics will be taught and the second most difficult task was to decide what all we need to cover in each subtopic and till what extent. It was not easy to clear everybody's doubts. But we finally managed to do it.

The topics that we covered were
Creating Web Sites: We first needed to set a server for which we used xampp to set up a local host. Then we finally used two web site making tools like Wordpress and Joomla. The best about these softwares was that we don't need any programming while using them.
Wire Shark: It's a spy kind of software. It captures your data packets from the net and then we can decode it so that we know about what the user accessed at that time.
Folder Guard: It's a software which can set password protection for any of your folder.
P2P:In it we covered lime wire through which friends can tranfer data among themselves.
Next, we taught about how we can connet two computers using R-45 cross cables and transfer data in windows to windows , windows to linux and linux to linux.

Over all it was a nice experience. All the project groups who trained us for leading this lab session were very helpful. I also enjoyed leading the lab session with Anulima Chaudhary.

Ayushi Goyal (2010025)

Group Project on PC Troubleshooting

"A lot happens when you stand up and promise yourself that you will do it however tough it is",
that is how I will describe my project.
When we(I and my group partners Jatin and Aishwarya) took up this project, we thought this was not going to be too tough,at least the name can make anybody believe that but things happen when they are least expected.
Troubleshooting in Windows was not too tough but the challenge began when we went on to Linux. We simply could not find anything to troubleshoot in Linux. It took days research and sleepless nights to get something meaningful and presentable.
Now, since a lot of you guys had a query or another about kernel I would explain what a linux kernel is.
A Kernel is not particularly made for Linux, it can be for any OS. It is basically just a medium between the software and the hardware of a computer. It contains some codes that allow your software to communicate with your hardware. Mostly it contains the drivers for your hardware and a process management system that determines what application will interact with the hardware at what point of time.
For more information on kernel visit http://en.wikipedia.org/wiki/Kernel_(computing)

In Linux this kernel determines what drivers you are running for your hardware. So, if you install some new hardware to your computer it may or may not happen that the OS recognizes the hardware. If it doesn't, that you have an option of upgrading the kernel. You just have to be careful that you download the correct upgrade for your version of Kernel.

Then the other confusing part of the log files comes. The log files that are stored in \var\log are not always meant to be understood as they contain some words that we are not well acquainted to right now. We are just required to deduce which were the processes that failed when an error occurred, then we need to find the possible reason that could have caused the problem. We all know that a problem becomes simpler if we can break it into smaller parts and that is what is happening over here. While trying to troubleshoot a problem you just need to find out which are the log files which would contain the logs related to that software or hardware and go through its latest records, and that may well solve your problem.

I hope, I was able to solve your queries to as much extent as possible.
BEST OF LUCK FOR EXAMS

Google Chrome Operating System


Google Chrome OS is an up coming LINUX-based, open source, lightweight operating system(and will be available to use at no cost) that will initially be made for netbooks. It is expected to be launched in the year 2011 before windows launches its new operating system.Google Chrome OS is being created for people who spend most of their time on the web, and is being designed to power computers ranging from laptops to full-size desktop systems.All web-based applications will automatically work and new applications can be written using your favorite web technologies. And of course, these apps will run not only on Google Chrome OS, but on any standards-based browser on Windows, Mac and Linux thereby giving developers the largest user base of any platform.Google is working with companies like Acer, Adobe, ASUS, HP, Lenovo, Qualcomm, Texas Instruments, and Toshiba(some more companies may be involved but i have no idea about them).
The image on the right shows a screenshot of the awaited Google Chrome OS.Though it looks more like the chrome browser but it has applications on the bottom like the dock in MAC and most of these are web based applications.( As wriiten a few lines above-
Google Chrome OS is being created for people who spend most of their time on the web).
Some of the biggest question marks till date:

1. Will Google Chrome OS replace Ubuntu?

2. Will this release affect Microsoft on a large scale?

3. Last but not the least - Will it come up to our expectations with the brand name of GOOGLE?

Windows Phone 7 vs. Android

I read the article on windows phone 7 and Android on following link:

http://www.zdnet.com/blog/cell-phones/windows-phone-7-vs-android-can-you-choose-just-one/5024

I found it interesting and hope you will also like it