Book Image

Kali Linux Intrusion and Exploitation Cookbook

By : Dhruv Shah, Ishan Girdhar
Book Image

Kali Linux Intrusion and Exploitation Cookbook

By: Dhruv Shah, Ishan Girdhar

Overview of this book

With the increasing threats of breaches and attacks on critical infrastructure, system administrators and architects can use Kali Linux 2.0 to ensure their infrastructure is secure by finding out known vulnerabilities and safeguarding their infrastructure against unknown vulnerabilities. This practical cookbook-style guide contains chapters carefully structured in three phases – information gathering, vulnerability assessment, and penetration testing for the web, and wired and wireless networks. It's an ideal reference guide if you’re looking for a solution to a specific problem or learning how to use a tool. We provide hands-on examples of powerful tools/scripts designed for exploitation. In the final section, we cover various tools you can use during testing, and we help you create in-depth reports to impress management. We provide system engineers with steps to reproduce issues and fix them.
Table of Contents (18 chapters)
Title Page
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Configuring remote connectivity services - HTTP, TFTP, and SSH


During penetration testing and auditing, we will be required to deliver payload on target machines from our Linux. For that purpose, we will leverage basic network services such as HTTP, FTP, and SSH. Services such as and SSH are installed by default in Kali Linux but Kali does not enable any network services to minimize detection.

In this recipe, we will show you to configure and start running services securely:

Getting ready

For this recipe, you will need a to the Internet with a valid IP address.

How to do it...

Perform the following steps for this recipe:

  1. Let's begin with starting an Apache webserver. To start the Apache service, use the following command:
      service apache2 start

You can verify that the service is by to the localhost using a as shown in the screenshot:

  1. To start the SSH service, SSH keys needs to be generated. Back in Backtrack r5, you used to generate SSH keys using the sshd-generate command, which is not available in Kali Linux. Using default SSH keys is a security risk and therefore a new SSH key should be generated. To generate SSH keys, you can either delete or backup your default keys generated by Kali Linux:
      # cd /etc/ssh
      # mkdir default_kali_keys
      # mv ssh_host_* default_kali_keys/
      # cd /root/
  1. First, we need remove run levels for SSH by issuing the following command:
      # update-rc.d -f ssh remove

 

  1. Now we need to the SSH run by issuing the command:
      # update-rc.d -f ssh defaults
  1. Regenerate the keys:
      # dpkg-reconfigure openssh-server 
      Creating SSH2 RSA key; this may take some time ...
      Creating SSH2 DSA key; this may take some time ...
      Creating SSH2 ECDSA key; this may take some time ...
      insserv: warning: current start runlevel(s) (empty) of script 
      `ssh' overrides LSB defaults (2 3 4 5).
      insserv: warning: current stop runlevel(s) (2 3 4 5) of script 
      `ssh' overrides LSB defaults (empty).
  1. You can check whether the SSH key hashes are different now:

  1. Start the SSH service using the following command:
      service ssh start

 

  1. You can verify the service is using the netstat command:
      netstat - antp | grep ssh
  1. Start the FTP server using the command:
      service pure-ftpd start
  1. To verify that the service is running, use the following command:
      netstat -ant | grep ftp
  1. To stop any service, you can the following command:
      service <servicename> stop

Here, <servicename> is the name of service required to terminate:

      service ssh stop

How it works...

In this recipe, we have configured and started basic network services, which we will be using to deliver payloads to our victim machines depending on the scenario. We have started HTTP service, FTP service, and we have backed up default SSH keys and generated new SSH keys, and started the SSH service.