elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Temas
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Ayuda win32.beginupdateresource(), win32.updateresource(), no funciona. en: 2 Noviembre 2010, 02:03 am
estuve probando varias maneras de cambiar los rescursos de un exe, al final lo que ando usando es:

Código
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Microsoft.Win32;
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14.    static class Program
  15.    {
  16.        /// <summary>
  17.        /// The main entry point for the application.
  18.        /// </summary>
  19.        [STAThread]
  20.        [DllImport("kernel32.dll", SetLastError = true)]
  21.        static extern IntPtr BeginUpdateResource(string pFileName, bool bDeleteExistingResources);
  22.        [DllImport("kernel32.dll", SetLastError = true)]
  23.        static extern bool UpdateResource(IntPtr hUpdate, string lpType, string lpName, ushort wLanguage, IntPtr lpData, uint cbData);
  24.        [DllImport("kernel32.dll", SetLastError = true)]
  25.        static extern bool EndUpdateResource(IntPtr hUpdate, bool fDiscard);
  26.        static unsafe void Main()
  27.        {
  28.            string path = "c:\\users\\sean\\desktop\\resourcer.exe";
  29.  
  30.            IntPtr hResource = BeginUpdateResource(path, false);
  31.            if (hResource.ToInt32() == 0)
  32.                throw new Exception("File Not Found");
  33.  
  34.            string newMessage = File.ReadAllText("c:\\users\\sean\\desktop\\newMessage.txt");
  35.            Byte[] bytes = new ASCIIEncoding().GetBytes(newMessage);
  36.            GCHandle bHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
  37.            IntPtr ptr = bHandle.AddrOfPinnedObject();
  38.  
  39.            ushort id = (ushort)Language.MakeLanguageID();
  40.  
  41.            if (UpdateResource(hResource, "FILE", "eva.txt", id, ptr, (uint)bytes.Length))
  42.                EndUpdateResource(hResource, false);
  43.            else
  44.                MessageBox.Show("Did not update", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  45.        }
  46.    }
  47.    public static class Language
  48.    {
  49.  
  50.        public static int MakeLanguageID()
  51.        {
  52.            CultureInfo currentCulture = CultureInfo.CurrentCulture;
  53.            int pid = GetPid(currentCulture.LCID);
  54.            int sid = GetSid(currentCulture.LCID);
  55.            return (((ushort)pid) << 10) | ((ushort)sid);
  56.        }
  57.  
  58.  
  59.        public static int GetPid(int lcid)
  60.        { return ((ushort)lcid) & 0x3ff; }
  61.  
  62.  
  63.        public static int GetSid(int lcid)
  64.        { return ((ushort)lcid) >> 10; }
  65.  
  66.    }
  67. }
  68.  


Para ver si funciona lo que hago es "descomprimir" el recurso del exe modificado.
Supuestamente deberia mostrar el nuevo .txt, pero no... cuando lo abro contiene el texto viejo.

Lo que hago para descomprimir los recursos del exe modificado es:
Código
  1.  
  2.      string strNewPathToSave = "new.txt";
  3.  
  4.      Assembly assembly = Assembly.GetExecutingAssembly();
  5.  
  6.      Stream resourceStream = assembly.GetManifestResourceStream("WindowsFormsApplication2.Resources.eva.txt");
  7.  
  8.      System.IO.FileStream fs = System.IO.File.OpenWrite(strNewPathToSave);
  9.  
  10.      try
  11.  
  12.      {
  13.  
  14.      // Save the File...
  15.  
  16.      byte[] buffer = new byte[resourceStream.Length];
  17.  
  18.      resourceStream.Read(buffer, 0, (int)resourceStream.Length);
  19.  
  20.      fs.Write(buffer, 0, buffer.Length);
  21.  
  22.      }
  23.  
  24.      finally
  25.  
  26.      {
  27.  
  28.      fs.Close();
  29.  
  30.      }

Redondeando....
Con exe1 cambio un recurso de exe2 (un .txt). Despues abro el exe2 y descomprimo el recurso .txt . Este en lugar de mostrar el nuevo texto, muestra el texto del recurso original.
Alguna idea?

Saludos
2  Programación / .NET (C#, VB.NET, ASP) / Generar un servidor desde un exe en: 30 Octubre 2010, 16:52 pm
Hola a todos.
Tengo una duda aver si alguien puede ayudarme.
Como se puede hacer para que desde una aplicacion se genere otra basada en unos parametros ingresados en la app1.
Para dar un ejemplo, el creador del servidor de cualquier troyano.
Durante la ejecucion del cliente hay una opcion para generar el servidor eligiendo puerto ip de conexion etc.
Se me ocurre que lo que hacen es tener el codigo del servidor ya armado leerlo y luego modificar solamente una parte (la del puerto y ip). El tema es que si uno borra el servidor por defecto este se genera igual, por lo tanto lo que esta haciendo no es modificar un exe ya creado, sino crearlo desde 0 con los parametros elegidos.
La duda viene entonces a como poder hacer esto.
Muchas gracias
3  Programación / Programación C/C++ / El for() no reconoce las marcas en: 17 Septiembre 2010, 22:10 pm
Hola que tal, el problema es el siguiente, cuando el programa se ejecuta y hace un for en busca de unas marcas ( '*' y '°') este no las encuentra.
Depure el programa y lo que me salio fue: "Se ha producido una violacion de acceso a memoria", el contador i estaba en: "16444".
El codigo de busqueda es el siguiente:



Código:
for(int i=0;i<tamanio;i++)
  {
          if(buffer[i] == '*' && buffer[i+1] == '*')
          {
                exe1 = buffer+i+2;
                a = i+2;
                break;        
          }

Y el codigo donde se agregan las marcas es el siguiente:



Código:
void crearFichero(char* buffer1, int tamanio1, char* buffer2, int tamanio2)
{
  char info[1];
  char info2[1];
  info[0] = '*';
  info[1] = '*';
  info2[0] = '°';
  info2[1] = '°';
  CopyFile("main.exe","bindedm.exe",TRUE);
  ofstream escritura1("bindedm.exe", ofstream::binary | ofstream::app);
  escritura1.write(info, strlen(info));
  escritura1.write(buffer1, tamanio1);
  escritura1.write(info2, strlen(info2));
  escritura1.write(buffer2, tamanio2);
  escritura1.close();
}

Aver quien me da una mano.
Gracias
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines