Blocking DNS requests with Shorewall to prevent OpenDNS Bypass

Here’s a way to block users from using a different DNS address other than your own local DNS server to bypass OpenDNS filtering. I’m currently using Shorewall in an Ubuntu 8.04 LTS server setup as my Firewall, Gateway and DNS, and works nicely. This should also work in 10.04 or other Ubuntu install that has Shorewall firewall. Side effect for the user will be that they wont be able to surf the net until they revert back to the assigned DNS to use.

In your Shorewall Rules file, add this above the other rules.


DNS/ACCEPT  $FW     net
DNS/ACCEPT  net     $FW
DNS/DROP    loc     net
DNS/DROP    net     loc

$FW is your firewall/gateway and in my setup my DNS. You can change $FW to loc:<dns_ip_address> if your DNS is located in another machine other than your gateway.

Have fun raining in on their parade 😉

P.S. You can add filters to allow certain IP or MAC addresses to use DNS outside (i.e. Google DNS ).

Auto Updating OpenDNS with Dynamic IP Address via Ubuntu Server

I have a linux Ubuntu server and a dynamic IP for the DSL connection. The office needs web filtering and getting a static IP will just add cost to the now tight budget. Looking around there is actually a way to update OpenDNS IP address under linux. Below are what is needed to be installed and configured.

  • Any latest Ubuntu server ( I’m using Ubuntu 10.10 Server )
  • ddclient installed (use “aptitude install ddclient”)
  • net connection, I have set up my linux server as a firewall/gateway

After installing ddclient, go to /etc and edit ddclient.conf, below is the format that I used, modify it to suite your configuration.

ssl=yes
use=web, web=whatismyip.org
server=updates.opendns.com
protocol=dyndns2
login=<openDNS_username_here>
password='<openDNS_password_here>'
<openDNS_network_label_here> #this can be found under settings, just the label, nothing else should be added here

Save the new configuration file and restart the client /etc/init.d/ddclient restart
Also make sure that the network that your going to update the IP address has set its Dynamic IP Update option enabled. This can be found under the advance setting of the network.

Special Character Encoding in XML

Ran into a problem returning an XML data with special characters encoded into it through an AJAX call. The problem was that special characters (i.e. &ntilde; -> ñ) throws an error when being returned through XML and is in the process of being parsed by the browser.

The catch?
XML does not support named entities by default, you have to declare it before hand. Only &lt; &gt; &amp; &quot; and &apos; are predefined.

Something like:

1
2
3
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">

Got this from here…

The fix…
Instead of using named entities in the XML (I think this also affects JSON, I could be wrong since I didn’t test this is JSON) like &ntilde;, use character references to support special character encoding.

Example:
white space = &nbsp; = &#160;
ñ = &ntilde; = &#241;

they are all the same… #160 is referenced/mapped to ” ” and #241 is referenced/mapped to ñ

So when forming your XML before returning it through an AJAX call, form the special characters via character reference.

Hope this helps you out there having this problem.

Java IO Problem in Tomcat

Encountered this problem today while testing an image upload AJAX script in tomcat. Later on I found out that the folder is actually protected Win7 and tomcat couldn’t write the cache or temporary file into the folder.

So anyone having this problem, check the following…

  • What OS are you running? Vista/Win7?
  • What IDE are you using?
  • Was your IDE elevated to admin status?

So, check your OS, I’m using Win7. I was developing this under WinXP a few months back, and now under Win7, the folder is protected since it was under the “Program Files (x86)” folder group. (Argh!)
I closed my IDE, using IDEA IntelliJ 9.0, ran the IDE under “Administrator Level” and the problem disappeared!

So check those out first.

Updates to come…

Been busy around.. but a little heads-up, I’ll be posting and update to installing tomcat and java to Ubuntu 9.10 since I’m “forced” to upgrade now lol… also I’ll be posting a tutorial on how to login-authenticate and query google Analytics using flash AS2, which I think some of you there are also having some problems 😉

Weird turn of events…

I’m now developing in flash actionscript 2…. ok from one language to the other….

Java JNI: Unsatisfied Link Error in Library Path

I’m currently playing around with Java Native Interfaces(JNI) and I must say its been too long since I programmed in Java. Its good to be back! Anyway, lets hop to the main topic…

I was following the tutorial from Sun in creating my first JNI and calling my compiled C++ library, I was stuck in the last part where this error popped out whenever I tried to invoke

java HelloWorld

the error was…

java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
          at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
          at java.lang.Runtime.loadLibrary0(Runtime.java:823)
          at java.lang.System.loadLibrary(System.java:1030)
          at HelloWorld.<clinit>(HelloWorld.java:<line number>)
Could not find the main class: HelloWorld. Program will exit.

one way of fixing this is to include the current location of your newly compiled shared library (ex. HelloWorld.so). I’m using Ubuntu linux,so to include the current folder where your “.so” file is located, invoke…

LD_LIBRARY_PATH=`pwd`
export LD_LIBRARY_PATH

or you can also do …
Continue Reading

Overdue Post…

Seems like I got caught up with my work again, ah well que sera sera… I’ll be posting some new stuffs later on, one will be mysql replication through SSH tunneling and the other are tips on extjs javascript framework I have been using for over 2 years now. Should have done this a looooong time ago.

Stay tune 😉

Continuous Explorer Restarting Virus/Trojan

Came across this little bugger in my manager’s pc. The whole thing is that after logging into windows, the windows explorer continuously restart and exits. You can click the start button, open something but will naturally kill itself when explorer exits. You can’t even open the drives and folders normally since it will close sooner or later, anything running under Explorer.exe will die when Explorer.exe dies. Simplest way around the folder and drives is using the good ol’ command prompt. Did this and amazingly it didn’t die, thank God for command prompts. As usual scouring the RECYCLER folder for hidden trojans resulted in a no show, next was the usual system32 and system folder under windows folder. These little buggers get smarter everyday. There weren’t and hidden files so I was already assuming the exe file is there and ran through windows startup using the registry. Using autoruns from sysinternals, found one of the problems, a rogue exe is started everytime the system starts. Deleted the entry from the registry, located the file under system32 folder and also removed it.

That didn’t fixed the problem.

There was something else running when windows starts up. Next target… DLLs. Amazingly, there were dlls that was out-of-placed and curiously named. Example crypt32.dll that wasn’t signed by microsoft. Removed the entry and tried to remove the dll. No luck, its being used. Next tool that was very useful was Unlocker. I ‘unlocked’ the hook for the dll and restarted. Still didn’t fix it but I was getting close. There were two more dlls I found that was very suspicious. I tried to kill one and removed, the other regenerated the dll. I try to unhook the other dll, the whole pc restarts. Smart bugger. Thank goodness for safe mode. Restarted in safe mode and use unlocker again to unhook the dll. Removed one of the dll and its entry in the registry. Good… it didn’t restart… just a countdown for a system shutdown.. freaking dll.

The system restarted and good news is the dll that forced the shutdown wasn’t regenerated. Last dll was a bit simpler. Used unlocker to unhook the dll, deleting was not successful, though unlocker had a feature to delete the dll after a restart. Selected the option and waited. Thankfully, the whole ordeal ended there. All three dlls didn’t regenerate after that.

Note to PC users who watch videos from torrent ( Heroes, Prison break…). If it asks you to download a player to run the video you downloaded.. DON’T!!

Slow update…

Well, its been a month… or more? of no updates… been busy for a while cleaning codes and installing some pcs. I was thinking of posting those extjs codes I used that gave me some ‘wtf?!’ or ‘doh!’ moments in the past….we’ll see. I’m also currently compiling the documentations on how I set up a replication master-slaver server on 3 different locations and replicate through SSH. I’ll be posting that later on also.