Sunday, March 8, 2009

Show link status of all interfaces

ip link show

whois - a dns client application

whois tool used to query whois servers , which maintains domain registration info about internet dns namespace

what are the informations that can be retrieved using whois ??

who is registered under a specific domain
and the authoritative dns servers for the domain


how to use whois tool ?

1) use the web based tools
ex:- provided at networksolutions.com

2) use command line clients
ex:- zodiac@zodioc:~$ whois ubuntu.com
whois -h whois.markmonitor.com ubuntu.com


why whois ?

1) to check whether authoritative nameservers for your domain are set correctly
2) to find out the ownership details of a domain using this simple command…

whois openjs.com

Basic Diff

If you use the diff command, you will be able to see the difference between the files as shown below:

diff file1 file2

diff -y file1 file2 -W 120 #View side by side

Saturday, March 7, 2009

curl command examples

FTP using curl

curl -T filename.txt -u username:password ftp://example.cot/filename.txt

Linux Command to Generate a Password

head -n1 /dev/urandom|md5sum -b|head -c 10

Change File Encoding

Creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.

iconv -f fromEncoding -t toEncoding inputFile > outputFile

Encrypt/Decrypt File using OpenSSL in Linux

Works on OS X, Linux, anywhere with OpenSSL installed:

To encrypt a file:


openssl des3 -salt -in infile.txt -out encryptedfile.txt

To decrypt the file:


openssl des3 -d -salt -in encryptedfile.txt -out normalfile.txt

Using Dvorak in Linux Console

If you are a user of the dvorak layout, this command will let you use that layout in the console…

loadkeys dvorak

warning not tested

spy on SSH users

See what your users are doing using SSH connected to your system - this will show you what happens on the first console. If someone is typing, you’ll be able to get an output of his keystrokes. Substitute cat /dev/vcs1 with cat /dev/vcs2 or cat /dev/vcs3 and so on for other consoles.

cat /dev/vcs1

warning Untested

shutdown command examples

Cancel a planned shutdown of the system shutdown -c

Shutdown the system after a specified time. shutdown -h hours:minutes &

Friday, March 6, 2009

LAN type

Recently a friend of mine asked me,on seeing a LAN,how to find its type?, the only answer i could give her was , on seeing the cabling used, we can say whether it is 10 Base T, or fast ethernet etc.

can any one give any other solution/answer ?

Tapio salonsari

# mii-tool
eth0: no link
eth1: negotiated 100baseTx-FD flow-control, link ok

On Debian systems that's found from net-tools package, ymmv. That can give you much more information as well, so check the manpage. Hope this helps.


Maxwell lol

There is also ethtool. I recently downloaded the source, and compiled it.It provides a lot of information, and options to control the NIC card.

Thursday, March 5, 2009

permission change without chmod

is it possible to change the permission of a file without using chmod command ?

pk

Sure, just write a C program that does that, give it a name different from "chmod", and call it. Or use a graphical file manager, right click, "properties" -> "permissions..." and change the permissions.

Michael black

You can change permission with lynx, though of course only if you have permission to do it (ie you are the owner of the file, or root). I'm sure MC can do it too.


The natural philosopher

You could remove the disk, and pick through the inode blocks with a hex editor on a hardware emulator..

Or you could recompile the kernel to treat all the file permissions completely differently..or wrote a whole new operating system.

Monday, March 2, 2009

nmap examples

ping scan

nmap -v -sP 192.168.2.0/24 or nmap -sP 192.168.2.*


Starting Nmap 4.53 ( http://insecure.org ) at 2009-03-03 10:17 IST
Initiating Ping Scan at 10:17
Scanning 256 hosts [1 port/host]
Completed Ping Scan at 10:17, 0.61s elapsed (256 total hosts)
Initiating Parallel DNS resolution of 256 hosts. at 10:17
Completed Parallel DNS resolution of 256 hosts. at 10:17, 13.63s elapsed
Host 192.168.2.0 appears to be down.
Host 192.168.2.1 appears to be up.
Host 192.168.2.2 appears to be down.
Host 192.168.2.3 appears to be down.
Host 192.168.2.4 appears to be down.


UDP scan

sudo nmap -v -sU 192.168.2.0/24

T.C.P connect scan

Ex:-
sudo nmap -sT -p 80 192.168.2.42

Starting Nmap 4.53 ( http://insecure.org ) at 2009-03-03 10:24 IST
Interesting ports on 192.168.2.42:
PORT STATE SERVICE
80/tcp closed http
MAC Address: 00:1B:38:7D:84:A4 (Compal Information (kunshan) CO.)

Nmap done: 1 IP address (1 host up) scanned in 0.601 seconds


Ex:- nmap -sT 192.168.2.1-254 -p 1433-1435

syn stealth scan

Ex:- sudo nmap -sS -v 192.168.2.42
Starting Nmap 4.53 ( http://insecure.org ) at 2009-03-03 10:25 IST
Initiating ARP Ping Scan at 10:25
Scanning 192.168.2.42 [1 port]
Completed ARP Ping Scan at 10:25, 0.02s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 10:25
Completed Parallel DNS resolution of 1 host. at 10:25, 0.31s elapsed
Initiating SYN Stealth Scan at 10:25
Scanning 192.168.2.42 [1714 ports]
Completed SYN Stealth Scan at 10:26, 33.22s elapsed (1714 total ports)
Host 192.168.2.42 appears to be up ... good.
All 1714 scanned ports on 192.168.2.42 are filtered (1652) or closed (62)
MAC Address: 00:1B:38:7D:84:A4 (Compal Information (kunshan) CO.)

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 33.809 seconds
Raw packets sent: 3373 (148.410KB) | Rcvd: 63 (2894B)

NB:- syn scan is used when you dont want much traffic sent


O.S Detection scan

Ex:- sudo nmap -O --vv 192.168.2.0/24
nmap -O -v 127.0.0.1

nmap adding decoys

Ex sudo nmap -sS -PN -p80 -n 192.168.2.32 -D 192.168.2.60 -v

Starting Nmap 4.53 ( http://insecure.org ) at 2009-03-04 11:58 IST
Initiating ARP Ping Scan at 11:58
Scanning 192.168.2.32 [1 port]
Completed ARP Ping Scan at 11:58, 0.01s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 11:58
Scanning 192.168.2.32 [1 port]
Discovered open port 80/tcp on 192.168.2.32
Completed SYN Stealth Scan at 11:58, 0.02s elapsed (1 total ports)
Host 192.168.2.32 appears to be up ... good.
Interesting ports on 192.168.2.32:
PORT STATE SERVICE
80/tcp open http
MAC Address: 00:21:97:1C:80:C2 (Unknown)

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.192 seconds
Raw packets sent: 3 (130B) | Rcvd: 2 (88B)


.........................................................................................

Ex 1 nmap -T Aggressive -vA 192.168.2.* --open

Starting Nmap 4.53 ( http://insecure.org ) at 2009-03-04 11:40 IST
Initiating Ping Scan at 11:40
Scanning 256 hosts [1 port/host]
Completed Ping Scan at 11:40, 0.62s elapsed (256 total hosts)
Initiating Parallel DNS resolution of 256 hosts. at 11:40
Completed Parallel DNS resolution of 256 hosts. at 11:41, 13.64s elapsed
Initiating Connect Scan at 11:41
Scanning 30 hosts [1714 ports/host]
Discovered open port 21/tcp on 192.168.2.32
Discovered open port 21/tcp on 192.168.2.175
Discovered open port 21/tcp on 192.168.2.180
Discovered open port 1723/tcp on 192.168.2.1
Discovered open port 22/tcp on 192.168.2.11
Discovered open port 80/tcp on 192.168.2.11
Discovered open port 22/tcp on 192.168.2.13
Discovered open port 80/tcp on 192.168.2.13
Discovered open port 80/tcp on 192.168.2.14
............................................
...........................................


T - gives you the kind of scan , it could be aggressive,paranoid etc.

Ex 2 nmap -T Aggressive --packet-trace 192.168.2.32

Ex 3 nmap -F 192.168.2.32

-F: Fast mode - Scan fewer ports than the default scan

Sunday, March 1, 2009

Incremental Backup using dump

Make a incremental backup of directory ‘/home/binnyva’

dump -1aj -f home.bak /home/binnyva/


Make a full backup of directory ‘/home’

dump -0aj -f home.bak /home


warning untested