Bác nào cho em xin source code connect ssh bằng Autoit với

wads

Junior
Joined
Feb 21, 2011
Messages
191
Reactions
111
MR
0.086
Chat with me via Skype
Em đang tập viết tool, mới tiếp cận Autoit còn nhiều cái ko biết, đang vướng chỗ connect ssh bằng bitvise
Bác nào cho em xin source code connect ssh bằng Autoit với
Có 1 bác share code này

Run("BvSsh\BvSsh.exe /host="&$sz_ip&" /user="&$sz_user&" /password="&$sz_pass&" /openTerm=n /openSFTP=n /openRDP=n /loginOnStartup /hide=auth /hide=banner /hide=popups /hide=trayIcon /hide=trayPopups /hide=trayTerm /hide=traySFTP /hide=trayRDP /hide=trayLog /hide=trayBSSCP")


Nhưng còn phần Proxy Forwarding để tạo sock với bảng Host Key Verification thì làm thế nào ạ
 

vikowelic

Banned
Joined
Oct 27, 2014
Messages
595
Reactions
446
MR
0.000
Call me! Call me! Chat with me via Skype
Em đang tập viết tool, mới tiếp cận Autoit còn nhiều cái ko biết, đang vướng chỗ connect ssh bằng bitvise
Bác nào cho em xin source code connect ssh bằng Autoit với
Có 1 bác share code này

Run("BvSsh\BvSsh.exe /host="&$sz_ip&" /user="&$sz_user&" /password="&$sz_pass&" /openTerm=n /openSFTP=n /openRDP=n /loginOnStartup /hide=auth /hide=banner /hide=popups /hide=trayIcon /hide=trayPopups /hide=trayTerm /hide=traySFTP /hide=trayRDP /hide=trayLog /hide=trayBSSCP")


Nhưng còn phần Proxy Forwarding để tạo sock với bảng Host Key Verification thì làm thế nào ạ

Check khi nào nó xuất hiện cái bảng đó lên thì bấm Accept, autoit mạnh vụ này mà.
Còn change đa luồng thì thêm vào cái processsID nữa.
 

candylop

Hero
Joined
Nov 24, 2013
Messages
4,091
Reactions
3,384
MR
0.003
Chat with me via Skype
Đây là hàm change SSH (mình thiết kế chạy nhiều luồng nên mới có thêm profile trong đó, dòng nào thấy ko cần thiết thì xoá đi)
Func _ChangeSSH($filessh,$sshprofile) ;$sshprofile="candylop1.bscp"
Local $timeout=30
If Not FileExists($filessh) then
Msgbox(4096,$programtitle,"File dữ liệu ssh không tồn tại, vui lòng kiểm tra lại!")
GUICtrlSetState($Issh,$GUI_FOCUS)
Return SetError(-1,0,"Error")
EndIf
Local $fSshOpen=FileOpen($filessh,1)
Local $line=FileReadLine($filessh,1)
If @error=-1 then
Msgbox(4096,$programtitle,"Đã hết SSH trong list rồi, vui lòng mua thêm đi đồ keo kiệt.")
FileClose($fSshOpen)
Return SetError(-1,0,"Error")
Endif

Local $aIP=_SpitUserPass($line)
If Not IsArray($aIP) then
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)
Return ""
Endif
Opt("WinTitleMatchMode",2)
$ParamSSH=" -profile="&$sshprofile&" -host="&$aIP[0] & " -user="&$aIP[1] & " -password="&$aIP[2] &" -hostKeyFile=candykey -loginOnStartup" ;" -profile="&$profile&
$Dirssh=@ProgramFilesDir&"\Bitvise SSH Client"
$spid_profile=_getpid("BvSsh.exe",$sshprofile)
If $spid_profile <> 0 Then
_SSHLoginLogout($spid_profile,"logout")
Sleep(2000)
_SSHLoginLogout($spid_profile,"exit")
Endif
Run(@COMSPEC & " /c "&"BvSsh" & $ParamSSH,$Dirssh,@SW_HIDE,0x2)
$code=WinWait($BITVISE_TITLE,"",$timeout)
$acceptkey=WinWaitActive("Host Key Verification","",$timeout)
if $acceptkey >0 then
ControlClick($acceptkey,"","[CLASS:Button; INSTANCE:2]","left")
sleep(5000)
Else
$sPid=WinGetProcess($code)
_SSHLoginLogout($sPid,"exit")
Msgbox(64,$programtitle,"Thời gian kết nối lâu quá "&$timeout&" giây",1)
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)

Sleep(2000)
Return SetError(-1,0,"")
Endif
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)
Local $thanhcong=_sockstatus(1080+1)
Local $wait=0
While $thanhcong <1 And $wait <7
sleep(5000)
$thanhcong=_sockstatus(1080+1)
$wait+=1
WEnd
If $wait >6 then return SetError(-1,0,"")
Return $aIP[0]
Endfunc ;---->_ChangeSSH

Func _SpitUserPass($string)
Local $st
$st=StringReplace($string," "," ",0,0)
$st=StringReplace($st," | ","|",0,0)
$pos1=StringInstr($st,"|",0,1)
$pos2 = StringInStr($st, "|", 0, 2)
$pos3= StringInStr($st,"|",0,3)
Local $aup=StringMid($st,1,$pos1-1)
Local $u=StringMid($st,$pos1+1,$pos2-$pos1-1)
Local $p=StringMid($st,$pos2+1,$pos3-$pos2-1)
Local $result[3]=[$aup,$u,$p]
If StringInStr($aup,".",0,3) < 1 then Return SetError(-1,0,"")
Return $result
EndFunc ;-----> _SpitUserPass
Đoạn code này dùng để vừa đợi con ssh đó có thời gian login vào remote computer, vừa để kiểm tra xem thử Bitvise đã tạo sock thành công chưa. Nếu thành công thì Enjoy trả về IP đã change , còn không thì xử nó.

Local $thanhcong=_sockstatus(1080+1)
Local $wait=0
While $thanhcong <1 And $wait <7
sleep(5000)
$thanhcong=_sockstatus(1080+1)
$wait+=1
WEnd
If $wait >6 then return SetError(-1,0,"")
Return $aIP[0]
 
Last edited:
Check khi nào nó xuất hiện cái bảng đó lên thì bấm Accept, autoit mạnh vụ này mà.
Còn change đa luồng thì thêm vào cái processsID nữa.

Đây là hàm change SSH (mình thiết kế chạy nhiều luồng nên mới có thêm profile trong đó, dòng nào thấy ko cần thiết thì xoá đi)
Đoạn code này dùng để vừa đợi con ssh đó có thời gian login vào remote computer, vừa để kiểm tra xem thử Bitvise đã tạo sock thành công chưa. Nếu thành công thì Enjoy trả về IP đã change , còn không thì xử nó.

Thank 2 bác, e làm được rồi nhưng còn phần SOCKS/HTTP Proxy Forwarding có cách nào enabled trên default profile luôn ko bác
 
Hic hic cái code post lên dài lắm. Tự nhiên bỏ trong qoute rồi lại trong spoile nên nó chỉ hiện tí xiú.

phần Forwarding chỉ dùng 1 lần khi cài đặt ban đầu. Không dùng thường xuyên cho nên cái đó làm bằng tay rồi save vào profile.
 
$ssh1 = "-host=" & $host_ssh & " -port=" & $port_ssh & " -username=" & $username & " -password=" & $password & " -proxy=n -hide=trayWRC,traySFTP,trayRDP,trayPopups,popups,trayLog -title=ssh1 -hostKeyMD5=xxx -hostKeyBB=xxx -hostKeyFile=xxx"
Sleep(10)
Run(@ScriptDir & "\syed\soft\BvSsh.exe -profile=soft\config\ssh1.bscp -loginOnStartup " & $ssh1, @ScriptDir, @SW_HIDE)
 

MinhPhap

Newbie
Joined
Dec 21, 2017
Messages
4
Reactions
0
MR
0.001
Đây là hàm change SSH (mình thiết kế chạy nhiều luồng nên mới có thêm profile trong đó, dòng nào thấy ko cần thiết thì xoá đi)
Func _ChangeSSH($filessh,$sshprofile) ;$sshprofile="candylop1.bscp"
Local $timeout=30
If Not FileExists($filessh) then
Msgbox(4096,$programtitle,"File dữ liệu ssh không tồn tại, vui lòng kiểm tra lại!")
GUICtrlSetState($Issh,$GUI_FOCUS)
Return SetError(-1,0,"Error")
EndIf
Local $fSshOpen=FileOpen($filessh,1)
Local $line=FileReadLine($filessh,1)
If @error=-1 then
Msgbox(4096,$programtitle,"Đã hết SSH trong list rồi, vui lòng mua thêm đi đồ keo kiệt.")
FileClose($fSshOpen)
Return SetError(-1,0,"Error")
Endif

Local $aIP=_SpitUserPass($line)
If Not IsArray($aIP) then
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)
Return ""
Endif
Opt("WinTitleMatchMode",2)
$ParamSSH=" -profile="&$sshprofile&" -host="&$aIP[0] & " -user="&$aIP[1] & " -password="&$aIP[2] &" -hostKeyFile=candykey -loginOnStartup" ;" -profile="&$profile&
$Dirssh=@ProgramFilesDir&"\Bitvise SSH Client"
$spid_profile=_getpid("BvSsh.exe",$sshprofile)
If $spid_profile <> 0 Then
_SSHLoginLogout($spid_profile,"logout")
Sleep(2000)
_SSHLoginLogout($spid_profile,"exit")
Endif
Run(@COMSPEC & " /c "&"BvSsh" & $ParamSSH,$Dirssh,@SW_HIDE,0x2)
$code=WinWait($BITVISE_TITLE,"",$timeout)
$acceptkey=WinWaitActive("Host Key Verification","",$timeout)
if $acceptkey >0 then
ControlClick($acceptkey,"","[CLASS:Button; INSTANCE:2]","left")
sleep(5000)
Else
$sPid=WinGetProcess($code)
_SSHLoginLogout($sPid,"exit")
Msgbox(64,$programtitle,"Thời gian kết nối lâu quá "&$timeout&" giây",1)
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)

Sleep(2000)
Return SetError(-1,0,"")
Endif
_FileWriteToLine($filessh,1,"",1)
FileClose($fSshOpen)
Local $thanhcong=_sockstatus(1080+1)
Local $wait=0
While $thanhcong <1 And $wait <7
sleep(5000)
$thanhcong=_sockstatus(1080+1)
$wait+=1
WEnd
If $wait >6 then return SetError(-1,0,"")
Return $aIP[0]
Endfunc ;---->_ChangeSSH

Func _SpitUserPass($string)
Local $st
$st=StringReplace($string," "," ",0,0)
$st=StringReplace($st," | ","|",0,0)
$pos1=StringInstr($st,"|",0,1)
$pos2 = StringInStr($st, "|", 0, 2)
$pos3= StringInStr($st,"|",0,3)
Local $aup=StringMid($st,1,$pos1-1)
Local $u=StringMid($st,$pos1+1,$pos2-$pos1-1)
Local $p=StringMid($st,$pos2+1,$pos3-$pos2-1)
Local $result[3]=[$aup,$u,$p]
If StringInStr($aup,".",0,3) < 1 then Return SetError(-1,0,"")
Return $result
EndFunc ;-----> _SpitUserPass
Đoạn code này dùng để vừa đợi con ssh đó có thời gian login vào remote computer, vừa để kiểm tra xem thử Bitvise đã tạo sock thành công chưa. Nếu thành công thì Enjoy trả về IP đã change , còn không thì xử nó.

code thiếu à bác ơi
có nhiều func không có để thực thi
 

kegiaumat

Junior
Joined
Aug 4, 2013
Messages
271
Reactions
60
MR
0.009
Bác @candylop có tool nào change đa luồng với auto 24/7 ko cho e xin với. Tool của bác dinhtai thì dc có 1 cổng với dùng bản bitvise 4.6 nên SSH ko được ổn định lắm. Thank bác nhiều
 

Announcements

Today's birthdays

Forum statistics

Threads
423,967
Messages
7,135,626
Members
176,443
Latest member
ww88sevents

Most viewed of week

Most discussed of week

Most viewed of week

Most discussed of week

Back
Top Bottom