Jump to content

Need help with something basic


GETBus
 Share

Recommended Posts

I'm trying to code some automation with AutoIT to perform the following steps:

 

1. Login to our firewall using SSH (plink or putty) - "plink.exe -ssh 192.168.1.3 -l admin"

2. Input the password "password" (for example here)

3. Reboot the device

 

For some reason, trying to do this from CMD results in me always being prompted for the password, even though I add it into the syntax (with using putty or plink by themselves). I'm having the same issue with AutoIT.

 

Here's what I have so far:

 

RunWait( @COMSPEC & " /c C:&&plink.exe -ssh 192.168.1.3 -l admin", "", @SW_SHOW)


ControlSend("C:\Windows\system32\cmd.exe", "", "", "password")

ControlSend("C:\Windows\system32\cmd.exe", "", "", "{ENTER}")

 

I've also tried the normal "Send" command rather than ControlSend and I had the same issue. I also tried using putty and same thing; I can't seem to get it to actually enter the password "password" then hit Enter. Currently, running this just sits on the password prompt then eventually times me out.

 

What am I doing wrong?

Link to comment
Share on other sites

If I remember correctly (and it's been a while since I've used putty) you can use user:password@ip_address for one of the command line parameters

ShellExeucte("Path To Putty.exe", "-ssh username:password@192.168.1.3")

As for rebooting, I know there is a problem with using send/control send with cmd. Search the forums and there are several topics and solutions for this.

Edit: Nvm, that was ftp

Edited by InunoTaishou
Link to comment
Share on other sites

1 hour ago, InunoTaishou said:

If I remember correctly (and it's been a while since I've used putty) you can use user:password@ip_address for one of the command line parameters

ShellExeucte("Path To Putty.exe", "-ssh username:password@192.168.1.3")

As for rebooting, I know there is a problem with using send/control send with cmd. Search the forums and there are several topics and solutions for this.

 

Thanks.

 

I still have the same issue using that syntax with putty. Even though I have the password included, it still prompts me for the password at login.

 

I've tried using AutoIT along with Putty and I still can't get it to pass any keystrokes. The script seems to pause, because I tried adding some other commands at the end of the script, such as killing the .cmd or .putty process, and it never executes. Once it gets to the point where I'm prompted for the password for our firewall, AutoIT's script just freezes permanently.

Link to comment
Share on other sites

I have no issues with this syntax

$Connection = "plink.exe -ssh COMPUTERNAME -l USERNAME -pw PASSWORD"
$log_dir = @ScriptDir & "\" & @MON & @MDAY & @YEAR & "\"

$log = ">" & $log_dir & "\REMOTE_LOGIN.log"
$Command1 = "grep -i -P '(extraweb__authen HTTP)' /var/log/daily.log"
runwait('cmd /c ' & $Connection & ' ' & $Command1 & $log)

And your title should be descriptive, not what we assume about every post in GH&S :)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

1 hour ago, iamtheky said:

I have no issues with this syntax

$Connection = "plink.exe -ssh COMPUTERNAME -l USERNAME -pw PASSWORD"
$log_dir = @ScriptDir & "\" & @MON & @MDAY & @YEAR & "\"

$log = ">" & $log_dir & "\REMOTE_LOGIN.log"
$Command1 = "grep -i -P '(extraweb__authen HTTP)' /var/log/daily.log"
runwait('cmd /c ' & $Connection & ' ' & $Command1 & $log)

And your title should be descriptive, not what we assume about every post in GH&S :)

 

Thanks. Could you give me a bit of information about each line? I'm not sure what lines 2-5 mean.

 

Also, the issue with the syntax and the password not being accepted may just be a Sonicwall issue, not entirely sure. If I could simply pass the keystrokes containing the password to that screen and hit enter with AutoIT, I could solve that problem.

Link to comment
Share on other sites

each line is used to format the text.  When doing large commands with varying quote needs, I find it helps to bust them up.

For your use you could delete 2&3, and then delete " & log" from the end of the runwait.  Should be fine through sonicwall.

As a last resort I would save a session in putty, and just run that session from Plink. 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I believe this post unfortunately violates rule #1.  For inputting a password for you.
 

  • Bypassing of security measures - log-in and security dialogs, CAPTCHAs, anti-bot agents, software activation, etc.
Edited by Cormin
Link to comment
Share on other sites

No it doesnt.   There is a significunt difference between Bypass and Automate (see the part where the username and password are supplied)

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

Cormin,

No it does not - merely automating the input of known usernames and passwords does not mean that security measures are being bypassed. The rule refers to dialogs such as UAC, as it clearly states.

M23

P.S. You might want to read this announcement.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

one more question @iamtheky or others...I don't get it... :-(

If I use this:

RunWait "plink.exe -ssh DiskStation -l root -pw xyzabc shutdown -h now"

...how can I add the sequence telling it to shutdown, e.g. "shutdown -h now"???

I seldom used AutoIt and have searched for days now, no luck yet! :-)

Link to comment
Share on other sites

Found it...al least ;-)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$var = Ping("DiskStation",250)
If $var Then
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Netzwerkcheck", 507, 248, 402, 14)
GUISetBkColor(0x008000)
$Label1 = GUICtrlCreateLabel("Das Gerät ist im Netz!", 108, 8, 290, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Pic1 = GUICtrlCreatePic("index.jpg", 84, 48, 338, 149)
$Label2 = GUICtrlCreateLabel("Netzlaufwerk einsatzbereit", 29, 208, 449, 24, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Radio_1 = GuiCtrlCreateRadio("Shutdown", 20, 40, 80, 20)
$Radio_2 = GuiCtrlCreateRadio("Close", 20, 80, 80, 20)
GuiSetState()
While 1
    $msg = GuiGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
 case $msg = $Radio_1
  MsgBox (0,"Checked", "Shutdown NAS")
  Run(@ComSpec & " /c " & 'plink.exe -ssh DiskStation -l root -pw xyzabc shutdown -h now', "", @SW_HIDE)
Exit
      exitloop
   case $msg = $Radio_2
  MsgBox (0,"Checked", "Close")
    exitloop
     EndSelect
WEnd
 #EndRegion ### END Koda GUI section ###
sleep (500)
Else
Run ("wolcmd.exe 001132555eb1 192.168.109.78 255.255.255.0 7")
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Netzwerkcheck", 523, 272, 419, 15)
GUISetBkColor(0x800000)
$Label1 = GUICtrlCreateLabel("Das Gerät ist nicht im Netz!", 84, 8, 354, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Pic1 = GUICtrlCreatePic("index2.jpg", 92, 48, 338, 149)
$Label2 = GUICtrlCreateLabel("Das Netzlaufwerk ist in ca. 2 Minuten einsatzbereit", 11, 232, 500, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Label3 = GUICtrlCreateLabel("Es wird nun gestartet ... einen Moment Geduld!", 37, 200, 449, 24, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
sleep (5000)

EndIf

...not the most elegant but working fine :-)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...