Exemplo n.º 1
0
def logPacket(raw):
    raw.accept()
    packet = net.IP(raw.get_payload())
    if net.DNS in packet or net.ICMP in packet:  #ignore there as they're not used for "actual" game netcode
        return
    IP = packet[net.IP]
    left = (local_colour if IP.src == machines["target"].ip else
            remote_colour) + f"{IP.src:>15}:{IP.sport:<5}\x1b[0m"
    right = (local_colour if IP.dst == machines["target"].ip else
             remote_colour) + f"{IP.dst:>15}:{IP.dport:<5}\x1b[0m"
    print(f"{left} > {right}")


print("Finding network devices...")
machines = get_machines.search(ps4=True)

#will default to UDP
network_thread = packet_analysis.NFQueueThread(machines["target"],
                                               callback=logPacket)
try:
    print("Starting nfqueue...")
    network_thread.start()
    network_thread.join()

except KeyboardInterrupt:
    print("Closing...")

except Exception as e:
    print(e)
    parser = argparse.ArgumentParser()
    parser.add_argument("--gateway_ip")
    parser.add_argument("--target_ip")
    parser.add_argument("--target_mac")
    parser.add_argument("--ps4", action="store_true")

    parser.add_argument("--game_protocol")
    parser.add_argument("--game_port")

    parser.add_argument("--http_port")
    parser.add_argument("--http_address")
    args = parser.parse_args()

    print("Finding network devices...")
    machines = get_machines.search(ps4=args.ps4,
                                   gateway_ip=args.gateway_ip,
                                   target_ip=args.target_ip,
                                   mac_startswith=args.target_mac)

    game_settings = {}
    if args.game_protocol: game_settings["game_protocol"] = args.game_protocol
    if args.game_port: game_settings["game_port"] = args.game_port

    http_settings = {}
    if args.http_port: http_settings["server_port"] = int(args.http_port)
    if args.http_address: http_settings["server_address"] = args.http_address

    #will default to UDP
    network_thread = packet_analysis.NFQueueThread(machines["target"],
                                                   **game_settings)
    try:
        print(