<commit_before>#!/usr/bin/env python

"""
Start of TCP fuzzing client. Still very rough!!
"""

import socket
import Queue
import os
import sys
import time
import constants as fuzz_constants


class FuzzTCPClient(object):
    """TCP Client object for thefuzz suite"""

    def __init__(self, server, port):
        self.server = server
        self.port = port
        self.fuzz_queue = Queue.Queue()
        self.header = None

        # Validate IP address
        try:
            socket.inet_aton(server)
        except socket.error:
            print "[-] Invalid IP address: %s" % server
            print "[-] Exiting."
            sys.exit(os.EX_USAGE)

        # Validate port number
        if port > 65535 or port < 1:
            print "[-] Invalid port number: %d" % port
            print "[-] Exiting."
            sys.exit(os.EX_USAGE)

        # Create client socket
        self.client = None 
        #self.client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        #self.client.setblocking(0)
        #fcntl.fcntl(self.client, fcntl.F_SETFL, os.O_NONBLOCK)

    @staticmethod
    def get_fuzz_strings(string):
        count = 0
        fuzz_strings = ()

        for variable in fuzz_constants.FUZZ_VARS:
            count += 1
            if variable[0] in string:
                fuzz_strings = fuzz_constants.FUZZ_VARS[count - 1][1]
                break

        return fuzz_strings

    def add_script(self, script_file):
        if not os.access(script_file, os.R_OK):
            print "[-] Could not open %s for reading" % script_file
            return False

        linecount = 0
        for line in open(script_file, "r"):
            linecount += 1
            line = line.rstrip()

            # Skip comments and blank lines
            if line[:1] == "#" or not line:
                continue
<commit_msg>trailing whitespace and irrelevant comments<commit_after>#!/usr/bin/env python

"""
Start of TCP fuzzing client. Still very rough!!
"""

import socket
import Queue
import os
import sys
import time
import constants as fuzz_constants


class FuzzTCPClient(object):
    """TCP Client object for thefuzz suite"""

    def __init__(self, server, port):
        self.server = server
        self.port = port
        self.fuzz_queue = Queue.Queue()
        self.header = None

        # Validate IP address
        try:
            socket.inet_aton(server)
        except socket.error:
            print "[-] Invalid IP address: %s" % server
            print "[-] Exiting."
            sys.exit(os.EX_USAGE)

        # Validate port number
        if port > 65535 or port < 1:
            print "[-] Invalid port number: %d" % port
            print "[-] Exiting."
            sys.exit(os.EX_USAGE)

        # Create client socket
        self.client = None


    @staticmethod
    def get_fuzz_strings(string):
        count = 0
        fuzz_strings = ()

        for variable in fuzz_constants.FUZZ_VARS:
            count += 1
            if variable[0] in string:
                fuzz_strings = fuzz_constants.FUZZ_VARS[count - 1][1]
                break

        return fuzz_strings

    def add_script(self, script_file):
        if not os.access(script_file, os.R_OK):
            print "[-] Could not open %s for reading" % script_file
            return False

        linecount = 0
        for line in open(script_file, "r"):
            linecount += 1
            line = line.rstrip()

            # Skip comments and blank lines
            if line[:1] == "#" or not line:
                continue

{'fraction_non_alphanumeric': 0.0931082981715893, 'fraction_numerical': 0.008438818565400843, 'mean_word_length': 1.8, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3659765', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1027, 'n_words': 299}