Pregunta

Me las arreglé para escribir un ejemplo semiworking EasyHook que los ganchos función recv. Escribí una forma, se añaden un componente WebBrowser, y empecé la aplicación. El problema es, consigo el HTTP paquetes, pero si hay una toma de corriente, parece que se detiene recv "enganche". El problema es que, con una aplicación externa, SpyStudio, que puedo conseguir que se conecten recv. Por lo tanto, lo que me estoy perdiendo?

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

editar : No tengo ninguna duda de recv, aquí está lo apimonitor me dice:

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

Así que, ¿Puede alguien ayudarme?

¿Fue útil?

Solución

Problema resuelto. La línea que fue creado problemas

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

He cambiado a

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

y ahora todo funciona bien. Gracias a todo el mundo:)

Otros consejos

Hay una gran cantidad de diferentes funciones que se utilizan con los zócalos. Tal vez el plugin no está utilizando la función llamada recv. De la parte superior de mi cabeza se me ocurre recvfrom, recvmsg, WSARecv, WSARecvFrom, WSARecvMsg, ReadFile, ReadFileEx.

A continuación, el plugin podría ser hacer peticiones con solapada I / O (posiblemente complicada por rutinas de finalización o puertos de finalización), en cuyo caso los datos no se almacena durante el ejemplo llamada a la función ReadFile pero en algún momento posterior. Enganchando los sería considerablemente más difícil.

Me escribió una herramienta vertido http usando sharppcs en C #. Utiliza el winpcap-conductor. Creo que es tan apihooks más fiables.

HTTPSaver (con fuentes)
SharpPcap
Winpcap

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top