[Plugin] PacketLogger

… since we are going to move to this new forum, i’ll post it just once again …

phBot PacketLogger

phBot plugin to log packets from server > client and from client > server

it also provides a GUI to control the logging


Available on my GitHub Account

2 Likes

here is my update on this plugin. what does it do?
If you are trying to do a dungeon like jupiter or jobcave uniques with your party, when you click “start” button on client to server option, plugin will record opcodes which start with 7045 and 705A, those opcodes are selecting npc and teleporting. After teleporting with a char, you should click “stop” button and click to “Send Captured Packets”. This button will send opcodes to party chat like “INJECT 7045, 00 00 00” so other chars will teleport if you use xcontrol. Dont forget to clicking “Clear Packet List” after using it.

from phBot import *
import phBotChat
import QtBind
import binascii
import threading
import time


gui = QtBind.init(__name__, 'PacketLogger')

padding_left = 260
padding_top = 125

QtBind.createLabel(gui, 'client to server', padding_left + 11, padding_top + 10)
QtBind.createButton(gui, 'log_client_start', 'start', padding_left + 10, padding_top + 30)
QtBind.createButton(gui, 'log_client_stop', 'stop', padding_left + 10, padding_top + 60)

QtBind.createLabel(gui, 'server to client', padding_left + 111, padding_top + 10)
QtBind.createButton(gui, 'log_server_start', 'start', padding_left + 110, padding_top + 30)
QtBind.createButton(gui, 'log_server_stop', 'stop', padding_left + 110, padding_top + 60)
lstcodes = QtBind.createList(gui, 10, 10,200,300)
QtBind.createButton(gui, 'send_captured_packets', 'Send Captured Packets',250, 20)
QtBind.createButton(gui, 'clear_packet_list', 'Clear Packet List', 250, 40)


log_client = False
log_server = False
captured_packets = []


def clear_packet_list():
    global captured_packets
    captured_packets = []
    QtBind.clear(gui, lstcodes)

    
def send_captured_packets():
    global captured_packets
    for packet in captured_packets:
        opcode = packet[0]
        data = packet[1]
        # Construct injected message
        injected_msg = f"INJECT {opcode:04X} {data}"
        # Send message to party chat
        phBotChat.Party(injected_msg)
        # Wait for 1 second
        time.sleep(1)
    log('[%s] sent captured packets to party chat' % (__name__))




def update_packet_list():
    global captured_packets
    packets_string = ""
    for packet in captured_packets:
        opcode = packet[0]
        data = packet[1]
        packet_string = f"Opcode: 0x{opcode:04X}, Data: {data}"
        packets_string += packet_string + "\n"

    QtBind.clear(gui, lstcodes)
    for packet in captured_packets:
        opcode = packet[0]
        data = packet[1]
        packet_string = f"0x{opcode:04X} {data}"
        QtBind.append(gui, lstcodes, packet_string)
    

def handle_silkroad(opcode, data):
    global captured_packets
    if log_client:
        if opcode == 0x2002:
            return True  # we don't want to log pings
        log('[%s] packet from client to server' % (__name__))
        log('[%s] \topcode: 0x%02X' % (__name__, opcode))
        if data is not None:
            hex_data = binascii.hexlify(data)
            hex_data_list = [hex_data[i:i+2].decode() for i in range(0, len(hex_data), 2)]
            log('[%s] \tdata: %s' % (__name__, ' '.join(hex_data_list)))
        if opcode == 0x7045 or opcode == 0x705A:
            hex_data = binascii.hexlify(data)
            hex_data_str = ' '.join([hex_data[i:i+2].decode() for i in range(0, len(hex_data), 2)])
            captured_packets.append((opcode, hex_data_str))
            log('[%s] packet from client to server' % (__name__))
            log('[%s] \topcode: 0x%02X' % (__name__, opcode))
            log('[%s] \tdata: %s' % (__name__, hex_data_str))
            QtBind.append(gui, lstcodes, f"Opcode: 0x{opcode:04X}, Data: {hex_data_str}")
            update_packet_list()  # captured_packets listesini güncelle
    return True


def handle_joymax(opcode, data):
    if log_server:
        log('[%s] packet from server to client' % (__name__))
        log('[%s] \topcode: 0x%02X' % (__name__, opcode))
        if data is not None:
            log('[%s] \tdata: %s' % (__name__, binascii.hexlify(data)))
    return True


def log_client_start():
    global log_client
    log('[%s] log client started' % (__name__))
    log_client = True
    global captured_packets
    captured_packets = []
    
def log_client_stop():
    global log_client
    log('[%s] log client stopped' % (__name__))
    log_client = False


def log_server_start():
    global log_server
    log('[%s] log server started' % (__name__))
    log_server = True


def log_server_stop():
    global log_server
    log('[%s] log server stopped' % (__name__))
    log_server = False
    


def clear_captured_packets():
    global captured_packets
    captured_packets.clear()
    log('[%s] captured packets cleared' % (__name__))    




update_packet_list()




log('[%s] loaded' % (__name__))

1 Like

well done i think people been craving for this for very long time

Hi bro,

Can I enter job cave auto with this plugin? Can you give detailed information about the subject pls?

I installed the plugin, but I cannot display it in my phbot plugin list.

image

This plugin likely isn’t whitelisted for TRSRO

1 Like