Friday, September 4, 2009

openVPN easyrsa batch em "build-key"

We were deploying a solution for our customer, Pizza Hut/KFC Malaysia which deploy pfSense as a VPN gateway and firewall to a little under 300 outlets in Malaysia.

Each outlet has a unique “storeID” which is then required to run OpenVPN daemon at the background and fires a connection whenever a layer 2 link is established.

To create under 300 certificates using OpenVPN’s (v2.x.x) easyrsa scripts on a CentOS clients isn’t funny. So being a lazy ass, i wrote a simple way to help to create these files fast!

Assuming you’ve got the whole works with OpenVPN and pfSense sorted. If not read this great document here. Once you’ve got the server side done on pfSense, you will need to generate more keys for (in this case, Pizza Hut’s) 300 branches peer certificates.

Snail factor

  • Build-key prompts amongst other things the commonName or server name each time a certificate is to be generated

What is needed?

  • To create store certificates that automatically creates the certificates without prompt and also using a $variable$ to “insert” the commonName value. This means, a certificate will be created with the storeID.key and storeID.crt and the storeID.csr

How - Conceptually?

  1. Automate the build-key file to disable prompts
  2. Fire a variable into the system to pickup the $variable$ which then will be the filename and the commonName

How – Technically

(Assumptions – easyrsa is in /etc/openvpn/easyrsa and keys are in /etc/openvpn/easyrsa/keys. In /easyrsa, you have all the scripts like build-ca, build-key)

Create a file called build_batch into /etc/openvpn/easyrsa with the following lines. Make the file executable chmod +x build_batch

#!/bin/sh

if test $# -ne 1; then
echo "usage: batch-build <name>";
exit 1
else
export KEY_CNAME=$1
./build-key $1
fi

Now, edit (nano/vi) the openssl.cnf file in the /etc/openvpn/easyrsa look for the following lines

commonName            = Common Name (eg, your name or your server\'s hostname)
commonName_max            = 64

Add a new line like below and save the file.

commonName            = Common Name (eg, your name or your server\'s hostname)
commonName_max            = 64

# Add this line below
commonName_default        = $ENV::KEY_CNAME

Now, edit (nano/vi) the build-key in that same directory. At the end of the openssl –req and openssl ca statements, add the –batch argument.

This is how part of the original file look like

openssl req -days 3650 -nodes -new -keyout $1.key -out $1.csr -config $KEY_CONFIG && \
openssl ca -days 3650 -out $1.crt -in $1.csr -config $KEY_CONFIG && \

We modify to add –batch at some part of the line like below and save the file

openssl req -days 3650 -nodes -new -keyout $1.key -out $1.csr -batch -config $KEY_CONFIG && \
openssl ca -days 3650 -out $1.crt -in $1.csr -batch -config $KEY_CONFIG && \

Now you’re ready to run in batch. But before that, please feed the vars in the environment like below in /etc/openvpn/easyrsa

source vars

Run a sample like below

./build_batch test01

This will build the test01.crt, test01.csr and test01.key automatically in /etc/openvpn/easyrsa/keys with the commonName test01 also :)

Done.

Now, if you want to do lots of these, use this Excel below

Exceleasy-rsa-linemaker.xls

Use the Excel file (build-cert sheet) to generate script lines (see the excel sample) so you can copy and paste into a SSH remote session in the appropriate directory.

Copy in batch up to 50 lines (within buffer) from the copypaster column and paste via a SSH session into the /etc/openvpn/easyrsa and it will generate without prompting anything. Quick and easy.

image

To remove/revoke certs, do the same but use the Excel’s revoke-cert sheet.

image

<Ignore CRL/STR_COPY issues, i don’t have CRLs defined>

If things mess up a lot, just run. Warning, this will remove your CA, server and dh information which you then need to repopulate inside pfSense.

./clean-all

After clean-all you must recreate all below

./build-ca
./build-key-server
./build-dh

Then re run the above stuff.

Monday, August 24, 2009

Microsoft Security Essentials 1.0 BETA vs. Kaspersky 2010

My colleague Henry asked to scan his USB he suspect a virus is lurking in there. I have both Kaspersky and MSE running in real-time.

MSE detects and Kaspersky snoozed!.

It was Win32/Vorus.CV

Capture1

And MSE cleans it. I am confident with this product. Since it’s gonna be free, i am a full supporter and advocator of MSE. Use it try and have a trouble free computing environment.

PS> Want a copy of MSE? I can give it to you but you have to write to me for with your email addy.

Capture2

Saturday, August 22, 2009

Immunet - Antivirus Cloud Computing


Immunet, a startup by Symantec senior execs take Antivirus to the cloud. Immunet attempts to aggregate the results and "opinions" of threats from people using this service. This means, if Bob gets an infection from Saudi Arabia, Immunet alongside your antivirus will then update everyone in this Immunet community about the threat in realtime and get protected from this threat.
They also plan to protect social networking and other communities (probably Twitter, etc..)
Interesting concept. Could Computing Antivirus.

In summary, this is like every single immunet user would then be a possible contributor to protect all other immunet users in realtime.
Checkout their narrative:
Immunet Protect is free, light weight, cloud based Anti-Virus software which uses new approaches to provide malware protection. It is designed to work alongside Symantec, AVG and Mcafee to provide significantly improved detection rates in those products. You can also install it alone. Immunet works by providing its own fast and light layer of cloud based virus detection on top of your existing Anti-Virus product. Once you have Immunet installed it ties you into the Immunet Cloud and allows you to build communities of friends and family. When Immunet Protect detects a threat on your system it automatically makes available protections for it to everyone in your community and to the global community protecting them instantly.
Checkout and download. It doesn’t work on my Windows 7 X64 RTM tho :(. So i had to put it on my XP32 running AVG. Perfect!
Currently, this product works better with those three AV products. I am using Kaspersky + Microsoft Security Essentials Beta, so probably i wont benefit much but probably some security information when a bug/security threat is detected on Windows. (not sure..shall try).
Requirements
Microsoft Windows XP with Service Pack 2 or later
* 300MHz or faster processor
* 256MB of RAM
* 10 MB of available hard disk space
Microsoft Windows Vista Home Basic/Home Premium
* Supports 32-bit platforms only at this time
* Must meet the minimum Windows Vista operating system requirements
Windows 7 (RC)
* Supports 32-bit platforms only at this time
* Must meet the minimum Windows 7 (RC) operating system requirements
Required for all installations:
* A working Internet connection

http://www.immunet.com
Note, this product is a pre-release i.e. BETA, so use with discretion.
image
Above: Number of people online and threats it can clean!!!, not bad.
INTERESTING. After about 20 minutes into writing this, the protection increases by 2!!!!!…SUPER COOL. There were no updates and downloads of threat patterns. Realtime, hell yeah!
image
If i click the threat meter..
image
nsDialogs.dll is apparenly “safe”
image
Settings and such.
To participate, you need to register. Without registering you wont be able to “help” others :)
image
Click on register and go get a new account at www.immunet.com. Then immediately sign in and you should be able to see like below;
image
image
Join the cloud? Let us know the experiences.

Thursday, August 13, 2009

My views on free VS. premiere security products.. and Microsoft’s Antivirus?

It's interesting how one AV product suppress the other in just a matter of months. Look at the graphs produced by those so called independent testers. A sample here. Its a big war of AV companies out there.
My problem is, it's sickening to know that we as consumers are always confused with all their gimmicks about free vs premiere/paid editions. You cannot do that with security products! <period>. Give it for 100% or don’t give it at all.
My take on it is, if you want to give something free, give it 100% (and the world shall love you for it). Tearing down features for free Vs. full versions is like saying "you get the car for free but the brakes work only 50%. So be careful. If you want full braking then you need to pay". This is their message and how i see it. This is also why the open source world keeps propelling and gaining mileage. They fall under the GPL which do not allow licenses to be sold, so how they profit? Professional support and services...
Know this…I am not talking about features, that’s different, maybe your security product perform system wide application update, now, that’s a feature, security such as filtering through different protocols, email filtering, web filtering for example, shouldn’t be a “paid” feature..it should just be a standard one.

Anyway, Microsoft will also soon be in the chase, prime time. Its called MS Security Essentials dubbed Morro- a new free AV for PCs (they stopped beta test downloads already so its getting ready for RC).

Combined with Security Center, Windows Update, MS Firewall, its almost a full desktop security suite. However, it's yet to get the real world challenge, this is a fact. So, wait till it releases and we shall all see. (Word to note, HOME PC…) So, not sure where this is going for corporations, yet.
From a commercial point this service will seriously dent the rest of the commercial AV market, no doubt, but again, i would rather get an AV at 100% free than of those "free but we wont give you 100% brakes" ones...This is good for consumers, the competition will ease of our pockets for sure.
I bet there will be certain camps that will say its from Microsoft, we can't trust bla bla, just so you know, MS products are seriously “tested” (ie smothered and smacked) by millions of testers worldwide as soon as it sees daylight, every second, even at the point i am writing this, this is why you get lots of "bugs/problems" reported, so effectively, for me, as security paranoia, i rather have those bugs exposed, fixed than have/use a product that no one knows if its a big ass Swiss cheese or not. I don’t really care about the games the corporations play, i just want good quality software.

Wednesday, August 12, 2009

Possible new breed of mass spreading worms ? New vulnerabilities found in MS products.


Microsoft Office OWC10.Spreadsheet ActiveX BorderAround() Heap Corruption Vulnerability

The specific vulnerability exists in the OWC10.Spreadsheet.10 ActiveX control installed by Microsoft Office. By accessing specific methods in a certain order heap corruption occurs leading to remote code execution. If exploited, complete control of the affected system can be achieved under the rights of the currently logged in user.
[http://www.securityfocus.com/archive/1/505679]
This looks like a perfect candidate for a possible mass spreading worm from a newly discovered (and patched) vulnerability in Microsoft Office Web Components.
  • Office XP, Office XP Web Components, and Office 2000 Web Components (all editions)
  • Office 2003, Office 2003 Web Components, and Office 2003 Web Components for the 2007 Microsoft Office system (all editions)
  • Internet Security and Acceleration Server 2004 and Internet Security and Acceleration Server 2006 (all editions)
  • Microsoft BizTalk Server (all editions)
  • Visual Studio .NET 2003 (all editions)
  • Microsoft Office Small Business Accounting 2006 (all editions)
Especially those running ISA server, this is seriously critical. You must get patched, get secure.
Since the attack takes the permission of the logged on user, it is possible that UAC will prevent privileged tasks from the remote exploit attempt.
Patch immediately or stand a chance to be part of the statistics (hopefully not)
http://www.microsoft.com/technet/security/bulletin/MS09-043.mspx

Monday, August 10, 2009

Logging on to Windows 2008 domain as an administrator on Windows 7 domain computer

This has probably been blogged a thousand times but let me be the 1001th ..blogger ;).

Thought I’d share this from Windows 7 perspective instead.

So, here’s the rundown:

  • I got myself W2008 R2 and Windows 7 RTM up and running, joined the domain and stuff.

Ok, so the thing is, when you use the logon UI from Vista/Windows 7, it does “see” the domain it just joined and sets it up for you by default as your default domain (there’s no more pull down domain lists).

image

Notice the part where it says “Log on to: BEAUTISEC”? Well, BEAUTISEC is my domain and you can skip the BEAUTISEC\username way of logging on and just go with username. If you want to log on to other than BEAUTISEC domain, do/see this …

image

So, lets say I've got a domain called MSFT, i would need to do the MSFT\domain user  and log on that way. But since i am in my primary domain i.e. BEAUTISEC, i don’t have to, i just logon.

I log on user sanjay and my password just like that works. But, when i log on as administrator, it doesn’t. Here’s why:

For administrator accounts

In the above scenario, local administrator logons will take precedence unless you specify the domain preceding the logon name like BEAUTISEC\administrator which is your domain administrator account. Then you get to logon as the domain “administrator” account.

See this screen below when i key in administrator (NOTE: The administrator here is the default built in administrator user for that PC, it could be renamed as admin or papasmurf and the effect below is still the same)

image

The “Log on to” value is automatically set to BEAUTIFULPC, which is the local PC name i.e logon locally. This “feature” can also help someone figure out what is the local built in admin account even before logging on, but yea..moving on..

For regular accounts

Domain logons will always take precedence unless you specify BEAUTIFULPC\<username> to log on to local accounts or in other words, other than the built-in administrator account. (See my note above about the local admin account)

image

The Log on to value automatically changes to my domain BEAUTISEC.

SIDE NOTE: You can’t change to classic logon interface for Vista/Windows 7 machines like how you see in XP for machines that are part of the domain. But you can enable the Interactive Logon: Do not display last username directive through registry or GPO (or GPEDIT locally). That shall let you enter your username manually but still no domain pulldowns… like in old days. ):

Saturday, August 8, 2009

My first Windows 7 BSOD

image

This happened when i was extracting a 7zip file and launching Google Chrome around the same time. I noticed that Kaspersky had reported some antiphishing around this same time when i was accessing a website.

Case: Win 7 64 bit RTM, Kaspersky Internet Security 2010, Google Chrome Beta 3, extraction using WinRAR Windows of a 7z file.

Windows 7 (RC, RTM) and static disk activity (about a minute of pause)


I was running into this problem since i got the RC build of Windows 7. I didn’t much bother as i was patient enough to wait till things started to work again (which eventually it does) and also figured it may be fixed by the time RTM is out.
Well, that isn’t the case, now, i am on the official RTM build (and 64bit) and it still choked every once in a while (similar to what i had on an RC 32bit).
Symptom.
Every other time, the disk activity on my SATA disk on my cheapo Dell Inspiron 1525 kept a static blink like a contiguous disk activity or as though there was a hardware failure on the disk. This causes certain newly launched apps or older ones which are running to freeze momentarily for almost about 30 seconds to 1 minute. This problem didn’t appear when i used Ubuntu 9.04 on this same exact system.
Solution
Well i found the problem (or more like the solution). It was the AHCI setting in my BIOS that causes this to happen (well, when i turned it to ATA mode, this problem didn’t crop up). This is also related to an older SATA HDD i inserted into my new Dell (the older SATA disk had higher RPM so i decided to use that instead)
SO if you get this annoying problem every once in a while, load up your BIOS, go to your SATA disk configuration and turn off AHCI and turn off flash cache (this is required according to the BIOS setting when you turn of AHCI.
Now, i am at peace :)
(NOTE: Some OSes including 7 BETA will not boot well according some internet searching i did) so, if things break, read next line.)
Use Ubuntu.

Thanks to my colleague Feroz Khan for the idea and this little snippet below from the WIKI link on AHCI above.

Friday, August 7, 2009

Check Point SSL Network Extender and Windows 7

If you use an older version of SSL Network Extender (SNEX) and you run the new Windows 7 (Beta, RC or RTM) on 64bit architecture you may get errors through both ActiveX and Java stating it failed to load. This is confirmed by Check Point and you need a new file.

You can fix this by manually downloading the SNEX client from CP’s website or click here that will update your older SNEX client. This should get you up and running in no time. Finally, get your admins to update their CPFW’s SNEX source files, available from this article from CP’s website to automatically upgrade other users as well.

Here’s a screenie.

image

Oh by the way, i am running Windows 7 64bit RTM. :D. Have a great weekend.

Malaysia for Internet Censorship? Vain Move. 5 reasons why.

I read the Star article and Nasdaq this on Internet censorship. I think this is simply a vain move by our government. Why?

  1. Nobody should play God, especially when it comes to information and information disclosure! Who determines if one site is politically “compliant” and is not. Who determines if a particular site is “racial” or simply stating the obvious? Who determines if a particular site is “good” or “bad”? Those who decides, are they being objective?
  2. No technology in the world can avoid accessing sites if people wanted. China tried, but people still could go to those sites “banned” by the government. When i was in Beijing in 2005, they blocked access to certain sites. All i had to do was to get myself a public proxy residing outside China and i could access those “banned” sites (to name a few methods. See this link for VPN feature. VPN keeps everything within an encrypted tunnel, so no one sees anything. And other ways of course :). I will definitely blog a comprehensive list if this were to materialize. :P
  3. It will slow things down even more. Putting up filters will undoubtedly slow things down. In fact, any devices in between you and the host-you-access/server can potentially slow stuff down. Especially if filtering is at the application layer (in this particular censorship case). Not to forget, we already have a substandard internet!
  4. Nobody will be happy to know that now EVERYTHING they do is now potentially INTERCEPTED. Those blocking tools basically get headers and certain data from your internet transaction and “analyze” them against their policy for a ACK or NACK. So, YES, EVERYTHING IS PICKED UP.
  5. It will create unnecessary workload to start managing and maintaining sites that are to be blocked (sites bloom faster than fungi on soggy bread), managing the devices, managing the people managing the devices etc..

Instead, the powers at play should educate users, encourage and promote the use of the internet to users to be wise and decide how they would like to use this facility. Give them an option to opt for a censorship program if they like, through installing of a software etc. Promote healthy thinking. Build trust with the people but also, keep the law in tact. Enforcement of cyber laws is really in its infancy here. This should be the first move.