Batch Renaming Files

by nealbailey 20. September 2008 16:00

Last weekend I found myself needing to rename some files on one of my servers. Ok, more like thousands of files because they were not named in a way that was conducive with XBMC's media information scraping features. When I looked at the sheer volume of files needing to be renamed I decided to write a small utility to rename the files in batch based on standard string replacements or Regular Expressions

For more details on the program or to get the code go to my code-project article on it. 

 

Tags:

Code

DVD Movie Server

by nealbailey 16. September 2008 19:11

For quite some time I have had a pretty decent DVD movie server running at the house. It consists of a File Server (Buffalo TeraStation 2TB), which is used to store raw DVD rips, a X3 chipped XBOX running XBOX Media Center, and a 52" Plasma television. One of the most impressive features of XBMC is it's scraping capability, or the ability to fetch information from websites for you and import it into your media center library such as plot summaries, movie reviews, cast, year, genre, etc, etc. With the latest SVN builds of XBMC I have begun to notice that the scraper is acting strange. I guess most people use this kind of setup to watch pirated movies, but in my case I'm using raw DVD rips from DVDs I own. As such my file structure is a bit different. For example the movie 310 To Yuma is in a folder named 310 to Yuma and inside that folder are the traditional VIDEO_TS and AUDIO_TS directories. Whenever I launch the IMDB scraper it searches for VIDEO_TS instead of 310 To Yuma since VIDEO_TS is a sub folder. To quickly resolve the issue I wrote a simple C# console application to do this:

  1. Enumerate the Movies Share
  2. For each folder move the files in VIDEO_TS into the root folder for the movie
  3. Delete the VIDEO_TS and AUDIO_TS folders

The script took 5 minutes to write and it saved hours of time of having to do this manually.

 

Tags: , , ,

HTPC

Dedicated BitTorrent Server Redux

by nealbailey 6. September 2008 11:01

This is a follow-up post to this one (Dedicated BitTorrent Server).

My enthusiasm for TorrentFlux was a bit overblown because after using it for a few weeks I came to the understanding that TorrentFlux sucks. Sorry to be so blunt but it's a fact (at least on a Windows Server & in comparison to other Windows clients). The web script is buggy and crashes often. When it's not crashing, it's busy having no idea how to read 3/4 of the torrents you try to upload to it and the logging is so poor that the user has no clue as to the nature of a failure. 

So, we're back to using the best BitTorrent client out there uTorrent. Of course uTorrent is a desktop application but it does come with a built in WebUI feature that allows users to remote control it from anywhere from any web browser. So for this to meet the goals of the previous post we need to be able to access the BitTorrent web server from any client and we need the server to run as a service so we don't have to log in with remote desktop and turn on uTorrent each time someone on the network wants to use it.

First things first, we install uTorrent on the Windows 2003 server. Next we edit the uTorrent properties to use the correct port for our network and setup WebUI. These settings can be found in the properties sheet of the program. See this post for detailed instructions for installing WebUI. Basically, I just had to download a zip file, rename it to WebUI.zip and place it in my user's %APPDATA% directory. 

I launched uTorrent and verified that I could access http://localhost:3000/gui/ in the web browser (3000 is the port I run WebUI on). 

 

Next up is the Windows NT Service Wrapper. Rather than write something I used an awesome Service daemon on code-project called XYNTService. Below you can see the ini configuration I used to setup the service.

 

[Settings]
ServiceName=XYNTService
CheckProcessSeconds = 30
[Process0]
CommandLine = C:\Progra~1\uTorrent\uTorrent.exe
WorkingDir= C:\Progra~1\uTorrent
PauseStart= 1000 
PauseEnd= 1000 
UserInterface = Yes 
Restart = Yes

In the Service Control Manager in Windows (compmgmt.msc) I set the service to log on with the account I installed uTorrent with. It won't work otherwise.

Thats it! Now we have a BitTorrent Server running on a network server that all of our users can use and we don't have to install BT software on every machine and we can monitor our users activity! 

 

Tags: ,

Networking

Beating WebSense Firewall Filtering

by nealbailey 2. September 2008 19:07

My wife was in the hospital for 4 days this past week and at the end of the first day my wife felt well enough to sit up and she wanted to log into her myspace page to post some photos. The hospital offered free Wi-fi internet access for staff and patients but they run a WebSense firewall which blocks just about every site online other than email sites and internal Sentara intranet sites. We tried about 25 sites and all but 4 were blocked by the firewall. You can see the screenshot below.

 



We tried several online proxies such as proxify.com but all of those were blocked as well as sites that outline steps for bypassing firewall filters. Ultimately, I left the hospital that night when my wife fell asleep and I went home to stand up a SOCKS SSH proxy server.

I don't have a full blown Linux server running at the house so I used my Windows 2003 Enterprise Web Server to host the OpenSSH server. 

The steps went like this:

After the server was installed, I went to my client and installed PuTTY which is used to create the encrypted tunnel from the client to the server. See the instructions here. Once the SSH session has been established all that's left is to configure firefox to use the tunnel as a SOCKS proxy.

Now that the tunnel was functional, I ran wireshark to sniff the traffic in order to validate that this setup wasn't going to set off alarms by the hospital admins. Wireshark revealed that firefox was leaking DNS requests, which means that even though my tunnel was fetching the remote sites, it was sending DNS requests to the host network DNS (which would setup a huge red flag).

Luckily in FireFox you canstop this behavior by typing about:config into the web browser and editting the setting network.proxy.socks_remote_dns to true.

I unplugged the laptop, set a port forwarding rule in my smoothwall router for inbound ssh traffic, and returned to the hospital and hooked it into the network there. Everything worked perfectly. 

Tags: , ,

Hacking | Networking

Powered by BlogEngine.NET 1.6.0.0
Theme by Extensive SEO