Domanda

Sono riuscito a scrivere un semiworking EasyHook esempio, che ami la funzione recv. Ho scritto un modulo, aggiunto un componente del browser web, e ha iniziato l'applicazione. Il problema è, ho l'HTTP pacchetti, ma se c'è una presa di corrente, sembra che recv ferma "aggancio". Il problema è, con un'applicazione esterna, SpyStudio, posso ottenere agganciandoli RECV. Allora, che cosa mi manca?

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

modifica : Non ho alcun dubbio su recv, qui è quello che apimonitor mi dice:

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

Quindi, Qualcuno può aiutarmi?

È stato utile?

Soluzione

problema risolto. La linea che guaio creato era

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

L'ho cambiato in

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

e ora tutto funziona bene. Grazie a tutti:)

Altri suggerimenti

Ci sono un sacco di diversi funzioni utilizzate con prese. Forse il plugin non utilizza la funzione denominata recv. Fuori della parte superiore della mia testa mi viene in mente recvfrom, recvmsg, WSARecv, WSARecvFrom, WSARecvMsg, ReadFile, ReadFileEx.

Quindi, il plugin potrebbe essere fare richieste con I / O sovrapposte (forse complicata da routine di completamento o porte di completamento), nel qual caso i dati non vengono memorizzati durante l'esempio funzione di chiamata ReadFile ma in un secondo momento. Agganciando quelli sarebbe molto più impegnativo.

ho scritto uno strumento di scarico http utilizzando sharppcs in C #. Esso utilizza il winpcap-driver. Penso che sia più affidabili apihooks tan.

HTTPSaver (con fonti)
SharpPcap
Winpcap

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top