Saturday, 19 October 2013

Bash script wrapper for Easy Firewall Generator IPTables

I wanted a gateway firewall, to share internet access from one interface to another.  Iptables is excellent for this, but setting it up manually is a pain.

Easy Firewall Generator provides a excellent gateway iptables script but in my environment the interface names could change and manually editing the script is no good.

This script basically a 'wrapper script' for the Easy Firewall Generator script, with a few mods.

The usage is: 
./ics.sh -i [Internet Interface] -e [Sharing Interface] -a [Sharing IP Address]
 
For example, if eth0 had internet access and I wanted to share the internet connection to hostapd wlan0 (10.0.0.1) then the command to enable sharing would be:

./ics.sh -i eth0 -e wlan0 -a 10.0.0.1


You will need to generate a iptables 'firewall script' using the Easy Firewall Generator site.
  • On the website just select arbitrary values for the interfaces and ip addresses.
  • On the website, in section "Select Type of Internet Address ", select "Dynamic Internet IP Address"
  • Click generate, save the code, comment out the "Internet Interface" and the "Local Interface Information" sections in the saved 'firewall script'.
  • In the 'firewall script' remove the first line "#!/bin/sh"
  • Then add the raw 'wrapper script' below to the top of your firewall script.
  • Save and chmod +x the file before trying it out.


Those instruction suck.
Find the script here or below:




WindyCityTech Blogger
WindyWindyCityTech Wordpress

UPDATE: Modern Bash Wifi Connection Script for Linux; goodbye network manager

An update to a previous post.  This script has some more command line features, including a random_config_mode.

The random config mode can be used to check several AP's in the area for internet access.  In internet cannot be found, the script will randomly try another connection until internet can be found again.  The timer to check for internet access is randomly set between 60 to 90 seconds for an extra touch.
A preferred AP can be initially chosen in the random mode, so if it does fail, another connection will become selected.  In no way is this script perfect, results may vary depending what distro you are using.

Completely run from the command line.  Great for Raspberry Pi.

View it here: http://pastebin.com/vcVC9iL9

or below.



WindyCityTech Blogger
WindyWindyCityTech Wordpress

GNURADIO needs a urgent overhall

From the GNURADIO website: "GNU Radio has a steep learning curve", Fuck off, what it really means is:

GNU Radio is porly written / implemented / not user fiendly / has too many obscure install options and is designed to simply waste your time.

Furthermore the build-gnuradio script is fucking stupid.  It will ruin your system, beware.  Best to stick to the deb packages if you are on Debian.



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Thursday, 10 October 2013

Get back the Black Bar Toolbar on Google


Why do Google remove efficient mouse based UI's for favor touch screen based UI's on PC platforms?  After the trouble everyone was having with the Google Compose in Gmail, this is another nail in the coffin.

The issue access to apps like "Drive",  "Calendar", "News", etc is NOW restricted by the need to navigate a grid all the way on the right side of the screen.  This focus stealing design is no way efficient and only tailors a user experience for touchscreen users.
What used to be "Look, Point, Click" is now, "Scroll Right, Click, Look, Read, Click".
Great F*ckin Work

There is a solution for the new time robbing issue:
Install Stylish from Userstyles.org or from FF Addons page.
Install Google black nav bar returns from the Userstyles.org page.

On a serious note, these stop gap solutions just to gain user efficiency is wearing thin.  And it is of a similar road to being frustrated with all the baggage tolerated using Microsoft Windows products, which lead to finding alternatives.


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 5 October 2013

Installing dhcpd dhcp server on Raspberry Pi isc-dhcp-server

Quick notes for installing isc-dhcp-server on the pi.  Should work the same for other Debian based distros.

Install isc-dhcp-server.
sudo apt-get autoremove dnsmasq
sudo apt-get install isc-dhcp-server


Give your interface  a fixed ip.
sudo nano /etc/network/interfaces
#
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1


Setting isc-dhcp-server to use eth0
sudo nano /etc/default/isc-dhcp-server
#
INTERFACES="eth0"
DHCPD_CONF=/etc/dhcp/dhcpd.conf


Setting up the dhcpd.conf for eth0, comment out everything else
sudo nano /etc/dhcp/dhcpd.conf
#
ddns-update-style none;
log-facility local7;
#
subnet 192.168.1.1 netmask 255.255.255.0 {
#
range 192.168.1.10 192.168.1.20;
option routers 192.168.1.1; #this is the gateway ip for your clients
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option domain-name-servers 8.8.8.8, 208.67.222.222, 192.168.1.1; #ns.exapmle.org
default-lease-time 86400;
max-lease-time 86400;
}



To test check your syslog while running:
sudo service isc-dhcp-server start


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Creating a static WLAN interface number for a wifi wireless adaptor using udev rules

If you need your USB wifi adaptor to be a certain number on boot, i.e wlan5

Using udev rules this is possible.  reference: www.backtrack-linux.org/forums/showthread.php?t=2848


Run a ifconfig and get the mac address of the adaptor:
HWaddr de:ad:be:ef:ca:fe

Create a new udev rule

sudo touch /etc/udev/rules.d/70-persistent-net.rules
sudo nano /etc/udev/rules.d/70-persistent-net.rules


Insert the following lines into the file.

# Comment for the device, the following below should be on one line!
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="de:ad:be:ef:ca:fe", ATTR{type}=="1", NAME="wlan5"



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Hostapd creation bash script for Linux pi

This script can do several things:
  • Setup and start a hostapd based AP from the command line
  • Save and recall previous hostapd AP configs created by the script
  • Use default variables for the configuration if some are omitted
  • Copy the config file to /etc/hostapd/hostapd.conf so the hostapd service can use it on startup
The script has been tested on the Raspberry pi  and should work with other Debian based distros.

Apart from requiring hostapd and echo, a suitable dhcp server should be installed on the system for the interface.
Also it is mandatory that the WLAN adaptor can support AP mode, otherwise the script will not work.




WindyCityTech Blogger
WindyWindyCityTech Wordpress

Get the Gmail Compose back on Firefox source code xpi oldcompose

I hate the new compose apart from resorting to Thunderbird, there was no viable solution.  Several people suggested oldcompose.com, which offers a Chrome and Firefox extension to give back the classic gmail compose interface.

Apart from bringing back the compose window like the way is should be, the extension also displays email addresses in the TO field in full text.

The link to the Firefox xpi addon page is here.

Inside the xpi archive there are three files:
  • bootstrap.js
  • icon.png
  • install.rdf
The files appear not to have any malicious code or call home urls.







WindyCityTech Blogger
WindyWindyCityTech Wordpress

Wednesday, 11 September 2013

Blue Track Wireless Mouse 5000 Teardown

This is the 2.4Ghz model with Bluetrack technology.  On thing that I hate with the mouse is the lack of tactile feeling with the scroll wheel.  BTW the mouse takes two AA batteries but can work of just one as well.



















WindyCityTech Blogger
WindyWindyCityTech Wordpress

Friday, 30 August 2013

Hate the new Gmail Compose!!!!

Why destroy something, if it works.

This new stupid compose window is geared to idiot hipsters and definately not power users.  The stupid window is smaller and the UI is not intuitive, involving more clicks than ever before.

Google have been stubborn to change, despite  thousands of people complaining on the forums.  The only way to resolve this issue, is to dump gmail as your favorite email client.  If you can tolerate Thunderbird, then the Imap access may be reasonable, otherwise ZOHO MAIL is another solution.

Zoho has the advantage of being linkable with your existing gmail account and it is free.  When sigining up with Zoho, you may see options to pay for hosting, however there is a small option for a FREE user@zoho.com.
Then it is a simple matter of forwarding your existing gmail mail to Zoho.
The other main advantage of Zoho is the absence of ads, however this may not be anything new if your browser is running adblock.


UPDATE: use oldcompose extension. 


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Sunday, 18 August 2013

Spell Check Wordlist Cleaner Sanitiser Script dictionary .dic

Spell checkers have been polluted with too much crap. They don't seem to be maintained very well if at all.

Do a file search for your browsers dictionary file. For instance en-US.dic will contain 45593, awe-inspiring, BIOS's, hep, hosp, Jugiong, mer's, ODs, Sc, Supt., kw.... and the list goes on and on.

Whether this is a solution or not needs to be debated, but the results are obvious. Out of about 43000 words, 13000 were found to be unsatisfactory.

The perl script below, runs the dictionary file through a bunch of regexes, pulling out unwanted expressions. It is default setup to be very harsh, but users can comment out the 'elsif' to '}' lines for expressions they don't need.
The script outputs two files, one cleaned and one with the bad.

By the way, it has been tested on Linux, perl 4 version 14.  Good luck getting it to run on windows, the line terminators may get you.  A good test is to probably re-run the script on the cleaned file and see if it yields any more results.


Be sure to copy out your dictionary file to local directory before running the script. You may have to rerun the script if the dictionary updates itself.

USAGE spellclean.pl FILE.dic

Link to script:
http://pastebin.com/PAa9m0Ud

References:
http://www.chromium.org/developers/how-tos/editing-the-spell-checking-dictionaries
http://www.openoffice.org/lingucomponent/dictionary.html
http://marcoagpinto.cidadevirtual.pt/proofingtoolgui.html
http://txt2re.com/

#!/usr/bin/perl

#spellclean.pl
#cleans the spell checking word list.
#USAGE spellclean.pl FILE.dic


my $filename=shift;  #shift command line argument to variable filename
my $filenamemod = $filename.'.cleaned';  #cleaned filename and extension
my $filenamebad = $filename.'.bad';  #bad lines filename and extension
my $linecount = 0;  #whole file line counter
my $removeline = 0;  #delete line flag
my @badlines = ();  #delete line array
my $modlinecount = 0;   #line counter for the destination file.

# open file for phrasing
open SPELLFILE, $filename or die "error opening file $filename\n";


print "Here is the preview of the words removed, press [Enter] to continue: ";
<STDIN>;  #wait for input


while ($line=<SPELLFILE>) {
 $linecount++;  #increment linecount

 if ($line=~m/^\d.*/) { #remove any words beginning with numbers
  $removeline = 1;
 }
 elsif ($line=~m/(^[A-Z]{2}?)/) { #remove any CAPital words, like acronyms
  $removeline = 1;
 }
 elsif ($line=~m/.-/gm) { #remove any words with hyphens
  $removeline = 1;
 }
 elsif ($line=~ /.\./gm) { #remove any words with dots
  $removeline = 1;
 }
 elsif ($line=~ /^.{1,3}$/gm) { #remove any one and two letter words
  $removeline = 1;
 }
 elsif ($line=~ /^.{4,4}$/gm) { #remove any three letter words
  $removeline = 1;
 }
 elsif ($line=~ /^.{5,5}$/gm) { #remove any four letter words
  $removeline = 1;
 }
 elsif ($line=~ /^[A-Z].*$/gm) { #remove any Name style words
  $removeline = 1;
 }
 elsif ($line=~ /'.*$/gm) { #remove any words with apostrophy
  $removeline = 1;
 }
 
 # push lines number to the array, reset the removeline flag to 0 before looping back
 if ($removeline == 1) {
  push (@badlines, $linecount);
  print "Bad line $linecount -> $line";
  $removeline = 0;
 }

}
close (SPELLFILE); # close the file


print "Preview complete, press [Enter] to remove words from list or ^C to abort! ";
<STDIN>;   #wait for input


#open the original file and a destination file.
open SPELLFILE, $filename or die "error opening file $filename\n";
open SPELLFILEMOD, ">$filenamemod" or die "error creating file $filenamemod\n"; 
open SPELLFILEBAD, ">$filenamebad" or die "error creating file $filenamebad\n";

$linecount = 0;  #reset line counter to zero.
$removeline = 0; #reuse this variable.
 

#checks if the line number of the original file matches the first element of the array [0], if it does then it is a badline
#and it wont be printed to the destination file.  The removeline variable is incremented for the next array element.

while ($line=<SPELLFILE>) {
 $linecount++;
 if ($badlines[$removeline]==$linecount) {
  print "Removing line $linecount -> $line";
  print SPELLFILEBAD "$line";
  $removeline++;
 }
 else {
   print SPELLFILEMOD "$line";
   $modlinecount++;
  }
}
#close the files
close SPELLFILE;
close SPELLFILEMOD;
close SPELLFILEBAD;

# summary
print "\n\nCompleted!\n";
print "Total lines in the original file is: $linecount\n";
print "Total lines removed is: ".scalar(@badlines)."\n";
print "Cleaned file has: $modlinecount lines\n";
print "Cleaned file is saved as: $filenamemod\n";
print "Bad lines file is saved as: $filenamebad\n";




WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 17 August 2013

PHP path checking script

Finding PHP paths can be difficult on web servers.  Depending on how they are setup the paths may vary from host to host.  You may have or have not permissions to change the php.info file to edit configurations as you need.

Here is a script to quickly check how the server paths are setup.

<?php
//php path checker  checkPath.php

echo 'PHP_SELF is: '.$_SERVER['PHP_SELF'].'<br>';
echo 'DOCUMENT_ROOT is: '.$_SERVER['DOCUMENT_ROOT'].'<br>';
echo 'dirname(__FILE__) is: '. dirname(__FILE__).'<br>';
echo 'basename(__FILE__) is: '.basename(__FILE__).'<br>';
echo 'basename(dirname(__FILE__)) is: '.basename(dirname(__FILE__)).'<br>';
?>

expected output


PHP_SELF is: /scripts/checkPath.php
DOCUMENT_ROOT is: /usr/local/apache/htdocs
dirname(__FILE__) is: /home/userName/public_html/scripts
basename(__FILE__) is: checkPath.php
basename(dirname(__FILE__)) is: /scripts


Tips for portability of PHP scripts.  Sometimes the best way to specify php paths in includes for your scripts is to create a configuration.php file.
In this file, assign variables to the full path for your scripts there.

<?php
//configuration.php
$base = "/home/userName/public_html/scripts";
$header = "/header.php";
$footer = "/footer.php"
?>

Then use these lines in you scripts for includes in the following fashion:

<?php
//myScript.php
include "/home/userName/public_html/scripts/configuration.php";
include "$base.$header";
echo "some text";
include "$base.$footer";
?>

You still have to use a full path link for the configuration file once, but that is it.

WindyCityTech Blogger
WindyWindyCityTech Wordpress

3R Max DVR Info and Ethernet FTP Telnet login



The 3R MAXDVR4000 is a 1U rackmount DVR with four composite inputs.

There is not much info out there about them, there are two IDE hard drives inside formatted with resizerfs, a Axis Video Controller serial and Ethernet port.

If there hard drives are no longer working, they can be removed and replaced with another pair of working drives.  The sizes do not have to match either.  The drives are formatted and file and folder structures are copied on to the new hard drives upon power up.  You may notice a file called 'Hdd_Image.tgz' copied on one or both drives, containing the default info.

Conducting a Wireshark trace on the Ethernet port, yielded a default static IP of 192.168.0.60, with a Telnet and FTP server.

Default login credentials are:
root
pass


Default front panel password is 0000
 


Files can be easily pulled from the unit using FTP and the unit work in a circular buffer mode.


Some console dumps:

Axis Developer Board LX release 2.0.0
Linux 2.4.5 on a cris (ttyp0)

[root@3R-miniMax /]112# mount
/dev/root on / type cramfs (ro)
proc on /proc type proc (rw)
/dev/flash2 on /mnt/flash type jffs (rw)
tmpfs on /var type tmpfs (rw)
/dev/hda1 on /mnt/hda1 type reiserfs (rw)

[root@3R-miniMax /]643# cat /proc/cpuinfo
cpu        : CRIS
cpu revision    : 11
cpu model    : ETRAX 100LX v2
cache size    : 8 kB
fpu        : no
mmu        : yes
mmu DMA bug    : no
ethernet    : 10/100 Mbps
token ring    : no
scsi        : yes
ata        : yes
usb        : yes
bogomips    : 166.40

[root@3R-miniMax /]643# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/flash2               1920      1344       576  70% /mnt/flash
tmpfs                     8432        48      8384   1% /var
/dev/hda1......


Some more info can be found from: http://www.chinasaixin.com/3R/3R/body02b-02_01.htm

WindyCityTech Blogger
WindyWindyCityTech Wordpress

Simple methods to get a System Shell in Windows

There are several ways to get a system shell in Windows without knowing the admin password.

One way is to see whats tasks on the taskbar are launched by System, explore them and look for a open file dialog box which can then be used to launch cmd.exe.  Another way is to see if the cmd.exe can be launched as a service with system privileges.

If you can bring up a local command prompt, with basic user privileges you can try to run the following:


sc create testsvc binpath= "cmd /K start" type= own type= interact
sc start testsvc



You can rename testsvc to whatever you want, like WindowsUpdateDaemon and the best part is that the service can be stopped and restared at any time.

And of course to remove the service:

sc delete testsvc


So what can you do with this?
If you were locked out from removing programs, editing services, checking system properties, things that involve the mmc console...
You could probably invoke these now using the command line.  Most of these programs exist in system32 folder.  Some may not be there or disabled, but there is no harm in trying.
Services Management     services.msc
Shared Folders     fsmgmt.msc
Remote Desktops     tsmmc.msc
Group Policy Management     gpmc.msc
Computer Management     compmgmt.msc

Bigger list here:  http://social.technet.microsoft.com/wiki/contents/articles/417.windows-mmc-snap-ins-msc.aspx


Ref: http://blogs.msdn.com/b/adioltean/archive/2004/11/27/271063.aspx

WindyCityTech Blogger
WindyWindyCityTech Wordpress

Monday, 24 June 2013

Running Dymo Label without a Dymo Printer Attached LabelWriter

Why?  Who cares why.

What is it:
Running DymoLabel 7.x without a printer connected / installed throws up a error message like:
"This program requires a Dymo Printer. "

How to Fix it:Go to the Dymo LabelWriter 320 support webpage and look for troubleshooting -> error messages.  There is a file called ASINSTALL.EXE.  Run it on your system


The go about installing a fake printer following the screens below:


  Goodbye Error Message!



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 15 June 2013

Friday, 14 June 2013

UPDATE: Modern Bash Wifi Connection Script for Linux; goodbye network manager

An update to a previous post.  This script has some more command line features, such as calling up previous saved sessions credentials from the command line and improved error handling.  Completely run from the command line.

View it here: http://pastebin.com/J229Gc1t

or below.


#!/bin/bash

# http://pastebin.com/J229Gc1t
# 12/06/2013
# This script attempts to semi-automate the wifi connection process from
# the command line.
# It is intended to be used on a headless machine without the
# requirement of typing several commands for a connection.
# The script stores previous connection credentials in PLAINTEXT as
# *.wpa files in the executed directory and in /etc/wpasupplicant.conf.
# These .wpa files are used to connect to several different ap using
# previously stored info.
# Probably a good idea to stop and other network managing software while
# running this script, also in testing wpa_supplicant does a pretty good
# job of re-connecting a disassociated link automatically.
#
# Mainly created from a combination of scripts taken from theses two
# sources:
# http://www.backtrack-linux.org/forums/archive/index.php/t-3367.html
# AND
# http://www.linuxquestions.org/questions/linux-general-1/wifi-connect\
# -script-tested-in-ubuntu-772646/
#
# old version1 http://pastebin.com/Pa90HBiU 01/06/2013
# very simple first version
# old version2 http://pastebin.com/FzJnv5Nk 02/06/2013
# minor additions
# old version3 http://pastebin.com/3mu1XT5Y 08/06/2013
# included ability to call up previous saved files from
# command line. Some checking of command line parameters and
# checking for empty saved files
# current version
# Added exit retrurn values
#
# Copy, Distribute and Modify Freely.
#


if [ -z "$1" ]; then
printf "Usage: $0 -i [interface] OR AND -f [SAVED_FILE.wpa]\n"
exit 1
fi

while getopts "i:f:" opt
do
case $opt in
i ) INT=${OPTARG};;
f ) ITEM=${OPTARG};;
\?) printf "Usage: $0 -i [interface] OR AND -f [SAVED_FILE.wpa]\n"
exit 1;;
* ) printf "Usage: $0 -i [interface] OR AND -f [SAVED_FILE.wpa]\n"
exit 1;;
esac
done

#
# check if root
#
if [ "$(id -u)" != "0" ]; then
printf "This script must be run as root\n" 1>&2
exit 1
fi

#
# check if interface is entered as command line argument
#
if [ -z "$INT" ]; then
printf "Usage: $0 -i [interface] OR AND -f [SAVED_FILE.wpa]\n"
exit 1
fi


#
# Search for previous saved config files
#
function read_saved (){
#
# Search or uses for previous wpa configuration files
# Checks if command line argument -f [SAVED_FILE.wpa] is greater than zero length and exists
# before writing the configiuration to wpa_supplicant.conf. Otherwise create a new
# configuration.
#
if [ -n "$ITEM" ]; then
if [ -s "$ITEM" ]; then
printf "File $ITEM exists, proceeding to connect\n"
write_conf $ITEM
else printf "File $ITEM is invalid or does not exist, proceeding to create a new configuration\n"
conf_create
fi
fi
#
# Save and change IFS so spaces in file names are not interpreted as
# separate lines in the array
#
OLDIFS=$IFS
IFS=$'\n'

#
# Read all file names into an array
# ref:http://www.cyberciti.biz/tips/handling-filenames-with-spaces\
# -in-bash.html
#
# " -printf '%f\n' " removes path info from outputs
#
# ref:http://serverfault.com/questions/354403/remove-path-from-find\
# -command-output
#
SAVED_LIST=($(find . -type f -name "*.wpa" -printf '%f\n'))

#
# restore ifs
#
IFS=$OLDIFS


#
# Tests for number of saved wifi connections, if none exit
#
if [ -z "${SAVED_LIST[0]}" ]; then
printf "There are no previous saved wifi connections\n"
#
# Create new connection
#
conf_create
fi

#
#PS3 Sets the prompt for the select statement below
#
PS3="Choose a previously saved wifi connection or 's' to skip: "

#
#Select one of the previous saved configurations to connect with or quit
#
select ITEM in "${SAVED_LIST[@]}"; do
#
# Quit if selected number does not exist or alpha in entered
#
if [ -z "$ITEM" ] ; then
printf "Skipping\n\n"
conf_create
fi
#
# Quick check if file is greater than zero length and exists
#
if [ -s "$ITEM" ]; then
printf "File $ITEM exists, proceeding to connect\n"
write_conf "$ITEM"
else printf "File $ITEM is invalid or does not exist, proceeding to create a new configuration\n"
conf_create
fi
done
}


function conf_create (){
#
# Scans for wifi connections & isolates wifi AP name
#
eval LIST=( $(iwlist $INT scan 2>/dev/null | awk -F":" '/ESSID/{print $2}') )

#
#PS3 Sets the prompt for the select statement below
#
PS3="Choose wifi connection or 'q' to quit: "

#
# Tests for number of wifi connections, exits if none
#
if [ -z "${LIST[0]}" ]; then
printf "No available wifi connection using $INT\n"
exit 1
fi

#
# Select from a LIST of scanned connections
#
select ITEM in "${LIST[@]}"; do

#
# Quit if selected number does not exist or alpha in entered
#
if [ -z "$ITEM" ] ; then
printf "Exiting\n"
exit 0
fi

#
# Get user input for passphrase no need to escape spaces
#
printf "Enter the passphrase for $ITEM?\n"
read "PASSPHRASE"

#
# Append the ITEM variable (ESSID) to .wpa to make a filename
# for saved configs
#
FILENAME=$ITEM".wpa"

#
# Run wpa_passphrase to generate a file for wpa_supplicant to
# use, store it locally and in etc/wpa_supplicant.conf
#
printf "Running wpa_passphrase\n"
wpa_passphrase "$ITEM" "$PASSPHRASE" > "$FILENAME" | xargs
#
# Jump to write_conf function, append configuration filename
# to ITEM varibale
#
ITEM="$FILENAME"
write_conf
done
}

function write_conf (){
#
# Copy local wpa_supplicant file to etc/wpa_supplicant.conf
#
printf "Writing new configuration file using $ITEM\n"
cat "$ITEM">/etc/wpa_supplicant.conf | xargs
#
# Jump to connect function, pass on the ESSID variable for connection
#
connect "$ITEM"
}

function connect (){
printf "Connecting using file $*\n"

#
# Capture incoming argument
#
ESSID=$*

#
# Kill previous instances of wpa_supplicant to stop other instances
# wpa_supplicant fighting several different AP's
# Kill based on
# ref: http://thegeekstuff.com/2011/10/grep-or-and-not-operators
# and
# http://stackoverflow.com/questions/3510673/find-and-kill-a-\
# process-in-one-line-using-bash-and-regex
#
# Release dhcp ip's and bring down the interface
#
kill $(ps aux | grep -E '[w]pa_supplicant.*\'$INT'' | awk '{print $2}') 2>/dev/null | xargs
dhclient $INT -r
ifconfig $INT down

#
# Assign new credentials to interface
#
iwconfig $INT mode managed essid "$ESSID"
printf "Configured interface $INT; Credential file is $ESSID\n"
ifconfig $INT up
printf "Interface $INT is up\n"
wpa_supplicant -B -Dwext -i$INT -c/etc/wpa_supplicant.conf 2>/dev/null | xargs
printf "wpa_supplicant running, sleeping for 15...\n"

#
# Wait to connect before asking for a ip address
#
sleep 15
printf "Running dhclient\n"
dhclient $INT

#
# Show current ip for interface
#
ifconfig $INT | grep inet
exit 0
}

function clean_slate (){
#
# Optional Clean Slate commands, it is recommended that you perform
# a "airmon-ng check kill" to ensure that any other network managers
# do not interfere with the connection process
#

printf "It is recommended that you perform a \"airmon-ng check kill\" once to ensure that any other network managers do not interfere with the connection process\n\n"

#
# Untested, airmon-ng check kill works better here
#
# service network-manager stop 2>/dev/null >/dev/null
# service avahi-daemon stop 2>/dev/null >/dev/null
# sleep 10
# killall wpa_supplicant 2>/dev/null
# ifconfig $INT up
}

#
# Start here
#
clean_slate
read_saved

exit 0




WindyCityTech Blogger
WindyWindyCityTech Wordpress

Wednesday, 12 June 2013

Firefox Progress of Ongoing Downloads Revert to old style

Once again, like the pdf thing that Mozilla did a while back.  The new download window:
  • Takes up a whole tab
  • Cannot be resized
  • Blocks any bookmarks on your bookmarks toolbar

Unfortunately the only fix to the old style, aka, before FF21 is to do two things:

  • Revert from private browsing (Preferences > Privacy > History > Custom Settings)
  •  Open about:config and toogle browser.download.useToolkitUI to TRUE
Un-tick private browsing :(





The analogy is that private browsing does not remember any downloading history, so the browser.download.useToolkitUI change will not show any downloads in the old style list.



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Tuesday, 4 June 2013

Ghostery, it's better than nothing or is it

Ghostery is probably better than nothing but several facts exist.
  1. Ghostery filters are updated by Ghostery company Evidon, Inc themselves.  This feel a little closed source for me, it means that they could white list some trackers if they felt like. 
  2. Ghostery is closed source, they claim that you can look thought their xpi package to see what is inside it, but that is like M$ asking their someone to look into their exe file to see what is inside.
  3. You may not disassemble or reverse engineer Ghostery for any purpose other than reviewing the code for personal edification, so much for trying to be open source soon...
  4. Participating in the GhostRank program (default)  This is a no-brainer.
  5. Merger, Sale, or Reorganization of Evidon
    If Evidon should ever file for bankruptcy, or have its assets sold to or merged with another entity, information Evidon receives from you, from the Website, is an Evidon asset and may be transferred.
  6. And this: http://venturebeat.com/2012/07/31/ghostery-a-web-tracking-blocker-that-actually-helps-the-ad-industry/

    "After all, the thinking goes, many ad networks sell their advertisements via real-time bidding, so they often lack a clear idea of where their tags are appearing. In short, online ad networks are just as hungry for information about web users as they are for data about themselves. Ghostery gives them that information."
    "This gives Evidon a clear target market and even clearer plan of attack: Use Ghostery users to build the tracker database, then turn around and license the data to ad networks who can use the data to bolster their own efforts."


So in essence, the use of Ghostery is helping ads networks find better and more covert ways to track you online presence and these guys are using you to make a nice little database....
I'm not bothering to go any further and look at the chatter on the wire, do not install it.  Stick with adblock-lite +Fanboy Adblock List + Tracking List + Annoyance Block List.

If you still don't get it, too bad your a sad panda.


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Quick install of Linux firmware htc_9271.fw for TP-LINK TLWN422G USB Wireless



Download firmware from here or search for newer.
http://wireless.kernel.org/download/htc_fw/1.3/htc_9271.fw

sudo cp htc_9271.fw /lib/firmware/.

Plug in device and do a dmesg to see if firmware is loaded.


Works great on airodump-ng, injection is super.\


lsusb

Bus 001 Device 004: ID 0cf3:1006 Atheros Communications, Inc. TP-Link TL-WN322G v3 / TL-WN422G v2 802.11g [Atheros AR9271]


Don't waste time trying to compile anything else.


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Sunday, 2 June 2013

Modern Bash Wifi Connection Script for Linux; goodbye network manager

19/10/2013 Update here

This script attempts to semi-automate the wifi connection process from
the command line.  It is intended to be used on a headless / GUI-less machine without the
requirement of typing several commands for a connection.  For instance a Raspberry PI.

It works reasonably well for most applications and can handle ESSID's / passwords with spaces.

Storage of previous connection credentials is in PLAINTEXT as [ESSID].wpa files in the executed directory and in /etc/wpasupplicant.conf.
These .wpa files are used to connect to several different AP's using previously stored info.
Probably a real good idea to stop and other network managing software while running this script, for instance running "airmon-ng check kill" will do a good job.
Also in testing wpa_supplicant does a pretty good job of re-connecting a disassociated link automatically.

Operation is simple.  In the case with Debian it is:
sudo ./connect.sh wlan0

Mainly created from a combination of scripts taken from theses two
sources:
http://www.backtrack-linux.org/forums/archive/index.php/t-3367.html
AND
http://www.linuxquestions.org/questions/linux-general-1/wifi-connect-script-tested-in-ubuntu-772646/

Feel free to comment or send improvements.

Download from http://pastebin.com/FzJnv5Nk
or below.

#!/bin/bash

# http://pastebin.com/Pa90HBiU
# 01/06/2013
# This script attempts to semi-automate the wifi connection process from
# the command line.
# It is intended to be used on a headless machine without the
# requirement of typing several commands for a connection.
# The script stores previous connection credentials in PLAINTEXT as
# *.wpa files in the executed directory and in /etc/wpasupplicant.conf.
# These .wpa files are used to connect to several different ap using
# previously stored info.
# Probably a good idea to stop and other network managing software while
# running this script, also in testing wpa_supplicant does a pretty good
# job of re-connecting a disassociated link automatically.
#
# Mainly created from a combination of scripts taken from theses two
# sources:
# http://www.backtrack-linux.org/forums/archive/index.php/t-3367.html
# AND
# http://www.linuxquestions.org/questions/linux-general-1/wifi-connect\
# -script-tested-in-ubuntu-772646/
#
# old version http://pastebin.com/Pa90HBiU 01/06/2013
#
# Copy, Distribute and Modify Freely.
#


INT=$1

if [ -z "$1" ]; then
printf "Usage: $0 [interface]\n"
exit
fi

if [ "$(id -u)" != "0" ]; then
printf "This script must be run as root\n" 1>&2
exit
fi

#
# Search for previous saved config files
#
function read_saved {
#
# Search for previous wpa configuration files.
#

#
# Save and change IFS so spaces in file names are not interpreted as
# separate lines in the array
#
OLDIFS=$IFS
IFS=$'\n'

#
# Read all file names into an array
# ref:http://www.cyberciti.biz/tips/handling-filenames-with-spaces\
# -in-bash.html
#
# " -printf '%f\n' " removes path info from outputs
#
# ref:http://serverfault.com/questions/354403/remove-path-from-find\
# -command-output
#
SAVED_LIST=($(find . -type f -name "*.wpa" -printf '%f\n'))

#
# restore ifs
#
IFS=$OLDIFS


#
# Tests for number of saved wifi connections, if none exit
#
if [ -z "${SAVED_LIST[0]}" ]; then
printf "There are no previous saved wifi connections\n\n"
#
# Create new connection
#
conf_create
fi

#
#PS3 Sets the prompt for the select statement below
#
PS3="Choose a previously saved wifi connection or 's' to skip: "

#
#Select one of the previous saved configurations to connect with or quit
#
select ITEM in "${SAVED_LIST[@]}"; do
#
# Quit if selected number does not exist or alpha in entered
#
if [ -z "$ITEM" ] ; then
printf "Skipping\n"
conf_create
fi

printf "$ITEM is selected\n"
cat "$ITEM">/etc/wpa_supplicant.conf | xargs
connect "$ITEM"
done
}

function conf_create (){
#
# Scans for wifi connections & isolates wifi AP name
#
eval LIST=( $(iwlist $INT scan 2>/dev/null | awk -F":" '/ESSID/{print $2}') )

#
#PS3 Sets the prompt for the select statement below
#
PS3="Choose wifi connection or 'q' to quit: "

#
# Tests for number of wifi connections, exits if none
#
if [ -z "${LIST[0]}" ]; then
printf "No available wifi connection using $INT\n"
exit
fi

#
# Select from a LIST of scanned connections
#
select ITEM in "${LIST[@]}"; do
ifconfig $INT | grep inet

#
# Quit if selected number does not exist or alpha in entered
#
if [ -z "$ITEM" ] ; then
printf "Exiting\n"
exit
fi

#
# Get user input for passphrase no need to escape spaces
#
printf "Enter the passphrase for $ITEM?\n"
read "PASSPHRASE"

#
# Append the ITEM variable (ESSID) to .wpa to make a filename
# for saved configs
#
FILENAME=$ITEM".wpa"

#
# Run wpa_passphrase to generate a file for wpa_supplicant to
# use, store it locally and in etc/wpa_supplicant.conf
#
printf "Running wpa_passphrase\n"
wpa_passphrase "$ITEM" "$PASSPHRASE" > "$FILENAME" | xargs
cat "$FILENAME">/etc/wpa_supplicant.conf | xargs
printf "Creating new configuration using $ITEM\n"

#
# Jump to connect function, pass on the ESSID variable for connection
#
connect $ITEM
done
}

function connect (){
printf "Connecting using file $*\n"

#
# Capture incoming argument
#
ESSID=$*

#
# Kill previous instances of wpa_supplicant to stop other instances
# wpa_supplicant fighting several different AP's
# Kill based on
# ref: http://thegeekstuff.com/2011/10/grep-or-and-not-operators
# and
# http://stackoverflow.com/questions/3510673/find-and-kill-a-\
# process-in-one-line-using-bash-and-regex
#
# Release dhcp ip's and bring down the interface
#
kill $(ps aux | grep -E '[w]pa_supplicant.*\'$INT'' | awk '{print $2}') 2>/dev/null | xargs
dhclient $INT -r
ifconfig $INT down

#
# Assign new credentials to interface
#
iwconfig $INT mode managed essid "$ESSID"
printf "Configured interface $INT; ESSID is $ESSID\n"
ifconfig $INT up
printf "Interface $INT is up\n"
wpa_supplicant -B -Dwext -i$INT -c/etc/wpa_supplicant.conf 2>/dev/null | xargs
printf "wpa_supplicant running, sleeping for 15...\n"

#
# Wait to connect before asking for a ip address
#
sleep 15
printf "Running dhclient\n"
dhclient $INT

#
# Show current ip for interface
#
ifconfig $INT | grep inet
exit
}

function clean_slate (){
#
# Optional Clean Slate commands, it is recommended that you perform
# a "airmon-ng check kill" to ensure that any other network managers
# do not intefere with the connection process
#

printf "It is recommended that you perform a \"airmon-ng check kill\" once to ensure that any other network managers do not interfere with the connection process\n"

#
# Untested, airmon-ng check kill works better here
#
# service network-manager stop 2>/dev/null >/dev/null
# service avahi-daemon stop 2>/dev/null >/dev/null
# sleep 10
# killall wpa_supplicant 2>/dev/null
# ifconfig $INT up
}

#
# Start here
#
clean_slate
read_saved

exit





WindyCityTech Blogger
WindyWindyCityTech Wordpress

Wednesday, 22 May 2013

Using a Common mode Choke (differential) as a joule thief transformer (working)

Almost any switch mode power supply has one of these chokes for noise suppression.  The type pictured below is the type that has been tested working.



The prewound choke Coil has even windings on both sides and uses many turns of thick wire around a ferrite core.
Using the standard Joule Thief configuration, it has been tested with a BD139 transistor, 1.4K Ohm Feedback Resistor and a Blue LED.
Starts up easily at 0.6V DC. and is much brighter than the standard joule thief at 1.5 Volts.

WindyCityTech Blogger
WindyWindyCityTech Wordpress

Click Nightguard Brand CLKRT200 Motion Torch Not charging

A great product, inductive coupled charged torch with nighttime motion detector.  Purchased from Bunnings 6 months ago for $20, stopped charging.  The base has a burnt smell coming from it.

Opened the base and found that the 224 / 400V polyester capacitor had ruptured and a resistor was burned beyond recognition.  Fuse was O.K.

It was very hard to  find a product website for the Click Brand.  A search on IP Australia disclosed that the trademark owner is Bunnings...

Alot of other are having similar issues with the CLKRT200 and CLKRT100.  Fuses blowing....  Poor design....
Lucky this did not catch on fire.

There is no real fix for this crap except to disable the inductive part altogether and power the thing of a external 5V AC or DC plugpack modded with a plugin connector.


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Create a Instant Microphone Audio Record Script using arecord and amixer

Why:  Sometimes you need to record something NOW.  Not Click menus and press record realizing that the microphone volume is too low.

Uses amixer, arecord and xterm all which are native applications with most Linux distros.  The script can be shortcutted to a button on the panel and give instant feedback that it is working with VU meters.  The record file is date-timestamped for easy reference.

The script is below and is commented for a bit more info on its working.


#!/bin/bash
amixer sset -c 0 'Mic' playback off
amixer sset -c 0 'Mic' 90%
amixer sset -c 0 'Mic Boost' 90%
amixer sset 'Capture' cap
amixer sset -c 0 'Capture' 90%
xterm -e arecord ~/record_$(date +%Y%m%d%H%M%S).wav -v -V'stereo' -f cd &




When you are done, just kill the script using Control+C and look in your home directory to find the datestamped wav file.  I found the arecord operating sends the microphone boost to 100% upon execution, but so does audacity.  This is not an issue for me but you may choose to use a lower 'Capture' level to even things out.

To migrate this script to a button on the panel, chmod +x the script file, then add the following command as a Custom Application Launcher

sh /path/to/script.sh


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Monday, 13 May 2013

New ebay.com.au fees and how to fight it

As you may be aware, ebay has increased its fees to four-finger the small time sellers out of the playground.

10% per item selling price and generally a extra 2.4% of the total price for paypal.  Further to this, the buy-it-now price must be over 30% of the initial bidding price, used to be allot lower.

Many have said they are moving to Gumtree, but Gumtree is owned by ebay and they are starting to exploit it's clients by charging just to edit a listing, what next...  I don't see the point of charging to edit a listing, it has no logic except to ween the user-base onto a fee structure.

Quicksales have announced, zero insertion and final value fees, but nothing sells there yet.  As with any corporations, as soon as it becomes popular, it's time to cash in on the party, so fees could be back around the corner.


To get back at ebay, you can protest by not selling anything there at all.  Here is a better way: 
The goal is to utilize you built up seller reputation and to make ebay appear to be a very expensive place to shop and if you are selling niche items, you definitely have an advantage of making some extra money.
  • Continue to list items on ebay, but jack the price up more than 20% and don't forget the postage, increase it as well :)
  • Utilize their buy-it-now (free) listing functions and make sure that the price is over 30% of your new total.
  • Utilize the scheduler (free) to schedule you new listings to list of the most convenient times without having to be in front of the computer, generally 10 days ahead of time.
Sit back and watch the occasional sucker emptying their wallet for you.  It is surprising how some people like to waste their money.  Generally due to time constraints, lack of concentration, stupidness or just luck on your side.




WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 4 May 2013

Electrolux E3 Error Fix for Free!

Electrolux Vacuums are now such a piece of crap.  Who the hell designs these things, their idiots.  Not like the old Electrolux days, the days that made the brand a popular and reliable choice.

The problem with this vacuum, it that it starts up for a few seconds, then the machine stops with a stupid E3 LED Flashing message.

The solution, bypass all the electronics and directly connect the power to the vacuum motor.  It is very simple and requires no alteration to the existing wiring.

Disassemble the vacuum.
At the back of the vacuum cleaner is a speed control board, find that.
Then look for two connectors, one with Blue/White wires (power) and one with both black wires (motor).
Separate both connectors and connect the male motor connector to the female power connector.  This bypasses the speed controller board altogether.
Put the whole thing back together.
No when you plug in the power, the vacuum comes on at full speed with no more crappy issues.  Electrolux products are a piece of crap.


To disassemble this thing, Alex from vacuumspot.com.au has a great video on dissembling the Electrolux vacuum below.  Buying a replacement board seems pointless as it is likely to happen again.



Brush Driver Board (Blown Fuse)
Speed Controller

Speed Controller, Stupid Air Cooling Cover Removed



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Friday, 5 April 2013

Disable Officeworks.com.au Autocomplete Search officeworks

Their autocomplete search is abysmal.  Bit of quick sniffing yields this adblock rule.

||clients1.google.com/complete/*

Who the hell beta checks their site, idiot monkeys. Bye bye autocomplete.

AUTOC....  AUTOCLAM , FFFFUUUUU!!!!!!


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Sunday, 31 March 2013

Disable NTP sending out requests on Raspberry PI Linux

As beautiful as NTP is, NTP chatter can pollute your network traffic.

Forget removing NTP services, that is too dramatic for the system.  A simple hack is to edit the /etc/ntp.conf file and remove the servers.

sudo nano /etc/ntp.conf

scroll down and hash out the lines like below:

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst


Control-X and yes to save

Restart NTP:
sudo /etc/init.d/ntp restart

Check syslog
cat /var/log/syslog



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 30 March 2013

Compiling mdk3 on Raspberry Pi Raspberian for a wifi hell

Compiling mdk3 on Raspberry Pi Raspberian.  Tested on the on the stock upgraded Raspbian distro kernel 3.6.11+.

After you get aircrack-ng suite installed and working, this is a no-brainer.

wget http://homepages.tu-darmstadt.de/~p_larbig/wlan/mdk3-v6.tar.bz2

extract
tar -xvjf mdk3-v6.tar.bz2

cd mdk3-v6


make

then move the mdk3 file somewhere where the shell can pick it up like
/usr/local/bin/



 WindyCityTech Blogger
WindyWindyCityTech Wordpress