Wednesday, May 16, 2012

Dynamic DNS update Python script, for use with a home gateway device

I use the free ZoneEdit service to keep a dynamic DNS entry up-to-date. I also now use a Netgear WNDR4000 wireless router to connect to the Internet through my cable modem.

I have authored a script that uses HTTP basic authentication to grab the IP address from my router, compare it to the last polled IP address, and update ZoneEdit with the new IP if it has changed. I have this script set to run every minute.

#!/usr/local/bin/python

import urllib2, re, tempfile, os

# User variables - change these to fit your router
debug=False

router_user=""
router_passwd=""
router_webpage="http://192.168.0.254/RST_st_dhcp.htm"

zoneedit_user=""
zoneedit_passwd=''
zoneedit_host=""

# Returns a string containing webpage contents
def fetch_webpage(location, username, password):
  passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
  passman.add_password(None, location, username, password)
  authhandler = urllib2.HTTPBasicAuthHandler(passman)
  opener = urllib2.build_opener(authhandler)
  urllib2.install_opener(opener)
  return urllib2.urlopen(location).read()


s=fetch_webpage(router_webpage, router_user, router_passwd)
pattern = re.compile("IP Address.*?([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", re.DOTALL)
m = pattern.search(s)
newip = m.group(1)
if debug: print "Current IP Address: " + newip

filename = tempfile.gettempdir() + "/router_ip"
flags = "r+"
if not os.path.exists(filename):
  flags = "w+"
f = open(filename, flags)

oldip = f.read().strip()

if (cmp(oldip,newip) == 0):
  if debug: print "Old IP is the same (" + oldip + ")"

else:
  web_result = fetch_webpage('https://dynamic.zoneedit.com/auth/dynamic.html?host='+zoneedit_host, zoneedit_user, zoneedit_passwd)
  if debug: print web_result

  f.seek(0)
  f.write(newip)

Monday, February 6, 2012

Make your GeForce GT 520 (or any Nvidia) video card sip power

I recently acquired an HP ProLiant Microserver N40L to replace my old giant mid-tower RAID box. Now that FreeBSD 9.0-RELEASE has integrated ZFS v28 for several months, I decided to migrate away from OpenIndiana 151a and enjoy FreeBSD's Linux binary compatibility, more up-to-date software selection, and a broader install base.

I imported my GeForce GT 520 video card into my new ProLiant microserver. The video card can be adapted to a "low profile" PCI slot by replacing the bracket in the front of the card. I disconnected the card's fan because it was loud, annoying, and making the dreaded "my bearings are out" screeeeeeeeching noise.

The GT 520 supports two digital monitors -- one connected via HDMI, and one via DVI. After enabling the commercially supported 'nvidia' driver by adding nvidia_load="YES" to /boot/loader.conf and generating a suitable xorg.conf file by running nvidia-xconfig, I was able to run nvidia-settings and watched my card idle at 85 degrees C. My power meter measured my system's idle consumption in X11 to be 80 watts. I also noticed that the PowerMizer showed that my card was operating at the maximum performance level.

After a bit of research, I discovered how to force the card into low-power mode. I added the following boldfaced lines into my /etc/X11/xorg.conf file:

Section "Device"
  Identifier     "Device0"
  Driver         "nvidia"
  VendorName     "NVIDIA Corporation"
  BoardName      "GeForce GT 520"
  Option  "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerDefaultAC=0x3"
EndSection
This tells the card to enable PowerMizer; 0x2222 stands for "fixed frequency on battery and on AC" (byte 0x22 is for fixed frequency, 0x33 is for adaptive frequency, MSB is for battery), and the default power profile on AC is the lowest level (0x3 is lowest power, 0x2 is medium power, and 0x1 is high power).

I rebooted, and measured my card's idle temperature at 48 degrees C and idle power consumption in X11 to be 70 watts. This is a ten-watt power savings -- and remember, I disconnected the GT 520's fan.

The GeForce GT 520 is a great choice for anyone wanting to attach one or more DVI monitors to a low-power or passively cooled workstation.

I do not recommend ATI cards because configuring them to dual-head in Solaris or BSD environments has been nothing but a headache for me.

Saturday, January 21, 2012

Very cool: Overlaying video on encrypted HDMI connections

Overlaying video on encrypted HDMI connections

(from Hackaday.com)


[bunnie] is up to his old tricks again. He successfully implemented a man-in-the-middle attack on HDCP-secured connections to overlay video in any HDMI video stream. There’s a bonus, too: his hack doesn’t use the HDCP master-key. It doesn’t violate the DMCA at all.


HDCP is the awful encryption scheme that goes into HDMI-compatable devices. Before HDCP, injecting video overlays or even chroma keying was a valid interpretation of fair use. [bunnie] thinks that HDMI devices should have the same restrictions analog devices have, so he decided to funnel his own video into his TV.


The build uses the NeTV, a handy and cheap FPGA board with an HDMI input and output. [bunnie] got the FPGA to snoop the HDMI bus and decide if a pixel needs to be changed or not. This isn’t much different from what researchers in Germany did a few months ago, but unlike the academic security researchers, [bunnie] gives you a shopping list of what to buy.


As an example of his work, [bunnie] implemented something like a ‘tweet ticker’ on HDCP-encrypted video. There’s very little the NeTV setup can’t do from chroma keying, filters, or simply dumping the HDMI stream to a hard disk. Check out the slides from [bunnie]‘s talk to get better idea of what he did.


[PAPPP] found a video of the talk in question. Check that out after the break.





Filed under: video hacks

Saturday, December 3, 2011

Vostro 220 Series CAN handle 8GB of RAM

Contrary to Dell's website, the Vostro 220 DOES support 8GB of RAM with the latest BIOS upgrade.

My wife's Dell Vostro 220 is now running Windows 7 x64 and has 8 GB of RAM. I upgraded her BIOS to 1.3.0 before swapping the memory (I read somewhere that the updated BIOS supports the full 8GB).


On a related note, you can actually get the service tag out of your Dell computer in Windows by issuing the following command.


Following WMIC command will give make and model number along with service tag (service tag is IdentifyingNumber here:

C:\>wmic csproduct get vendor,name,identifyingnumber
IdentifyingNumber    Name                Vendor
ABCDEF1              PowerEdge 2950      Dell Inc.
 
In Linux:
 
[remote-host]# dmidecode -s system-serial-number
ABCDEF1
 
HT: http://www.thegeekstuff.com/2008/10/view-dell-service-tag-and-express-service-code-from-linux-and-windows/ 

Saturday, November 19, 2011

Treacle Pudding

Fresh & Easy is a subsidiary of Tesco, the world's third-largest retailer. As Tesco is from the UK, they carry things that Americans do not normally experience. Having heard about treacle about a decade ago when listening to the Lords of Acid - Voodoo U album, last week I decided I would try Treacle Pudding.



It comes in a can.

Open the top of the can, run a knife around the inside, and then open the bottom of the can in order to express the cake thing out onto a microwavable platter.


It is imbued with "golden syrup." This photo does not do it justice. Mine had a gelatinous ring of treacle enshrouding the rounded edge of the top of the cake.

It tastes British.

My wife liked it, although it tasted "canned" to her.

Saturday, October 22, 2011

Adware/spyware infested computer, Baitisj style

The following article will probably frighten many of you, but hopefully this is helpful to folks who have gone through this kind of frustration.

A friend of mine had infested computer. Her Windows XP computer had slowed to a crawl, and I offered to help take a look. Process Explorer showed me some very suspicious process names. Poking around, I found a directory named "C:\Program Files\Invisible Keylogger."


The first thing I did was to install wonderful extension called "Folder Size for Windows"
I noticed that her hard drive had very little free space, and I wanted to figure out where all the space had gone.

Using Folder SIze for Windows, I discovered a HUGE temporary internet files directory
(C:\Documents and Setting\Owner\Local Settings\Temporary Internet Files)

I deleted all files out of this folder, but Folder Size was still showing that there was 22 GB of data inside. Even with hiding system files disabled, looking inside of this folder showed nothing in Windows. Creepy.

I Did some online research, and noticed that previous versions of Windows XP use a file named "content.ie5" for cached data. Interesting.

I ran cmd and cd'd into the Temporary Internet Files directory. After I "cd content.ie5" and executed dir to list the files in the directory. Nine directories with cryptic file names like
3CNW8S1M were finally exposed.

I typed "explorer 3CNW8S1M", and found a LOT of files inside of these hidden directories.

A couple of takeaways:
  • Windows XP hides files inside of the Temporary Internet Files directory, even if the Explorer shell is configured to show system files and folders. cmd or Cygwin are your friends.

  • A password manager that saves your usernames and passwords to various websites protects you from screenshot and keylogger attacks. I really suggest setting up a password manager with a password that is sufficiently different from the password patterns that you use to log into Internet websites or whatnot.