Archive for the ‘DigitalOcean’ Category
Hacking Planet Atwood with Python and AWS
Peter Atwood is a hobbyist who creates limited edition pocket tools and puts them up for sale on his site at Planet Pocket Tool. His tools are fairly popular and being limited are hard to acquire.
Peter posts the sales randomly and the tools generally sell out within a few minutes of being listed. The best way to capture a sale is to periodically check his site and get alerted when a sale is in progress. This write-up is about automating the check and sending an alert via SMS and email using Python.
Blogspot publishes a RSS feed for their blogs. I wrote a simple function to use feedparser to grab the datetime of the first item in the feed and compare it against the previous version. I send out an alert if the datetime of the first item is different from the one I have saved.
#Get the blog entry feed = feedparser.parse('http://atwoodknives.blogspot.com/feeds/posts/default') #Figure out the publish time of the first entry firstEntryPubTime = time.strftime('%Y%m%d%H%M%S', feed.entries[0].published_parsed) #The newest post time did not match the previously saved post time #We have a new post if firstEntryPubTime != currentUpdateTime: #Save the new first blog entry time setCurrentUpdateTime(firstEntryPubTime) url = feed.entries[0].link subject = 'Atwood: ' + feed.entries[0].title body = url + feed.entries[0].summary #Send an alert send_alert(subject, body, url) else: print "No Update"
Now, to send the alert we leverage Amazon Web Services and BOTO the AWS Python interface. Amazon has a service called Simple Notification Service or SNS. SNS is a push service that lets users push messages in various formats like SMS and email.
Getting started is simple. First create a topic to which people can subscribe using create_topic. Then subscribe your phone number, email address, and any other form of communication using subscribe. Now you are all set.
def send_alert(message_title, message_body, message_url): #Connect with boto using the AWS token and secret key c = boto.connect_sns('token','secret_key') topicarn = "arn:aws:sns:us-east-1:TopicName" #Publish or send out the URL of the blog post for quick clicking publication = c.publish(topicarn, url, subject=url[:110]) #Close connection c.close()
I set up this script on a server at DigitalOcean and ran it periodically using cron. I was able to get to the buy link for most of Atwood’s sales with this methodology and eventually bought a Fancy Ti Atwrench. While nice and well made, it is definitely not worth what Peter Atwood charges for it.
libapache2 mod_mono install freezing during install on Ubuntu at Digital Ocean
I had a problem with my libapache2-mod-mono install freezing during install when trying to run ASP.NET applications on Ubuntu.
The workaround for this is to open another session and restart/reload apache:
[email protected]:/home/xyzio# service apache2 reload
[email protected]:/home/xyzio# service apache2 restart
This is what I would see and the session would freeze at the [OK]:
apt-get install libapache2-mod-mono
Setting up libapache2-mod-mono (2.11+git20130708.6b73e85-2) ...
Using mono-apache-server4...
apache2_invoke: Enable module mod_mono
* Restarting web server apache2 [ OK ]
apache2_invoke: Enable module mod_mono_auto
* Restarting web server apache2 [Sun Dec 08 23:03:01.698809 2013]
[so:warn] [pid 4455] AH01574: module mono_module is already loaded, skipping
[ OK ]
Source:
http://askubuntu.com/questions/135547/how-do-i-set-up-mod-mono-on-11-10
AnalogDesert – A Free Android DigitalOcean App
AnalogDesert is a simple open-source ad-free Android app to check the status of your Digital Ocean Droplets.
Download it here:
https://play.google.com/store/apps/details?id=com.xyzio.analogdesert
Initial Setup:
Go to the settings menu and enter your Digital Ocean Client ID and API Key.
To get your Digital Ocean Client ID and API Key, log into your account and click on API.
Do you see bugs or want more features? Contact Me!
Analog Desert supports the following:
Droplets – Create, Destroy, Details, Disable/Enable backups, Password reset, Power On/Off, Reboot, Rebuild, Rename, Resize, Restore, Shutdown, Snapshot and Visit.
Images – View all global & personal images, destroy, transfer
Sizes – View sizes
Domains – View domains, domain information, create domains
Source:
https://bitbucket.org/xyzio/analogdesert
Screenshots:

New Droplet
Private Internet Access OpenVPN on Ubuntu at Linode or Digital Ocean
Update 9/14: These instructions no longer seem to work at Linode. Please leave a message in the comments if you see a mistake in my directions.
I’ve written about using Apache to proxy connections over SSH in order to hide sensitive information in public places. For an extra fee you can gain additional anonymity on the internet via companies like Private Internet Access which provides multiple VPN gateways for around $40/year without the risk of hacking or mis-configuration that comes with doing your own setup. You also get the ability to use VPNs in multiple countries and US locations thus further obfuscating information.
Private Internet Access has instructions on how to set up a VPN on Ubuntu using Network Manager. However I’m using a server install at Digital Ocean and I don’t feel like installing the desktop just to use Network Manager. In addition there is setup required to allow you to access the VPS while still routing outgoing data through the VPN. This should also work at Linode. Here is how to do it:
1) Install open-vpn : apt-get install network-manager-openvpn
2) Download a copy of Private Internet Access’ config files or if their site is down, here. Unzip the files in a new directory. The zip file contains everything you need to access their VPN servers without dealing with Ubuntu’s Network Manager.
3) Now you configure your VPS so that any traffic that comes to the VPS is responded to by the VPS. Otherwise once you start your VPN any attempt to connect to the VPS will be answered through the VPN which is not what the connecting software expects.
Type this at the prompt:
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev ethX
ip route add table 128 default via z.z.z.z
Where x.x.x.x is your public IP y.y.y.y/y is the subnet of your public IP address ethX is your public Ethernet interface z.z.z.z is the default gateway To get the x, y, and z use ip route: ip route show. The last three lines of the output will look something like this:
93.115.84.202 via 127.0.0.1 dev eth0
128.0.0.0/1 via 10.155.1.5 dev tun0
127.0.0.0/24 dev eth0 proto kernel scope link src 127.0.0.1
Match the color coded output to the ip commands above. You need to type these in every time you restart your VPN so it helps to save them in a shell script.
4) Optional: Create a password file. You can create a password file to supply OpenVPN with your login info If you are lazy and don’t feel like entering a password every time you connect to Private Internet Access. To do this, make a file that contains your username on the first line, password on the 2nd line, and nothing else.
5) Start OpenVPN using one of the config files from step 2. Each config file is set up to connect to one of the VPN servers run by Private Internet Access. You can specify your password file from step 4 using the auth-user-pass argument. Here is what I use to connect to their Romania server:
openvpn –config Romania.ovpn –auth-user-pass password_file
Finally, check your IP using their ‘Where’s My IP‘ page.
Questions or comments? Feel free to leave a message using the comments box below.
Sources:
http://openvpn.net/index.php/open-source/documentation/howto.html#client
http://www.cyberciti.biz/faq/how-to-find-out-default-gateway-in-ubuntu/
https://forum.linode.com/viewtopic.php?t=8737
https://www.privateinternetaccess.com/pages/client-support/#ubuntu_openvpn