Solved

Sending data to a dos program

Posted on 2011-09-22
8
221 Views
Last Modified: 2012-05-12
Hello everyone,

I have a program that runs lets call it testrunner, that excepts 2 parameters, databasename and userid.  So for example

testrunner -d test -u testuser

It then prompts for a password, there is no parameter for it in the command line.

I need to call testrunner from a service, but I'm not sure if there is a way to run it, and then send the keystrokes to type hte password in when it prompts for it.

Any idea's?

Thanks!

DJB
0
Comment
Question by:dbridle
8 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 250 total points
ID: 36578948
You can try if
cmd /c echo password | testrunner -d test -u testuser
works. If not, you will have to use the VB Sendkey method, applied to the application/cmd window to send the key strokes required for the password, combined with some sleep time to allow for the password prompt.
0
 

Author Comment

by:dbridle
ID: 36578966
Thanks for your response, I will give the cmd /c command a shot,
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36579048
also if not there is a great free app called autoit which you can use to send keys, mouse clicks, wait for things to appear first etc.  yoou write this as a simple tect file script like batch file or vbscript and then it can compile it into an exe.

So you could have (pseudo copde)

run program testrunner etc.
Wait for window testrunner to appear
type in password
exit

the app would continue to run and accept other keystrokes if needed.  if you pipe the password in it will accept no real keystrokes

also as you compile it into an exe the password is not there in plain text

can help with links s syntax if needed... Once on pc but there are loads of example scripts with it when you download anyway.


Steve
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36582217
You can also try another approach using the Process class. Find example code on below link

http://stackoverflow.com/questions/6969731/get-output-into-my-application-from-another-java-console

The code only shows reading output from the console app but you can use the same principle of streams to write text as input to console app(e.g p.StandardInput.WriteLine("Password"))
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36590485
Have you tried simple redirection as in the following?

   echo password | testrunner -d test -u testuser

or:

   echo password | (testrunner -d test -u testuser)


You could also try it without the spaces around the '|' (pipe symbol).
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36590502
You might even prefer to get the password from a file. Suppose your password is stored in a text file named PASSWORD.TXT

You can then use the following:

   testrunner -d test -u testuser <password.txt

or:

   (testrunner -d test -u testuser) <passowrd.txt

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36591922
I'm sure I hit submit on a comment like this last night, Paul I'm surprised you didn't suggest using ADS to hide the password like in your answer from before which I keep for my info here... I hadn't seen it used before BillDL and you mentioned it in this question and has come in handy on a number of occasions since -- no-one has worked out where the password comes from :-)

http://scripts.dragon-it.co.uk/links/batch-password1
( http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_25000620.html?cid=1133#a26130150 )

Steve
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36592435
Ah, Steve (dragon-it), I never did reply to that thread.... I was playing about with ADS at the time and never finished my write-up on it as I digressed onto something else (as we do).

I've only got a few more things I want to accomplish in DOS at the moment and as they all involve embedded assembly code I've been dragging my heels for far too long now.... All will be revealed in the very near future.

I'm not sure whether the asker wanted to 'hide' the password from the user or whether he merely wanted a non-user assisted solution to logging into his program.

The solutions above only address the non-user assisted methods for getting a password into a program. They may not even work depending on whther the program flushes the keyboard buffer prior to fetching keystrokes (as you probably know quite well).

Sure, ADS, and even redirection can be used to hide a password from a casual user to some extent but i don't think that's the issue in this case. I could be wrong though.

:)


dbridle

Just so as you know what Steve is refering to, I wrote this comment (under the peened name t0t0) quite some time ago. It deals with hiding and retrieving a password using ADS:

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_25000620.html?cid=1133#a26130150
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question