Showing posts with label Networking. Show all posts
Showing posts with label Networking. Show all posts

FreeRADIUS PAP Challenge Authentication using rlm_perl

Let's see how to configure the FreeRADIUS2.x application to respond with an Access-Challenge for incoming Access-Request messages using the rlm_perl module scripting

System Specifications:

Ubuntu 12.04 LTS (i686 i686 i386 GNU/Linux)
FreeRADIUS v2.1.10


Configuration:

Step 1:

Edit the “clients.conf” file in the /etc/freeradius directory and add the Client's IP details as below

client 192.168.3.33 {
 secret = testing123   < -- Shared secret between Client and Radius server
 shortname = NodeToBeAuth
 netmask = 32
}


Step 2:

Edit the “users” file in the /etc/freeradius directory and add the users to be authenticated as below

user1 Auth-Type := Perl   < -- Use rlm_perl module for Authentication
user2 Cleartext-Password := "abc#123"  < -- Use plain text password for Authentication


Step 3:

Edit the “perl” file in the in the /etc/freeradius/modules directory and specify the script you would like to execute when the Auth Type is set to Perl as above in the users file

perl {
 module = ${confdir}/challenge.pl < -- Perl script on the /etc/freeradius directory
}


Step 4:

Enable the rlm_perl module by editing the “inner-tunnel” and the “default” files in the /etc/freeradius/sites-available directory as follows. Add the perl module under the authenticate section so that the perl module will be included and loaded when FreeRADIUS is started

authenticate {
 Auth-Type Perl {
  perl
 }
.
.
.
.
}


Script for Authentication:

Copy the example code posted on the official FreeRADIUS website and paste into a file named as challenge.pl in the /etc/freeradius directory

http://wiki.freeradius.org/modules/Rlm_perl

Edit the subroutine authenticate() as follows

# Function to handle authenticate
sub authenticate {
    # For debugging purposes only
    if ($RAD_REQUEST{'User-Name'} =~ /^baduser/i) {
            # Reject user and tell him why
             $RAD_REPLY{'Reply-Message'} = "Denied access by rlm_perl function";
             return RLM_MODULE_REJECT;
    } else {        < -- Any user except a bad user
            # Accept/Challenge user and set some attribute
  $RAD_REPLY{'State'} = "some state code here";
              $RAD_REPLY{'Reply-Message'} = "Enter the pin number";
  $RAD_CHECK{'Response-Packet-Type'} = "Access-Challenge"; < -- Send challenge back
  return RLM_MODULE_HANDLED;
    }
}


The above logic can be extended for the case of a user responding to the Access-Challenge by handling the condition of verifying the user response to the challenge found in the RADIUS attributes of the response message

Verification:

Start the RADIUS server in debug mode. Make sure that no freeradius daemon already running in the background before starting the server

# freeradius –X
{or}
#LD_PRELOAD=/usr/lib/libperl.so.5.14 /usr/sbin/freeradius –X  < -- Ubuntu 12.04 bug


Now test plaintext password authentication for user 2 as below

# radtest user2 abc#123 127.0.0.1 0 testing123
Sending Access-Request of id 203 to 127.0.0.1 port 1812
    User-Name = "user2"
    User-Password = "abc#123"
    NAS-IP-Address = 127.0.1.1
    NAS-Port = 0


rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=203, length=20

Now test challenge authentication for user 1 as below
# radtest user1 doesntmatter 127.0.0.1 0 testing123
Sending Access-Request of id 33 to 127.0.0.1 port 1812
    User-Name = "user1"
    User-Password = "doesntmatter"
    NAS-IP-Address = 127.0.1.1
    NAS-Port = 0

rad_recv: Access-Challenge packet from host 127.0.0.1 port 1812, id=33, length=60
    Reply-Message = "Enter pin number"
    State = 0x736f6d6520727461746524636f66652068657265


Please note that we are doing this testing using localhost (127.0.0.1) and the NAS-IP-Address should point to the RADIUS server IP address for remote RADIUS server. Please refer to the wiki page of FreeRADIUS for configuration details of FreeRADIUS 3.x or higher

References:

http://wiki.freeradius.org/modules/Rlm_perl

Tutorial to continuously measure the Bluetooth RSSI of a connected Android device (Java)


Bluecove RSSI Polling Android
Bluetooth RSSI - Nexus7 & Nokia Xpress Music
At the time of this writing, there is no Android API available to continuously retrieve the RSSI of an existing bluetooth connection even though API exists for getting WiFi RSSI. The current API will get the Bluetooth RSSI only during the initial connection setup process. In this article we will find out how to continuously get the Bluetooth RSSI of an Android device and a Nokia Mobile Phone from a computer running Linux.

The RSSI of any device connected to the computer can be determined by using the hcitool in Linux. But this may not be possible with commercial Android devices as root access is required in order to call any functions from the Bluetooth HCI layer using the Android NDK. For experimental purposes, in order to exploit the bluetooth equipment onboard commercial handheld devices, we shall measure the RSSI of these devices by connecting them to a computer or a laptop.

In this experiment the RSSI is being measured continuously in motion from an Android Device (Nexus 7 Tablet) and a Nokia Mobile Phone (Xpress Music) from a computer based on Ubuntu. The source code uses the Bluecove bluetooth library to extract the RSSI information from these connected devices. The Android device and the Nokia device acts like a server and the computer acts like a client.

At the computer, we need to write the client code that will continuously poll the RSSI from our known devices. In order to do this we need to first checkout the bluecove bluetooth libraries from here (http://bluecove.org/source-repository.html). Then we can make use of the BluetoothRSSIPollingClient.java to get the RSSI readings. We can filter out the other discovered devices using the Bluetooth MAC address of our known devices. We can obtain the Bluetooth MAC address of a device from the Preferences Tab of the Bluetooth Menu in Ubuntu after connecting the device with the computer.

Client:

public void PollRSSI()
{
try {
while(true)
                 {
        try {
        System.out.println();
        if(Android_Device != null)
        System.out.println("Android RSSI = " + RemoteDeviceHelper.readRSSI(Android_Device));
     } catch (Exception e) { System.out.println("Android RSSI = Connection Error"); }
        try {
        if(Nokia != null)
        System.out.println("Nokia RSSI = " + RemoteDeviceHelper.readRSSI(Nokia));
      } catch (Exception e) { System.out.println("Nokia RSSI = Connection Error"); }   
        Thread.sleep(2000);
                }
     } catch (Exception e){ e.printStackTrace(); }
}

For the Android device we need to write our own server code in order to overcome the [13] Permission denied error. We might need to run more than one server thread (AcceptThread.java) on the Android device so the incoming connection request will be finally accepted after an initial permission denied error. We will also specify the RFCOMM UUID and a Service name which the client can search and connect to. The entire server has to be implemented as a Service in Android (BluetoothRSSIService.java) so that the connection is not lost if the display screen is timed out.

Server:

public AcceptThread()
{
                   BluetoothServerSocket tmp = null;
                   mBluetooth = BluetoothAdapter.getDefaultAdapter();
                   mUuid = UUID.fromString("00000003-0000-1000-8000-00805F9B34FB");
        try {
                tmp = mBluetooth.listenUsingInsecureRfcommWithServiceRecord("BluetoothCustomService",      mUuid);          
             } catch (IOException e) { }
                myServerSocket = tmp;
         }

public void onCreate()
{
super.onCreate();

thread1 = new Thread(new AcceptThread());
thread1.start(); //First thread will often be denied
thread2 = new Thread(new AcceptThread());
thread2.start(); //Most probably be accepted

}

For the Nokia device there is no explicit server necessary and we can simply connect using the Bluetooth Serial Port Profile connection url. Once the connection is establish we can continuously poll the RSSI from both the devices periodically.

Note: RSSI of Bluetooth may not be an efficient and reliable parameter for applications such as indoor positioning

Source Code:

BluetoothRSSIPollingClient.java       AcceptThread.java       BluetoothRSSIService.java

References:

"A Bluetooth Based Supermarket Navigation System" - Pearl Manoharan, Vignesh Subramanian & Anusha Vutukuri - Course Project - Mobile Systems 16:332:559:02 F12 (Rutgers Fall 2012) -->
http://developer.android.com/guide/topics/connectivity/bluetooth.html
http://stackoverflow.com/questions/12251785/android-bluetooth-read-rssi-signal-strength
http://bluecove.org/bluecove-examples/bluecove-tester/index.html

What is a VPN?

Virtual private network is a cost effective solution for companies to extend network connectivity to its employees in every corner of the globe. Consider a company sends an employee to another country that is far away from the company headquarters on a secret mission. There must be some way for the employee to retort to the company and access the private network of the company in a secure way. The company cannot install a private network across countries because it would be expensive. Therefore they must find a way to communicate with the employee in a secure manner using the internet. This is were a virtual private network comes in to the picture. A VPN is a private network connection that is virtual in the sense that there is no dedicated private physical network connecting the entities. But the traffic is sent via the public internet that is vulnerable to attack in a secure manner. Private traffic is carried on the public network in a safe manner using several technologies like encryption, firewalls, authentication, IPsec, etc. VPN gives an organization the freedom to clandestinely communicate with its outbound employees in an economical fashion.