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

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Temas
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19
51  Programación / Programación C/C++ / Pasar argumentos a WinMain en: 25 Marzo 2017, 00:10 am
Estaba intentando convertir una consola a formulario. Para ello lo hice añadiendo una configuración equivocada ya que eso era para Qt.
La manera correcta de convertir una consola a un formulario y luego pasar los argumentos de linea de comandos a la aplicación es usando GetCommandLine
52  Programación / Programación C/C++ / Como mostrar la version de windows 32 o 64 bits usando c++ en: 24 Marzo 2017, 17:13 pm
Como puedo mostrar que versión utilizo en un programa intente esto:
Código:
#if_WIN64
 isWow64=true;

#elif_WIN32
 isWow64=false;

if(isWow64==true){
 windows="Windows64bits";
}else{
 windows="Windows32bits";
}
Sería correcto o debería hacer alguna otra cosa.
53  Programación / Programación General / Que es user32 y kernel32¿? que diferencias existen? en: 23 Marzo 2017, 20:26 pm
Se que son  bibliotecas de enlace dinámico que implementa la biblioteca de windows pero mi pregunta es cuando uno esta usando la librería kernel32 o user32 cuando uno es administrador usa kernel32 o cuando uno usa user32 esta en modo usuario¿? Soy un total ingnorante al respecto por lo que cualquier explicacion me vendría bastante bien. Gracias.
54  Programación / Programación C/C++ / Tutorial como poner tus procesos en PWNED en: 20 Marzo 2017, 12:25 pm
Hola en este tutorial os enseñare a como poner tus procesos en PWNED con la siguiente apariencia:


El inyector:
Código:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <Tlhelp32.h>
#include <wchar.h>
#include <iostream>
using namespace std;

void error(char *err);

HANDLE myProc = NULL;

void error(char *err)
{
if (myProc != NULL) CloseHandle(myProc);
printf("%s", err);
exit(0);
}

HANDLE Startpausedprocess( char* cmd, PHANDLE ptr_thread ) // cleaned up a bit, but no RAII
{
    if( ptr_thread == nullptr ) return nullptr ;

    PROCESS_INFORMATION pi;
    STARTUPINFOA si {} ; // initialize with zeroes.
    si.cb = sizeof(STARTUPINFOA);

    if( !CreateProcessA( nullptr, cmd, nullptr, nullptr, false, CREATE_SUSPENDED,
                         nullptr, nullptr, std::addressof(si), std::addressof(pi) ) )
    {
        std::cerr << "CreateProcess failed, " << GetLastError() << '\n' ;
        *ptr_thread = nullptr ;
        return nullptr;
    }

    *ptr_thread = pi.hThread;
    return pi.hProcess;
}


int main(int argc, char *argv[])
{
char cmd[] = "taskmgr.exe" ; // note: non-const (writeable array)
    HANDLE thread = nullptr ;
    auto myProc=Startpausedprocess( cmd, std::addressof(thread) ) ;
if(myProc)
    {
        std::cout << "press enter to resume process... " && std::cin.get() ;
        ResumeThread(thread) ;

        //CloseHandle(thread) ;
        //CloseHandle(myProc) ;
    }

// Reservar memoria para el argumento (ruta de la DLL)
char thData[] = "dllmain.dll";
LPVOID dirToArg = VirtualAllocEx(myProc, NULL, strlen(thData), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (dirToArg == NULL)
error("[-] Error reservando memoria para argumento.\n");
else
printf("[+] Memoria reservada para argumento (%i bytes).\n", strlen(thData));


// Escribir la ruta de la DLL en la memoria reservada
SIZE_T written = 0;
if (WriteProcessMemory(myProc, dirToArg, (LPVOID)&thData, strlen(thData), &written) == 0)
error("[-] Error escribiendo memoria.\n");
else
printf("[+] Memoria escrita (arg %i bytes).\n", written);
//Lanzar un hilo con LoadLibrary
//Load the DLL
//Load the DLL
HANDLE rThread = CreateRemoteThread(myProc, NULL, NULL, (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "LoadLibraryA"), dirToArg, NULL, NULL);
if (rThread == NULL)
error("[-] Error creando el hilo.\n");
else
printf("[+] Hilo creado.\n");
CloseHandle(rThread);
}

El código, simplemente compilas en gcc y inyectais.
Código:
#include "stdafx.h"
#include "cabecera minhook"//MHook header
#include <iostream>
#include <windows.h>
#include <Commctrl.h>
#include <conio.h>

using namespace std;

typedef void (*SENDMESSAGEW)();//Typedef for the hooked function
static SENDMESSAGEW Basewritefoobar;//Backup of the originak fonction

static wchar_t pwned[]=L"PWNED";

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
    {
        ((LVITEMW*)lparam)->pszText=pwned;//Replace the item text with our text.
    }
    return SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
}

static bool Hook();

template <typename T>
inline MH_STATUS MH_CreateHookEx(void* target, void* const base, T** original)
{
    return MH_CreateHook(target, base, reinterpret_cast<void**>(original));
}


extern "C" __declspec (dllexport) void __cdecl SendWrite()
{

}

BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
//Different behaviors depending on the reason why DllMain is called
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
if (!Hook())//Hook "Writefoobar"
{
cout << "Hook failed" << endl;
return 1;
}
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}

return TRUE;
}

bool Hook()
{
    if (MH_Initialize() != MH_OK)
    {
        return false;
    }

    if (MH_CreateHookEx((void*)&SendMessageW, (void*)&BSSSendMessageW, &Basewritefoobar) != MH_OK)
    {
        return FALSE;
    }
    return MH_EnableHook((void*)&SendMessageW) == MH_OK;
}

Funcionara como filtro y cambiara la apariencia de vuestro administrador de tareas.
55  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..
56  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?
57  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?
58  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.
59  Programación / Scripting / Actualizar mi ip usando dyndns en python en: 14 Marzo 2017, 19:27 pm
Hola estoy verificando un pequeño programa para obtener la ip actualizada de mi dns lo que hago es lo siguiente:
Código
  1. #!/usr/bin/python
  2. import requests
  3. import json
  4. user = "email"
  5. password = "pass"
  6. checkip = "http://thisisnt.com/api/getRemoteIp.php"
  7. dynupdate = "https://members.dyndns.com/nic/update"
  8. print "starting. Get current IP..."
  9. ipraw = requests.get(checkip)
  10. if ipraw.status_code is not 200:
  11.  raise "Cannot get IP address"
  12.  exit
  13.  
  14. ip = ipraw.json()['REMOTE_ADDR']
  15. print "Remote IP: " + ip
  16. print "updating..."
  17. # update dyndns
  18. headers = {'user-agent': 'mPythonClient/0.0.3'}
  19. dyn = requests.get(dynupdate, \
  20.              headers=headers, \
  21.              auth=(user, password), \
  22.              params={'hostname': 'mydyndns', \
  23.                       'myip': ip, \
  24.                       'wildcard': 'NOCHG', \
  25.                       'mx': 'MX', \
  26.                       })
  27. if dyn.status_code is not 200:
  28.  print "Update failed. HTTP Code: " + str(dyn.status_code)
  29. if "good" in dyn.text:
  30.  print "update successful.."
  31. else:
  32.  print "Update unsuccessful: " + dyn.text.strip()

El resultado que obtengo siempre es
Código:
Update unsuccessful: 

Es decir dyn.text la peticion no la hace bien por lo que tenga hacer la peticion de otra manera. Alguien sabría como podría obtener mi ip con my dyndns usando python?
60  Programación / Programación C/C++ / Como resolver estos errores? en: 14 Marzo 2017, 14:21 pm
Estoy intentando compilar ejemplos de esta libreria:
Código:
https://www.codeproject.com/KB/winsdk/LibMinHook/MinHook_133_src.zip

El tio compila ejemplos de todos pero cuando yo lo intento me devuelve:
Código:
C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h:141:
22: note:   candidate expects 5 arguments, 4 provided
DynamicLinkSample.cpp:12:18: note: template<class T> MH_STATUS MH_CreateHookApiE
x(LPCWSTR, LPCSTR, LPVOID, T**)
 inline MH_STATUS MH_CreateHookApiEx(LPCWSTR pszModule, LPCSTR pszProcName, LPVO
ID pDetour, T** ppOriginal)
                  ^
DynamicLinkSample.cpp:12:18: note:   template argument deduction/substitution fa
iled:
DynamicLinkSample.cpp:37:88: note:   cannot convert 'DetourMessageBoxW' (type 'i
nt (__attribute__((__stdcall__)) *)(HWND, LPCWSTR, LPCWSTR, UINT) {aka int (__at
tribute__((__stdcall__)) *)(HWND__*, const wchar_t*, const wchar_t*, unsigned in
t)}') to type 'LPVOID {aka void*}'
     if (MH_CreateHookApiEx(L"user32", "MessageBoxW", &DetourMessageBoxW, &fpMes
sageBoxW) != MH_OK)

        ^
DynamicLinkSample.cpp:43:35: error: invalid conversion from 'int (__attribute__(
(__stdcall__)) *)(HWND, LPCWSTR, LPCWSTR, UINT) {aka int (__attribute__((__stdca
ll__)) *)(HWND__*, const wchar_t*, const wchar_t*, unsigned int)}' to 'LPVOID {a
ka void*}' [-fpermissive]
     if (MH_EnableHook(&MessageBoxW) != MH_OK)
                                   ^
In file included from DynamicLinkSample.cpp:2:0:
C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h:154:
22: note: initializing argument 1 of 'MH_STATUS MH_EnableHook(LPVOID)'
     MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget);
                      ^
DynamicLinkSample.cpp:52:36: error: invalid conversion from 'int (__attribute__(
(__stdcall__)) *)(HWND, LPCWSTR, LPCWSTR, UINT) {aka int (__attribute__((__stdca
ll__)) *)(HWND__*, const wchar_t*, const wchar_t*, unsigned int)}' to 'LPVOID {a
ka void*}' [-fpermissive]
     if (MH_DisableHook(&MessageBoxW) != MH_OK)
                                    ^
In file included from DynamicLinkSample.cpp:2:0:
C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h:161:
22: note: initializing argument 1 of 'MH_STATUS MH_DisableHook(LPVOID)'
     MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget);
                      ^

Supongo algo estare haciendo mal. En este caso estoy intentando desde consola con g++, que el compilador sería mingw.
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines