Move Minecraft Spawn with Python

The setup for this post is that in a vanilla Minecraft server there isn’t a way to set the protection size to 0 (yes, I know bukkit can do this but, meh).  This makes having the spawn in the middle of a nice area with shared chests, smelting, etc. a pain.  So I wanted to move the spawn but I didn’t want to have to download the whole world, open it with a map editor, and then re-upload the whole thing again.  Especially since I know the values are just stored inside the level.dat.  So, below is how I used twoolie’s python NBT interface to move the spawn on our server.

To install NBT, grab it from either github or pypi

spawn-move.py
1
2
3
4
5
6
7
8
from nbt import *
level = nbt.NBTFile('/<insert.path.here>/world/level.dat','rb')
level["Data"]["SpawnX"].value = newx
level["Data"]["SpawnY"].value = newy
level["Data"]["SpawnZ"].value = newz
print(level.pretty_tree())  # show changes
level.write_file('/<insert.path.here>/world/level.dat')
exit()

On Hacking: Larsson’s Folly

This post is a tangent that I was thinking about this past week when I was listening to NPR’s On The Media. The specific segment, The Chiquita Phone Hacking Scandal, examines the current News of the World phone ‘hacking’ case and illegal and unethical journalistic practices in the light of the historic “Chiquita Phone Hacking Scandal”. The segment is worth while and I highly recommend listening to it if you have a few minutes (or you can read the transcript here).

At any rate here is a nice little synopses: Chiquita was doing bad things and the Enquirer published the findings of reporter Mike Gallagher. Unbeknownst to the Enquirer, Gallagher had ‘hacked’ Chiquita’s phone systems and this fact was revealed after the publication. The result, “The Enquirer fired Gallagher, relocated its editor, agreed to pay Chiquita millions of dollars, apologized repeatedly and recanted the stories.”

The take away nugget is this, summarized by Kelly McBride of The Poynter Institute:

The lesson is when your methods for gathering information are dishonest, the information you gather is suspect. And that case is the perfect lesson in that. No one has challenged the findings of the newspaper. Yet, nobody talks about that as a great investigative piece. They talk about it as an ethical scandal.

Okay, so that all makes sense. But then I had a secondary thought and which gave me flashbacks to Steig Larssons Milenium Trilogy (The Girl With the Dragon Tattoo, The Girl Who Played With Fire and The Girl Who Kicked the Hornets’ Nest): In each book, the main character hacks into the antagonists machines and the information she gathers almost becomes a deus ex machina saving her and the rest of the journalist protagonists. This is great for a fictional story and it draws attention to the ease and power of information gathering. However, I do not think Mr. Larsson addressed the seriousness of how screwed they all would be if their ‘informant’ was actually revealed to be a hacker, illegally gaining access to the information.

If there were one take away it would be this: All fiction aside, hacking will never save your ass, it will burn it.

Namecoin on Ubuntu 11.10

So I setout to try a setup of Namecoin, the sibling to Bitcoin that is used for name/value storage and is the foundation for the dot-bit project. The dependencies were not explicitly laid out in the README so I wrote up the things I found I needed. Hopefully someone else doing the same thing will not have to do as much searching as I did.

  • Setup: namecoin version 0.3.24.64-beta
  • Target: Ubuntu 11.10 (x64), Amazon EC2 (Server) and Desktop
1
2
3
4
5
6
7
sudo apt-get install git build-essential libssl-dev \
libdb4.7++-dev libboost-dev libboost-system-dev \
libboost-filesystem-dev libboost-program-options-dev \
libboost-thread-dev libglibmm-2.4-dev
git clone git://github.com/vinced/namecoin.git
cd namecoin/src
make -f makefile.unix USE_UPNP=

I built my install list from the headers that were missing from a mostly generic 11.10 install. The list of the errors I came across are below. Shoot me a line if anyone comes across other packages that need added to the list.

If you get this far you can start running namecoind which is well documented here: Post Install

If you have compilation errors you can read more after the jump.

Read on →

Moving Window Buttons back to the right in Ubuntu 10.04+

I have gone and looked this up too many times. So for you and me both here is the long and short of it. The simple command that will move the windows buttons (minimize, maximize, and close) back to the right side, where all proper window buttons should be.

1
2
# move windows back to the right side in Ubuntu 10.04+
$ gconftool-2 --set /apps/metacity/general/button_layout type string menu:minimize,maximize,close

Update: I have confirmed that this does also work with all Ubuntu distros up through 12.04

EFF Tor Challenge + Amazon EC2 Free Usage Tier

Goal: Setup a Tor Node (Exit) on a Free Usage Tier Amazon VPS Image (EC2). This and easy and free way to join the EFF in their annonced TOR Challenge.

What you’ll need:

  • Amazon AWS Account
  • Some basic Linux know-how

First setup your new instance with the below specs. Check the EC2StarterGuide and the Ubuntu Cloud AMI Finder for help.

AMI: Micro (free usage tier) - Ubuntu 10.10 - x86_64 - EBS - (ami-cef405a7)

  • Use the default Instance Properties
  • Create a new Key Pair
  • Create new Security Group (name it something recognizable, like tor)
  • Add SSH + 9001 ports to the security group.

Now that the VPS is up and running login to it, run some updates, install and configure Tor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# replace with your new key name and ec2 address.
ssh -i yournewkey.pem ubuntu@ec2-xxx-xxx-xxx-xxx.yyyyyyyy.amazonaws.com
sudo apt-get update
sudo apt-get upgrade

# add the tor project repository
sudo apt-add-repository \
     'deb http://deb.torproject.org/torproject.org maverick main'
sudo apt-get update

# install tor
sudo apt-get install tor tor-geoipdb

# make a backup of the standard config file
sudo mv /etc/tor/torrc /etc/tor/torrc.bak

Edit /etc/tor/torrc or create a new config from scratch and make it look like this

/etc/tor/torrc
1
2
3
4
5
6
7
SocksPort 0 # we are not going to make local connections, aka a simple relay
ORPort 9001 # what port to advertise for incoming Tor connections
Nickname xxxxxxxxxxxxx # Give your node a nickname for the EFF Tor Challange
BandwidthRate 300 KB
BandwidthBurst 350 KB
AccountingStart month 1 00:00
AccountingMax 3 GB

The last two lines of this is important. We want to make sure our node does not use enough traffic to use up the entire allowed free bandwidth that a free image is allotted because then you will have to start paying for those bits. You could up it to around 15 GB which is where you start paying but we can start low for now. Finally, we can startup Tor. I like to use screen to run it so startup a new screen and run tor.

1
2
screen -S tor
/usr/sbin/tor

Watch for errors, if none show up, head over to http://metrics.torproject.org/relay-search.html and after an hour or so you should be able to search for your node’s nickname.

When your done don’t forget to submit your new node’s nickname to the EFF’s Tor Challenge!

Resources Used: