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

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 53
131  Programación / Programación C/C++ / Re: mi dll hace lo contrario de lo que debería hacer en: 20 Marzo 2017, 11:45 am
Solucionao
132  Programación / Programación C/C++ / Re: Iniciar un proceso de forma pausada c++ en: 20 Marzo 2017, 05:33 am
Los tipos de Windows que empiezan con P o con LP suelen sen punteros.
En cualquier caso: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx

De todos modos, si no te gusta PHANDLE, puedes poner HANDLE*. La razón de que hayan puesto un HANDLE* en esa función es para poder devolver el HANDLE.
Código
  1. *hthread = pi.hThread;
Pues al final lo corregi haciendo la conversión pasando el * intente pero no iba. Pero aún así mi inyector falla cuando hago esto de iniciar un proceso pausado y llamo a la función obviamente si descarto esto funciona. Pero el objetivo es iniciar un proceso de manera pausada, sacar el pid nuevo para ese proceso y luego inyectar una dll en el proceso.  Supongo que no debería poner *ph = (PHANDLE)GetCurrentProcess();  ya que estoy llamando a otro proceso diferente que sería el taskmgr.. claro que estaría cerrado yo lo iniciaria.
El código es el siguiente:
Código
  1. // injector.cpp: define el punto de entrada de la aplicación de consola.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <windows.h>
  8. #include <Tlhelp32.h>
  9. #include <wchar.h>
  10. #include <iostream>
  11. using namespace std;
  12.  
  13. void error(char *err);
  14.  
  15. HANDLE myProc = NULL;
  16.  
  17. void error(char *err)
  18. {
  19. if (myProc != NULL) CloseHandle(myProc);
  20. printf("%s", err);
  21. exit(0);
  22. }
  23.  
  24. HANDLE Startpausedprocess(char *cmd, PHANDLE hthread)//Not const char* because CreateProcess may write on it
  25. {
  26.    PROCESS_INFORMATION pi;
  27.    STARTUPINFOA si;//STARTUPINFOA is the ANSI version of STARTUPINFO.
  28.    ZeroMemory(&si, sizeof(STARTUPINFOA));
  29.    si.cb = sizeof(STARTUPINFOA);
  30.  
  31.    if (!CreateProcessA(NULL, cmd, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &si, &pi))//The flag "CREATE_SUSPENDED" will create the process and pause the main thread.
  32.    {
  33.        cout << "CreateProcess failed, " << GetLastError() << endl;
  34.        return NULL;
  35.    }
  36.    *hthread = pi.hThread;
  37.    return pi.hProcess;
  38. }
  39.  
  40. int main(int argc, char *argv[])
  41. {
  42. PHANDLE *ph=NULL;
  43. *ph = (PHANDLE)GetCurrentProcess();
  44. Startpausedprocess("taskmgr.exe",*ph);
  45. HANDLE processList = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  46. PROCESSENTRY32 pInfo;
  47. BOOL st = TRUE;
  48. pInfo.dwSize = sizeof(PROCESSENTRY32);
  49. Process32First(processList, &pInfo);
  50. int myPid = 0;
  51. do
  52. {
  53. std::wstring name(L"taskmgr.exe");
  54. const wchar_t* szName = name.c_str();
  55. if (wcscmp(pInfo.szExeFile, szName) == 0)
  56. {
  57. myPid = pInfo.th32ProcessID;
  58. cout << myPid << endl;
  59. break;
  60. }
  61. Process32Next(processList, &pInfo);
  62. } while (st != FALSE);
  63.  
  64. // Abrir el proceso
  65. printf("[+] Opening process %i\n", myPid);
  66. myProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, myPid);
  67. if (myProc == NULL) error("[-] Error abriendo proceso.\n");
  68. else printf("[+] Proceso abierto.\n");
  69.  
  70. // Reservar memoria para el argumento (ruta de la DLL)
  71. char thData[] = "dllmain.dll";
  72. LPVOID dirToArg = VirtualAllocEx(myProc, NULL, strlen(thData), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  73. if (dirToArg == NULL)
  74. error("[-] Error reservando memoria para argumento.\n");
  75. else
  76. printf("[+] Memoria reservada para argumento (%i bytes).\n", strlen(thData));
  77.  
  78.  
  79. // Escribir la ruta de la DLL en la memoria reservada
  80. SIZE_T written = 0;
  81. if (WriteProcessMemory(myProc, dirToArg, (LPVOID)&thData, strlen(thData), &written) == 0)
  82. error("[-] Error escribiendo memoria.\n");
  83. else
  84. printf("[+] Memoria escrita (arg %i bytes).\n", written);
  85. //Lanzar un hilo con LoadLibrary
  86. //Load the DLL
  87. //Load the DLL
  88. HANDLE rThread = CreateRemoteThread(myProc, NULL, NULL, (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "LoadLibraryA"), dirToArg, NULL, NULL);
  89. if (rThread == NULL)
  90. error("[-] Error creando el hilo.\n");
  91. else
  92. printf("[+] Hilo creado.\n");
  93. CloseHandle(rThread);
  94.  
  95. }
  96.  

El error que me devuelve a la mejor creo por hacer conversion al handle..
Código:
Problem signature:
  Problem Event Name: APPCRASH
  Application Name: injector.exe
  Application Version: 0.0.0.0
  Application Timestamp: 58cf59ba
  Fault Module Name: injector.exe
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp: 58cf59ba
  Exception Code: c0000005
  Exception Offset: 000179a9
  OS Version: 6.1.7601.2.1.0.256.1
  Locale ID: 1043
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt

Debugeando podría ver pero aún así se cual es la razón al incluir la función para que arranque mi proceso de manera pausada algo estaré haciendo mal, si me sugieres debuguear podría tambien chekearlo.
133  Programación / Programación C/C++ / mi dll hace lo contrario de lo que debería hacer en: 20 Marzo 2017, 02:03 am
Este es el injector:
Código
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <windows.h>
  5. #include <Tlhelp32.h>
  6. #include <wchar.h>
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. void error(char *err);
  11.  
  12. HANDLE myProc = NULL;
  13.  
  14. void error(char *err)
  15. {
  16. if (myProc != NULL) CloseHandle(myProc);
  17. printf("%s", err);
  18. exit(0);
  19. }
  20.  
  21. int main(int argc, char *argv[])
  22. {
  23. HANDLE processList = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  24. PROCESSENTRY32 pInfo;
  25. BOOL st = TRUE;
  26. pInfo.dwSize = sizeof(PROCESSENTRY32);
  27. Process32First(processList, &pInfo);
  28. int myPid = 0;
  29. do
  30. {
  31. std::wstring name(L"taskmgr.exe");
  32. const wchar_t* szName = name.c_str();
  33. if (wcscmp(pInfo.szExeFile, szName) == 0)
  34. {
  35. myPid = pInfo.th32ProcessID;
  36. cout << myPid << endl;
  37. break;
  38. }
  39. Process32Next(processList, &pInfo);
  40. } while (st != FALSE);
  41.  
  42. // Abrir el proceso
  43. printf("[+] Opening process %i\n", myPid);
  44. myProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, myPid);
  45. if (myProc == NULL) error("[-] Error abriendo proceso.\n");
  46. else printf("[+] Proceso abierto.\n");
  47.  
  48. // Reservar memoria para el argumento (ruta de la DLL)
  49. char thData[] = "dllmain.dll";
  50. LPVOID dirToArg = VirtualAllocEx(myProc, NULL, strlen(thData), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  51. if (dirToArg == NULL)
  52. error("[-] Error reservando memoria para argumento.\n");
  53. else
  54. printf("[+] Memoria reservada para argumento (%i bytes).\n", strlen(thData));
  55.  
  56.  
  57. // Escribir la ruta de la DLL en la memoria reservada
  58. SIZE_T written = 0;
  59. if (WriteProcessMemory(myProc, dirToArg, (LPVOID)&thData, strlen(thData), &written) == 0)
  60. error("[-] Error escribiendo memoria.\n");
  61. else
  62. printf("[+] Memoria escrita (arg %i bytes).\n", written);
  63. //Lanzar un hilo con LoadLibrary
  64. //Load the DLL
  65. //Load the DLL
  66. HANDLE rThread = CreateRemoteThread(myProc, NULL, NULL, (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "LoadLibraryA"), dirToArg, NULL, NULL);
  67. if (rThread == NULL)
  68. error("[-] Error creando el hilo.\n");
  69. else
  70. printf("[+] Hilo creado.\n");
  71. CloseHandle(rThread);
  72.  
  73. }

Este es la .dll:
Código
  1. // dllmain.cpp : Defines the entry point for the DLL application.
  2. #include "stdafx.h"
  3. #include "C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h"//MHook header
  4. #include <iostream>
  5. #include <windows.h>
  6. #include <Commctrl.h>
  7. #include <conio.h>
  8.  
  9. using namespace std;
  10.  
  11. typedef void (*SENDMESSAGEW)();//Typedef for the hooked function
  12. static SENDMESSAGEW Basewritefoobar;//Backup of the originak fonction
  13.  
  14. static const wchar_t *pwned=L"PWNED";//PWNED
  15. LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  16. {
  17.    if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
  18.    {
  19.        ((LVITEMW*)lparam)->pszText=pwned;//Replace the item text with our text.
  20.    }
  21.    return baseSendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
  22. }
  23. static bool Hook();
  24.  
  25. template <typename T>
  26. inline MH_STATUS MH_CreateHookEx(void* target, void* const base, T** original)
  27. {
  28.    return MH_CreateHook(target, base, reinterpret_cast<void**>(original));
  29. }
  30.  
  31.  
  32. extern "C" __declspec (dllexport) void __cdecl SendWrite()
  33. {
  34.  
  35. }
  36.  
  37. BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
  38. {
  39. //Different behaviors depending on the reason why DllMain is called
  40. switch (ul_reason_for_call) {
  41. case DLL_PROCESS_ATTACH:
  42. if (!Hook())//Hook "Writefoobar"
  43. {
  44. cout << "Hook failed" << endl;
  45. return 1;
  46. }
  47. break;
  48. case DLL_PROCESS_DETACH:
  49. break;
  50. case DLL_THREAD_ATTACH:
  51. break;
  52. case DLL_THREAD_DETACH:
  53. break;
  54. }
  55.  
  56. return TRUE;
  57. }
  58.  
  59. bool Hook()
  60. {
  61.    if (MH_Initialize() != MH_OK)
  62.    {
  63.        return false;
  64.    }
  65.  
  66.    if (MH_CreateHookEx((void*)&SendMessageW, (void*)&BSSSendMessageW, &Basewritefoobar) != MH_OK)
  67.    {
  68.        return FALSE;
  69.    }
  70.    return MH_EnableHook((void*)&SendMessageW) == MH_OK;
  71. }

Cuando lo hago me muestra un hola mundo el cual ni lo incluí en mi codigo:


Que no deberia..
134  Informática / Software / Grabar una sesion meeting de teamviewer sin tener ocupada la pantalla en: 19 Marzo 2017, 22:43 pm
Hola hay alguna manera de grabar la sesion de un meeting en teamviewer sin necesidad de tener que grabarlo ocupando la pantalla es decir una vez que abra la sesion se graba y . y al mismo tiempo uno puede estar haciendo otras cosas?
135  Programación / Programación C/C++ / Re: Iniciar un proceso de forma pausada c++ en: 19 Marzo 2017, 17:01 pm
que diferencia hay entre un handle y un phandle son lo mismo? Esque encuentro informacion sobre handle pero no phandle.. disculpa las molestias..
136  Programación / Programación C/C++ / Iniciar un proceso de forma pausada c++ en: 19 Marzo 2017, 14:46 pm
Hola estoy haciendo un pequeño programa que me iniciara mi proceso de forma pausada el siguiente código obtengo el pid y se lo paso a mi funcion:
Código
  1. int main(int argc, char *argv[])
  2. {
  3. HANDLE processList = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  4. PROCESSENTRY32 pInfo;
  5. BOOL st = TRUE;
  6. pInfo.dwSize = sizeof(PROCESSENTRY32);
  7. Process32First(processList, &pInfo);
  8. int myPid = 0;
  9. do
  10. {
  11. std::wstring name(L"miproceso.exe");
  12. const wchar_t* szName = name.c_str();
  13. if (wcscmp(pInfo.szExeFile, szName) == 0)
  14. {
  15. myPid = pInfo.th32ProcessID;
  16. cout << myPid << endl;
  17. break;
  18. }
  19. Process32Next(processList, &pInfo);
  20. } while (st != FALSE);
  21.  
  22. char chaine[10];
  23. sprintf(chaine,"%d",myPid);
  24. Startpausedprocess(chaine,processList);
  25. }
La funcion:
Código
  1. HANDLE Startpausedprocess(char *cmd, PHANDLE hthread)//Not const char* because CreateProcess may write on it
  2. {
  3.    PROCESS_INFORMATION pi;
  4.    STARTUPINFOA si;//STARTUPINFOA is the ANSI version of STARTUPINFO.
  5.    ZeroMemory(&si, sizeof(STARTUPINFOA));
  6.    si.cb = sizeof(STARTUPINFOA);
  7.  
  8.    if (!CreateProcessA(NULL, cmd, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &si, &pi))//The flag "CREATE_SUSPENDED" will create the process and pause the main thread.
  9.    {
  10.        cout << "CreateProcess failed, " << GetLastError() << endl;
  11.        return NULL;
  12.    }
  13.    *hthread = pi.hThread;
  14.    return pi.hProcess;
  15. }

Sigo teniendo problemas al resolver errores de argumentos. Los errores son los siguientes:
Citar
Build FAILED.

"C:\Users\Androide\Desktop\colo\injector\injector\injector.vcxproj" (default ta
rget) (1) ->
(ClCompile target) ->
  c:\users\androide\desktop\colo\injector\injector\injector.cpp(64): error C266
4: 'HANDLE Startpausedprocess(char *,PHANDLE)': cannot convert argument 2 from
'HANDLE' to 'PHANDLE' [C:\Users\Androide\Desktop\colo\injector\injector\injecto
r.vcxproj]
  c:\users\androide\desktop\colo\injector\injector\injector.cpp(63): error C499
6: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s
 instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help
for details. [C:\Users\Androide\Desktop\colo\injector\injector\injector.vcxproj
]

    0 Warning(s)
    2 Error(s)

 :P No me hace la conversión char * correctamente alguna idea como convertir mi entero a char *? Y luego PHandle que diferencia tiene con Handle?
137  Programación / Programación C/C++ / Re: Como llamar a la funcion de windows api en: 16 Marzo 2017, 23:34 pm
Tienes razon tengo primero que aprender lo basico ejemplo: a crear una ventana con la API de Windows, mis preguntas son muy poco maduras me lanzo a cosas que a lo mejor antes de preguntar deberia plantearme  si se lo básico y luego ir entrando a cosas complejas porque la mayoría son asuntos facilmente deducibles y por mi parte no lo estoy resolviendo asi que disculpa.
Y tampoco me di cuenta que al final es una funcion luego simplemente hay que pasarle los valores.. luego.. un grave error por mi parte..
138  Programación / Programación C/C++ / Como llamar a la funcion de windows api en: 16 Marzo 2017, 22:46 pm
Hola como podría llamar a la siguiente funcion desde el int main usando windows api.
Funcion:
Código:
static const wchar_t *lol=L"";

LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
    {
        if (!lstrcmpW(((LVITEMW*)lparam)->pszText, lol))//The lparam is a LVITEM* struct.
        {
            return 0;//we simply return 0 (and we do not call the real SendMessage function.
        }
        return 0;
    }
    return base.SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
}

Int main:
Código:
int main()
{
//calling api function
}

Como podría a la función de windows api desde el main.
139  Programación / Programación C/C++ / Re: como arreglo este error en: 15 Marzo 2017, 16:59 pm
Puedes usar detour o api hooking centrado a video juegos. Con eso podrás interceptar las funciones de estos juegos y hacer determinadas cosas(como dispara rcuando la distancia sea X, entre otras muchas cosas).

Aqui te paso un video que intercepta las llamadas del buscaminas para ganar la partida:
140  Programación / Programación C/C++ / Re: Nose si se puede en: 15 Marzo 2017, 16:56 pm
Todos son buenos python tambien es muy valioso en general cualquier te vale a no ser que sea un lenguaje de scripting que puede variar un poco.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 53
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines