|
|||||||
| Programming A place for our community to discuss their own security related coding projects. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Quote:
Code:
read WEPKEY
WEPKEY=`echo $WEPKEY | cut -c 1-26`
HEXSTRIPPED=`echo $WEPKEY | sed 's/[^0-9A-F]//g'`
if [ $HEXSTRIPPED -ne $WEPKEY ];
then
# key is ASCII
SHORTASCII=`echo $WEPKEY | cut -c 1-10`
# now we have $SHORTASCII and $WEPKEY, we need to check the length
# of SHORTASCII and compare it to the length of WEPKEY. If SHORT is equal
# to 10, and wepkey is not equal to 26, then we use short, else wepkey
# unless neither are the right size, then we bail out.
# bonus side effect: we fail through to a 10char ascii key, rather than a
# 15 character ascii key
SHORTLEN=`expr length $SHORTASCII`
# etc. Same applies to HEX
else
# key is HEX
fi
Edit: And wahey he finally joins the ranks of Senior Members!
__________________
Never underestimate the power of human stupidity - it is like a force of nature, capable of destroying even the most well laid plans. Last edited by Gitsnik; 11-04-2009 at 10:34 PM. |
|
||||
|
OK Gitsnik
Sorry for being late to respond. It was a hell of day, today. I think I got it now. I have hard time with sed. It's not fully understandable by me, until now. It will be. Quote:
Anyway. I am starting to believe that it is fate's (or yours ) decision to carry me out in your shoulders.Thank you, again Nick PS Get out of my way newbies. Here comes a Senior member.
__________________
The quieter you become.... Last edited by Nick_the_Greek; 11-05-2009 at 08:51 PM. |
|
||||
|
sed is a joy once you get it - there is a page full of one liners on sourceforge, as well as one similar for awk and others.I doubt the Moirae have anything to do with me - though they might because you keep asking questions I have answers to!
__________________
Never underestimate the power of human stupidity - it is like a force of nature, capable of destroying even the most well laid plans. |
|
||||
|
It's not pretty but you could also simply try the command with the given input and then check the exit status based on the $? environment variable.
__________________
I'm a compulsive post editor, you might wanna wait until my post has been online for 5-10 mins before quoting it as it will likely change. I know I seem harsh in some of my replies. SORRY! But if you're doing something illegal or posting something that seems to be obvious BS I'm going to call you on it. |
|
||||
|
Quote:
Maybe you missed out my first post Thorin. ![]() Code:
.....
iwconfig wlan0 key $key >/dev/null 2>&1
if [ $? != 0 ]; then
echo "Your key is `echo ${#key}` characters long"
echo "It should be : a) 10 or 26 ASCII characters long"
echo " or : b) 5 or 13 HEX characters long"
else
echo "Valid key"
fi
Thank you for trying.
__________________
The quieter you become.... Last edited by Nick_the_Greek; 11-06-2009 at 04:18 PM. |
|
||||
|
Ya I didn't bother reading your code, oh darn....
__________________
I'm a compulsive post editor, you might wanna wait until my post has been online for 5-10 mins before quoting it as it will likely change. I know I seem harsh in some of my replies. SORRY! But if you're doing something illegal or posting something that seems to be obvious BS I'm going to call you on it. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|