Archive for the 'software' Category

libprimrender Preview

Wednesday, December 19th, 2007

libprimrender
sceneviewer using the new libprimrender engine

Just finished committing an early preview of libprimrender to the libsecondlife source tree. libprimrender takes libsecondlife primitive objects and creates 3D mesh data. The library only uses basic math and libsecondlife data types, so there is no platform or rendering library dependency. The code is released as a GPL v2 library written in C#, based on the official Second Life viewer source code (llvolume.cpp). The screenshot above shows sceneviewer (an old Second Life client written in C# using libsecondlife and XNA) using libprimrender to draw a twisted and sheared cube. The noise in the background is wireframe water left over from the original codebase.

The source code can be browsed at:
http://openmetaverse.org/svn/index.cgi/libsl/libprimrender/

Or checked out through SVN at:
svn://openmetaverse.org/libsl/libprimrender/

This is an early preview, it does not calculate tangents/normals/binormals and there are likely still some bugs. If you spot any please use the libsecondlife Issue Tracker or post a comment here.

Opening Files and Folders With the Enter Key in OSX Finder

Tuesday, July 24th, 2007

Just got my first Apple computer, a Macbook Pro a few days ago. One of the few things that has been annoying me are the keyboard shortcuts in Finder for navigating around. In Firefox I press Apple-Left and Apple-Right to go back in forward, so to make Finder act more like my browser I went to System Preferences -> Keyboard & Mouse -> Keyboard Shortcuts and added two new ones for Finder.app, mapping “Back” and “Forward” to the shortcuts I wanted. Almost there, but pressing Enter on a file or folder and having it want to rename the item instead of open it really annoyed me. I won’t get in to a rant on the contextual meaning of the Enter key in a file navigation program, the fact is that I often open files and folders and rename them only a fraction of the time so I want to press a single key to open things. My friend who is an engineer at Apple gave me these instructions:

  • Create a shortcut for “Open” just like “Back” and “Forward”, and map to something not in use like Ctrl+X
  • Run “open ~/Library/Preferences/com.apple.finder.plist” in Terminal
  • Find the NSUserKeyEquivalents branch, and then find the entry for Open
  • Open TextEdit and press Enter to create a newline, and copy the newline by dragging from the first line to the second line and copying
  • Back in the shortcut for Open, erase the Ctrl+X binding and paste in the newline character
  • Close and save. To make the changes take effect I had to kill Finder at the Terminal, you could also reboot OSX to make the new bindings take effect

sceneviewer Video

Monday, October 30th, 2006

Here’s a video of the 3d Second Life client sceneviewer I’ve been working on. At the end of it you can see a moving object, the program actually shows everything in real-time including creating, moving, resizing/rotating, and deleting objects. Support for spheres, rings, and torii is next, along with support for clicking on prims and then a full SL-style camera. Hopefully by then someone makes some progress on a decoder for LayerData packets so we have terrain, and our cloud renderer is ready to go. Texture support is just around the corner as well, we can already download and decode textures from Second Life but some more robust (and asynchronous) downloading methods are needed, along with texture support in the prim library. And maybe by that time either I’ll have a better grasp on shaders, or we’ll have another person helping with the project. For now I’ll have to take a break on this as school and some contract software design will be filling up my schedule.

For the readers outside of the libsecondlife circle, sceneviewer is a C# program using Microsoft’s new XNA library. That means it’s a Windows-only program for now, but hopefully someday we could either abstract out the 3D code to target both XNA and Tao.OpenGL, or maybe Mono.Xna will mature. We are always looking for new coders for libsecondlife, so if you know C# and want to help with sceneviewer or libsecondlife drop in #libsl on EFNet.

Exporting Prim Data From Second Life

Tuesday, September 12th, 2006

Every Second Life player that has aspired to build their own grand project at some point has yearned for more powerful tools. Second Life has made a building and texturing toolset that is incredibly easy for the average user with no familiarity with 3D modeling, but lacking in ability compared to full-scale 3D software. There are also times when you want to build things without being connected to the grid, and import them later. To fill this niche, Jeffrey Gomez has created an excellent plugin for Blender called prim.blender. The plugin is open source Python code, released under the GPL license and reads and writes a simple xml format that stores Second Life “prim” (primitive, a building block object) information. This is a great piece of software that allowed the creation of the wonderful libsecondlife headquarters shown below.

libsecondlife Headquarters

To complete the circle, I’ve been working on an object exporter named primexport to get prim data out of Second Life and in to Blender. This will eventually allow you to build structures in-world, export them and do the texture mapping, then import the finished product to Second Life. For now it’s still in very early beta, once a couple more issues are worked out a public beta will be available from the libsecondlife website. Here’s an example of a motorcycle created in Second Life and exported in to Blender. This is different from just grabbing the raw OpenGL data because it’s stored in an xml format that describes the prim information, so it can be edited and imported back in to Second Life with an existing import script.


primexport example

If you look closely you’ll see a cube on the middle of the seat, which is the invisible prim that avatars sit on when they ride the bike. Transparency isn’t handled so it’s fully visible in prim.blender, and you also might notice a part of the seat is missing, hence why the software is early beta and still being worked on heavily. The rough edges should be smoothed over soon enough, and this could be a fundamental change in how Second Life information is treated. Traditionally, data in the SL metaverse is thought of as being locked up in a black box, and bought and sold between agents. By putting prim information in to an xml format, it can be transferred between grids, stored in versioning systems, downloaded from websites or peer-to-peer software, and integrated in to the rest of the web in general. It also brings the intellectual property of builders to about the same level of security that webpages, where anyone is free to view and copy the html source code. Should security measures be built in to primexport to try and hold on to the SL permissions system? Should such artificial restrictions be thrown to the wind so the virtual wild west can be embraced? What implications will this have for the Second Life building process, the economy, and intellectual property in the metaverse?

Bypassing Cisco Clean Access

Wednesday, August 16th, 2006

It was brought to my attention that the information in this post was putting the Washington State University Information Technology department at an increased risk for malware and viruses. It was my original hope that users tech savvy enough to install this fix would not be contributing to network stability issues, and my only goal was to allow residents Internet access. The defect has already been discovered by another independent team and registered in the NIST National Vulnerability Database, and Cisco Systems has clarified that the design flaw is not a security exploit because it does not bypass authentication in any way.

Open Proxy RBL Lookups in PHP

Thursday, May 26th, 2005

If you’re developing a web application that could be susceptible to what’s called a “hitbot”, or a script/program that attempts to repetetively impersonate a task such as voting on a poll, posting comments to a blog, brute-forcing a password protected site, clicking ad banners, etc, you want to implement some reasonable protection from these attacks. The simplest form of attack is a program such as ClickBot that just repetitively makes a GET or POST request to a server. To defeat this you just track $_SERVER['REMOTE_ADDR'] in a log or database and prevent multiple hits from the same IP address. The next type of attack uses a slightly more advanced piece of software such as Smart Hitbot that takes a list of proxy servers and connects to the target through these.

Smart Hitbot can hit one page first, picking up the proper referrer tag and/or cookies before hitting the second, so those prevention methods won’t help. What’s important to understand about proxy servers is not all proxies are equal. Some will pass HTTP_PROXY_CONNECTION = keep-alive or something along those lines, but merely detecting it’s a proxy won’t do you any good, as lots of people are connected to the net through caching proxies or censoring firewalls. But many (so called non-anonymous) proxies pass HTTP_FORWARDED, HTTP_X_FORWARDED_FOR, HTTP_VIA, HTTP_XROXY_CONNECTION, HTTP_PROXY_CONNECTION, or HTTP_CLIENT_IP to give away the original IP address. If one of these is detected you need to log BOTH the source IP and the proxy IP address. I’ve seen some scripts that will detect these fields then log only the original IP address, leaving them open to an attack where a machine pretends to be an open proxy and hits a site directly, forging the HTTP_X_FORWARDED_FOR field with random IP addresses. You need to make reasonable accommodations though; if two people connect through the same proxy to your site it’s not wise to assume they’re cheating the system and fire off warning alarms and autobans.

The other type of proxy is the most difficult to detect; it won’t pass any client IP address or give any clues that it’s making the request for someone else, it looks exactly like a normal client. Attackers will compile huge databases of open proxies by querying popular websites or using bots that search Google for lists, then meticulously prune them to find fast, completely anonymous proxies using programs such as Charon. Fortunately you have a defense against these "e;super-proxies”, known as an RBL, or Realtime Blackhole List. SORBS maintains an RBL for open http proxies, and it’s trivial in PHP to check a connecting IP address against the blacklist. For example:


/* function check_rbl()
* Checks to see if the client is listed in any proxy blacklists
* Returns true if the host if blacklisted, false if not
*/
function exists_in_rbl() {
$rbls = array('http.dnsbl.sorbs.net', 'misc.dnsbl.sorbs.net');
$remote = $_SERVER['REMOTE_ADDR'];

if (preg_match(”/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/”,
$remote, $matches)) {
foreach ($rbls as $rbl) {
$rblhost = $matches[4] . “.” . $matches[3] . “.” .
$matches[2] . “.” . $matches[1] . “.” . $rbl;

$resolved = gethostbyname($rblhost);

if ($resolved != $rblhost) {
return true;
}
}
}
return false;
}

A word of warning with RBLs: some sites (SORBS is notorious for this) are very trigger happy when it comes to adding addresses or even entire subnets they believe are zombie networks to the blacklist. If you get a single connection from a blacklisted IP, don’t put your site in to DEFCON 1 and launch ICBMs at the client. A simple warning in the log will do, and if start getting tens/hundreds/thousands of blacklist positives in a small timeframe THEN you can set off the sirens. Note that during an attack like this all you can do is silently ignore blacklisted clients or send them a nasty warning. If your site automatically goes in to lockdown of some form you open yourself to a denial of service attack.