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


  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 ... 34
111  Programación / Programación General / Re: [VBS] Saber si eres administrador en: 26 Febrero 2014, 23:15 pm
Si devuelve Falso es porque no eres Admin, quizás sólamente eres usuario con privilegios elevados, pero no Administrador.

PD: Yo uso Windows 8.

Saludos

Estoy probando tu script, y ejecutandolo en Windows XP, desde la cuenta de administrador me devuelve Falso...  :-\

La función IsUserAnAdmin solo funciona desde XP a vista. Te recomiendo que uses CheckTokenMembership, que funciona desde XP hasta 8.

He encontrado esta función, pero veo mucho código y no se muy bien que es lo que hace la función en sí  (Utiliza la función que me has dicho) :rolleyes:

Código
  1. Option Explicit
  2.  
  3. Private Const TOKEN_DUPLICATE = &H2&
  4. Private Const TOKEN_QUERY = &H8&
  5. Private Const ERROR_NO_TOKEN = 1008
  6.  
  7. Private Const SECURITY_BUILTIN_DOMAIN_RID = &H20&
  8. Private Const DOMAIN_ALIAS_RID_ADMINS = &H220&
  9. Private Const SECURITY_NT_AUTHORITY = &H5&
  10.  
  11. Private Type SID_IDENTIFIER_AUTHORITY
  12. Value(6) As Byte
  13. End Type
  14.  
  15. Private Enum SECURITY_IMPERSONATION_LEVEL
  16. SecurityAnonymous
  17. SecurityIdentification
  18. SecurityImpersonation
  19. SecurityDelegation
  20. End Enum
  21.  
  22. Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, ByRef TokenHandle As Long) As Long
  23. Private Declare Function OpenThreadToken Lib "advapi32" (ByVal ThreadHandle As Long, ByVal DesiredAccess As Long, ByVal OpenAsSelf As Long, ByRef TokenHandle As Long) As Long
  24. Private Declare Function AllocateAndInitializeSid Lib "advapi32" (ByRef pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, ByVal nSubAuthority7 As Long, ByRef lpPSid As Long) As Long
  25. Private Declare Function CheckTokenMembership Lib "advapi32" (ByVal TokenHandle As Long, ByVal SidToCheck As Long, ByRef IsMember As Long) As Long
  26. Private Declare Function DuplicateToken Lib "advapi32" (ByVal ExistingTokenHandle As Long, ByVal ImpersonationLevel As Long, ByRef DuplicateTokenHandle As Long) As Long
  27. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  28. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  29. Private Declare Function GetCurrentThread Lib "kernel32" () As Long
  30. Private Declare Sub FreeSid Lib "advapi32.dll" (ByVal pSid As Long)
  31.  
  32. Public Function IsInRoleAdmin() As Boolean
  33.  
  34.    Dim NtAuthority As SID_IDENTIFIER_AUTHORITY
  35.    Dim AdminGroup As Long
  36.    Dim Success As Long
  37.    Dim hToken As Long
  38.    Dim hTokenDup As Long
  39.  
  40.    If OpenThreadToken(GetCurrentThread, TOKEN_DUPLICATE Or TOKEN_QUERY, True, hToken) = 0 Then
  41.        OpenProcessToken GetCurrentProcess, TOKEN_DUPLICATE Or TOKEN_QUERY, hToken
  42.    End If
  43.  
  44.    If DuplicateToken(hToken, SecurityImpersonation, hTokenDup) Then
  45.        ' Well-known SIDs
  46.        NtAuthority.Value(5) = SECURITY_NT_AUTHORITY
  47.        ' allocates and initializes a security identifier (SID)
  48.        Success = AllocateAndInitializeSid(NtAuthority, 2, _
  49.            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, AdminGroup)
  50.        If Success Then
  51.            If CheckTokenMembership(hTokenDup, AdminGroup, Success) = 0 Then
  52.                Success = 0
  53.            End If
  54.        FreeSid AdminGroup
  55.        End If
  56.    End If
  57.  
  58.    IsInRoleAdmin = Success
  59.  
  60.    CloseHandle hToken
  61.    CloseHandle hTokenDup
  62.  
  63. End Function

Es decir, por ejemplo este trozo:

Código
  1. Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, ByRef TokenHandle As Long) As Long
  2. Private Declare Function OpenThreadToken Lib "advapi32" (ByVal ThreadHandle As Long, ByVal DesiredAccess As Long, ByVal OpenAsSelf As Long, ByRef TokenHandle As Long) As Long
  3. Private Declare Function AllocateAndInitializeSid Lib "advapi32" (ByRef pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, ByVal nSubAuthority7 As Long, ByRef lpPSid As Long) As Long
  4. Private Declare Function CheckTokenMembership Lib "advapi32" (ByVal TokenHandle As Long, ByVal SidToCheck As Long, ByRef IsMember As Long) As Long
  5. Private Declare Function DuplicateToken Lib "advapi32" (ByVal ExistingTokenHandle As Long, ByVal ImpersonationLevel As Long, ByRef DuplicateTokenHandle As Long) As Long
  6. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  7. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  8. Private Declare Function GetCurrentThread Lib "kernel32" () As Long

Para que necesita esas declaraciones? OpenProccess, OpenThread...  :huh:

Saludos
112  Programación / Programación C/C++ / Re: ayuda de programación en c++ en: 24 Febrero 2014, 22:22 pm
Quizás un libro le ayude mas... no sabe que es C++  :silbar:

Quizás  :laugh:
113  Programación / Programación General / Re: [VBS] Saber si eres administrador en: 24 Febrero 2014, 22:16 pm
En Windows 8 siempre devuelve Falso..  :rolleyes:

Muchas gracias por la info y por el ejemplo en vbs, investigaré el método y te digo que tal  ;D

Saludos
114  Programación / Programación General / [VBS] Saber si eres administrador en: 23 Febrero 2014, 19:41 pm
Hola a todos,

Estoy intentando saber si eres administrador desde vbs, he publicado este post en Visual Basic, con unos trozos de código, pero quizas con vbs es más fácil, a ver si me pueden dar ideas...  :huh: :huh:

Visual Basic: http://foro.elhacker.net/programacion_visual_basic/saber_si_eres_administrador_vb6-t409096.0.html

Saludos
115  Programación / Programación C/C++ / Re: ayuda de programación en c++ en: 23 Febrero 2014, 19:26 pm
0x0058477

Código
  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6.  
  7.    DWORD hPid;
  8.    HWND hVentana;
  9.    HANDLE hProcess;
  10.  
  11.    DWORD Buffer;
  12.    DWORD BytesT;
  13.  
  14.    float Valor= 1000;
  15.  
  16.    if (!(hVentana = FindWindow(NULL,"Nombre_de_la_ventana")))
  17.    {
  18. MessageBox(NULL,"No se pudo encontrar la ventana","Error",MB_OK);
  19.        return -1;
  20.    }
  21.    if (!(GetWindowThreadProcessId(hVentana,&hPid)))
  22.    {
  23.        MessageBox(NULL,"No se pudo encontrar el ID del proceso","Error",MB_OK);
  24.        return -1;
  25.    }
  26.    if (!(hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,hPid)))
  27.    {
  28.        MessageBox(NULL,"No se pudo obtener el handle del proceso","Error",MB_OK);
  29.        return -1;
  30.    }
  31.    if (!(ReadProcessMemory(hProcess,(LPCVOID)0x0058477,&Buffer,sizeof(Buffer),&BytesT)))
  32.    {
  33.        MessageBox(NULL,"No se pudo leer la direccion de memoria","Error",MB_OK);
  34.        return -1;
  35.    }
  36.  
  37.    Valor = Buffer + Valor;
  38.  
  39.    if (!(WriteProcessMemory(hProcess,(LPVOID)0x0058477,&Valor,sizeof(Valor),&BytesT)))
  40.    {
  41.        MessageBox(NULL,"No se pudo escribir la direccion de memoria","Error",MB_OK);
  42.        return -1;
  43.    }
  44.  
  45.    CloseHandle(hProcess);
  46.  
  47. }
  48.  

El código está en C, lo unico que hace es buscar el nombre de la ventana, encontrar el PID, leer la posicion de memoria que tu pones, y sumar 1000 a ese valor que esta en la posicion de memoria, y luego escribes en ella

Quizás este código te ayuda

Saludos
116  Programación / Programación C/C++ / Re: Compilar en 32bits desde linux 64bits en: 23 Febrero 2014, 19:20 pm
Si lo has compilado en un sistema 32bits te agradeceria que me enviaras un enlace con el archivo, ya que me gustaria analizarlo con Ollydbg.

https://mega.co.nz/#!IR80GTzR!4w1tzCiYBuXj94xw8rCNU-RN0g7xCtcYpJtSd8W9y4c

Saludos  ;)
117  Programación / Programación C/C++ / Re: ayuda de programación en c++ en: 20 Febrero 2014, 12:31 pm
Paga.

Hahaha como os pasais  :laugh:

¿Que necesitas exactamente? Es que solo has pedido códigos sin decir que quieres que hagan...  :¬¬

Saludos
118  Programación / Programación C/C++ / Re: Compilar en 32bits desde linux 64bits en: 20 Febrero 2014, 12:27 pm
Os adjunto el código por si alguien se anima a intentar compilarlo bajo un sistema de 32 bits y a ver si alguien se le ocurre que puede estar pasando.

A mi me compila perfecto con Code::Blocks  :rolleyes:

Windows XP x86




Saludos  :silbar:
119  Programación / Programación Visual Basic / [?] Saber si eres Administrador vb6 en: 20 Febrero 2014, 12:08 pm
Buenas!  ;D

He estado buscando como saber si eres administrador o no con vb6, he encontrado estas dos funciones, y en Windows XP, funcionan perfectas, pero en Windows 8 siempre me devuelve false  :-[

(En Windows 7 y Windows Vista no lo he probado)


Código
  1. Option Explicit  
  2.  
  3. ' constantes  
  4. ''''''''''''''''''''''''''''''  
  5.  
  6. 'Constantes para usar con OpenSCManager  
  7. Private Const GENERIC_READ = &H80000000  
  8. Private Const GENERIC_WRITE = &H40000000  
  9. Private Const GENERIC_EXECUTE = &H20000000  
  10.  
  11. ' declaraciones Api  
  12. ''''''''''''''''''''''''''''''  
  13.  
  14. 'Función Api OpenSCManager  
  15. Private Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" ( _  
  16.    ByVal lpMachineName As String, _  
  17.    ByVal lpDatabaseName As String, _  
  18.    ByVal dwDesiredAccess As Long) As Long  
  19.  
  20. 'Función Api CloseServiceHandle  
  21. Private Declare Function CloseServiceHandle Lib "advapi32.dll" ( _  
  22.    ByVal hSCObject As Long) As Long  
  23.  
  24. Private Sub Form_Load()  
  25. Dim Admin As Long  
  26.  
  27.    Admin = OpenSCManager(vbNullString, _  
  28.                               vbNullString, _  
  29.                               GENERIC_READ Or GENERIC_WRITE Or GENERIC_EXECUTE)  
  30.  
  31.    'Si la función retorna 0 no es Administrador  
  32.    If Admin = 0 Then  
  33.        MsgBox "No es un Administrador", vbInformation  
  34.    Else  
  35.        CloseServiceHandle Admin  
  36.        MsgBox "Es un administrador", vbInformation  
  37.    End If  
  38.  
  39. End Sub

Código
  1. Option Explicit  
  2.  
  3.  
  4. 'Función Api IsNTAdmin  
  5. Private Declare Function IsNTAdmin Lib "advpack.dll" ( _  
  6.    ByVal dwReserved As Long, _  
  7.    ByRef lpdwReserved As Long) As Long  
  8.  
  9. Private Sub Form_Load()  
  10.    MsgBox "Administrador de este equipo: ? " & _  
  11.            CBool(IsNTAdmin(ByVal 0&, ByVal 0&)), vbInformation  
  12. End Sub

Se puede mirar de otra manera? Es decir, alguna clave en el registro o con alguna otra funcion?  :-\ :-\

Espero que puedan ayudarme  :(

Saludos
120  Programación / Programación C/C++ / Re: [?] Error fgets (Solucionado) en: 19 Enero 2014, 16:53 pm
Pues esa no era la solución xD.

El código original funciona perfectamente, lo que pasa esque el último elemento es el caracter nulo. Por eso te sale -48.

En un principio habia pensado lo del caracter nulo, pero al pasarlo por el debugger tampoco me ponia el '\0', asi que lo he descartado  :-[

De todas formas ya he modificado un par de cosas y funciona bien  :laugh:

Gracias  ;-)
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 ... 34
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines