Beispiel #1
0
def handle(conn, file_path, chunk_size):
    for chunk in chunked_file(file_path, chunk_size):
        send(conn, chunk)
    close(conn)
from trapy import close, recv, dial, send
#from socket_trapy import *

#host = "127.0.0.1"
host = "10.0.0.1"
port = 6
print("-------------CLIENT--------------")
tests = [
    "a", "0123456789", "#0123456789ABCDEF",
    "ReallyBigPackage000000001234567890A1234567890B01234567890C01234567890",
    "Rodri i lov you"
]
client = dial(host + f":{port}")
if client:
    for val in tests:
        #val = input("Input Data:")
        a = send(client, bytes(val, "utf8"))
        print("*******Data Sent***********\n", val[0:a])
        r = recv(client, 10)
        print("*******Data Recieved*******\n", r)
        print("----------Succeded-----------")
        input()
    close(client)
Beispiel #3
0
def handle(conn, file_path, chunk_size):
    for chunk in chunked_file(file_path, chunk_size):
        send(conn, chunk)
        logger.info(f'Chunk sent with lenght {len(chunk)}')
    close(conn)
    logger.info('Connection closed')
Beispiel #4
0
# chunk_size = 64
def chunked_file(file_path, chunk_size):
    file = open(file_path, 'rb')
    data = file.read(-1)
    chunks = []
    if len(data) % chunk_size == 0:
        chunks_count = len(data) / chunk_size
    else:
        chunks_count = len(data) // chunk_size
        chunks_count += 1
    for i in range(chunks_count):
        if i == chunks_count - 1:
            chunks.append(data[i * chunk_size:])
        else:
            chunks.append(data[i * chunk_size:i * chunk_size + chunk_size])
    # print(f'chunks {chunks}')
    return chunks


# conn = dial('127.0.0.1:4545')
conn = dial('10.0.0.2:4545')
# conn = dial('192.168.43.156:4545')
# conn = dial('192.168.43.190:4545')
# exit()
for chunk in chunked_file(file_path, chunk_size):
    # print(f'calling send with {chunk}')
    send(conn, chunk)
close(conn)
print('conn closed')
Beispiel #5
0
import trapy
from struct import *

conn = trapy.dial("10.0.0.2:8080")

ip_header = b'\x45\x00\x00\x28'  # Version, IHL, Type of Service | Total Length
ip_header += b'\xab\xcd\x00\x00'  # Identification | Flags, Fragment Offset
ip_header += b'\x40\x06\xa6\xec'  # TTL, Protocol | Header Checksum
ip_header += b'\x0a\x00\x00\x01'  # Source Address
ip_header += b'\x0a\x00\x00\x02'  # Destination Address

tcp_header = pack('!HH', 8080, 8080)  # Source Port | Destination Port
tcp_header += b'\x00\x00\x00\x00'  # Sequence Number
tcp_header += b'\x00\x00\x00\x00'  # Acknowledgement Number
tcp_header += b'\x50\x02\x71\x10'  # Data Offset, Reserved, Flags | Window Size
tcp_header += b'\xe6\x32\x00\x00'  # Checksum | Urgent Pointer

packet = ip_header + tcp_header + b'aaaaaaaaaaaaaaaaaaaaaaab1234567i8op-oiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432qoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccoiuytrewaszdfghjklpoiuytrew32134rt5yu7i8kjmnhgfewq23456789oikjhgfewqdccmjyt65432q  qasdfgkjmhngrew32wertyuioikujytrewqertyuioplkuyjtrewqwertyujiop;[]poikujhgfdsafgjkl;lkjhmgfdsdfl.,mjhngfdsfghyukjbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww'

trapy.send(conn, packet)