#!/usr/bin/python3

#
# playbook_tuner.py
#
# Copyright (C) 2021 by University of Southern California
# Written by ASM Rizvi<asmrizvi@usc.edu>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#

# Usage: bzcat hitlist_file | ./getting_hitlist_ips output_file
# Example: bzcat internet_address_hitlist_it88w-20191127.fsdb.bz2 | ./getting_hitlist_ips ip_list_20191127.txt



import sys

if len(sys.argv) < 2:
    print("Please provide a name for the output file.")
    exit()

for line in sys.stdin:
    s = line.split("\t")
    if len(s) < 3:
        continue
    
    score = int(s[1])
    if score >= 0:
        f = open(sys.argv[1], "a")
        f.write(s[2])
        f.close()
