Showing posts from September, 2015

Parsing Multiple nmap Scan Output Files into a csv File

Today I was faced with a challenge where I had to parse multiple nmap scans that were saved in a directory.  The format was saved in the regular .nmap output.  The following python script came alive that parses the files and outputs the IP Address, MAC Address and each port that was found into output to the screen that could then be saved as a csv file.

This script depends on the output that is located in the .nmap output and the version of nmap.

#!/usr/bin/python nmapOutputDirectory="scans" import os import re for file in os.listdir(nmapOutputDirectory): portStatusPattern = re.compile("^[0-9]{1,5}\/(tcp|udp)\s*(open|closed)\s*[0-9a-zA-Z- ]{3,}$") macAddrPattern = re.compile(".*([0-9A-Fa-f]{1,2}[:-]){5}[0-9A-Fa-f]{2}.*") portInfoList = [] ipAddress = '' macAddr = '' fileLocation = nmapOutputDirectory + "/" + file f = open(fileLocation, 'r') for line in f: currentLine = line.strip() if "Nmap scan repor…

Python - Vega Conflict Script to Maximize Fleet Sizes based on Fleet Mass

On the side I have been playing a game created by Kixeye called Vega Conflict.  Their description of the game is below:

Stake your claim, command your fleets, and wage epic war in space. Band together with other players in a bloody rebellion to take back the galaxy from the evil VEGA Federation.  CUSTOMIZE YOUR WAR: Different targets call for different strategy, outfit your fleet for victory.  REAL-TIME PvP: Real war doesn’t wait its turn - attack enemies at will in real-time.  BATTLE ANYWHERE: Conflict never ends. Continue your progress on phone, tablet, or in browser.

In the game you progress based on leveling the buildings on your planet.  Currently in the game I have a level 7 Fleet Bay which allows you to have a maximum of 7 Fleets.  Each Fleet can only have a total mass of 10,100.  This presents a difficulty in taking all of the ships that you have built and creating 7 Fleets with as close as you can get the maximum mass for each fleet.   A note on strategy:  The best strategy is …