A Remote Vulnerability in Firefox Extensions

Check out remote-vulnerability-in-firefox… It’s describes that firefox extensions hosted on a non https site are vulnerable. The vast majority of the open source/hobbyist made Firefox extensions – those that are hosted at https://addons.mozilla.org – are not vulnerable to this attack. Users of popular Firefox extensions such as NoScript, Greasemonkey, and AdBlock Plus have nothing to worry about.

Advertisements

Bigip : multiple virtual services running on different ports connected to one pool

Scenario
– Two application servers
– Each application server hosts different 3 services (different ports) which depend on eachother

Objective
When one of the services on a node goes down (checked by a monitor), then all services should be marked as down.

Possible Solutions

  • Solution “divided” : A seperate pool for each service
    The way you normally do this, yet it’s not that clean as you make the situation a bit more bloated.
  • Solution “combined” : One pool for all services
    Use the “translate service disable” option when creating a virtual server. This will disable port translation for the specific virtual server.

Example
If the virtual port is 65001, and the port used for the poolmembers is 65101, then when a request is send to the virtual ip on port 65001, then it will be rerouted to the pool member’s port 65101.
If the “translate service” option is set to “disable”, then the request will be sent to the pool member’s port 65001.
In this case you can setup one pool, with different checks for all services the nodes should provide. And create virtual servers pointing to one single pool.

man virtual

translate service
The options are enable or disable. You can turn port translation
off for a virtual server if you want to use the virtual server to
load balance connections to any service.

Bigip : connection mirroring

Scenario
There are two loadbalancers which are setup as a redudant pair which provides a default simple virtual server (with pool).
Let’s say you’d setup a connection towards this virtual server, and afterwards there’dd be a failover.

What happens to the connection that was setup to the load balancer that was setup?

  • The connection is being migrated to the other load balancer.
  • The connection remains as it was, directed to the “failed” load balancer.
  • The connection is terminated/reset (by the BigIP).

It might be a surprise to some, that the correct answer is the second one. The connection remains “as it was”. Off course it won’t be functional; Yet there will be no fail over of this connection by default, or will the connection be terminated/reset by the BigIP
When (and how) the connection will be reset depends solely on the client!

So one might ask: “Why doesn’t the BigIP send a fin/rst to the client?”
Another question might answer this: “How would the BigIP be able to send the fin/rst packet as it failed?” A failover occurs when the unit isn’t accessible anymore (If it got disconnected from the network, crashed… etc). It wouldn’t be able to send this packet.

There is however a mechanism that does a fail over to the other BigIP. But there is a (performance) trade off involved. This mechanism is called “connection mirroring”. So the state of all the connections made to the active BigIP are also kept on the standby BigIP.

HOWTO
You can enable the “connection mirroring” thru :
– the command line (“man virtual”) : “b virtual *name* mirror conn enable”
– the GUI (virtual server -> advanced) : GUI Screenshot

So if you REALLY need it, you can use the option, yet be aware of the performance degradation that’ll cause.

New layout!

I was tired of the “default” wordpress theme, so I’ve switched the site to “DkBlog 1.1 by Seobilgi“. A personal improvement based on style, but also on layout. The default theme removed all menu bars (and so on) when viewing a post, where this theme keeps the important things where they should be.

I’ve also extended the wordpress installlation with the “WP-Syntax” plugin. This is nicer on the code I’ve been posting. Where this plugin keeps the layout, and even does some highlighting.

The octaldump of the unix2dos / dos2unix

Let’s start out with a file we’ve created in unix (solaris). When doing an octal dump (od) of this file, we’ll see that the end-of-line (newline) is represented with an n

bash-2.03$ cat test
linetest
bash-2.03$ od -c test
0000000 l i n e t e s t n
0000011

Let’s convert this file to a DOS (windows) file:

bash-2.03$ unix2dos test test2

If we do an octaldump of this newly generated file, then we’ll see that it had a “return” and a “newline”.

bash-2.03$ cat test2
linetest
bash-2.03$ od -c test2
0000000 l i n e t e s t r n
0000012

NOTE(s):
– the unix2dos & dos2unix are eachother’s equivalents…
– the commands can be used to convert files for to be compatible for the other

My own setlock program written in oldskool C

Following on my previous post on my own setlock code;

I found out that (even after some extra versions), the bash version was simply not solid enough to be used in production. So I’ve written the code in C, where I could use the “fcntl” directly.

The objectives for writing the program, was to extent the regular “setlock” program (from Daemon Tools) to:
– a freely usable code (without Copywright), thus “our own” code
– have an “override” feature (force option)

This program is used in a small framework where it’s architecture was setup in a way where one process periodically updates data. And that this data could be accessed from time to time to be manipulated.

The code:
[my_clearcase_view]kvaes@solaris:~/setlock cat setlock-nsn.c

#include 
#include 
#include 
#include 
#include 
#include 
#include 

int DoLock(int, int, int);
#define read_lock(LockFD) 
                        DoLock(LockFD, F_SETLK, F_RDLCK)
#define read_wait_lock(LockFD) 
                        DoLock(LockFD, F_SETLKW, F_RDLCK)
#define write_lock(LockFD) 
                        DoLock(LockFD, F_SETLK, F_WRLCK)
#define write_wait_lock(LockFD) 
                        DoLock(LockFD, F_SETLKW, F_WRLCK)
#define unlock(LockFD) 
                        DoLock(LockFD, F_SETLK, F_UNLCK)

pid_t PidLock(int, int);
#define readlocked(LockFD) 
                        PidLock(LockFD, F_RDLCK)
#define writelocked(LockFD) 
                        PidLock(LockFD, F_WRLCK)

int
main ( int argc, char *argv[] ){
  int LockFD;
  int EXIT;

  if ( argc  0 ) 
          {
            EXIT=kill(PID,SIGTERM);
            if ( EXIT != 0 )
            {
              printf("Error while trying to kill pid $d.n", PID);
              exit(errno);
            } 
            EXIT=unlock(LockFD);
            if ( EXIT != 0 )
            {
              printf("Error while trying to unlock.n");
              exit(errno);
            }
          }
          EXIT=write_lock(LockFD);
          FOUND=1;
        }
      }
      MATCHES = strcmp( argv[3], "read" );
      if ( MATCHES == 0 )
      {
        TYPE=2;
        MATCHES = strcmp( argv[2], "wait" );
        if ( MATCHES == 0 )
        {
          EXIT=read_wait_lock(LockFD);
          FOUND=1;
        }
        MATCHES = strcmp( argv[2], "nowait" );
        if ( MATCHES == 0 )
        {
          EXIT=read_lock(LockFD);
          FOUND=1;
        }
        MATCHES = strcmp( argv[2], "force" );
        if ( MATCHES == 0 )
        {
          printf("The option %s cannot be used here.n", argv[2]);
          exit(-1);
        }
      }
      if ( FOUND == 0 ) {
        printf("Wrong wait type entered. (%s)n", argv[2]);
        EXIT=-1;
      }
      else
      {
        if ( EXIT == 0 ) 
        {
          EXIT=execute(argc,argv);
          unlock(LockFD);
        }
        else
        {
          printf("Error while trying to use a %s lock.n", argv[2]);
          exit(errno);
        }
      }
    }
  }
  exit(EXIT);
}

int execute(int argc, char *argv[])
{
  int ret = 0;
  char *cmd[argc-4];
  char *prog;

  int i = 0;
  int j = 0;
  for ( i = 0; i < argc; ++i )
  {
    switch ( i ) {
      case 0:
        //executable name
        break;
      case 1:
        //lock file
        break;
      case 2:
        //how do we wait?
        break;
      case 3:
        //read or write?
        break;;
      case 4:
        prog=argv[i];
        cmd[j]=argv[i];
        j++;
        break;
      default:
        cmd[j]=argv[i];
        j++;
        break;
    }       
  }
  cmd[j]=(char *)0;

  ret = execvp(prog, cmd);
  return ret;
}

pid_t PidLock(int LockFD, int type) 
{
  struct flock lock;
  lock.l_type = type;
  lock.l_start = 0;
  lock.l_whence = SEEK_SET;
  lock.l_len = 1;
  if (fcntl(LockFD,F_GETLK,&lock) < 0)
  {
    perror("fcntl"); 
    exit(1);
  }
  if (lock.l_type == F_UNLCK) 
  {
    return(0);        
  }
  return(lock.l_pid); 
}
 
int DoLock(int LockFD, int cmd, int type)
{
  struct flock lock;
  lock.l_type = type;
  lock.l_start = 0;
  lock.l_whence = SEEK_SET;
  lock.l_len = 1;
  return(fcntl(LockFD, cmd, &lock));
}

Linux vs Solaris Runlevels

Linux

  • Runlevel 0 is reserved for the “shutdown” phase. Entering init 0 from the shell prompt will shutdown the system and usually power off the machine.
  • Runlevel 1 is usually for very basic commands. This is the equivalent to “safe mode” used by Windows. This level is usually only used to asses repairs or maintenance to the system. This is a single-user mode and does not allow other users to login to the machine.
  • Runlevel 2 is used to start most of the machines services. However, it does not start the network file sharing service (SMB, NFS). This will allows multiple users to login to the machine.
  • Runlevel 3 is commonly used by servers. This loads all services except the X windows system. This means the system will boot to the equivalent of DOS. No GUIs (KDE, Gnome) will start. This level allows multiple users to login to the machine.
  • Runlevel 4 is usually a “custom” level. By default it will start a few more services than level 3. This level is usually only used under special circumstances.
  • Runlevel 5 is everything! This will start any GUIs, extra services for printing, and 3rd party services. Full multi-users support also. This runlevel is generally used on by workstations.
  • Runlevel 6 is reserved for “reboot” only. Be carefully when running this command. Once you have entered init 6, there is no stopping it!
  • Solaris

  • S, s – Single user mode. Doesn’t require properly formated /etc/inittab. Filesystems required for basic system operation are mounted.
  • 0 – Go into firmware (sparc)
  • 1 – System Administrator mode. All local filesystems are mounted. Small set of essential system processes are running. Also a single user mode.
  • 2 – Put the system in multi-user mode. All multi-user environment terminal processes and daemons are spawned.
  • 3 – Extend multi-user mode by making local resources available over the network.
  • 4 -Is available to be defined as an alternative multi-user environment configuration. It is not necessary for system operation and is usually not used.
  • 5 – Shut the machine down so that it is safe to remove the power. Have the machine remove power, if possible.
  • 6 – Reboot
  • Notice Runlevel 5… so don’t mix them up 😉