Thursday, March 18, 2010

Finding serial number of PC

On windows:
1. On your Windows PC, activate WMIC (Windows Management Instrumentation Command-line). Open the "Start" menu and choose the "Run" option. In the dialogue box that is opened, type "wmic." If this is the first time you have used WMIC, Windows will install it automatically.
2.Type the serial number request into WMIC. When installed, WMIC will display a command prompt, into which various commands can be typed into. The command to retrieve your PC's serial number is "bios get serialnumber."





Reference:
http://www.ehow.com/how_5794011_serial-number-pc-windows.html

Monday, March 15, 2010

Proxy Server

A proxy server, also known as a "proxy" or "application level gateway", is a computer that sits between a client and a server to intercept requests. There are several uses of a proxy server, but the most common is to speed network traffic by caching pages or files that are requested often. By doing so, the proxy server can deliver the request quickly, only polling the server when required. In this way, a proxy server not only speeds up network traffic, but also relieves server load. Major Internet hubs and Internet Service Providers (ISPs) employ dozens of proxy servers.

With proxy server an enterprise can ensure security, administrative control, and caching service.

A proxy server is associated with or part of a gateway server that separates the enterprise network from the outside network and a firewall server that protects the enterprise network from outside intrusion.

Some proxy servers are a group of applications or servers that block common Internet services. For example, an HTTP proxy intercepts web access, and an SMTP proxy intercepts email.

Note: Do not confuse a proxy server with a NAT (Network Address Translation) device. A proxy server connects to, responds to, and receives traffic from the Internet, acting on behalf of the client computer, while a NAT device transparently changes the origination address of traffic coming through it before passing it to the Internet.

For those who understand the OSI (Open System Interconnection) model of networking, the technical difference between a proxy and a NAT is that the proxy server works on the transport layer (layer 4) or higher of the OSI model, whereas a NAT works on the network layer (layer 3).



References:
http://www.wisegeek.com/what-is-a-proxy-server.htm
http://whatis.techtarget.com/definition/0,,sid9_gci212840,00.html
http://kb.iu.edu/data/ahoo.html

Thursday, March 11, 2010

expect

Expect keywords:
spawn
send
expect
interact
$expect_out(0,string)
$expect_out(buffer)
set timeout
expect eof


EXPECT EXAMLES: 
1. Pattern matching 
#!/usr/bin/expect
set timeout 15
expect "hi"  { send "You said hi\n" } \
     "hello"  { send "Hello to you\n" } \
     "bye"    { send "Goodbye\n" } \
     timeout  { send "I’m fed up\nbye\n" }


2. Expect script to connect to ssh server iteratively:
#!/usr/bin/expect -f
set timeout 3600
set iter 50
for {set i 1} {$i <= $iter} {incr i} {
        puts "SSh Iteration : $i \n"
        spawn ssh admin@192.168.1.4
        expect "Password:"
        send "mail4567\n"
        close $spawn_id
        after 900
}
 

3. Expect example
$ cat test.sh
#!/bin/sh
echo "Whats your name"
read name
echo "Hello $name"Here is expect script "test.exp" to automate the above script#!/usr/bin/expect -f

spawn ./test.sh

expect "Whats your name"
send "RAJA\r"
interact$ expect test.exp
spawn ./test.sh
Whats your name
RAJA
Hello RAJA

4. attaching to gdb server
#!/usr/bin/expect                                                              
spawn telnet 10.64.70.21                                                      
expect "$ " {send "gdbserver :1234 --attach \$(pgrep wncd)\n"}                 
interact


5. Attaching to gdb client:
#!/usr/bin/expect                                                              
spawn /auto/binos-tools/bin/mcp_gdb  -r $env(PWD) -p $env(PWD)/linkfarm/x86_64_cge7/usr/binos/bin/wncd
expect "\(gdb\) " {send "target remote 10.64.70.21:1234\n"}                   
interact  







References:

http://www.tcl.tk/man/expect5.31/expect.1.htmlhttp://www.tcl.tk/man/expect5.31/expect.1.html
http://unstableme.blogspot.com/search/label/Expect

http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html
http://www.thegeekstuff.com/2010/10/expect-examples/http://www.thegeekstuff.com/2010/10/expect-examples/

Monday, March 8, 2010

Port forwarding

There are a couple of concepts you need to know before you can understand port forwarding. I'm going to make a couple broad statements that are almost always true. For simplicity lets assume they are true for now.

1.) Every device on the internet has at least one ip address. The IP address is a number that is used to identify a device. For more information on ip addresses refer to our What is an IP Address page.

2.) Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an ip address to a port on an ip address. For more information on ports refer to our What is a Port page.

3.) A port can only be used by one program at a time.

Now that we've got those general concepts out of the way let's talk about NAT. NAT is an acronym for Network Address Translation. NAT takes one ip address and basically breaks it into many ip addresses.

[img]http://www.portforward.com/help/BasicNetwork.jpg[\img]

Here the external ip address is broken into two internal ip addresses. The first ip address "IP Address1" is the gateway. While "IP Address2" is the ip address of the first computer. Take note that the router has two ip addresses. It has the external ip address, and an internal ip address which acts as the gateway for every computer on the network.

[img]http://www.portforward.com/help/NetworkVisibility.jpg[\img]

Excuse my rough drawing. Computers on the internal network can only "see" internal ip addresses. So computers on the internal network can not send data directly to a computer outside of the network. When a computer on the network wants to send data to a computer outside of the network, it sends the data to the gateway. Remember the gateway is the internal ip address of the router. The router then takes this data and sends it out to the computer on the internet. The router sends the data out of the external ip address. The same thing is true of computers on the internet. A computer outside of the network can not "see" a computer inside of the network. They can only "see" and send data to the external ip address of the router. The router must then decide what to do with this data. Lucky for us NAT takes care of most of the work for us. There are some programs that NAT was not designed to work with, those are the programs we need to set up port forwarding for. Okay take a deep breath! We are on to port forwarding.

Now that you understand the general concepts of a network, explaining port forwarding is easy. When a computer on the internet sends data to the external ip address of the router, the router needs to know what to do with the data. Port Forwarding simply tells the router which computer on the local area network to send the data to. When you have port forwarding rules set up, your router takes the data off of the external ip address:port number and sends that data to an internal ip address:port number. Port Forwarding rules are created per port. So a rule set up for port 53 will only work for port 53.

A port can only be used by one program at a time! Think of how this rule interacts with NAT. Well you've only got one external ip address on your router. When computer 1 is using port 500, it is using port 500 on it's internal ip address. If you have set up a port forwarding rule for computer 1 and port 500, the external ip address's port 500 is also in use. This means that you can only use port 500 on one computer on the network at a time. Using port 500 on two computers at the same time would violate the one program rule, and your data would get messed up. Most routers require you to specify an internal ip address to forward ports to, just for this reason. Some do not, so be aware of this. Port Forwarding rules will only work for one computer at a time!

Reference:
http://portforward.com/help/portforwarding.htm

Friday, February 26, 2010

Firefox

To change the firefox, start from - about:config

How to make firefox ask me to choose whether to open or save links
tools>options>applications ; Find the program that you want changed. Change action to "Always Ask"

Monday, February 8, 2010

Switching & Routing

Difference b/w Switching & Routing.
In short, If packet forwarding is dependent on mac then your doing switching and if it IP then your doing routing.

Difference between L3 switch and a Router.
Router does forwarding through S/W algoritms whereas L3 does through inbuilt ASICs.
In latest trend, any forwarding done in h/w is named as a switch :-).

L2 switch is a bridge which forward the packets based on MAC address.

Switch is faster than a router because forwarding is built in h/w.

bridges can’t block a broadcast (where a data packet is sent to all nodes on a network). Broadcasts can consume a great deal of bandwidth. Routers are able to block broadcasts, so they provide security and assist in bandwidth control.

Switching:
Ethernet is fundamentally what we call a shared technology.And that is, all users of a given LAN segment are fighting for the same amount of bandwidth.

A by-product that we have in any Ethernet network is something called collisions. And this is a result of the fundamental characteristic of how any Ethernet network works.Basically, what happens in an Ethernet network is that many stations are sharing the same segment. So what can happen is any one of these stations can transmit at any given time.And if 2 or more stations try to transmit at the same time, it's going to result in what we call a collision.

It's also important to understand fundamentally how transmissions can occur in the network. There's basically three different ways that we can communicate in the network.
1. Unicast
2. Broadcast
3. Multicast

in shared bandwidth, Broadcasts Consume Bandwidth & Processor Performance.







References:
http://www.e-tutes.com/index.html
http://www.e-tutes.com/lesson8/networking_fundamentals_lesson8_1.htm
http://www.tcpipguide.com/

Sunday, February 7, 2010

Linux

You know how telnet works in linux..

In general xinetd will be listening for general daemons like ssh & telnet. When telnet request comes, xinetd handovers the control to telnetd and it inturn starts login which

xinetd--->telnetd--->login--->shell
xinetd--->sshd--->shell

PAM: Pluggable Authentication Modules
PAM is a library.
Through the PAM we can customize our the authentication methods.
For example: telnet spawns login. login will be having dependency on libpam.so. libpam.so reads the configuration file where we can define our customized authentication method(as a library) or we can use default linux authentication method.

similar to login for telnet, sshd will be having dependency on libpam.so.

To know the installed packages in linux:
Fedora:
#yum list installed 
#rpm -qa
Ubuntun:
#dpkg --get-selections

Linux repositories are at:
#ls /etc/yum.repos.d/*  OR
#cat /etc/yum.conf

Installing firefox in fedora:
http://www.if-not-true-then-false.com/2011/install-firefox-5-on-fedora/ 

To add new search plugin to firefox:
cp cisco.xml /usr/lib64/firefox/searchplugins/




Difference between zombie & orphan process