Kastang Ramblings of a Geek

4Dec/100

Using Python to Parse WoW Server XML.

THIS CODE IS OBSOLETE. Blizzard changed the way information can be grabbed from their servers. Please view my PHP Class which will work.

The below Python script will parse the WoW Server XML file and return status, type, name, and load about a specified WoW Server. It also stores the Server XML file into a cache.txt file so constant requests to the script will not result in an IP ban on Blizzards servers.

Python 2.6+ must be used for this script to function correctly. It will work out of the box with no third party libraries required.

Please change the SERVER_NAME (on line 32) variable to your servers name.

#!/usr/bin/python
 
"""
Author: Josh Grochowski (Kastang)
 
This script will parse the WoW Server Status XML file and return
information about a specified server. This Python script works
for me, but it may not work for you. Use this script at your
own risk. 
 
Python 2.6+ must be used.
"""
 
"""
The below four lines assume this script will be loaded onto a
webserver. If you are planning to run this script in a CLI
enviornment, feel free to remove the below four lines of code.
"""
import cgitb
cgitb.enable()
print "Content-Type: text/html;charset=utf-8"
print
 
#Imports
from xml.etree.ElementTree import parse
import urllib, os, time
 
#WoW Server Status Path
WOW_XML = "http://www.worldofwarcraft.com/realmstatus/status.xml"
 
#Change SERVER_NAME to the your server.
SERVER_NAME = "Eitrigg"
 
#Display information for the Realm information.
rStatus = ["Offline", "Online"]
rType = ["", "PVE", "PVP", "RP", "RP PVP"]
rLoad = ["", "Low", "Medium", "High"]
 
#Modification time of the cache file.
modTime =  os.stat("cache.txt").st_mtime
 
#Current system time.
currTime =  time.time()
 
"""
If this function is called, the cache file will be
updated with the newest information from the WoW
Server Status XML file.
"""
def updateCache():
    cache = open("cache.txt", "w")
    cache.writelines(urllib.urlopen(WOW_XML))
 
"""
Given a Realm name and XML file, it will find the
XML string containing information about the specified
Realm and return it to the requesting function.
"""
def findRealm(realm, xml):
        for l in xml.findall('rs/r'):
                if l.get('n') == realm:
                        return l
 
        return False
 
#Displays information about the specified Server.
def printOutput(server):
    print "Realm Name: " + server.get('n')
    print "Realm Type: " + rType[int(server.get('t'))]
    print "Realm Status: " + rStatus[int(server.get('s'))]
    print "Realm Load: " + rLoad[int(server.get('l'))]
 
"""
If the cache file has not been updated for 10 minutes,
it will be updated. Otherwise, the existing file will
be used to find current information about the specified
realm. 
 
If the specified Realm is not a valid WoW Realm, nothing
will be returned. 
 
"""
def main():
    if (currTime - modTime) > 600:
        updateCache()
 
    xml = parse("cache.txt").getroot()
    server = findRealm(SERVER_NAME, xml)
 
    if server != False:
        printOutput(server)
 
if __name__ == "__main__":
    main()

A sample output can be seen below:

# python realmstatus.py
Realm Name: Eitrigg
Realm Type: PVE
Realm Status: Online
Realm Load: High
Tagged as: , , No Comments
7Aug/101

Installing and Configuring WoW on Linux

A few months ago I wrote a blog post answering some frequently asked questions about playing World of Warcraft on Linux (more specifically, on Ubuntu). I am making a return to WoW after an extensive break. During my break I did a fresh install of Ubuntu 10.04. I am in the process of reinstalling WoW on my Ubuntu partition. While reinstalling and reconfiguring WoW for my system, I took a few screenshots and notes. Hopefully they will be helpful for anyone who wants to play WoW on Linux.

This guide is tailored to Ubuntu 10.04 users, but should be similar for any Debian based OS users. I like to think everything is fairly straight forward. I assume you have some sort of basic Linux knowledge before attempting this guide. For example, if you do not know how to navigate around in Terminal, you probably shouldn't try this.

Prerequisites

Before installing Wine or WoW a few things need to be done with your system.

  • Update your graphics drivers: Updating your graphic drivers is probably the most important thing to do to ensure stable performance in WoW. Both NVidia and ATI have made great improvement over the past few years in improving the quality of their Linux drivers. Each release seems to increase the stability and performance of their cards.
  • Turn off special effects: If you are using Compiz (or an equivalent) turn it off before trying to play WoW. 9/10 times it will severely diminish performance and cause system lockups. If you use Gnome or KDE, I suggest switching to more lightweight option such as XFCE. This is not mandatory, XFCE my desktop environment of choice. If you want to give XFCE a try, in terminal type: sudo apt-get install xubuntu-desktop

Install and Configuring Wine

Make sure you have the newest version of Wine installed. If you are using Ubuntu, open terminal and type the following:

sudo apt-add-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine

The above commands will install the newest version of Wine on your system. At the time of this writing, the newest version is Wine 1.2. After issuing the above commands, type wine --version in Terminal to make sure you have the newest version available. To check the newest version, head over to WineHQ and check the latest Stable Release version.

Generally speaking the newest version of Wine is always the best. Occasionally a bug will occur in a build in which case you will have to manually install a previous version. World of Warcraft is a very well supported game in the Wine community so the chances of such a bug happening are slim.

For now, only one optional change needs to be made in the Wine Configuration. If you are only using a single monitor system, you can probably skip this. If you are using dual (or more) monitors, you should set an emulate desktop. Type winecfg in terminal. Click the Graphics tab, and check the "Emulate a virtual desktop" checkbox. Enter the screen resolution of the monitor you are going to play WoW on under Desktop Size. What this does is create a virtual desktop for Wine programs to run in. This is sometimes needed because certain games may appear distorted or overlap to a second monitor in full screen mode. If you are using Dual Monitors for example, you will need this activated so you can play correctly in full windowed mode and still be able to access your second monitor while playing WoW.

Installing WoW from Scratch

*If you have WoW installed on a seperate Windows partition you can use it rather then installing from scratch. If you do, ignore the installation instructions below and scroll down to Special Cases at the bottom of this post.

After Wine is installed and configured we can start the installation process. This process is pretty straight forward. I am using the WoW Online installer since I do not own the physical WoW discs. You can download the WoW Installer directly from Battle.net here. If this link does not work, login to your Battle.net account and download the Windows version of the WoW Installer.

After the file downloads, open terminal and navigate to the directory where InstallWoW.exe is located and run:

wine InstallWoW.exe

If this is your first time using Wine, the process may take a few extra seconds while configuration files are created. Your screen may also flicker a few times, don't worry, its normal. If all goes well, a screen should pop up asking which version of WoW you want to install. Select WoLK. You should see the following screen shortly after:

WoW Downloading

WoW Installer downloading the required files to continue.

After the required files are done downloading, you may receive an error about some system components failing the minimum requirements. This is most likely due to Ubuntu not reporting the proper system information.  Ignore any such warnings and click Install.

Ignore any failing minimum requirements warnings.

Next you will be prompted to select an install location for WoW. I personally chose C:\Program Files inside of Wine. You can safely choose whichever directory you want. For future reference, the "C" drive Wine creates is mapped to ~/.wine/drive_c/. In my example, my WoW folder will be: ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/

Choosing the WoW Install Directoy.

The longest part of the install when 7.5 GB of WoLK files are being downloaded and installed. I am receiving pretty constant speeds from Blizzards servers of around 800-900KB/s with spikes sometimes around 1.5MB/s. The install part will take a few hours to complete. I would recommend getting to this step before bed.

WOLK Installing

After the base install of WOLK is done, the game will automatically launch the Blizzard updater and patch WoW to the newest version. If all goes well, this should be done automatically, without issue. In my case, Wine froze while updating to Patch 3.3.3. If the game freezes on you during updating, open terminal and type:

sudo killall wineserver
wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Launcher.exe

The launcher should re-launch and the game should continue to upload without any issues.

Configuring WoW

By now WoW should be installed and fully patched. Before running the game, I recommend editing the Config.wtf file before launching WoW for the first time.

#Copy your original Config file to a new location.
cp ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf ~
#Remove the original
rm ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf
#Create a new Config.wtf file and copy the below inside it
vi ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf

This config file sets all of the performance settings to the lowest possible setting(don't worry, you'll adjust these later. Just for the initial launch it makes life easier), sets OpenGL by default, accepts the TOS and EULA, and sets a low screen resolution.

SET readTOS "1"
SET readEULA "1"
SET readScanning "-1"
SET readContest "-1"
SET readTerminationWithoutNotice "-1"
SET installType "Retail"
SET locale "enUS"
SET movie "0"
SET showToolsUI "1"
SET portal "us"
SET realmList "us.logon.worldofwarcraft.com"
SET patchlist "us.version.worldofwarcraft.com"
SET hwDetect "0"
SET gxWindow "1"
SET gxRefresh "60"
SET gxMultisampleQuality "0.000000"
SET gxFixLag "0"
SET videoOptionsVersion "3"
SET textureFilteringMode "0"
SET Gamma "1.000000"
SET Sound_OutputDriverName "System Default"
SET Sound_MusicVolume "0.40000000596046"
SET Sound_AmbienceVolume "0.60000002384186"
SET farclip "177"
SET particleDensity "0.10000000149012"
SET baseMip "1"
SET environmentDetail "0.5"
SET weatherDensity "0"
SET ffxGlow "0"
SET ffxDeath "0"
SET gxResolution "1024x760"
SET gxApi "opengl"

Now you should be good to boot the game for the first time. You should have a WoW Icon on your Desktop. If you do, double click on it and it will launch the WoW screen. If you do not have a WoW Icon on your desktop, enter the following command in terminal:

wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Wow.exe

If you did not have a WoW Icon on your Desktop, look at the bottom of this post to see how to create an Alias to launch WoW through terminal.

From here it is up to you to configure the settings to your liking. I recommend taking it slow, gradually update the settings until you are happy with the performance. Personally speaking, most of my settings are very similar to the settings I would play with in Windows. Both ATI and NVidia Linux drivers have come a long way in recent years. You should not see much a performance loss between playing on Windows or Linux. In some instances, you may even see a performance boost.

AddOns

Generally speaking, all AddOns will work fine under Linux. Rather then manually installing my AddOns, I prefer having a program do the manual work for me. One of my favorite programs for such a task is WoWMatrix. As far as I know, WoWMatrix is the only AddOn updater I know that offers a native Linux client.

Download WoWMatrix Linux version from WoWMatrix and execute the following commands:

#Navigate to where wowmatrix.tar.gz file was downloaded
tar zxvf wowmatrix.tar.gz
./wowmatrix

If all goes well, WoWMatrix should launch and ask where your WoW folder is located. In the window, right click in the white space and click Show Hidden Files. Navigate to ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/ - After the folder is selected, accept the license agreement. The rest should be self explanatory.

As with configuring your video performance, I recommend gradually adding AddOns. Make sure none cause issues.

Create a Terminal Alias for WoW

If for some reason a Desktop icon was not created, or you do not use a windows manager, you can create an alias to launch WoW via Terminal. If you use bash, add this to your ~/.bash_aliases file:

alias wow='wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Wow.exe'

After changes are made to your aliases file, you will need to apply the changes by typing source ~/.bash_aliases in Terminal. From now on you will be able to type wow in Terminal and the game will execute.

Special Cases

Unless you were previously directed to read this section, skip it.

Using an existing WoW Install:

If you already have WoW installed on a Windows partition, you have two options to choose from:

  • Running WoW directly from your Windows partition.
  • Copying your WoW directory from your Windows partition to your Ubuntu parition.

I am assuming you do not have your Windows partition mounted. If this is the case you will first need to know the which partition your Windows is located:

$ sudo fdisk -l
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13       31871   255897600    7  HPFS/NTFS
/dev/sda3           31871       44648   102631425    5  Extended
/dev/sda5           31871       44029    97654784   83  Linux
/dev/sda6           44029       44527     3998720   82  Linux swap / Solaris
/dev/sda7           44527       44648      975872   83  Linux

Issue the above command. it will display a list off all partitions on your hard drives. Look for the largest NTFS filesystem, this will most likely be your Windows partition. In my case, my Windows partition is located on /dev/sda2.

Now that you know which partition Windows is installed on, execute the following commands:

sudo mkdir -p /media/Windows
#REPLACE /dev/sda2 with your Windows partition.
sudo mount /dev/sda2 /media/Windows

This will create a directory for your Windows partition to reside in then mount the partition to the newly created folder.  I recommend you copy your existing WoW install your Ubuntu partition. For consistency, we will move your WoW folder to Wine virtual directories. This is not necessary though, the WoW folder can be placed anywhere on your Ubuntu HD.

sudo cp -r /media/Windows/path/to/World\ of\ Warcraft/ ~/.wine/drive_c/Program\ Files/

This will take awhile to complete. I suggest starting the copy and walking away for an hour.

If you choose to use your Windows partition to run WoW instead of copying it to Ubuntu, you should automount your NTFS drive on boot. Look up how to by editing your fstab file. I will not cover this in my guide.

Conclusion

If you are at this point, chances are you have a working WoW install. Congratulations!

Tagged as: , 1 Comment
25Jan/100

World of Warcraft Account Security

Recently there has been discussions in my Guild regarding World of Warcraft account security. I believe this is a perfect opportunity to give my opinion on measures that I believe must be taken to ensure increased general security of your computer along with your World of Warcraft account.

One thing I must make clear is there is no such thing as a completely secure networked computer. The suggestions listed below are simply extra precautions that must be taken to minimize the chance of your computer being compromised.

* - Applies to World of Warcraft only.

Get an Authenticator*
Having an Authenticator will virtually eliminate the chance of your account being compromised. The Blizzard Authenticator costs $6.50 from the Blizzard Store. If you are an iPhone/iTouch user, you can download the Mobile Authenticator for free. Having an Authenticator is no excuse not to do the remaining suggestions.

Web Browser
Use a secure browser. For the sake of speaking, that pretty much means anything besides Internet Explorer. My personal recommendation is Google Chrome or Firefox. For each, I highly recommend the WOT plugin.

WOT’s safe browsing tool warns you about risky sites that can’t be trusted: Online shops that cheat customers; download sites that deliver malware; sites that send spam; and those with inappropriate content for kids.

Web of Trust provides an additional layer of security when visiting websites. WOT is community managed, meaning if someone spots a phishing website, they can report it. The report is upload to WOT servers, if you try to access the website that has received a poor rating, WOT will block you from going to the website without your express permission. If you use Firefox, in addition to WOT, I also highly suggest NoScript. Currently, Google Chrome does not have a  NoScript extension available.

Passwords
Your World of Warcraft password should be entirely different from any other service you use. Generally speaking, a password should be at least 8 characters long with upper/lower case letters, numbers, and symbols. Your World of Warcraft password (along with other sensitive passwords) should be changed at least once a month. It takes 2 minutes to do, don't be lazy. An example of a good password would be 'I3n&$VW49*'.

Anti-Virus, etc.
Windows users - Having AV software is not full proof. Consider it just another way to decrease the chances of having malicious software installed on your computer (for a long period of time). I personally recommend Avira or NOD32. Along with AV software, I also recommend Spybot and Malwarebytes (Free Edition is fine). Malwarebytes is specifically targeted to Malware, harmful software that is generally not picked up by AV software. AV software should be set to automatically update and run daily (Both NOD32 and Avira provide this option, as do many other AV's such as AVG and Avast).  I would recommend running anti-malware software at minimum once a week.

For Mac(OSX)/Linux users, The options for security software is rather slim. I can recommend ClamXav(Mac) and Clamav(Linux) for virus scanning. I also recommend rkhunter for OSX/Linux systems. Generally speaking, there is not much more that can be done for OSX systems in terms of AV software. Sadly, Apple has spread false information on commercials by suggesting OSX is immune to viruses, until OSX suffers a mass attack, it is unlikely much further production of AV software will occur. As for Linux systems, there are other precautions that can be taken, but I will assume if you use Linux, you should know how to properly secure your system.

Note: Debian based distrobutions can run the follow command to download rkhunter and clamav:

sudo apt-get install clamav rkhunter
#rkhunter -c to run
#clamscan -r in '/' directory to run

Updates
Windows users - Automatic Updates should be turned on. Keep your system updated at all times. Microsoft is constantly releasing security patches to fix potential vulnerabilities in your system. If you are still using XP (or anything older) update to Windows 7 as soon as possible. When updates for your system become available, do not postpone restarting your computer to take effect, do it immediately when it asks.

OSX users - By Default, OSX will check for System Updates once a week (This setting can be changed in System Preferences -> Software Update). Install updates whenever they are available.

Linux users - If you are using a Debian based system, the following commands can be executed from a Terminal:

sudo apt-get update
sudo apt-get upgrade

Other non-Debian based Distributions should consult the proper documentation.

Common Sense
Be smart when you use your computer.

  • One precaution that should be taken is when reading email. Never click on links masked by anchor tags (HTML), especially World of Warcraft related emails. If you receive an email from Blizzard asking you to log in to your account, or a beta key, it is most likely a scam.
  • When using your laptop on a public network, be very careful to use SSL connections while logging in/reading email or any other services. If you are on a public network, you should always assume that someone is watching and logging everything you do (this includes cleartext logins). For maximum security, I recommend always using hardwired connection wherever possible (this includes on a home network also).
  • If at any point you find your computer acting strange, immediately stop what you are doing, update and run your protection software.
  • If your World of Warcraft account is compromised, and virus scans show up nothing on your computer. Do not assume one is not there. Change the password for your email and WoW account on a different computer, then work on finding out what caused the security breach on your WoW computer.

Conclusion
Everything above may seem like a lot to take in at first, especially if you have little to no protection on your computer to begin with. The hour or two it will take to setup will be well worth it if your World of Warcraft account becomes compromised. Not only will following my suggestions increase the overall security of your system, it will also save you from possible embarrassment if your account becomes compromised. Once you get everything setup, it should not take more then a half hour of manual work per week to keep your system up to date and secure. I will repeat again, having this security software in place will not make your computer full proof against attack. The above software will only minimize the chances of your system becoming compromised.

12Jan/100

Parsing the WoW Armory – Part 2.1

I forgot to post this information in Part 2 of Parsing the WoW Armory. When parsing the guild-info.xml file, some fields are represented by  numerical values. Below is conversion table from XML numerical representations to actual values.

genderId:
0 - Male
1 - Female

raceId:
1 - Human
2 - Orc
3 - Dwarf
4 - Night Elf
5 - Undead
6 - Tauren
7 - Gnome
8 - Troll
10 - Blood Elf
11 - Draenei

classId:
1 - Warrior
2 - Paladin
3 - Hunter
4 - Rogue
5 - Priest
6 - Death Knight
7 - Shaman
8 - Mage
9 - Warlock
11 - Druid

For easy converting from numerical to actual values I would recommend using a PHP array(). Below is an example of the Sorted Guild list from Part 2 with the addition of the class of each character included.

< ?php
function sortedList($x) {
    $classArray = array(1 => "Warrior", 2 => "Paladin", 3 => "Hunter", 4 => "Rogue", 5 => 
          "Priest", 6 => "Death Knight", 7 => "Shaman", 8 => "Mage", 9 => "Warlock", 11 => "Druid");
 
    $array = array();
    foreach($x as $char) {
        $array[] = getName($char)." - ".getLevel($char)." - ".$classArray[(int)getClassId($char)]."<br />";
    }
    sort($array);
 
    return $array;
}
 
?>
12Jan/100

Parsing the WoW Armory – Part 2

I chose to expand on Part 1 by providing a function file that provides access to all available character related information from the guild-info.xml file from the WoW Armory. The guild-info.xml file provides the following information for the entire guild: Achievement Points, Class ID, Gender ID, Level, Character Name, Race ID, Guild Rank, URL to Character Page.

Some neat things can be calculated by using the available resources. I provided three examples in the code below: Average achievement points, average level, and a sorted list of all characters in the guild (also provided in Part 1).

< ?php
 
ini_set("user_agent", "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8"); 
 
//Average guild achievement score. 
function achAverage($x) {
    $counter = 0;
    $total = 0;
 
    foreach ($x as $p) {
        $total += getAchPoints($p);
        $counter++;
    }
    return ($total/$counter);
}
 
//Sorted Guild Characters Names/Levels in ABC Order. 
function sortedList($x) {
    $array = array();
    foreach($x as $char) {
        $array[] = getName($char)." - ".getLevel($char)."<br>";
    }
    sort($array);
 
    return $array;
}
 
//Returns the average level of the entire guild. 
function avgLevel($x) {
    $counter = 0;
    $total = 0;
 
    foreach ($x as $p) {
        $total += getLevel($p);
        $counter++;
    }
    return ($total/$counter);
}
 
/**
 * Other functions that can be used to pull information
 * from the XML sheet. Use these functions to expand
 * and create other functions. 
 **/
function getAchPoints($x) { return $x['achPoints']; }
function getClassId($x) { return $x['classId']; }
function getGenderId($x) { return $x['genderId']; }
function getLevel($x) { return $x['level']; }
function getName($x) { return $x['name']; }
function getRaceId($x) { return $x['raceId']; }
function getRank($x) { return $x['rank']; }
function getURL($x) { return $x['url']; }
 
?>

New functions can be created by using the get functions at the bottom of the file. Using the get functions and sample functions, it should be easy enough to expand on what I have.

The below code is an example of how to use the function code from above.

< ?php
//Functions file. 
include ('guild.php');
 
//Set Server/Guild Here. 
$server = "Eitrigg";
$guild = "We+Know";
 
$url='http://www.wowarmory.com/guild-info.xml?r='.$server.'&gn='.$guild;
$xml = simplexml_load_file($url);
$xml = $xml->guildInfo->guild->members->character;
 
//-------ABOVE THIS LINE IS REQUIRED----------
 
 
//Below are some possible ways to use the functions. 
 
/** Prints Without Array Numbers **/
for($i=0, $array = sortedList($xml);$array[$i] != null; $i++) {
    echo $array[$i];
}
 
/** Alternative Implementation, Prints with Array Numbers
print_r(sortedList($xml));
**/
 
//Displays the average number of guild achievements. 
echo achAverage($xml)."<br />";
 
//Displays the average level of the guild. 
echo avgLevel($xml);
 
?>