News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Old test piece to determine administrative access.

Started by hutch--, December 07, 2009, 10:30:59 AM

Previous topic - Next topic

GregL

#15
Quote<> is basic's does not =, use != instead

Yes, you are right, that part needs to be corrected.  :red


Edit: I changed the .IF eax <> 0 to .IF eax != 0 in my previous post.  I also tested it and it still works correctly in Windows 7 x64.

I wonder how it ever assembled like that?  Strange.

Edit: The original code, in C, was from here CheckTokenMembership Function.  I translated it to MASM.




jj2007

Quote from: Greg Lyon on December 08, 2009, 07:26:26 PM
I wonder how it ever assembled like that?  Strange.

Indeed. Sure you used Masm?
:bg

298     cycles, 2 bytes for 100* .if eax aka or eax, eax
298     cycles, 2 bytes for 100* .if eax!=0 aka or eax, eax
266     cycles, 2 bytes for 100* test eax, eax, .if !Zero?
261     cycles, 3 bytes for 100* cmp eax, 0, .if Zero?

(Celeron M)

Vortex

This code lists the members the Local Administrators group :


.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\netapi32.inc
include     \masm32\include\msvcrt.inc

include     \masm32\macros\ucmacros.asm

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\netapi32.lib
includelib  \masm32\lib\msvcrt.lib

.data


WSTR            LocalGroup,"Administrators"
format1         db "M",0,"e",0,"m",0,"b",0,"e",0,"r",0,"=",0,"%",0,"s",0,13,0,10,0,0,0
ResumeHandle    dd 0

.data?

buffer          dd ?
EntriesRead     dd ?
TotalEntries    dd ?

.code

start:

    invoke  NetLocalGroupGetMembers,NULL,ADDR LocalGroup,\
            3,ADDR buffer,MAX_PREFERRED_LENGTH,\
            ADDR EntriesRead,ADDR TotalEntries,ADDR ResumeHandle

    call    ListMembers

    invoke  NetApiBufferFree,buffer

    invoke  ExitProcess,0

ListMembers PROC USES esi ebx

    mov     esi,buffer
    mov     ebx,EntriesRead
@@:   
    invoke  crt_wprintf,ADDR format1,LOCALGROUP_MEMBERS_INFO_3.lgrmi3_domainandname[esi]
    add     esi,SIZEOF LOCALGROUP_MEMBERS_INFO_3
    dec     ebx
    jnz     @b
    ret

ListMembers ENDP

END start

hutch--

Thanks Erol, all of this stuff is very useful to me at the moment.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php