Posted in Penetration Testing, Scripting

PenScan: first jump into creation

pexels-photo

I’ve always been fascinated with creation. My hobbies always included creating something out of nothing. Guitar playing, photography and now cyber security. Yes for now, cyber security is a hobby for me.

I heard that coding could help create an advantage in the industry to help speed things up. I learned low level coding in college. Visual Basic 6 was the order of the day and I enjoyed it a lot. The advice at the time was to dive into this world as it’s a growing sector. I opted to stay in Technical Support. A decision I had to live with. It’s only now that I feel I can spread my wings again with coding.

Linux almost teases the coder out in you. Using the terminal seems such a waste if you can’t at least create something, right? I’d created a little BASH script previously and felt confident that I could expand on it.

I didn’t give it a name at the time. Didn’t feel it was useful enough for a name until I started using functions in the script. WOW! What did I just do? I started using functions in a script? I had never done this, and always struggled with the concept, however, here I was using them. It opened up so many possibilities for ideas beyond my original plan.

You can view the project here – PenScan

What does it do?

  • Takes input of a Company name & creates a folder structure
  • Asks where those folders are to be saved? (ZephrFish add)
  • Gives a menu to select whether you want to DNS scan or Ping Sweep
  • Takes input for both options.
  • Outputs the results to the relevant folder

It wasn’t until I asked @ZephrFish for his opinion that I thought it had room for growth and I gave it a name. He kindly added a few tweaks and it’s still very much an exciting project to work on. Not because it’s going to be really useful in the world of Pen Testing, but, it’s going to be something to keep my brain active. Coding is funny. You need to be doing it all the time to keep it well oiled in your brain.

PenScan

Future Plans?

  • Input validation
  • Options for better scans
  • Option to CAT out to screen after scan

I love creating things, and this looks like it could be something I’d actually use one day once I get my ideas into practice.

Don’t hold back with your ideas. They’ll just annoy you until you do something about it.

Posted in Penetration Testing, Scripting

BASH ping sweeper

I had a little problem that was annoying me for a while. I wanted to learn BASH scripting, however, I didn’t really have an idea or a problem to solve using it. I’ve written small BASH scripts before to update things like Kali.

I use nmap a lot, so I wanted to use BASH as a way to prompt for a user input, save to a file and let nmap use that data to perform a ping sweep of the given data and return the results as clean IP address of all active hosts to the terminal.

Below is the source code I wrote for this task. Ping sweeping isn’t something probably requires a complex BASH script, however, I wanted to learn it, and it bugged me. It’s open to a lot of uses so I may develop it further.

#!/bin/bash

touch hostlist.txt
echo ">> Please enter IP/range"
   read ip_input
echo $ip_input > hostlist.txt
echo "$(tput setaf 3)[+]$(tpu sgr0) Running ping sweep on $ip_input"
   nmap -sP -iL hostlist.txt -oG pingscan > /dev/null
   grep Up pingscan | awk '{print$2}' > /root/Desktop/SCanResult/uplist
   grep Down pingscan | awk '{print$2}' > /root/Desktop/ScanResult/downlist
   cat /root/Desktop/ScanResult/uplist
echo "$(tput setaf 2)[+]$(tput sgr0)Hosts that are up from '$ip_input'"
  rm hostlist.txt

I plan to check for the hostlist.txt file on startup using some sort of if statement. If the file exists, then overwrite the file, else create it. I’m also not sure about how I want deal with the hostfile.txt. I’ve set it in the code to delete it once we’ve used it, but it may be needed later for documentation.

 

The exercise was one to solve an Input, Process & Output problem with minimal input.

 

Thanks for reading and feel free to use the code.