Witam, przeczytałem artykuł z hakin9 o przechwytywaniu wiadomości gadu-gadu. Jest tam przedstawiony program, który ma przechwytywać wiadomości. Artykuł znajduję się tu: http://hakin9.org/system/artic[...]mosci_gadu-gadu.pdf?1249336600. Program się uruchamia, ale gdy piszę z swojego gg np do Infobota program nic nie zapisuje. Dostaje 2 ostrzeżenia podczas kompilacji:
System.Net.Dns.GetHostByName(string)' is obsolete: 'GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202'

using (File.Create(filePath)); //tu , gdy jest średnik otrzymuje ostrzeżenie: Possible mistaken empty statement, bez średnika znika ostrzeżenie znika.

Dlaczego ten program nie działa co jest źle? Próbowałem z gg w wersji 6, 7.7 i najnowszej. Program nie zapisuje danych albo ich wcale nie zapisuje po prostu nie ma pliku.

IPHeader.cs
Kod:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace PrzechwytywanieGG
{

    enum EProtocolType
    {
        TCP,
        OTHER
    }
    class IPHeader
    {
        private byte versionAndHeaderLength;
        private byte typeOfService;
        private ushort totalLenght;
        private ushort identification;
        private ushort flagsAndOffset;
        private byte tTL;
        private byte protocolType;
        private short checkSum;
        private uint sourceAddress;
        private uint destinationAddress;
        private byte headerLength;
        private byte[] ipData = new byte[4096];

        public IPHeader(byte[] dataReceived, int received)
        {
            try
            {
                MemoryStream sm = new MemoryStream(dataReceived,0,received);
                BinaryReader br = new BinaryReader(sm);
                versionAndHeaderLength=br.ReadByte();
                typeOfService=br.ReadByte();
                totalLenght=(ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                identification=(ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                flagsAndOffset=(ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                tTL=br.ReadByte();
                protocolType=br.ReadByte();
                checkSum=IPAddress.NetworkToHostOrder(br.ReadInt16());
                sourceAddress=(uint)(IPAddress.NetworkToHostOrder(br.ReadInt32()));
                destinationAddress=(uint)IPAddress.NetworkToHostOrder(br.ReadInt32());
                headerLength=versionAndHeaderLength;
                headerLength=(byte)((headerLength & 0x0f)*4);
                Array.Copy(dataReceived,headerLength,ipData,0,totalLenght-headerLength);
            }
            catch(Exception ex)
            {
                //błąd
                MessageBox.Show("Wyjątek z konstruktora IPHeader" + ex);
            }
        }
        //Właściwości klasy IPHeader
        public byte[] Data
        {
            get
            {
                return ipData;
            }
        }
        public EProtocolType TypeOfProtocol
        {
            get
            {
                if (protocolType == 6)
                    return EProtocolType.TCP;
                return EProtocolType.OTHER;
            }
        }
        public int MessageLength
        {
            get
            {
                return totalLenght - headerLength;
            }
        }
        
    }
}
TCPHeader.cs
Kod:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace PrzechwytywanieGG
{
    class TCPHeader
    {
        private ushort sourcePort;
        private ushort destinationPort;
        private uint sequenceNumber;
        private uint acknowledgmentNumber;
        private ushort dataOffsetAndFlags;
        private ushort window;
        private short checkSum;
        private ushort urgentPointer;
        private byte headerLength;
        private byte[] tcpData = new byte[4096];

        public TCPHeader(byte[] data, int received)
        {
            try
            {
                MemoryStream sm = new MemoryStream(data, 0, received);
                BinaryReader br = new BinaryReader(sm);
                sourcePort = (ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                destinationPort = (ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                sequenceNumber = (uint)IPAddress.NetworkToHostOrder(br.ReadInt32());
                acknowledgmentNumber = (uint)IPAddress.NetworkToHostOrder(br.ReadInt32());
                dataOffsetAndFlags = (ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                window = (ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                checkSum = (short)(IPAddress.NetworkToHostOrder(br.ReadInt16()));
                urgentPointer = (ushort)IPAddress.NetworkToHostOrder(br.ReadInt16());
                headerLength = (byte)(dataOffsetAndFlags >> 12);
                headerLength *= 4;
                Array.Copy(data, headerLength, tcpData, 0, received - headerLength);
            }
            catch (Exception ex) 
            {
                MessageBox.Show("Wyjątek z Konstuktora TCPHeader" + ex);
            }
        }
        //Właściwości klasy TCPHeader
        public byte[] TcpData
        {
            get
            {
                return tcpData;
            }
        }
        public ushort SourcePort
        {
            get
            {
                return sourcePort;
            }
        }
        public ushort DestinationPort
        {
            get
            {
                return destinationPort;
            }
        }
    }
}