Ethertubes
  • Home
  • About

Bash

Bash, System Administration, VBScript

Finding Malware URLs in W97M infected Word Docs

An email with a trojan Microsoft Word document made it past the spam filter today at work. At least one user reported opening the attachment. The attachment was named: DOCO943488.doc, but running the file through virustotal.com it was clear that it’s been known by other names.. To help affected people find this page here are…

Bash

Bash Snippet: Luhn Algorithm

I like Bash, but it isn’t well suited for some tasks. For fun I sometimes ignore that. Occasionally people seem to find this useful. In that spirit, here is my implementation of the popular Luhn / mod10 algorithm used in credit card, IMEI, and other number sequences. download [luhn.zip] [cc theme=”blackboard” width=”100%” height=”100%” lang=”bash”] #…

Bash

Bash Snippet: Decimal to Binary Conversion

Convert a decimal value into the binary representation and vice versa in Bash using only built-ins. If you know a better way, please let me know. To ensure a properly formatted expression for the arithmetic expansion in bin2dec, the dec2bin function prefixes zeros as needed to pad to a character count evenly divisible by 8….

Bash, System Administration

Detect Wi-Fi Clients on your DD-WRT Router

Here is a script I wrote that scrapes the web interface of a router running DD-WRT. The script looks for the MAC addresses of wireless users. When it sees a MAC address that it hasn’t logged before it issues an alert. To help identify the new equipment, a portion of the MAC address is sent…

Bash

Bash Snippet: Trim Function

Occasionally I find myself wanting to removing leading and/or trailing occurrences of a character or string from a larger string in bash. A couple common uses are removing quotes, or stripping an unknown number of spaces leading into the data of interest. This can be done pretty easily with other methods such as awk or…

Bash, System Administration

Zombie Process: Killing the Undead

Is your Ubuntu MOTD warning you of a zombie process? [cc theme=”blackboard” width=”100%”] Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-20-server x86_64) * Documentation: https://help.ubuntu.com/11.10/serverguide/C System information as of Thu Jun 28 18:36:57 EDT 2012 System load: 0.0 Processes: 94 Usage of /: 68.2% of 1.79TB Users logged in: 1 Memory usage: 29% IP address for eth0:…

Bash, Helpful Tools, System Administration

Access an APC AP5456 IP Gateway for Analog KVM in Linux

I recently wrote about running an ActiveX component without Internet Explorer. I used that technique to come up with a shell script front-end for downloading, unpacking and running an executable in Wine for accessing an APC IP KVM (model AP5456). Here is the results of that effort. At a minimum the script requires Wine and…

Bash

Bash Snippet: URL Encoding

One approach would be to encode everything, but the approach I took was to just encode things I thought might be problematic to pass over the query string. URL (a.k.a percent) encoding of a string in bash: [cc lang=”bash” theme=”blackboard” width=”100%”] urlencode () { tab=”`echo -en “\x9″`” i=”$@” i=${i//%/%25} ; i=${i//’ ‘/%20} ; i=${i//$tab/%09} i=${i//!/%21}…

Bash

Bash Snippet: Calculating the Distance Between 2 Coordinates

I have a tendency to do things in bash that I’d probably be better off doing in perl or python. Although bash may have super powers, math is not one of them, and so like my last post this script also requires bc. I’ll try and keep these code snippet posts short and sweet, and…

Bash

Bash Snippet: HTML &#code; decoder

A short and simple way to decode HTML decimal (and hex) character codes in bash. [cc lang=”bash” theme=”blackboard” width=”100%”] html_decode () { html_encoded=”$1″ html_encoded=${html_encoded//&#/ } html_encoded=(`echo $html_encoded`) for html_dec in ${html_encoded[@]} do html_dec=”${html_dec//X/x}” html_dec=”${html_dec//;/}” if [ “${html_dec:0:1}” == “x” ]; then html_hex=${html_hex:1:${#html_hex}} else html_hex=”`printf “%02X\n” $html_dec`” fi echo -en “\x$html_hex” done echo “” } html_decode…


Search