Attempting to make something, using bash that will generate a list of numbers from 000 to 999, with the leading zeroes.
I've tried several different versions, but all seem to have some sort of problem.
[CODE]check(){
printf $1
}
for i in 0 {0..999}; do
max=100;
check "%0*d\n" ${#max} $i
done[/CODE]
That will constantly output zero...
I'd imagine not dealing with functions would make this easier, but I'm making use of "expect" which, for whatever reason, doesn't like variables being used once it's called. For example, this one doesn't work because it requires "$i"
[CODE]#!/usr/bin/expect --
for i in 0 {0..999}; do
spawn su user
expect "password:"
send "printf "%0*d\n" 3 $i; ""
expect eof
EOF
done[/CODE]
Ignoring the idiocy of using this for gaining root access (there's a reason for this, just trust me...) anyone have some insight?
What's the reason? Because whatever you're doing is wrong, and is probably done in a better way.
[QUOTE=Jookia;32884227]What's the reason? Because whatever you're doing is wrong, and is probably done in a better way.[/QUOTE]
I know that it can probably be done in a better way. Basically, I just need the random three number string, with leading zeros, automatically sent to the su command. Is that possible?
Here's a binary for you, just place it in /bin and it'll give you the 3 random numbers you need.
[url]http://67.177.47.177/rand[/url]
[editline]asdf[/editline]
sending it to a command is as easy as:
[code]NUM=`rand`
su $NUM[/code]
[QUOTE=dmillerw;32884263]I know that it can probably be done in a better way. Basically, I just need the random three number string, with leading zeros, automatically sent to the su command. Is that possible?[/QUOTE]
Are you trying to DoS the su command?
[QUOTE=Jookia;32886525]Are you trying to DoS the su command?[/QUOTE]
No, and besides, I figured out what I was trying to do.
Macs at our school have unrestricted terminal access, and all are formatted yearly with the same image. These all have an admin account. I knew most of the password, save for the last three numbers...
I think you can guess what all this was about.
Compromising security? Well here at the programming forum, we completely support you. Fuck, why don't you have my password.
...can't tell if you're being sarcastic or not.
In any case, thanks for the help.
[QUOTE=dmillerw;32887157]...can't tell if you're being sarcastic or not.
In any case, thanks for the help.[/QUOTE]
I'm not an expert on these things, but I'm pretty sure he's being 100% serious.
Sorry, you need to Log In to post a reply to this thread.