KeyGen.cs

Wednesday, 18 February 2009 21:04 by Tamir

The following sample demonstrates the RSA/DSA keypair generation feature of SharpSSH. It asks the user for a passphrase and a location of the output_keyfile.

If everything works fine, you it will generate the DSA or RSA keypair files named 'output_keyfile' and 'output_keyfile.pub'. The private and public key files are in the OpenSSH file format.

View the latest versison of this file here.

KeyGen.cs

using System;
using Tamir.SharpSsh.jsch;

/* KeyGen.cs
 * ====================================================================
 * The following example was posted with the original JSch java library,
 * and is translated to C# to show the usage of SharpSSH JSch API
 * ====================================================================
 * */
namespace sharpSshTest.jsch_samples
{
    /// <summary>
    /// This progam will demonstrate the RSA/DSA keypair generation.
    /// You will be asked a passphrase for output_keyfile.
    /// If everything works fine, you will get the DSA or RSA keypair,
    /// output_keyfile and output_keyfile+".pub".
    /// The private key and public key are in the OpenSSH format.
    /// </summary>
    public class KeyGen
    {
        public static void RunExample(params string[] arg)
        {
            if(arg.Length<3)
            {
                Console.Error.WriteLine(
                    "usage: java KeyGen rsa output_keyfile comment\n"+
                    "       java KeyGen dsa  output_keyfile comment");
                return;
            }

            try
            {
                //Get sig type ('rsa' or 'dsa')
                String _type=arg[0];
                int type=0;
                if(_type.Equals("rsa")){type=KeyPair.RSA;}
                else if(_type.Equals("dsa")){type=KeyPair.DSA;}
                else
                {
                    Console.Error.WriteLine(
                        "usage: java KeyGen rsa output_keyfile comment\n"+
                        "       java KeyGen dsa  output_keyfile comment");
                    return;
                }
                //Output file name
                String filename=arg[1];
                //Signature comment
                String comment=arg[2];

                //Create a new JSch instance
                JSch jsch=new JSch();

                //Prompt the user for a passphrase for the private key file
                String passphrase=InputForm.GetUserInput("Enter passphrase (empty for no passphrase)", true);


                //Generate the new key pair
                KeyPair kpair=KeyPair.genKeyPair(jsch, type);
                //Set a passphrase
                kpair.setPassphrase(passphrase);
                //Write the private key to "filename"
                kpair.writePrivateKey(filename);
                //Write the public key to "filename.pub"
                kpair.writePublicKey(filename+".pub", comment);
                //Print the key fingerprint
                Console.WriteLine("Finger print: "+kpair.getFingerPrint());
                //Free resources
                kpair.dispose();
            }
            catch(Exception e)
            {
                Console.WriteLine(e);
            }
            return;
        }
    }
}

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharpSSH
Actions:   E-mail | Permalink | Comments (41) | Comment RSSRSS comment feed

ARP Example

Wednesday, 18 February 2009 02:58 by Tamir

This is an example showing how to use SharpPcap's ARP Resolver class:

Read more...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharpPcap
Actions:   E-mail | Permalink | Comments (70) | Comment RSSRSS comment feed

ARP Resolver C# Class

Wednesday, 18 February 2009 02:54 by Tamir

This is a Class utilizing SharpPcap to resolves MAC addresses from IP addresses using the Address Resolution Protocol (ARP).
See this post for an example showing how to use this class.

Small update: please make sure to always check out the latest version of this class at the SVN repository.

Read more...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharpPcap
Actions:   E-mail | Permalink | Comments (24) | Comment RSSRSS comment feed

Sending Packets with SharpPcap - SendTcpSynExample.cs

Tuesday, 17 February 2009 09:31 by Tamir

Here is a sample showing how to build a SYN packet and send it using SharpPcap.
The program prompt the user for a Network Interface, builds a TCP SYN packet, injects it through the interface and print the SYN/ACK reply from the remote host. 

Read more...

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharpPcap
Actions:   E-mail | Permalink | Comments (28) | Comment RSSRSS comment feed

Thailand

Thursday, 20 December 2007 10:05 by Tamir

Some pics from our vacation in Thailand:

2007-12, Thailand

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Pictures
Actions:   E-mail | Permalink | Comments (15) | Comment RSSRSS comment feed

1993, Vertigo Show

Sunday, 21 February 1993 04:30 by Tamir

1993, The Vertigo Show

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Pictures
Actions:   E-mail | Permalink | Comments (19) | Comment RSSRSS comment feed