flat assembler
Message board for the users of flat assembler.

Index > Windows > Process impersonation

Author
Thread Post new topic Reply to topic
genius



Joined: 10 Mar 2007
Posts: 5
genius 23 Apr 2007, 15:00
Hello I wish to copy a file from one computer on another.
For example:

first computer:

network : workarea
comp IP : 85.170.32.15
username : workuser
pass : qwerty

second computer:

network : hoearea
comp IP : 157.17.210.38
username : homeuser
pass : qwerty

And full UNC path
source file: \\85.170.32.15\Reports\report.doc
dest file: \\157.17.210.38\userdir\report.doc

But I had problems, what I do incorrectly?

Code:

format PE GUI 4.0
entry start

  include 'win32a.inc'

section '.data' data readable writeable

  szTitle db 'Win32 Imerus',0
  szErrorPrivateProfile db 'Error invoke GetPrivateProfileStringA.',0
  szErrorLogonUser db 'Error invoke LogonUserA.',0
  szImpersonateLoggedOnUser db 'Error invoke ImpersonateLoggedOnUser.',0
  szErrorCopyFile db 'Error invoke CopyFile',0
  szErrorRevertToSelf db 'Error invoke RevertToSelf.',0
  szComplete db 'Operation complete!',0

  szSourceFile db '\\85.170.32.15\Reports\report.doc',0
  szDestFileName db '\\157.17.210.38\userdir\report.doc',0


  szUserName db 'homeuser',0
  szDomain db 'hoearea',0
  szPassword db 'qwerty',0
  LOGON32_LOGON_INTERACTIVE equ 2
  hToken dd ?


section '.text' code executable readable

  start:
        ; login my user
    continue_logonuser:
        invoke  LogonUser,szUserName,szDomain,szPassword,LOGON32_LOGON_INTERACTIVE,0,hToken
        test    eax,eax
        jnz     continue_impersonaly
        invoke  MessageBox,0,szErrorLogonUser,szTitle,MB_OK+MB_ICONERROR
        jmp     error_exit

        ; I do not know what to do further with Token
    continue_impersonaly:
        invoke  ImpersonateLoggedOnUser,[hToken]
        test    eax,eax
        jnz     continue_copyfile
        invoke  MessageBox,0,szImpersonateLoggedOnUser,szTitle,MB_OK+MB_ICONERROR
        jmp     error_exit

    continue_copyfile:
        invoke  CopyFile,szSourceFile,szDestFileName,0
        test    eax,eax
        jnz     continue_complete
        invoke  MessageBox,0,szErrorCopyFile,szTitle,0
        jmp     error_exit

    continue_reverttoself:
        invoke  RevertToSelf
        test    eax,eax
        jnz     continue_complete
        invoke  MessageBox,0,szErrorRevertToSelf,szTitle,MB_OK+MB_ICONERROR
        jmp     error_exit


    continue_complete:
        invoke  MessageBox,0,szComplete,szTitle,MB_OK+MB_ICONINFORMATION

    error_exit:
        invoke  ExitProcess,0

section '.idata' import data readable

  library advapi32,'ADVAPI32.DLL',\
          kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  include 'api\advapi32.inc'
  include 'api\kernel32.inc'
  include 'api\user32.inc'

    



Thanks
Post 23 Apr 2007, 15:00
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 23 Apr 2007, 15:09
Hi genius,
i don't have seen your code but note that in NT System your Workgroup Name must be the same for both PC.
Post 23 Apr 2007, 15:09
View user's profile Send private message Reply with quote
hidden



Joined: 14 Feb 2007
Posts: 49
hidden 23 Apr 2007, 23:41
I've newer try to do this and not sure about same workgroup with impersonation. But maybe the problem is in skipped "m" letter in "hoearea"
Post 23 Apr 2007, 23:41
View user's profile Send private message Reply with quote
genius



Joined: 10 Mar 2007
Posts: 5
genius 24 Apr 2007, 04:54
Thanks, but the Workgroup, User name and Passwords here are invented. At myself I use the presents. The problem consists in copying a file on a computer from other working group.
I cannot understand with parameters of function LogonUser, the mistake occurs here. If it is possible explain on a working example.

Thanks.
Post 24 Apr 2007, 04:54
View user's profile Send private message Reply with quote
kandamun



Joined: 20 Jul 2005
Posts: 25
kandamun 24 Apr 2007, 05:36
Lookup in MSDN the following functions:
Code:
WNetAddConnection2
WNetUseConnection    
Post 24 Apr 2007, 05:36
View user's profile Send private message ICQ Number Reply with quote
HexEdit



Joined: 31 Jul 2006
Posts: 6
Location: Russia
HexEdit 28 Apr 2007, 14:40
Also try to use LOGON32_LOGON_NETWORK instead of LOGON32_LOGON_INTERACTIVE.
Post 28 Apr 2007, 14:40
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.