Everyone and there mother says I need to know Python.
So, after going through the buffer overflow portion of the course I’m in, I’m taking a break to automate recon scans with python.
Below is theunfinished code and where I’m having issues so far.
I wrote out basic pseudocode and have been writing out the program from the pseudocode.
Once the initial 4 scans work and create output files properly, then I’ll break each scan into a function and just call the functions.
The basic idea above is that when I run the script, I’d like to clear the terminal, then make sure that I ran as root, then name a new folder (HTB box name) and input the IP. This will help me keep things orderly. I’d also like to generate a “quick notes” textfile from the scans, but that’s for later. I have to get this script’s most basically proposed functionality working, first. THEN I can ruin it with more stuff.
Note: The above is performing an all port scan at default speed. The idea is that it’s much faster to do a non-aggressive scan of all ports, then do an aggressive scan of only the open ports. This way, I don’t have to worry about missing something in a fast scan, which most certainly WILL miss something.
The above lines use bash to pull open ports from the above nmap scan, create a separate textfile of the open ports, then do the same for the open http ports.
Above performs an aggressive nmap scan on only the open ports, also runs the vulnerability scan on said ports, then outputs to a separate file.
The above block does a gobuster scan on each http port and SHOULD output the results to a separate file, but I can’t get that part to work in the way that I’m approaching it.
The above performs a wfuzz subdirectory scan of each open http port, and SHOULD output the results to a separate file but again, this method I’m using is not working. The files are created and named for each port, but they are empty.
This last bit is cleanup, a vague notion that I believe I should be doing either as the program steps through, or all at the end. Right now it’s commented out so that I can see what’s going on.
The script needs a lot of work, still. I’m hoping that as I fumble my way through figuring out how to save scan output to a textfile, I will also have stumbled upon some other python-ish solutions for more of what is now basically just bash commands. We’ll see.
python, projects, homelab
I feedback.
Let me know what you think of this article on twitter @cpardue09 or leave a comment below!