LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Closed Thread
  Search this Thread
Old 03-18-2011, 05:18 AM   #1
vanid
LQ Newbie
 
Registered: Mar 2011
Posts: 11

Rep: Reputation: 0
expect script for random password and random commands


Hi,,

Here i have attached a text file where iam facing problem in my code.

Please read the file and help me out of this issue..


Thanks in advance
Attached Files
File Type: txt expect.txt.txt (1.4 KB, 108 views)
 
Old 03-18-2011, 05:22 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What is this script meant for? To me it looks like hacking activity, similar to brute force attack. Please, can you elaborate?
 
Old 03-19-2011, 01:56 AM   #3
vanid
LQ Newbie
 
Registered: Mar 2011
Posts: 11

Original Poster
Rep: Reputation: 0
expect script for random password and random commands

Firstly thank you so much for replying....
actually i am new to expect:

I am able to execute the commands automatically using expect for telnet session.

Now my requirement is:
as of now those commands are all valid one's, which i am seeing on output but

now i want them to automate for all invalid conditions like..
when commands are unexpectedly typed wrong by human manually, it show corresponding error message...so now i want the same effect using expect automatically for all valid commands which i have done it for.

the attachment is what i have written sample code for randomizing passwords ..i tried this to get idea to my actual problem. that's it
please if you again not clear on question: please do ask i will try to elaborate it clearly once again

thank you
 
Old 03-19-2011, 01:59 AM   #4
vanid
LQ Newbie
 
Registered: Mar 2011
Posts: 11

Original Poster
Rep: Reputation: 0
expect script for random password and random commands

here is my code:



Code:
#!/usr/local/bin/expect —f
proc insertchar {c} {
global password
set password [linsert $password \
[rand [expr 1+[llength $password]]] $c]
}
set _ran 5
proc rand {n} {
global _ran
set period 233280
set _ran [expr ($_ran*9301 + 49297) % $period]
expr int($n*($_ran/double($period)))
}
send_user "rand n\n"
send_user "insertchar c\n"
set minnum 2
set minlower 4
set minupper 4
expect "$ "
set pwd "vani"
set password [join "$pwd" ""]
for {set i 0} {$i<$minnum} {incr i} {
send "$password [rand 10]\n"
}
for {set i 0} {$i<$minlower} {incr i} {
send "$password [format "%c" [expr 0x61 + [rand 26]]]\n"
}
for {set i 0} {$i<$minupper} {incr i} {
send "$password [format "%c" [expr 0x41 + [rand 26]]]\n"
}
result for above code is:


Code:
rand n
insertchar c
vani 4
vani 8
vani n
vani v
vani o
vani j
vani A
vani E
vani Z
vani L
but i want the letters to be inserted in to the string by picking up randomly like :


Code:
v1ani
Vani
Va1ni
so that i can test commands for all invalid cases also.
 
Old 03-27-2011, 11:57 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And since the op seems to have lost interest after being asked
what the hacking attempt is in aid of I'm closing this.



Cheers,
Tink
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
virus on random web pages at random intervals irian Linux - Security 13 11-17-2009 01:50 PM
random password script kernel-P4N1C Programming 2 08-07-2009 02:37 AM
Box is attempting to scan and ssh into random machines using random usernames gianh Linux - Security 2 11-09-2008 05:42 PM
using /dev/random to output random numbers on a text file guguma Programming 4 04-02-2007 01:42 PM
KDE Random wallpaper or script to create symbolic links to random files cvelasquez Linux - Software 2 02-26-2007 06:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration