Jump to content
Sign in to follow this  
jezzjj

Help Me create showing log on editbox

Recommended Posts

Hello Water,

i Gues i fix the plink problem, now how to show the openvpn log on my editbox just like plink?

here is my openvpn script :

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Users\Jezz\Pictures\blackhole.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayMenuMode", 1)
Opt("WinTitleMatchMode", 2)
$DIRPATH = @ScriptDir
$IPADDRESS1 = @IPAddress1
$USER = IniRead(@ScriptDir & "\ophreak.ini", "Data", "Username", "NotFound")
$PASS = IniRead(@ScriptDir & "\ophreak.ini", "Data", "Password", "NotFound")
Sleep(100)
Run(@SystemDir & '\route.exe ADD IP.53 MASK 255.255.255.0 "' & $IPADDRESS1 & '"', @SystemDir, @SW_HIDE) ;---IP VPN SERVER & SUBNET MASK
Sleep(100)
ProcessClose("openvpn.exe")
Sleep(100)
ProcessClose("openvpn-gui-1.0.3.exe")
Sleep(100)
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 0)
If $FILE = True Then
FileClose($FILE)
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 2)
FileWrite($FILE, "client" & @CRLF)
FileWrite($FILE, "dev tun" & @CRLF)
FileWrite($FILE, "proto tcp" & @CRLF)
FileWrite($FILE, "remote IP 443" & @CRLF) ;-----SSH LOCALHOST ; PORT FORWARD----
FileWrite($FILE, "resolv-retry infinite" & @CRLF)
FileWrite($FILE, "nobind" & @CRLF)
FileWrite($FILE, "persist-key" & @CRLF)
FileWrite($FILE, "persist-tun" & @CRLF)
FileWrite($FILE, "ca ca.crt" & @CRLF) ;<<<----- server US
FileWrite($FILE, "tun-mtu 1500" & @CRLF)
FileWrite($FILE, "tun-mtu-extra 32" & @CRLF)
FileWrite($FILE, "mssfix 1450" & @CRLF)
FileWrite($FILE, "redirect-gateway def1" & @CRLF)
FileWrite($FILE, "auth-user-pass" & @CRLF)
FileWrite($FILE, "comp-lzo" & @CRLF)
FileWrite($FILE, "verb 3" & @CRLF)
EndIf
FileClose($FILE)
Sleep(1000)
Run(@ProgramFilesDir & '\OpenVPN\bin\openvpn-gui-1.0.3.exe --connect inter.ovpn --config_dir "' & $DIRPATH & '" --show_script_window 0 --log_dir "' & $DIRPATH & '" --allow_service 0 --allow_proxy 0 --allow_edit 0 --allow_password 0 --silent_connection 0', @ProgramFilesDir & "\OpenVPN", @SW_SHOW)
Sleep(2000)
If $FILE = True Then
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 2)
FileRecycleEmpty($FILE)
EndIf
FileClose($FILE)
Sleep(1000)
WinWaitActive("OpenVPN - User Authentication")
Sleep(1000)
Send($USER)
Sleep(9000)
Send("{TAB}")
Sleep(1000)
Send($PASS)
Sleep(9000)
Send("{ENTER}")

Share this post


Link to post
Share on other sites

I don't know OpenVPN but I would do it the same way as with Plink. Check the docu how to write the messages to StdOut and then grab it with your Autoit script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Hello water, thank's for the advice, i have try this :

Global $bRunning = False

If $bRunning = False Then
Local $foo = Run(@scriptdir & "\openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --persist-key --persist-tun --ca ca.crt --tun-mtu 1500 --tun-mtu-extra 32 --mssfix 1450 --redirect-gateway def1 --auth-user-pass --comp-lzo --verb 3", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
GUICtrlSetData($Edit1, "")
$bRunning = True
While ProcessExists($foo)
If $bRunning = False Then ExitLoop
$Line = StdoutRead($foo)
If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Edit1, $Line, 1)
Sleep(10)
Wend
$bRunning = False
EndIf

Local $line=""
While 1
$line &= StdoutRead($foo)
If @error Then ExitLoop
;MsgBox(0, "STDOUT read:", $line)
GUICtrlSetData($Edit1, $line)
Wend

While 1
$line &= StderrRead($foo)
If @error Then ExitLoop
; MsgBox(0, "STDERR read:", $line)
GUICtrlSetData($Edit1, $line)
Wend


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

it's work, but before it connected, it will show authentication on edit control

like this

Posted Image

How to continue authentication on my edit control after i press enter?

or any secure script to start authentication?

Edited by jezzjj

Share this post


Link to post
Share on other sites

OpenVPN tries to read the password from StdIn. StdIn is assigned to your script so you need to use StdInWrite to provide the password.

Insert

StdInWrite($foo, $sUserId) ; Pass the User-Id to OpenVPN
StdInWrite($foo, $sPassword); Pass the password to OpenVPN
after the Run statement. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Where does the userid "oxid" come from? i can't find it in the Run statement.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Local $foo = Run(@scriptdir & "\openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --persist-key --persist-tun --ca ca.crt --tun-mtu 1500 --tun-mtu-extra 32 --mssfix 1450 --redirect-gateway def1 --auth-user-pass --comp-lzo --verb 3", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)

i type it manually, because the auth process from "--auth-user-pass", openvpn have two authentication way, from the command line prompt like on the picture, and read from the file (.ini), this is the example for my old openvpn script :

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Users\Jezz\Pictures\blackhole.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayMenuMode", 1)
Opt("WinTitleMatchMode", 2)
$DIRPATH = @ScriptDir
$IPADDRESS1 = @IPAddress1
$USER = IniRead(@ScriptDir & "\ophreak.ini", "Data", "Username", "NotFound")
$PASS = IniRead(@ScriptDir & "\ophreak.ini", "Data", "Password", "NotFound")
Sleep(100)
Run(@SystemDir & '\route.exe ADD 192.211.51.53 MASK 255.255.255.0 "' & $IPADDRESS1 & '"', @SystemDir, @SW_HIDE) ;---IP VPN SERVER & SUBNET MASK
Sleep(100)
ProcessClose("openvpn.exe")
Sleep(100)
ProcessClose("openvpn-gui-1.0.3.exe")
Sleep(100)
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 0)
If $FILE = True Then
FileClose($FILE)
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 2)
FileWrite($FILE, "client" & @CRLF)
FileWrite($FILE, "dev tun" & @CRLF)
FileWrite($FILE, "proto tcp" & @CRLF)
FileWrite($FILE, "remote 192.211.51.53 443" & @CRLF) ;-----SSH LOCALHOST ; PORT FORWARD----
FileWrite($FILE, "resolv-retry infinite" & @CRLF)
FileWrite($FILE, "nobind" & @CRLF)
FileWrite($FILE, "persist-key" & @CRLF)
FileWrite($FILE, "persist-tun" & @CRLF)
FileWrite($FILE, "ca ca.crt" & @CRLF) ;<<<----- server US
FileWrite($FILE, "tun-mtu 1500" & @CRLF)
FileWrite($FILE, "tun-mtu-extra 32" & @CRLF)
FileWrite($FILE, "mssfix 1450" & @CRLF)
FileWrite($FILE, "redirect-gateway def1" & @CRLF)
FileWrite($FILE, "auth-user-pass" & @CRLF)
FileWrite($FILE, "comp-lzo" & @CRLF)
FileWrite($FILE, "verb 3" & @CRLF)
EndIf
FileClose($FILE)
Sleep(1000)
Run(@ProgramFilesDir & '\OpenVPN\bin\openvpn-gui-1.0.3.exe --connect inter.ovpn --config_dir "' & $DIRPATH & '" --show_script_window 0 --log_dir "' & $DIRPATH & '" --allow_service 0 --allow_proxy 0 --allow_edit 0 --allow_password 0 --silent_connection 0', @ProgramFilesDir & "\OpenVPN", @SW_SHOW)
Sleep(2000)
If $FILE = True Then
$FILE = FileOpen(@ScriptDir & "\inter.ovpn", 2)
FileRecycleEmpty($FILE)
EndIf
FileClose($FILE)
Sleep(1000)
WinWaitActive("OpenVPN - User Authentication")
Sleep(1000)
Send($USER)
Sleep(9000)
Send("{TAB}")
Sleep(1000)
Send($PASS)
Sleep(9000)
Send("{ENTER}")

or any script to change the way of authentication process?like add the inputbox for username password like plink does

Edited by jezzjj

Share this post


Link to post
Share on other sites

Sorry, I'm out of ideas. That doesn't look like an AutoIt problem but one with OpenVPN.

I've never used OpenVPN so can't help with that.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

But how to make my editbox can send command just like CMD does ?

Can you help me?

Posted Image

that is my last problem, i don't know how to send command using edit control just like in CMD

Share this post


Link to post
Share on other sites

That's what the two StdInWrite statements are for. The run statement connectso to the StdIn and StdOut streams. If OpenVPN accepts data from StdIn then this problem should be easy to solve.

Just open a CMD prompt and enter the following command to check if OpenVPN accepts data fromStdIn:

echo oxid | openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --........

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Ok. So

$sUserID = "oxid"
$sPassword = "......"
Global $foo = Run(@scriptdir & "\openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --persist-key --persist-tun --ca ca.crt --tun-mtu 1500 --tun-mtu-extra 32 --mssfix 1450 --redirect-gateway def1 --auth-user-pass --comp-lzo --verb 3", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
StdInWrite($foo, $sUserId) ; Pass the User-Id to OpenVPN
StdInWrite($foo, $sPassword); Pass the password to OpenVPN
should work as I posted in #24.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

ehm, sorry i want to ask about cmd command,

about this command on post 30:

echo oxid | openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --........

echo oxid | <----- This only send the username...

how to send password too?

Share this post


Link to post
Share on other sites

You could try:

echo oxid | echo password | openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --........
But I'm not sure it works.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

hello water,

im still with the same problem..

but i have try load auth file using openvpn cmd, and its work

Posted Image

this is my fullscript now :

Global $bRunning = False

If $bRunning = False Then
Local $foo = Run(@ScriptDir &amp; "\openvpn.exe --client --dev tun --proto tcp --remote MYIP 7070 --resolv-retry infinite --nobind --persist-key --persist-tun --ca ca.crt --tun-mtu 1500 --tun-mtu-extra 32 --mssfix 1450 --redirect-gateway def1 --auth-user-pass login.txt --comp-lzo --verb 3", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
GUICtrlSetData($Edit1, "")
$bRunning = True
While ProcessExists($foo)
If $bRunning = False Then ExitLoop
$Line = StdoutRead($foo)
If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Edit1, $Line, 1)
Sleep(10)
Wend
$bRunning = False
EndIf

Local $line=""
While 1
$line &amp;= StdoutRead($foo)
If @error Then ExitLoop
;MsgBox(0, "STDOUT read:", $line)
GUICtrlSetData($Edit1, $line)
Wend

While 1
$line &amp;= StderrRead($foo)
If @error Then ExitLoop
; MsgBox(0, "STDERR read:", $line)
GUICtrlSetData($Edit1, $line)
Wend

While 1
$line &amp;= StdinWrite($foo)
If @error Then ExitLoop
; MsgBox(0, "STDERR read:", $line)
GUICtrlSetData($Edit1, $line)
Wend

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Here the condition in my script :

1. if im not using auth file in openvpn command, "im still stuck on auth proccess", everytime i type my username/password there is nothing happen..the authentication not continue...

- Maybe there is a script i should add to my edit control, so my edit control can send username/password just like in CMD

2. if im using the auth file in the command, it said "can't found the specific file"

- Its just the same, i can't login...

How to make my edit control active, just like CMD, so i can pass the authentication process

Edited by jezzjj

Share this post


Link to post
Share on other sites

We got your Plink script running but are having problems with OpenVPN. So it looks like a problem with OpenVPN. As I don't know OpenVPN I can't help here.

Maybe someone else on the forum knows OpenVPN better so he/she can help you with your problem?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

i guess, not about the openvpn...

because, when the plink prompt this :

"Store key in cache? (y/n) y" -- I answer "y"

and there is nothing happen, not like if i connect from CMD

this is screenshot in my program

Posted Image

and this is in CMD

Posted Image

whats wrong with myscript?can you help me?

just like in the picture when Plink connect to host, it show authentication if the specified port is not cached before.

When i answer "y", it means, i send command to process right?

but it freeze..

that is what happen to openvpn >_<

when i send username/password it freeze, process not continue..

if there is nothing wrong with the "send command to proccess using stdout,stdin write" [iMHO]

Your script in in post #32 will work perfectly....

can you help me?

because, i guess this problem about the editbox script or stdin/outwrite.....[iMHO] :ermm:

Share this post


Link to post
Share on other sites

jezzjj,

at the moment the script is made to work like this:

Plink/OpenVPN write all output to StdOut which is then grabbed by your script and written to the edit control.

Plink/OpenVPN read all input from StdIn. You can pass data to StdIn by using function StdInWrite (I showed how to provide userid/password in an earlier post).

So what you could do is:

In the loop that grabs the data from StdOut and writes it to the edit control you have to check for specific messages. For example

While ProcessExists($foo)
    If $bRunning = False Then ExitLoop
    $Line = StdoutRead($foo)
    If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Edit1, $Line, 1)
    If $Line = "Store key in cache (y/n)?" then StdInWrite($foo, "y")
    Sleep(10)
Wend

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...