OpenVPN --auth-user-pass FILE option on Windows [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
If you try to pass the username/password to OpenVPN from a file via the --auth-user-pass switch, you get the following error:
"Sorry, 'Auth' password cannot be read from a file."
At least they're polite.
So our workaround was to programmatically write to "standard in" when we get the Auth Username: and Auth Password: prompts (this is in C#).
Something with the timing isn't 100% reliable, so I was looking for a way to pass the credentials to OpenVPN in a different way and came across this post: OpenVPN Post
It says you can recompile the source with a --enable-password-save option. Has anyone been able to do this?
My final question is: How can I pass an auth username/password to openvpn.exe on the client side? And does OpenVPNGUI somehow do this (maybe we can copy what they do)?

NOTE! param auth-user-pass not work if start by GUI "C:\Program Files\OpenVPN\config\name.ovpn"
Made start file start_openvpv.cmd (+ link to with "run as admin") with content:
cd C:\Users\Name\Documents\VPN
"C:\Program Files\OpenVPN\bin\openvpn.exe" --config C:\Users\Name\Documents\VPN\myvpnconfig.ovpn --auth-user-pass "C:\Users\Name\Documents\VPN\pass.txt"
pass.txt:
yourusername
yourpassword
OR put line to name.ovpn, as in upper messege:
auth-user-pass pass.txt
+start_openvpv.cmd:
cd C:\Users\Name\Documents\VPN
"C:\Program Files\OpenVPN\bin\openvpn.exe" --config C:\Users\Name\Documents\VPN\myvpnconfig.ovpn

It's possible to open a VPN connection via a script by using the following DOS command (however this is not recommended since the password is not encrypted)
$openvpn.exe config.ovpn < username < password

It turns out the problem wasn't with standard in.
I was using some locking where if the process exited in the middle of writing to standard in, there could be a deadlock.
There is no issue sending the password in this manner.

For automatic authentication to Openvpn you have to modify the config.ovpn file.
-Go to OpenVPN\config directory and edit the .ovpn file
-Add this line to the config file -> auth-user-pass password.txt
-Then create the password.txt file and write in it:
yourusername
yourpassword
-After these steps your openvpn will connect automatically.

Related

Executing command using SSH.NET on digi 6030dx modem - what are this character sequences starting with left square bracket?

I have some large project that connect to many devices over SSH.NET
Now I have to add support for new modem witch is digi 6030dx.
I added it and I am able to connect with no issues
But when I send some/any command like show config the output is:
[16C[0K
[16C[0Ks
[17C[0Kh
[18C[0Ko
[19C[0Kw
[20C[0K
[20C[0Kc
[21C[0Ko
[22C[0Kn
[23C[0Kf
[24C[0Ki
[25C[0Kg
Commands
-------------------------------------------------------------------------------
config View and modify the configuration
exit Exit the CLI
analyzer Analyzer commands.
cli-legacy Enter the legacy Admin CLI.
cp Copy a file or directory.
help Show CLI editing and navigation commands.
ls List a directory.
mkdir Create a directory.
modem Modem commands.
more View a file.
mv Move a file or directory.
ping Ping a host.
reboot Reboot the system.
rm Remove a file or directory.
scp Copy a file or directory over SSH.
show Show instance statistics.
system System commands.
traceroute Print the route packets trace to network host.
update Update firmware.
dra.wk.0001> ashowconfigdra.wk.0001> ashowconfig
[16C[0K
Does anyone known what are this strange signs / why my command is splited by this and newlines?
It is first device that have this issue and the app support over 200 other with no issues.
I guess some coding issue or something ? putty does not show this signs so probably 'understand' them somehow?
Those are ANSI escape codes.
In general, with SSH, you get these only if your client (library) declares support for terminal emulation.
SSH.NET library does that always, when you use the "shell" channel (SshClient.CreateShell or SshClient.CreateShellStream).
In general (were you connecting to well behaving SSH server), to avoid getting the codes:
Use "exec" channel (use SshClient.RunCommand). SSH.NET does not use terminal emulation on "exec" channel. Though SSH servers on "devices" (contrary to full servers) usually do not implement the "exec" channel. See also What is the difference between exec_command and send with invoke_shell() on Paramiko?
Modify SSH.NET code not to request terminal emulation for the "shell" channel. – Remove SendPseudoTerminalRequest request from Shell.Start implementation.
Though as you are connecting to some "device" and telneting further to another device and the codes probably come from the far device, the question is whether this will in fact have any effect on that device at all. Possibly you won't be able to avoid getting the codes. Lack of terminal emulation on the first SSH connection possibly won't have any effect on the second telnet connection.
In the end, you may have to deal with the codes.
See also How to strip ANSI escape codes from AIX topas command result in C#.
i did for now
this.answer = Regex.Replace(this.answer, #"\r\[\d{0,3}C\[0K", "", RegexOptions.IgnoreCase);
will see if have any negative impact but looks perfect for now :D

Secure password communication between 2 applications

I am writing a program, which is like a swiss army knife of tools that my colleagues need in their day to day work. One feature of this tool is, to be able to connect to a client remotely and control it.
We already have an application called Dameware Mini Remote Control, not written by us, that does this exact job. My application just starts this software in a process and hands over username and password, the user has entered beforehand.
In the documentation of the Dameware Tool, it says that the process should be called with these arguments:
"dwrcc.exe [-?|-?:] [-c:] [-h:] [-m:MachineName] [-u:UserName] [-p:Password | -p:"Password"] [-d:Domain] [-o:TCPport] [-s:SharedSecret] [-r:] [-vnc:] [-a:0|1|2] [-prxa:MRCproxyAddress] [-prxp:MRCproxyPort] [-prxsMRCproxySecret] [-v:] [-md:] [-i:n] [-x:] [-bh:CentralServerHostAddress] [-bpn: CentralServerPortNumber] [-bu:CentralServerUserName] [-bps:CentralServerUserPassword]"
My concern is that providing the password in the -p option is not secure, because it is basically plain text.
Here is the part of my code where i provide the command line arguments:
proc.StartInfo.Arguments = $"-c: -h: -x: -m:{TxtHostname} -d:{MainUI.Credentials.DomainName} -u:{MainUI.Credentials.UserName} -p:{LoginCredentials.Decrypt(MainUI.Credentials.EncryptedPassword)}";
Is there a secure way of handing over the password to the Dameware application inside the process?
Any suggestions are greatly appreciated.
This is not possible in general. If the only option is to pass the password via a command line parameter, you do only have this option.
However it would be possible if the target application supports another way of receiving the password. This is application specific and doesn't apply to every application.
As I'm not familiar with Dameware Mini Remote Control, I can't tell if such an option exists in this specific case.

Bitbucket default repository not configured [duplicate]

This question already has an answer here:
Mercurial "no username supplied" error on Mac
(1 answer)
Closed 7 years ago.
I am totally lost here as i have been trying to create a repository and push my existing Unity3D C# project to it.
The current output is:
realm: Bitbucket.org HTTP
user:
password:
warning: bitbucket.org certificate with fingerprint 46:de:34:e7:9b:18:cd:7f:ae:fd:8b:e3:bc:f4:1a:5e:38:d7:ac:24 not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 46:de:34:e7:9b:18:cd:7f:ae:fd:8b:e3:bc:f4:1a:5e:38:d7:ac:24 not verified (check hostfingerprints or web.cacerts config setting)
searching for changes
warning: bitbucket.org certificate with fingerprint 46:de:34:e7:9b:18:cd:7f:ae:fd:8b:e3:bc:f4:1a:5e:38:d7:ac:24 not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 46:de:34:e7:9b:18:cd:7f:ae:fd:8b:e3:bc:f4:1a:5e:38:d7:ac:24 not verified (check hostfingerprints or web.cacerts config setting)
abort: error: ''
Peters-iMac:myProject Peter$ hp puch -v --debug
-bash: hp: command not found
Peters-iMac:myProject Peter$ hg push -v --debug
pushing to default-push
abort: default repository not configured!
(see the "path" section in "hg help config")
Peters-iMac:myProject Peter$
I have been trying to understand what i need to do to fix this but have not succeeded, i did check the "hg help config" but did not fully understand anyhow.
Anyone that can lead the blind (me)?
You need to tell mercurial where to push to. You can do that in two ways:
Command line: hg push URL where URL is the pathwhere to push to, e.g. hg push https://bitbucket.org/YOURLOGIN/YOURREPOSITORY (it then will ask for login and pw on the command line)
In your repository's configuration file found in .hg/hgrc:
[paths]
default = https://bitbucket.org/YOURLOGIN/YOURREPOSITORY
See also hg help config.paths
You can also use the hgrc to store the login information in order to remove the need to enter them each time you push, but that is unsecure. Better use ssh authentication which doesn't require storing any credentials.

"This file came from another computer and might be blocked to protect this computer." - How to programmatically remove this attribute in C# .net? [duplicate]

This question already has answers here:
Unblock File from within .net 4 c#
(3 answers)
Closed 8 years ago.
I made a program in C#. It copies itself to startup if the user ticks the box to do so.
The application adds itself to startup using the registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Run".
It works fine, aside from the problem that every time the machine is restarted, the user is prompted whether they're sure they want to run the program because it's blocked by Windows because it "comes from another computer".
Any way I can get rid of this Windows "blocked" flag through the code so that the user isn't prompted everytime the program tries to run itself?
Thanks
When downloaded/copied to the machine, Windows attached a Zone Identifier (http://msdn.microsoft.com/en-us/library/dn392609.aspx) based in the location it the file came from (http://msdn.microsoft.com/en-us/library/ms537183.aspx)
In order to unblock the file, you will either have to have the user open up the file properties and click the Unblock button, or remove it yourself.
You can find more information on how this happens and a few ways to do so (including with code) here: http://weblogs.asp.net/dixin/archive/2009/03/14/understanding-the-internet-file-blocking-and-unblocking.aspx
try powershell script
http://technet.microsoft.com/en-us/library/hh849924.aspx
Unblock-File
Unblocks files that were downloaded from the Internet.
Syntax
Parameter Set: ByPath
Unblock-File [-Path] [-Confirm] [-WhatIf] [ ]
Parameter Set: ByLiteralPath
Unblock-File -LiteralPath [-Confirm] [-WhatIf] [ ]
Detailed Description
The Unblock-File cmdlet lets you open files that were downloaded from the Internet. It unblocks Windows PowerShell script files that were downloaded from the Internet so you can run them, even when the Windows PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files.
Before using the Unblock-File cmdlet, review the file and its source and verify that it is safe to open.
Internally, the Unblock-File cmdlet removes the Zone.Identifier alternate data stream, which has a value of "3" to indicate that it was downloaded from the Internet.
For more information about Windows PowerShell execution policies, see about_Execution_Policies (http://go.microsoft.com/fwlink/?LinkID=135170).
This cmdlet is introduced in Windows PowerShell 3.0.

Saving all browsers urls history

I need to write a log system that will save all the domain names and time of visit (if possiable the closing time too) that was made using all browsers which are installed on windows.
for example:
http://stackoverflow.com 14:45 - 16:55
I couldnt find any implementation info on google, Please forward me or explain what is the way to go.
what you ask for is highly dependent on browser/browser version used (and potentially Windows version too)...
Since you don't describe what the goal is it is hard to come up with specific solutions/options...
One rather browser-agnostic option would be to implement a proxy and configure the system/browsers to use that proxy... the proxy would then do the logging. but this could easily be circumvented by changing the proxy configuration in the browser...
See if you can read the history files for each browser and parse the details from there.
CHROME:
in xp = C:\Documents and Settings\USER\Local Settings\Application Data\Google\Chrome\User Data\Default\
in vista = C:\users\USER\Local Settings\Application Data\Google\Chrome\User Data\Default\
FIREFOX:
C:\Documents and Settings\owner\Local Settings\History
IE:
C:\Documents and Settings\YOURUSERNAME\Local Settings\History
I have never tried this an don't know if the history is stored encrypted, and what level of details (time opened, time closed etc) are stored.

Categories

Resources