cyeshink / DDOS-Detection

DDOS Detection
1 stars 3 forks source link

Error message when there is 1-8 strings on a single line #5

Open Alackey opened 7 years ago

Alackey commented 7 years ago

We could check the first line to see if there is the right amount of strings in a single line and assume the rest of the lines are fine. Giving the script an empty files does nothing and report.daf ends up empty, which is good enough.

serverlog.txt: adfpga;oifj lajsd l;fkj a;df

script output: Traceback (most recent call last): File "rbddos.py", line 13, in logn, date, time, etc, protocol, x, port, ipin, ipout = curlog.split() ValueError: not enough values to unpack (expected 9, got 4)

cyeshink commented 7 years ago

if os.stat(log).st_size==0: print 'Incorrect Log Format or Empty Log' sys.exit(0)

Fixes empty log error. Prints to console and returns empty report.daf file

if check == 0: llist = curlog.split(' ') if not llist: print 'Incorrect Log Format' sys.exit(0) elif len(llist) != 9: print 'Incorrect Log Format' sys.exit(0) else: check == 1

Fixes error for log of wrong size. Checks length of first line. If the number of entries in first line is not equal to 9, prints to console and exits. If it is, turns check variable off.