Modify simple python script

Modify simple python script

Closed - This job posting has been filled.

Job Description

Modify this simple python script.

Deliverable is a new script and a .txt output file.

Currently, it take as input a .txt file of network circuit paths with 5 IP addresses per row, which constitute the path a network circuit takes. Columns (attributes) are:
Source IP
Guard IP
Middle IP
Exit IP
Destination IP

The main circuit input file represents many circuits, each consisting of 5 hops (IPs). The script looks up the country of each IP and applies a set of scoring factors. It returns an overall circuit risk for each row in the circuit.

The script takes 6 arguments total:
'Usage: %s geoip.dat iso3166 hostility_scores mlats circuits output_prefix' % (sys.argv[0])

http://dev.maxmind.com/geoip/legacy/geolite/

The first modification requirement:
Assign a random IP for "source" for each row on the fly while looping(random_IP is already in score_circuits.py)

The input files do not change. The overall goal is to breakdown and capture the 5 sub-elements of the overall circuit score. The input should not be modified,But, when it is performing the calculation of each row's score (5 IPs), it should not capture only the overall score, it should also bucket the individual scores of each of the 5 IPs.

Instead of returning a single overall score for each row in the circuit input file (consisting of 5 IPs), the script needs to calculate an individual score for each of the 5 IP addresses in the row. It the needs to assign a number of accumulator variables to accumulate the average individual scores of each column:
Source IP (randomly generated on the fly by calling random_IP before scoring each row)
Guard IP
Middle IP
Exit IP
Destination IP

It needs to return the average for each of the 5 columns, plus the std deviation.

Each circuit input file is scored in this way against 5 different countries:
US, UK, IR, CN, DE

So, 25 *2 = 50 results are required:

when adversary is:
US:
Average score:
1)Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

Std deviation of average score:
1) Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP


when adversary is:
DE:
Average score:
1)Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

Std deviation of average score:
1) Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP


when adversary is:
CN:
Average score:
1)Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

Std deviation of average score:
1) Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP


when adversary is:
IR:
Average score:
1)Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

Std deviation of average score:
1) Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP


when adversary is:
UK:
Average score:
1)Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

Std deviation of average score:
1) Source IP
2) Guard IP
3) Middle IP
4) Exit IP
5) Destination IP

resuts must be output to a .txt file.

Open Attachment