Monday, 25 January 2016

C++ program to find area of triangle circle and square using function overloading

#include <iostream>

using namespace std;

class Shape{
    public:
    float findarea(float radii){
        return(3.14*(radii*radii));
    }
   
    int findarea(int side){
        return(side*side);
    }
   
    int findarea(int base, int height){
        return((base*height)/2);
    }
};

int main(){
int ch;
float r;
int b, h, s1;

cout << "Select and Find Area" << "\n1:CIRCLE 2:SQUARE 3:TRIANGLE " << endl;
cout << "Enter choice :";
cin >> ch;

Shape S;

if(ch==1){
    cout <<"Enter radius: ";
    cin >> r;
    cout << "Area of circle of raduis " << r << " is " << S.findarea(r) << endl;
}else if(ch==2){
    cout <<"Enter the value of Side ";
    cin >> s1;
    cout << "Area of square with side " << s1 << " is " << S.findarea(s1) << endl;
}else if(ch==3){
    cout <<"Enter base and height: ";
    cin >> b >> h;
    cout << "Area of triangle with base " << b << " and height " << h << " is " << S.findarea(b, h) << endl;
}else{
    cout << "Invalid input ";
}
   
return 0;
}


Thursday, 21 January 2016

Netcat



Netcat is a tool capable of writing data across a network using TCP or UDP protocol but this simple capability allows it to perform many functionalities. Its capability to create almost any kind of connection makes it a simple and efficient network debugging and exploration tool. It has been built in such a manner that it can act as a client as well as a server, which elevates its utility to a higher level.

Common uses for Netcat:
  • Chat/Messaging Server : By using Netcat, an operator can redirect simple text between two computers in a simplistic chat or in an instant message interface.
       Machine A root@bt:- # nc –l –p 123
      Machine B C:\> nc 192.168.118.130 123



http://2we26u4fam7n16rz3a44uhbe1bq2.wpengine.netdna-cdn.com/wp-content/uploads/Figure1-new.jpg



  • File Transfers : Netcat allows you to transfer files between computers without the need to install a full-blown FTP server

    Machine A root@bt:- # nc –lv -p 123 > test.txt
    Machine B C:\> nc 192.168.118.130 123 < test1.txt
 
  • Banner Grabbing : Netcat allows an operator to establish a socket to a specific port to potentially identify the operating system, service, version, and other information necessary to enumerate the purpose and/or potential weaknesses in the service.                                                
     Machine A root#kali# nc 172.35.9.1 21 

 
  • Port Scanning: Netcat allows the operator to utilize a rudimentary port scanning function, whereby a port or series of ports can be interrogated to determine if the port is open or closed.
       Machine B C:\> nc –v –w 2 –z 192.168.118.130 1-100 

 
  • Port Redirection: A simple technique used to transfer traffic from one port to another. It is utilized to access services which are restricted in any specific environment.
       Machine A root@bt:- # nc –l –p 8008 –c “nc google.com 80”
       Machine B Browse 192.168.118.130:8008
 Figure 4. Port Forwarding