示例#1
0
文件: net.py 项目: norsig/MobileVPN
def send_packet(packet):
    packet = IP(packet)
    del packet.chksum
    if UDP in packet:
        del packet[UDP].chksum
    if TCP in packet:
        del packet[TCP].chksum
    packet = packet.__class__(str(packet))
    send(packet, verbose=False)
示例#2
0
文件: net.py 项目: norsig/MobileVPN
def fix_packet(packet):
    packet = IP(packet)
    del packet.chksum
    if UDP in packet:
        del packet[UDP].chksum
    if TCP in packet:
        del packet[TCP].chksum
    packet = packet.__class__(str(packet))
    return str(packet[IP])
示例#3
0
print(ip_dest)

ip_header.version = 4
ip_header.ihl = ip_hdr_len // 4
ip_header.tos = 0x0
ip_header.len = (ip_hdr_len + udp_pkt_len)
ip_header.id = 0
ip_header.flags = 0
ip_header.frag = 0
ip_header.ttl = 64
ip_header.proto = 17
#ip_header.chksum= 0x7ce6
ip_header.src = ip_src
ip_header.dst = ip_dst
del ip_header.chksum
ip_header = ip_header.__class__(str(ip_header))

#ip_header.show2()
#print("-------------------------------------")
#hexdump((ip_header.version << 4) | ip_header.ihl)
#print(ip_header.version << 4)
#print(ip_header.ihl)
#print(ip_header.proto)
#hexdump(ip_header)

#ip_pkt_len = ip_hdr_len + udp_pkt_len
#ip_version = 4
#ip_ihl = ip_hdr_len // 4
#ip_tos = 0
#ip_id = 0
#ip_frag_off = 0
	#incoming_time = int.from_bytes(decrypted_payload[0:8], byteorder='big')
	
	#incoming_pkt = IP(decrypted_payload[8:])
	incoming_pkt = IP(inbound_sidechannel_shaper.process_packet(sender, decrypted_payload))
	
	incoming_pkt.src = localdb_ipmappings[sender]
	
	#Debug
	#timediff = abs(incoming_time - int(time.time() * 1000))
	#sys.stderr.write("Incoming packet delayed by {} ms.\n".format(timediff))
	
	#Assign the appropriate destination IP (this is a constant)
	incoming_pkt.dst = CONST_DST_IP
	
	#Recalculate the IPv4 checksum
	del incoming_pkt.chksum
	
	#If this carries a UDP packet recalculate the checksum from the new pseudoheader
	if incoming_pkt.haslayer(UDP):
		del incoming_pkt[UDP].chksum
	
	#If this carries a TCP packet recalculate the checksum from the new pseudoheader
	if incoming_pkt.haslayer(TCP):
		del incoming_pkt[TCP].chksum
	
	incoming_pkt = incoming_pkt.__class__(bytes(incoming_pkt))
	
	#Send it over to Socat
	sys.stdout.buffer.write(socat_format(incoming_pkt))
	sys.stdout.buffer.flush()