Page 1 of 1
read arguments for console application
Posted: Sat Jan 23, 2010 7:35 pm
by SteveTX
I am writing a modular program that runs in user mode. However, the program will need a kernel driver and DLL running. If those items are not present, I would like to install them. Is there a way to temporarily escalate execution level for a single command and WMI stuff (because some users have UAC running silent mode and don't see the requests, just deny them)?
I was thinking it would be better to have an external program that requested administrative privileges, and then would read the arguments passed to it and perform the functions. For example:
// No Driver Installed
get shell("adminpriv.exe /installdriver /installtask /installDLL")
So in writing adminpriv, how would I read the arguments that were passed to it (/installdriver, etc) ? Is there a better way to pass arguments to a runrev application (windowless)?
Re: read arguments for console application
Posted: Sun Jan 24, 2010 2:21 am
by RRobert
Hello Steve,
Is there a way to temporarily escalate execution level for a single command and WMI stuff (because some users have UAC running silent mode and don't see the requests, just deny them)?
I would ask for username and password, escalate the execution level by the
runas command or the
ShellExecute API via VBScript, check the permissions and do my stuff.
I was thinking it would be better to have an external program that requested administrative privileges, and then would read the arguments passed to it and perform the functions.
That's up to you.
[...] how would I read the arguments that were passed to it (/installdriver, etc) ? Is there a better way to pass arguments to a runrev application (windowless)?
Look in the docs for the
dollar keyword. Specify "-ui" as part of the launching commandline or hide the stack, handle the arguments in the preopenStack handler, write your output to
stdout and dont forget to
quit the engine.
Robert
Re: read arguments for console application
Posted: Sun Jan 24, 2010 4:19 am
by SteveTX
Well i got it working as a console thing. However, I am having some trouble getting the output to show up.
I am running shell commands but i can't seem to capture the output and print it to the terminal.
ex:
Code: Select all
set the hideconsolewindows to true
write "Hello? Anyone Home?" to stdOut
get shell("netsh firewall delete portopening protocol = TCP port = 22217")
write it to stdOut
Nothing shows up in the terminal. Does stdOut need to be initialized somehow?
Re: read arguments for console application
Posted: Sun Jan 24, 2010 6:02 am
by RRobert
Nothing shows up in the terminal.
Sorry I forgot that this is a know
issue or bug. And I bet that "-ui" is not working anymore too cause of the
4.0 engine changes. So you have to use something else (
AutoIT, a VBScript using
cscript or a command line- / batch script).
AutoIT could create compiled console applications and if you deceide to use VBScript or a command line / batch script, you could use a script packaging application or a batch compiler to get a binary. Simply search for "vbs to exe" or "batch compiler" in the search engine of your choice.
I would suggest that use a command line script, thats the easiest way and it should sufficient too for the mentioned task.
sample.cmd
@echo off
echo.Sample v.1.0
echo.Copyright (C) 2010 by ... All rights reserved.
echo.
if %1!==! goto argument_missing
if %1==status goto status
:status
echo. Status Overview
echo.
goto quit
:argument_missing
echo.Missing argument!
echo.
echo.Valid arguments are status, ...
echo.
goto quit
:quit
I used
QuickBFC in the past to create a compile application and could recommend it.
Of course you could also use C/C++ to create a Win32 console application in a fairly amount of time depending on your knowledge. If you like to do so check out
Visual C+ 2008 Express Edition.
Robert
Re: read arguments for console application
Posted: Sun Jan 24, 2010 7:21 am
by SteveTX
Thanks for that. I can see this is an issue as well for Windows. However, I was able to capture the stdout and just stick it elsewhere for the time being.
Re: read arguments for console application
Posted: Tue Apr 06, 2010 3:40 pm
by RRobert
I took some time to look into the issue in detail. The reason why you could not write to stdout under Windows using the put command is caused by the fact that the executable is set to WINDOWS_GUI instead of WINDOWS_CUI (console application) in the subsystem field within the
PE header.
You could change that by patching the binary with
PE Patcher for example.
Simply change Windows GUI to Windows Console and click "Save".
PS: You still need to start your executable using the -ui argument.
Robert
Re: read arguments for console application
Posted: Wed Apr 07, 2010 1:45 am
by BvG
for cgi and faceless apps, you don't use "write to x" for outputting stuff. you use "put", like this:
Code: Select all
#rev -ui
on startup
put "hello world"
end startup
Re: read arguments for console application
Posted: Wed Apr 07, 2010 2:40 am
by RRobert
Yes you could also use put. But in general you need to change the subsystem value in the PE header to create a console application for Windows otherwise your content will not appear.
Robert