Question

J'ai réussi à écrire un semiworking exemple EasyHook que des crochets recv fonction. J'ai écrit une forme, a ajouté un composant WebBrowser, et a commencé l'application. Le problème est, je reçois les paquets HTTP, mais s'il y a une prise, il semble que recv arrête « crochetage ». Le problème est, avec une application externe, Spystudio, je peux obtenir les accrocher recv. Alors, qu'est-ce que je manque?

using System;
using System.Collections.Generic;
using System.Data;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Ipc;
using EasyHook;

namespace flashing
{
    public partial class Form1 : Form,EasyHook.IEntryPoint
    {
        public LocalHook CreateRecvHook;

        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("Ws2_32.dll")]
        static extern int recv(
                    IntPtr socketHandle,
                    IntPtr buf,
                    int count,
                    int socketFlags
            );


        [UnmanagedFunctionPointer(CallingConvention.StdCall,
            CharSet = CharSet.Unicode,
            SetLastError = true)]


        delegate int Drecv(
                    IntPtr socketHandle,
                    IntPtr buf,
                    int count,
                    int socketFlags
            );


        static int recv_Hooked(
                    IntPtr socketHandle,
                    IntPtr buf,
                    int count,
                    int socketFlags)
        {
            int bytesCount = recv(socketHandle, buf, count, socketFlags);
            if (bytesCount > 0)
            {
                byte[] newBuffer = new byte[bytesCount];
                Marshal.Copy(buf, newBuffer, 0, bytesCount);
                string s = System.Text.ASCIIEncoding.ASCII.GetString(newBuffer);
                TextWriter tw = new StreamWriter("log.txt");
                tw.Write(s);
                tw.Close();
                Debug.WriteLine("Hooked:>" + s);
            }
            return bytesCount;
        }


        private void bottonHook_Click(object sender, EventArgs e)
        {
            try
            {
                CreateRecvHook = LocalHook.Create(
                    LocalHook.GetProcAddress("Ws2_32.dll", "recv"),
                    new Drecv(recv_Hooked),
                    this);

                CreateRecvHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
            }
            catch (Exception ExtInfo)
            {
                Debug.WriteLine("Error creating the Hook");
                return;
            }
            RemoteHooking.WakeUpProcess();
        }

        private void buttonLoader_Click(object sender, EventArgs e)
        {
            axShockwaveFlash1.LoadMovie(0, "test.swf");
        }
    }    
}

modifier : Je ne doute pas sur les recv, voilà ce que apimonitor me dit:

# TID Module API Return Error
5 2696 Flash10l.ocx recv ( 1992, 0x07080000, 65536, 0 ) 1

Alors, quelqu'un peut me aider?

Était-ce utile?

La solution

Problème résolu. La ligne qui a créé des problèmes était

CreateRecvHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });

Je l'ai changé à

CreateRecvHook.ThreadACL.SetInclusiveACL(new Int32[] { 0 });

et maintenant tout fonctionne très bien. Merci à tous:)

Autres conseils

Il y a beaucoup de différentes fonctions utilisées avec des prises. Peut-être que le plugin n'utilise pas la fonction nommée recv. Du haut de ma tête, je peux penser à recvfrom, recvmsg, WSARecv, WSARecvFrom, WSARecvMsg, ReadFile, ReadFileEx.

Ensuite, le greffon peut être fait avec les demandes d'E / S en chevauchement (éventuellement compliquée par des routines d'achèvement ou de ports d'achèvement), auquel cas les données ne sont pas stockées par exemple au cours de la appel de fonction ReadFile mais à un moment plus tard. Accrocher ceux serait beaucoup plus difficile.

J'ai écrit un outil de dumping http en utilisant sharppcs en C #. Il utilise le winpcap-pilote. Je pense qu'il est apihooks tan plus fiables.

HTTPSaver (avec les sources)
SharpPcap
Winpcap

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top