Cyber security

Coustom Bash – A Tool To Automate Penetration Testing Tasks

Custom bash scripts have emerged as powerful tools for automating a range of penetration testing tasks, from reconnaissance to payload creation.

Tailored specifically for use with Kali Linux, these scripts streamline activities like scanning, enumeration, and the generation of malicious payloads using Metasploit.

This article delves into the intricacies of setting up and leveraging such scripts, ensuring that security professionals can efficiently harness their capabilities while also addressing potential issues and troubleshooting.

Custom bash scripts used to automate various penetration testing tasks including recon, scanning, 
enumeration, and malicious payload creation using Metasploit. For use with Kali Linux.
  • Lee Baird @discoverscripts
  • Jay “L1ghtn1ng” Townsend @jay_townsend1
  • Jason Ashton @ninewires

Download, Setup, And Usage

  • git clone /opt/discover/
  • Discover should be run as root from this location.
  • cd /opt/discover/
  • sudo ./discover.sh
  • Select option 15 to update Kali Linux. Discover scripts, various tools, and the database before using the framework.
RECON
1.  Domain
2.  Person

SCANNING
3.  Generate target list
4.  CIDR
5.  List
6.  IP, range, or URL
7.  Rerun Nmap scripts and MSF aux

WEB
8.  Insecure direct object reference
9.  Open multiple tabs in Firefox
10. Nikto
11. SSL

MISC
12. Parse XML
13. Generate a malicious payload
14. Start a Metasploit listener
15. Update
16. Exit

RECON

Domain

RECON

1.  Passive
2.  Active
3.  Find registered domains
4.  Previous menu

Passive uses ARIN, DNSRecon, dnstwist, goog-mail, goohost, theHarvester, Metasploit, Whois, multiple websites, and recon-ng.

Active uses DNSRecon, recon-ng, Traceroute, wafw00f, and Whatweb.

Acquire API keys for maximum results with the Harvester.

  • Add keys to /etc/theHarvester/api-keys.yaml

Person

RECON

First name:
Last name:
  • Combines information from multiple websites.

SCANNING

Generate Target List

SCANNING

1.  ARP scan
2.  Ping sweep
3.  Previous menu
  • Use different tools to create a target list, including Angry IP Scanner, arp-scan, netdiscover, and nmap pingsweep.

CIDR, List, IP, Range, Or URL

Type of scan:

1.  External
2.  Internal
3.  Previous menu
  • External scanning will set the nmap source port to 53 and the max-rrt-timeout to 1500 ms.
  • Internal scanning will set the nmap source port to 88 and the max-rrt-timeout to 500 ms.
  • Nmap is used to perform host discovery, port scanning, service enumeration, and OS identification.
  • Nmap scripts and Metasploit auxiliary modules are used for additional enumeration.
  • Addition tools: enum4linux, smbclient, and ike-scan.

WEB

Insecure Direct Object Reference

Using Burp, authenticate to a site, map & Spider, then log out.
Target > Site map > select the URL > right click > Copy URLs in
this host. Paste the results into a new file.

Enter the location of your file:

Open Multiple Tabs In Firefox

Open multiple tabs in Firefox with:

1.  List
2.  Files in a directory
3.  Directories in robots.txt
4.  Previous menu

Examples:

  • A list containing multiple IPs and/or URLs.
  • You finished scanning multiple web sites with Nikto and want to open every HTML report located in a directory.
  • Use wget to download a domain’s robot.txt file, then open all of the directories.

Nikto

This option cannot be ran as root.

Run multiple instances of Nikto in parallel.

1.  List of IPs
2.  List of IP:port
3.  Previous menu

SSL

Check for SSL certificate issues.

List of IP:port.


Enter the location of your file:
  • Uses sslscan, sslyze, and nmap to check for SSL/TLS certificate issues.

MISC

Parse XML

Parse XML to CSV.

1.  Burp (Base64)
2.  Nessus (.nessus)
3.  Nexpose (XML 2.0)
4.  Nmap
5.  Qualys
6.  Previous menu

Generate A Malicious Payload

Malicious Payloads

1.   android/meterpreter/reverse_tcp         (.apk)
2.   cmd/windows/reverse_powershell          (.bat)
3.   java/jsp_shell_reverse_tcp (Linux)      (.jsp)
4.   java/jsp_shell_reverse_tcp (Windows)    (.jsp)
5.   java/shell_reverse_tcp                  (.war)
6.   linux/x64/meterpreter_reverse_https     (.elf)
7.   linux/x64/meterpreter_reverse_tcp       (.elf)
8.   linux/x64/shell/reverse_tcp             (.elf)
9.   osx/x64/meterpreter_reverse_https       (.macho)
10.  osx/x64/meterpreter_reverse_tcp         (.macho)
11.  php/meterpreter_reverse_tcp             (.php)
12.  python/meterpreter_reverse_https        (.py)
13.  python/meterpreter_reverse_tcp          (.py)
14.  windows/x64/meterpreter_reverse_https   (multi)
15.  windows/x64/meterpreter_reverse_tcp     (multi)
16.  Previous menu

Start A Metasploit Listener

Metasploit Listeners

1.   android/meterpreter/reverse_tcp
2.   cmd/windows/reverse_powershell
3.   java/jsp_shell_reverse_tcp
4.   linux/x64/meterpreter_reverse_https
5.   linux/x64/meterpreter_reverse_tcp
6.   linux/x64/shell/reverse_tcp
7.   osx/x64/meterpreter_reverse_https
8.   osx/x64/meterpreter_reverse_tcp
9.   php/meterpreter/reverse_tcp
10.  python/meterpreter_reverse_https
11.  python/meterpreter_reverse_tcp
12.  windows/x64/meterpreter_reverse_https
13.  windows/x64/meterpreter_reverse_tcp
14.  Previous menu

Update

  • Update Kali Linux, Discover scripts, various tools, and the locate database.

Troubleshooting

Some users have reported being unable to use any options except for 3, 4, and 5. Nothing happens when choosing other options (1, 2, 6, etc.).

Always Run Discover As Root

cd /opt/discover/
sudo ./discover.sh

Verify The Download Hash

Hash-based verification ensures that a file has not been corrupted by comparing the file’s hash value to a previously calculated value. If these values match, the file is presumed to be unmodified.

macOS

  1. Open Terminal
  2. Shasum -a 256 /path/to/file
  3. Compare the value to the checksum on the website.

Windows

  1. Open PowerShell
  2. Get-FileHash C:\path\to\file
  3. Compare the value to the checksum on the website.

Running Kali On VirtualBox Or Windows Subsystem For Linux (WSL)

Some users have reported that the fix is to use the VMware image instead of WSL.

Other users have noticed issues when running a pre-made VirtualBox Kali image instead of the bare-metal Kali ISO through VirtualBox.

If you are unwilling or unable to use VMware Workstation to run Kali, we encourage you to try running a Kali ISO as a Guest VM in VirtualBox.

  1. Download the Kali-provided bare-metal ISO.
  2. Verify the ISO hash (see above).
  3. Start a new Kali VM within VirtualBox with the bare metal Kali ISO.

There will be some basic installation instructions you will be required to fill out during the installation.

Note: If you have problems accessing root after setting up a bare metal ISO.

Tamil S

Tamil has a great interest in the fields of Cyber Security, OSINT, and CTF projects. Currently, he is deeply involved in researching and publishing various security tools with Kali Linux Tutorials, which is quite fascinating.

Recent Posts

Bomber : Navigating Security Vulnerabilities In SBOMs

bomber is an application that scans SBOMs for security vulnerabilities. So you've asked a vendor…

10 hours ago

EmbedPayloadInPng : A Guide To Embedding And Extracting Encrypted Payloads In PNG Files

Embed a payload within a PNG file by splitting the payload across multiple IDAT sections.…

10 hours ago

Exploit Street – Navigating The New Terrain Of Windows LPEs

Exploit-Street, where we dive into the ever-evolving world of cybersecurity with a focus on Local…

2 days ago

ShadowDumper – Advanced Techniques For LSASS Memory Extraction

Shadow Dumper is a powerful tool used to dump LSASS (Local Security Authority Subsystem Service)…

3 days ago

Shadow-rs : Harnessing Rust’s Power For Kernel-Level Security Research

shadow-rs is a Windows kernel rootkit written in Rust, demonstrating advanced techniques for kernel manipulation…

2 weeks ago

ExecutePeFromPngViaLNK – Advanced Execution Of Embedded PE Files via PNG And LNK

Extract and execute a PE embedded within a PNG file using an LNK file. The…

3 weeks ago