Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ in banner; expect4r assumes prompt on ios #6

Open
bthornto opened this issue Sep 27, 2014 · 5 comments
Open

$ in banner; expect4r assumes prompt on ios #6

bthornto opened this issue Sep 27, 2014 · 5 comments

Comments

@bthornto
Copy link

Hey there-

First thanks for your work on this. It is proving to be very useful. It working fine on our lab but our production routers have a banner motd with a $ in it and it is parsed as a prompt and therefore the password never given:

debug: buf0: [,and may result in fines of $]
debug: match PROMPT
debug: ,and may result in fines of $
debug: print: "show ip route\r", io_writer: #File:0x007fcfe89a8ca0

The actual line of the banner is:

,and may result in fines of $250,000 and/or imprisonment.

Any thoughts?

Brad

@jeanmichel-gh
Copy link
Owner

Hi Brad,

Thanks for the feedback,
Have you looked at login method in CicoCommon module?
What the exact banner?

Jean-Michel

@bthornto
Copy link
Author

This is the exact banner:

^
WARNING
Unauthorized access to this system is a violation of the
Federal Electronics Communications Privacy Act of 1986
,and may result in fines of $250,000 and/or imprisonment.
(Title 18, USC)
^Password:

I was going to modify that but I didn't want to hard code anything in the code. It's seems the $ is what is throwing it off. I'm also not able to change the banner on the entire population of devices.

Brad

@bthornto
Copy link
Author

I have a temporary fix for myself, would you consider this change:

in ios.rb and iox.rb:

#remove $ as a prompt, since Cisco doesn't use it

def initialize(args)
super
@PS1 = /(.
)(>|#)\s*$/
@more = / --More-- /
end

@bthornto
Copy link
Author

A little more testing here. We have some interesting line in our configs and thus need a very specific regex for the prompt. (please excuse my rookie coding skills)

Here's some examples:

an ACL with a remark:

remark 1###########################################

an IPSLA with an 'owner'

owner User Name user@foo.com

Both seem to trigger a prompt find. So rather than hard code it (in ios.rb)

Allow the passing of a prompt:

def initialize(args)
super
if !args[1][:prompt].nil? then
@PS1 = args[1][:prompt]
else
@PS1 = /(.
)(>|#)\s*$/
end
@more = / --More-- /
end

The reason for the \r in the regex is, nx-os appears to add a \r to the promt sometime (\rhostname#)

Brad

@jeanmichel-gh
Copy link
Owner

Removing the '$' char from the prompt seems a better approach.
For the remark issue, you will need to either customize the prompt regex to not match or change the remark value itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants