Nmap Development mailing list archives

execute a batch script on a remote computer with smb-psexec


From: Daniel leibowitz <danileibow () gmail com>
Date: Mon, 12 Jan 2015 11:33:35 +0200

hi,
i have a problem with smb-psexec, i'm posting this here as a last resort
after reading every piece of information available on this subject.

so, i'm trying to use smb-psexec to upload and execute a script from one
computer to another.
it uploads the script file successfully, but fails to execute it. it gives
this error:
"Failed to create the process".
one of the files created on the remote computer mention this error:
"This program cannot be run in DOS mode".
the script file runs just fine locally on the machine, and even remotely
through smb-psexec without uploading it.
after some digging, i found out that the script fails to run as it is being
renamed to somename.txt and by this the file type is changed.
i modified the smb-psexec.nse code not to change the name, and the script
was uploaded and executed fine. this means the problem is with the name
obfuscation.
i'm probably doing something wrong here, but i can't find out what.
i appreciate any help on this, as this message is my last resort.

here's my config file:

mod = {}
mod.upload           = true
mod.name             = "dir test"
mod.program          = "dir_test.bat"
mod.path             = "c:/temp"
table.insert(modules, mod)

and my cli:

nmap -n -d -p445 -script=smb-psexec
--script-args=smbuser=username,smbpass=password,config=dir_test_conf,randomseed=abc,share=temp,sharepath="c:\temp"
1.1.1.1

where of course the username, password and ip are changed.

any answer will be much appreciated.
thanks
Dani
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/

Current thread: