Search results

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

  1. S

    Script for creating random numbers, and more

    Script for creating random numbers, hex strings, octal strings, random passwords... This is one of those scripts I should have written a long time ago. 32-character hex string: randoms -f 32 32-character hex string with upper-case letters: randoms -F 32 50 random decimal numbers, 8 digits...
  2. S

    Adventures in random: Nanoseconds

    I was experimenting with the nanosecond counter (/proc/timer_list) from which nanoseconds can be derived by this:awk 'NR==3 {print $3}' /proc/timer_list | egrep -o '.{9}$' After millions of tests, in loops with various delays, the 3rd digit in that string (millisecond; one thousandths of a...
  3. S

    Set time on a router without internet access

    I'm playing around with a router that does not have access to "The Internet", so it can't set itself to the correct time and date. Here's a one-liner to set the time and date on that router, from a Linux box that keeps reasonably accurate time. ssh admin@192.168.3.1 "date ; date -s@$( date +%s...
  4. S

    Display boot time

  5. S

    Pretty prompt and "login" conveniences

    Here's a pretty prompt with some nice "login" conveniences. Here's the profile, in "/jffs/etc/profile": ## there's no .login support in this busybox shell ## so use this as a test to see if this is a fresh login ## otherwise, just skip this conditional list when this file is sourced [...
  6. S

    Cryptographic hash script

    I got tired of typing "openssl sha1" every time I needed to hash a file, so I wrote a script to hash files and stdin using the following hashes: sha1, sha224, sha256, sha384, sha512, sha, ripemd160, md5, md4, whirlpool Here's the script: #!/bin/sh case $( basename ${0} ) in sha1|sha1sum)...
  7. S

    Display boot time

    Just thought I'd share this one-liner to display device boot-time. date -d@$(( $( date +%s ) - $( cut -d. -f1 < /proc/uptime ) )) Of course the output format can be customised with all of the usual format strings for "date". Tested and working spectacularly on an AC68U. The displayed boot time...
  8. S

    VPN on/off via cron script

    This limit can be overcome by using "expr", instead of the shell's arithmetic functions. This is as high as we can go using the shell's built-in arithmetic functions:echo $(( $(printf "%d" 0x7fffffff) ))Only just past two billion. But this works fine:expr $(printf "%d" 0x7fffffffffffffff)So we...
  9. S

    VPN on/off via cron script

    And here's a re-write of my "openssl rand" script from comment #21, to correctly make use of upper and lower bounds: #!/bin/sh ## IMPORTANT ## ## use more than 1 byte of random data from "openssl rand" ## for higher ranges and/or less skew from the modulus operation BOUND_LOWER=1...
  10. S

    VPN on/off via cron script

    There are reasons to be suspicious of hashes as a source of "randomness", but the randomness of the hexadecimal representation of a hash is just as random as it would be in binary form. In hexadecimal, there's 4 bits of entropy per character, and the limiting factor is the quality of the input...
  11. S

    VPN on/off via cron script

    Does that need to run in a loop? Or just spit out one random number per invocation? If the output is in the range of 1-6, do you need 3 bytes? or is 1 byte sufficient? 1 byte gives output in the decimal range of 0-255. Skew isn't a problem, see below. As for the seed, "openssl rand" will...
  12. S

    Make random string

    Now, the script looks like this, for generating 10 character passwords for the guest-networks: #!/bin/sh PATH=/usr/sbin:/usr/bin:/bin pass_new=$( openssl rand -rand /dev/urandom:/proc/timer_list -base64 9 2> /dev/random | head -c 10 ) ## un-comment to display new password # echo "${pass_new}"...
  13. S

    Make random string

    Actually... Now I'm thinking this may be the best "engine" for generating random passwords on these machines: openssl rand -base64 9 Adjust the final number on that in multiples of 3 (3, 6, 9, 12, 15, 18, 21...) to avoid trailing equal-signs. And to seed openssl from "/dev/urandom" and...
  14. S

    Make random string

    And a script to reset guest-network passwords with an 8 character string... #!/bin/sh PATH=/usr/sbin:/usr/bin pass_new=$( openssl sha384 -binary < /proc/timer_list | openssl base64 | head -c 8 ) ## if using this at boot-up, comment-out the line above, and un-comment the line below #...
  15. S

    Make random string

    Just thought I'd share this little one-liner script, in case anyone needs to generate random passwords or something.openssl sha384 -binary < /proc/timer_list | openssl base64 I've got that in a script "/jffs/scripts/make-random-string": #!/bin/sh openssl sha384 -binary < /proc/timer_list |...
  16. S

    Breaking connections - with intent

    Not applicable here. His time is "controlled" by his desktop. When the desktop says he's not logged in, I want his phone and laptop cut off. This allows him some freedom to determine when he can access the net, while still limiting how much time he can spend online. It also encourages him to...
  17. S

    Breaking connections - with intent

    I'm working on a script to limit my kid's computer time. For now, this is the part of the script that kicks him off when his time is up: # disable his computers access to internet nvram set MULTIFILTER_ENABLE='2>2>0' # commit the change nvram commit # restart the firewall to...
  18. S

    Running out of nvram

    That helped, thanks.
  19. S

    Running out of nvram

    nvram show > /dev/null size: 65545 bytes (-9 left) How can I work around this? Or clear out "garbage"?
  20. S

    Running out of nvram

    N66U: bl_version 1.0.1.9 Not sure what the proper way to check is, but it looks like I've got 64K of nvram - nvram show 2> /dev/null | wc -c 65514 And that's not enough. It's full, and new changes are causing data to be lost. Is there a way to increase nvram? 256K would be nice. I've also...
Top