Showing posts with label Appliances. Show all posts
Showing posts with label Appliances. Show all posts

Sunday, October 14, 2012

Retrieve credential values stored in WiFi device

Introduction

When setup a WiFi network using network appliances, an account credential is always required to logon to network services provided by ISP (Internet Service Provider).  For example, using modem router to access ISP’s broadband internet service. 

The ISP account credentials is usually enter once during configuration at first time and it should persist in the device’s RAM is ready to work for next power on.  Compare ISP account credential with the other account credentials like your email account or desktop OS account that use every day, the user tend to forget or lost the ISP account credential easily.  This happens when we upgrade to new WiFI device or hard reset the device due to some technical issues.

This article introduces some software tools to attempt recover the account credential values store in WiFi device.

Retrieve configuration file from WiFi device

Most WiFI devices allow user to backup the configuration in a file.  Read the user guides of the WiFi device to find out if it has the configuration backup option.

For example, most D-Link WiFi device supports configuration backup via HTTP URL.  Enter URL like:

http://192.168.1.1/config.bin

in browser to download the configuration file.  Most configuration are compressed and encrypted.  Some tools is needed to decode the information stored in the configuration file.

Router Pass View

RouterPassView is a software tool to decode the configuration file retrieved from WiFI router.  Please note that not all WiFi device is supported, refer to the web site for a list of supported device.

It is easy to use RouterPassView.  Download and launch the software, open the configuration file in the software and the configuration information should show in text format:

image

Sunday, November 13, 2011

Make host based USB printer work with OpenWrt’s P910nd print server

A host-based printer like HP-LaserJet 1020 needs to download a firmware every time when boot up or else it won’t print.  These printers works fine when connect to Windows that has drivers install.  For Linux, foo2zjs may help upload the firmware to printer by USB hotplug daemon.

It is very hard to make host-based printers work with networked print server appliance as the printer won’t work without firmware.  Most print server appliance don’t have firmware ready or it won’t upload the firmware to printer.

Some print server like D-Link DPR 1061 claims to work with host based printer but it is a different story.  A software (PS-Link or PS-Wizard) is required to deploy on workstations in network to act as USB redirector to send firmware to printer.  This isn’t a favor solution as it increase deployment effort on workstation.

This topic use TP-Link 1043ND wireless router as hardware device to act as printer server alternative to those branded printer server in market.  The TP-Link 1043ND is patched with Gargoyle WRT (backed by OpenWrt).  A small printer daemon p910nd is installed in the device to serve as printer server for network.

Here are some brief steps to install and configure:

  1. Find a low cost router that has few RJ45 network sockets (usually 4 LAN port + 1 WAN port) and USB port
  2. Patch the device with OpenWrt or Gargoyle Wrt
  3. Install p910nd daemon
  4. Download Printer Firmware
  5. Configure USB hotplug daemon to send firmware to printer
  6. Add a printer device in Windows / Linux workstation that print to Standard TCP/IP port (e.g.: Port 9100)

Print Server Device: TP-Link 1043ND

In this article, A gigabit wireless router: TP-Link 1043ND is used as example.  The router has 4 LAN + 1 WAN ports and a USB port mainly for flash drive.  We will make the USB port work with USB host based printer.

Printer: HP Laser Jet 1020

HP laser jet 1020 is a USB host based printer that is not friendly to many network print server in the market.

Patch with Gargoyle WRT

Download suitable flash firmware for TP-Link 1043ND from Gargoyle.  Follow instruction to patch the device.  After finish patching, do some simple configuration:

  1. Set the root access password
  2. Set IP address for the device (e.g.: 192.168.1.1)
  3. Enable SSH access to the device (e.g.: port 22)
  4. Try using SSH console like Putty to access the device

Install software on device

  1. SSH into device. e.g.: ssh 192.168.1.1
  2. Enter “root” as username and supply with password
  3. Update OpenWRT software packages:
    root@Gargoyle:~# opkg update
  4. Install Kernel modules for USB Printer support:
    root@Gargoyle:~# opkg install kmod-usb-printer
  5. Install printer server:
    root@Gargoyle:~# opkg install p910nd

Configure Printer Server: P910nd

  1. Enable p910nd daemon that sustain for device fresh booting:

    root@Gargoyle:~# /etc/init.d/p910nd enable
  2. Start p910nd daemon for current session
    root@Gargoyle:~# /etc/init.d/p910nd start

Printer Firmware

  1. Download a suitable printer firmware (e.g.: http://oleg.wl500g.info/hplj/)
    root@Gargoyle:~# wget -o /usr/lib/sihp1020.dl http://oleg.wl500g.info/hpl
    j/sihp1020.dl
    root@Gargoyle
    :~# ls -al1 /usr/lib/si* -rw-r--r-- 1 126151 Nov 12 16:31 /usr/lib/sihp1020.dl
  2. Create a USB hotplug script file (/etc/hotplug.d/20-hpjl1020) for printer HP1020:
    root@Gargoyle:~# cat /etc/hotplug.d/usb/20-hplj1020
    #!/bin/sh
    
    FIRMWARE="/usr/lib/sihp1020.dl"
    DEVICE=/dev/lp0
    LOGFILE=/var/log/hp
    
    if [ "$PRODUCT" = "3f0/2b17/100" -a "$ACTION" = "add" ]
    then
            for i in $(seq 30); do
                    if [ -c $DEVICE ]; then
                            echo "$(date) : Sending firmware to printer." > $LOGFILE
                            cat $FIRMWARE > $DEVICE
                            echo "$(date) : done." >> $LOGFILE
                            exit
                    fi
                    sleep 1
            done
    fi
  3. You may adjust parameters in the script file to suit you environment.
  4. Product ID: “3f0/2b17/100” is the printer ID for my HP Laser Jet 1020.  Change it to suitable ID for the printer you attempt to connect.  You may attempt to grep the printer ID by patching the script file to output printer id to a log file.

Test Printer Firmware

  1. Plug printer USB cable to device and check log file:
    root@Gargoyle:~# cat /var/log/hp
  2. The log file consist some information that is useful for troubleshooting
  3. Power off both printer and device
  4. Power on both printer and device
  5. Check log file again to make sure firmware may send to printer properly

Print from Windows

  1. Logon to Windows workstation and add a local printer:
    1
  2. Create a new Standard TCP/IP port for the printer:
    2
  3. Enter IP Address for the printer: e.g.: 192.168.1.1
    3
  4. Specify additional information for the connection:
    4
  5. Choose “Raw” protocol and set port number. e.g.: 9100
    5
  6. Pick a suitable printer driver:
    6
  7. You may try to print a test page to the printer.

Reference

  1. p910nd Printer Server. URL: http://wiki.openwrt.org/doc/howto/p910nd.server

Thursday, July 07, 2011

Using TurnKey Linux Appliances

Introduction

TurnKey Linux (TKL) appliances provides an easy turn key solution to deploy essential and common network services for your organization or team on LAN or WAN.  It is deployed as an appliance.  All configurations is done via web browser.  It save your time to study and install related software packages by packing everything in a single 130~200MB ISO file.  You may install these software appliance in bare machine, virtual machine or even Amazon EC2 could server.

At the time this article is written, there are 45+ ready TurnKey appliances ranging from content management, web development, issue tracking and messaging.  These appliances are based on Ubuntu Linux – one of the most friendly and easy to use Linux distributor in the market.

Once install, the console will show you how to access the server.  The configuration may perform in Webmin GUI via HTTP web browser.  This save your time and efforts compare to command line configuration practice in used by Linux community.  User with little or no knowledge of Linux may perform the job well too.

However, TurnKey Linux appliance is not perfect.  This article is not about using TurnKey Linux appliance but attempt to illustrate some features that you may want in TKL appliance.  Some of these features need to configure in command line console.

Upgrade Webmin1

Webmin is widely used in TurnKey appliance as front end configuration control panel.  Both Webmin and TurnKey Linux are independent to each others.  You may attempt to upgrade Webmin to latest version to get more updated features.

To upgrade Webmin, simply use “Upgrade Webmin” icon in Webmin configuration page.

To ease the installation and save your time and bandwidth if you have many TKL appliances deployed, try download the latest Webmin .tar.gz file and use the upload option to upgrade Webmin.

Add or Upgrade Webmin modules

Use “Webmin Modules” icon in Webmin configuration page to manage Webmin modules.  You may install or upgrade new Webmin module that you need but missing in TKL appliance.

Add or Upgrade Software Packages

New features or updates may available in updated software packages.   Using System | Software Packages to upgrade to latest updates.

Webmin: Time

Webmin Time module is missing in TKL appliance.  Install a time module and you are ready to configure time zone and date time of TKL appliance instance.

LDAP Authentication

If LDAP directory services is available to serve the account information, you may configure TKL to support account authentication via LDAP.

First, install these packages:

  1. libpam-ldap
  2. libnss-ldap
  3. nss-updatedb
  4. libnss-db

You may use apt-get in console:

# apt-get install libpam-ldap libnss-ldap nss-updatedb libnss-db

or using the Webmin’s Software Packages to install those packages.

Configure LDAP client via:

# dpkg-reconfigure ldap-auth-config

Follow the screen instruction to fill in relevant LDAP parameters.2

LDAP client configuration is available in Webmin too.  Install “ldap-client” to get this feature in Webmin.

Edit /etc/nsswitch.conf to add ldap support:

# vi /etc/nsswitch.conf
passwd:         compat ldap
group:          compat ldap

This may also configured by “Services using LDAP” of Webmin LDAP client:

To verify the LDAP configuration,  run “getent passwd” to check if the LDAP accounts appears in the list.

If LDAP accounts are alias accounts.  You may add “DEREF always” in /etc/ldap.conf to make dereference works.

Create home directory

A common usage of LDAP account authentication is provide a secure shell login option for users.  Home directories will not be created for LDAP accounts by default.  There is a feature in pam that may automatically create home directory for user when login.

Edit “/etc/auth-client-config//profile.d/acc-default” to add pam_mkhomedir.so as follow:

# cat /etc/auth-client-config//profile.d/acc-default
...
#
# this example is for using ldap to authenticate and authorize.  This is only
# an example, and you will most likely have to create your own profiles to
# authenticate with your system. Note that this example requires the
# libpam-cracklib package to be installed.
#
[ldap_example]
nss_passwd=passwd: files ldap
nss_group=group: files ldap
nss_shadow=shadow: files ldap
nss_netgroup=netgroup: nis
pam_auth=auth       required     pam_env.so
        auth       sufficient   pam_unix.so likeauth nullok
        auth       sufficient   pam_ldap.so use_first_pass
        auth       required     pam_deny.so
pam_account=account    sufficient   pam_unix.so
        account    sufficient   pam_ldap.so
        account    required     pam_deny.so
pam_password=password   required     pam_cracklib.so difok=2 minlen=8 dcredit=2 ocredit=2 retry=3
        password   sufficient   pam_unix.so nullok md5 shadow use_authtok
        password   sufficient   pam_ldap.so use_first_pass
        password   required     pam_deny.so
pam_session=session    required     pam_limits.so
        session    required     pam_unix.so
        session    required     pam_mkhomedir.so skel=/etc/skel/
        session    optional     pam_ldap.so

Next execute this to update pam configuration:

# auth-client-config -a -p ldap_example

Now, user login to via ssh may have the home directory created automatically.