Ejemplo n.º 1
0
        public void processPackets()
        {
            L2Packet l2packet = null;


            while (this.clientStr.MorePackets())
            {
                l2packet = this.gameSniffer.handlePacket(this.clientStr.ReadPacket(), false);
                if (l2packet != null)
                {
                    this.packetContainer.AddPacket(l2packet);
                    l2packet.PacketNo = this.count++;
                    this.NewPacketArrived(this);
                }
            }
            while (this.serverStr.MorePackets())
            {
                l2packet = this.gameSniffer.handlePacket(this.serverStr.ReadPacket(), true);
                if (l2packet != null)
                {
                    this.packetContainer.AddPacket(l2packet);
                    l2packet.PacketNo = this.count++;
                    this.NewPacketArrived(this); //Raise Event
                }
            }
        }
Ejemplo n.º 2
0
        //private Dictionary<FilterItem, FilterItem> filter = new Dictionary<FilterItem, FilterItem>();

        public void AddPacket(L2Packet p)
        {
            this.packetList.Add(p);
            //wenn nicht im Filter, auch der Anzeigenden liste hinzufügen
            if (!this.filter.ContainsKey(new FilterItem(p.OpCode, (p is GameServerPacket)).GetHashCode()))
            {
                this.diplayedList.Add(p);
            }
        }
Ejemplo n.º 3
0
        private void fastObjectListView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            L2Packet p = (L2Packet)this.fastObjectListView1.SelectedObject;

            if (p != null)
            {
                this.hexBox1.ByteProvider = new DynamicByteProvider(p.Data.Get_ByteArray());
            }
        }
Ejemplo n.º 4
0
        private void onMyTargetSelected(L2Packet packet)
        {
            packet.Data.SetIndex(3);
            int objId = packet.Data.ReadInt32();

            if (this.lastTarget != objId)
            {
                this.labelClan.Text = "";
                if (this.knownNpcs.ContainsKey(objId))
                {
                    int npcId = this.knownNpcs[objId];
                    this.labelName.Text       = NpcNames.GetInstance().GetName(npcId);
                    this.labelName.ForeColor  = Color.LightGray;
                    this.labelTitle.Text      = NpcNames.GetInstance().GetTitle(npcId);
                    this.labelTitle.ForeColor = NpcNames.GetInstance().GetColor(npcId);

                    this.lastNpcId = npcId;
                }
                else if (this.knownPcs.ContainsKey(objId))
                {
                    L2Pc pc = this.knownPcs[objId];
                    this.labelName.Text       = pc.VisibleName;
                    this.labelTitle.Text      = pc.Title;
                    this.labelTitle.ForeColor = Color.LightGray;

                    // Karma/PvP
                    this.labelName.ForeColor = Color.LightGray;
                    if (pc.PvpFlag)
                    {
                        this.labelName.ForeColor = Color.Pink;
                    }
                    if (pc.Karma > 0)
                    {
                        this.labelName.ForeColor = Color.Red;
                    }

                    // Clan
                    if (this.knownPlegdes.ContainsKey(pc.ClanId))
                    {
                        this.labelClan.Text = "Clan: " + this.knownPlegdes[pc.ClanId].ClanName;
                    }
                }
                else if (this.myCharObjId == objId) // myself
                {
                    this.labelName.Text       = this.myCharName;
                    this.labelTitle.Text      = "";
                    this.labelTitle.ForeColor = Color.LightGray;
                }
                else
                {
                    this.labelName.Text      = "id:" + objId;
                    this.labelName.ForeColor = Color.LightGray;
                    this.labelTitle.Text     = "";
                }
                this.lastTarget = objId;
            }
        }
Ejemplo n.º 5
0
 private void onUserInfo(L2Packet packet)
 {
     packet.Data.SetIndex(3);
     packet.Data.ReadInt32();
     packet.Data.ReadInt32();
     packet.Data.ReadInt32();
     packet.Data.ReadInt32();
     this.myCharObjId = packet.Data.ReadInt32();
     //string ownName = packet.Data.ReadString();
 }
Ejemplo n.º 6
0
        private void device_PcapOnPacketArrival(object sender, Packet packet)
        {
            if (!(packet is TCPPacket))
            {
                return;
            }

            TCPPacket tcpPacket = (TCPPacket)packet;
            // Creates a key for the dictionary
            TCPConnection c = new TCPConnection(tcpPacket);

            // Todo: gescheiter Filter
            if (!(c.DestinationPort == port || c.SourcePort == port))
            {
                return;
            }

            // create a new entry if the key does not exists
            if (!sharpPcapDict.ContainsKey(c) && !this.gotLock)
            {
                TcpRecon.TcpRecon tcpRecon = new TcpRecon.TcpRecon(this.serverStr, this.clientStr);
                sharpPcapDict.Add(c, tcpRecon);
                this.gotLock = true;
            }

            // Use the TcpRecon class to reconstruct the session
            if (this.sharpPcapDict.ContainsKey(c))
            {
                sharpPcapDict[c].ReassemblePacket(tcpPacket);
            }

            L2Packet l2packet = null;


            while (this.clientStr.MorePackets())
            {
                l2packet = this.gameSniffer.handlePacket(this.clientStr.ReadPacket(), false);
                if (l2packet != null)
                {
                    this.packetContainer.AddPacket(l2packet);
                    l2packet.PacketNo = this.count++;
                }
            }
            while (this.serverStr.MorePackets())
            {
                l2packet = this.gameSniffer.handlePacket(this.serverStr.ReadPacket(), true);
                if (l2packet != null)
                {
                    this.packetContainer.AddPacket(l2packet);
                    l2packet.PacketNo = this.count++;
                }
            }
        }
Ejemplo n.º 7
0
        private void onPledgeInfo(L2Packet packet)
        {
            packet.Data.SetIndex(3);
            L2Plegde clan = new L2Plegde((GameServerPacket)packet);

            if (this.knownPlegdes.ContainsKey(clan.ClanId))
            {
                return;
            }

            this.knownPlegdes.Add(clan.ClanId, clan);
        }
Ejemplo n.º 8
0
        private void onExFishingHpRegen(L2Packet packet)
        {
            packet.Data.SetIndex(5);
            int obId = packet.Data.ReadInt32();

            if (obId != this.myCharObjId)
            {
                return;
            }
            int   time     = packet.Data.ReadInt32();
            int   hp       = packet.Data.ReadInt32();
            short hpMode   = packet.Data.ReadInt16();
            short gootUse  = packet.Data.ReadInt16();
            short anim     = packet.Data.ReadInt16();
            int   penalty  = packet.Data.ReadInt32();
            byte  hpBarCol = packet.Data.ReadByte();

            switch (hpMode)
            {
            case 0:
                this.labelExpanderHint.Text = hpBarCol == 0 ? "Pumping" : "Reeling";
                //this.fishBot.UsePump();
                if (OptionsForm.Instance.EnableFishbot)
                {
                    if (hpBarCol == 0x00)
                    {
                        this.fishBot.UsePump();
                    }
                    else
                    {
                        this.fishBot.UseReel();
                    }
                }
                break;

            case 1:
                this.labelExpanderHint.Text = hpBarCol == 0 ? "Reeling" : "Pumping";
                //this.fishBot.UseReel();
                if (OptionsForm.Instance.EnableFishbot)
                {
                    if (hpBarCol == 0x00)
                    {
                        this.fishBot.UseReel();
                    }
                    else
                    {
                        this.fishBot.UsePump();
                    }
                }
                break;
            }
        }
Ejemplo n.º 9
0
 private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem.Text.Equals("Add to Filter") && this.packetContainer != null)
     {
         L2Packet p = (L2Packet)this.fastObjectListView1.SelectedObject;
         if (p != null)
         {
             this.packetContainer.AddFilter(p.OpCode, p is GameServerPacket);
             //refresh
             this.RefreshListView();
         }
     }
 }
Ejemplo n.º 10
0
        private static void device_PcapOnPacketArrival(object sender, Packet packet)
        {
            try
            {
                if (packet is TCPPacket)
                {
                    L2Packet l2packet = null;

                    TCPPacket etherFrame = (TCPPacket)packet;
                    if (etherFrame.Data.Length != 0 && etherFrame.SourcePort == 2106 &&
                        etherFrame.Ack && etherFrame.Psh)    // packet contains data and is from port 2106
                    {
                        l2packet = client.handlePacket(etherFrame.Data, true);
                    }
                    else if (etherFrame.Data.Length != 0 && etherFrame.SourcePort == 7777 &&
                             etherFrame.Ack && etherFrame.Psh)
                    {
                        //TCPPacket tcpP = reAss.processPacket(etherFrame);
                        // if (tcpP != null)
                        gpHandler.handlePacket(etherFrame.Data);

                        while (gpHandler.BufferQueue.Count > 0)
                        {
                            l2packet = game.handlePacket(gpHandler.BufferQueue.Dequeue(), true);
                        }
                        if (clientPort == 0)
                        {
                            clientPort = etherFrame.DestinationPort;
                        }
                    }
                    else if (etherFrame.Data.Length != 0 && etherFrame.SourcePort == clientPort &&
                             etherFrame.Ack && etherFrame.Psh)
                    {
                        cpHandler.handlePacket(etherFrame.Data);
                        while (cpHandler.BufferQueue.Count > 0)
                        {
                            l2packet = game.handlePacket(cpHandler.BufferQueue.Dequeue(), false);
                        }
                    }

                    if (l2packet != null)
                    {
                        Console.Out.WriteLine("Packet is " + l2packet.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 11
0
        private void onNpcInfo(L2Packet packet)
        {
            packet.Data.SetIndex(3);
            //writeD(_activeChar.getObjectId());
            //writeD(_idTemplate + 1000000);  // npctype id
            int objId = packet.Data.ReadInt32();
            int npcId = packet.Data.ReadInt32() - 1000000;

            if (this.knownNpcs.ContainsKey(objId))
            {
                return;
            }

            this.knownNpcs.Add(objId, npcId);
        }
Ejemplo n.º 12
0
        private void onDeleteObject(L2Packet packet)
        {
            packet.Data.SetIndex(3);
            int objId = packet.Data.ReadInt32();

            if (this.knownNpcs.ContainsKey(objId))
            {
                this.knownNpcs.Remove(objId);
            }

            if (this.knownPcs.ContainsKey(objId))
            {
                this.knownPcs.Remove(objId);
            }
        }
Ejemplo n.º 13
0
        private void onExFishingStart(L2Packet packet)
        {
            // Start Fishing, Expand the Window
            packet.Data.SetIndex(5);
            int obId = packet.Data.ReadInt32();

            if (obId != this.myCharObjId)
            {
                return;
            }

            this.Expanded = true;
            this.labelExpanderHint.Text  = "Warte auf einen Fisch...";
            this.labelExpanderHint2.Text = "";
        }
Ejemplo n.º 14
0
        private void onExFishingStop(L2Packet packet)
        {
            // Stop Fishing, Collapse the Window
            packet.Data.SetIndex(5);
            int obId = packet.Data.ReadInt32();

            if (obId != this.myCharObjId)
            {
                return;
            }

            this.Expanded = false;
            this.labelExpanderHint.Text  = "";
            this.labelExpanderHint2.Text = "";
        }
Ejemplo n.º 15
0
 public ArrayList GetStructure(L2Packet p)
 {
     if (p is GameServerPacket)
     {
         if (this.knownServerPackets.ContainsKey(p.OpCode))
         {
             return(((PacketInfo)this.knownServerPackets[p.OpCode]).structure.structure);
         }
     }
     else if (p is ClientPacket)
     {
         if (this.knownClientPackets.ContainsKey(p.OpCode))
         {
             return(((PacketInfo)this.knownClientPackets[p.OpCode]).structure.structure);
         }
     }
     return(null);
 }
Ejemplo n.º 16
0
        private void onCharInfo(L2Packet packet)
        {
            packet.Data.SetIndex(3 + 16);
            //writeD(_x);
            //writeD(_y);
            //writeD(_z);
            //writeD(0x00);

            //writeD(_activeChar.getObjectId());

            int objId = packet.Data.ReadInt32();

            if (this.knownPcs.ContainsKey(objId))
            {
                return;
            }

            this.knownPcs.Add(objId, new L2Pc((GameServerPacket)packet));
        }
Ejemplo n.º 17
0
        private void onSpoil(L2Packet packet)
        {
            packet.Data.SetIndex(3);
            int messageId = packet.Data.ReadInt32();

            switch (messageId)
            {
            case 612:     // Spoil ok
                this.labelName.Text = "Gespoilt";
                if (!OptionsForm.Instance.MuteSounds)
                {
                    this.beep.Play();
                }
                break;

            case 357:     // Allready Spoiled
                this.labelName.Text = "Schon gespoilt";
                break;
            }
        }
Ejemplo n.º 18
0
        private void onExFishingStartCombat(L2Packet packet)
        {
            packet.Data.SetIndex(5);
            int obId = packet.Data.ReadInt32();

            if (obId != this.myCharObjId)
            {
                return;
            }
            int   time          = packet.Data.ReadInt32();
            int   hp            = packet.Data.ReadInt32();
            short mode          = packet.Data.ReadInt16();
            short lureType      = packet.Data.ReadInt16();
            short deceptiveMode = packet.Data.ReadInt16();

            if (deceptiveMode == 1)
            {
                this.labelExpanderHint2.Text = "Täuschender Modus!";
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Mappt den Opcode in einen Aussagekräftigen String um
        /// </summary>
        /// <param name="p">Das L2Packet</param>
        /// <returns>den Namen des L2Packets</returns>
        public string GetName(L2Packet p)
        {
            string name = String.Format("0x{0:x2}", p.OpCode);

            if (p is GameServerPacket)
            {
                if (this.knownServerPackets.ContainsKey(p.OpCode))
                {
                    name = ((PacketInfo)this.knownServerPackets[p.OpCode]).name
                           + String.Format(": 0x{0:x2}", p.OpCode);
                }
            }
            else if (p is ClientPacket)
            {
                if (this.knownClientPackets.ContainsKey(p.OpCode))
                {
                    name = ((PacketInfo)this.knownClientPackets[p.OpCode]).name
                           + String.Format(": 0x{0:x2}", p.OpCode);;
                }
            }
            return(name);
        }
Ejemplo n.º 20
0
 private void onCharSelected(L2Packet packet)
 {
     packet.Data.SetIndex(3);
     this.myCharName       = packet.Data.ReadString();
     this.labelStatus.Text = String.Format("Verbunden als {0}", this.myCharName);
 }
Ejemplo n.º 21
0
        void sniffer_NewPacketArrived(object sender, L2Packet packet)
        {
            if (packet is ClientPacket)
            {
                return;
            }

            int opCode = packet.OpCode;

            switch (opCode)
            {
            case 0x62:     //SystemMessage
                this.onSpoil(packet);
                break;

            case 0x0b:     //CharSelected
                this.onCharSelected(packet);
                break;

            case 0xb9:     //MyTargetSelected
                this.onMyTargetSelected(packet);
                break;

            case 0x0c:     //NpcInfo
                onNpcInfo(packet);
                break;

            case 0x31:     //CharInfo
                onCharInfo(packet);
                break;

            case 0x32:     // Userinfo
                onUserInfo(packet);
                break;

            case 0x08:     //DeleteObject
                onDeleteObject(packet);
                break;

            case 0x89:     //PlegdeInfo
                onPledgeInfo(packet);
                break;

            case 0xfe1e:     //ExFishingStart
                // Expanderausklappen
                onExFishingStart(packet);
                break;

            case 0xfe1f:     //ExFishingStop
                // Expander einklappen
                onExFishingStop(packet);
                break;

            case 0xfe27:     //ExFishingStartCombat
                onExFishingStartCombat(packet);
                break;

            case 0xfe28:     //ExFishingHpRegen
                onExFishingHpRegen(packet);
                break;
            }
        }