How to do it...

Sparta is a great interface for performing our scanning and collecting our information in one place. Before we begin, let's make a change to Sparta that will prevent it from running all its tools automatically. As we saw in the previous recipe, Sparta will do a great deal of scanning and launch a number of tools based on what it finds. This may not always be the approach we want to take, especially if we are trying to be stealthy. To make this change, open a terminal window and type vi /usr/share/sparta/sparta.conf.
Change the line enable-scheduler-on-import=True to enable-scheduler=False and save:

The following steps will guide you to create custom commands:

  1. To get started, navigate to Applications | Information Gatheringsparta:
  2. Once Sparta has started, we need to define our target. Select Click here to add host(s) to scope. For our examples, we will be using an IP range of 172.16.69.0/24.
  3. Uncheck Run staged nmap scan. If left checked, it will run a number of Nmap scans identifying ports and services: 
  4. After the Nmap host discovery scan has been run, we can see the discovered IPs under the Hosts tab, as seen in the following screenshot:
  1. Now that we have a list of discovered hosts, we can right-click on any one of them to see a menu of what we can do next, as shown in the following screenshot:
  1. Before we go any further, let's save our Sparta session by going to File | Save As. Save your session:

We can add additional tools to Sparta, provided they run in non-interactive mode. To demonstrate this, we will add fping to the tools contained within Sparta.
There are three types of actions you can define in Sparta:

  • Host: A host action is one that would target a specific machine
  • Port: Port actions target a specific port or service
  • Terminal: Terminal actions allow you to spawn a terminal from within Sparta

To add an action, it needs to be defined in the following format:

tool=label, command, services

Let's not look at the meaning of each of these words:

  • tool: This is the name of the tool we are adding.
  • label: This is what will show within the contextual menus in Sparta.
  • command: This is what you would type if running the tool from the terminal. The command tool uses the following placeholders: [IP], [PORT], and [OUTPUT]. These variables are replaced with the appropriate values at runtime.
  • services: Services is a list of Nmap service names the tool would apply to.

Let's now define a tool as an example. For our example, we will use the command fping. This will be a host action, as fping is used to see whether a host is up. Running fping from the command line would look something like fping 172.16.69.130.
You should see something similar to the following screenshot:

  1. Now, let's add fping to Sparta. Open a terminal window and type the following command:
        vi /usr/share/sparta/sparta.conf

You should see something similar to the following screenshot:

  1. Now, we will add a tool to the Sparta configuration. We will define fping under [HostActions], shown as follows:
        fping=Run fping, fping [IP]

You will note that we do not use [PORT] or [OUTPUT] as fping does not require them. Also, services is not required in our definition because fping is a host action.

  1. Save the file by hitting the Esc key, then typing, :wq and hitting the Enter key.
  2. In order to see our new command in Sparta, we will need to restart the service. To close Sparta, go to the File | Exit menu option. Now we can reopen Sparta. Once started, go to the File | Open menu option and load back in the Sparta scan we saved earlier.
  3. Now when we right-click on the host, you will see Run fping, the host action we created. Select that option, and our fping command will run. You will notice that a new tab opens up within Sparta, displaying the results:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset