Philly 2600

Crack Liberty Bells & Passwords

Mining Bitcoin for Fun and (Basically No) Profit, Part 2: The Project

If you have not yet, please read the first article in this series: Mining Bitcoin for Fun and (Basically No) Profit, Part 1: Introduction

I have a few Raspberry Pis around my house that I like to play with – four in total. Prior to this idea of a Bitcoin project, I had one running as a media center and another operating as a PBX. Of the remaining two, one was an early model B with 256MB of RAM while the other was the shiny new revision sporting 512MB. I wanted to save the revised model for the possibility of a MAME project, so I decided to put the other, older one to work. It would help me on my quest to mine bitcoins.

Raspberry Pi Model B

Raspberry Pi Model B

But what is mining exactly you may ask? Bitcoin works on a system of verified transactions achieved through a distributed consensus (a mouthful I know). Every transaction is kept as a record on the Bitcoin block chain. Mining is more or less the process of verifying a “block” of these transactions and appending them to the chain. These blocks have to fit strict cryptographic rules before they can be appended, else blocks could be modified and invalidated. When someone properly generates one of these blocks, the system pays them in a certain amount of bitcoins (currently 25). This process repeats every ten minutes.

I knew that at this stage in the mining game I had to go with an ASIC setup and I new I wanted to run it off of my Raspberry Pi. Simple enough. The Raspberry Pi is a fantastic platform for this considering its price, power consumption, and horsepower. For mining hardware, I decided to buy the cheapest ASIC miners I could get my hands on. I found the ASICminer USB Block Eruptor Sapphire for the low price of $45 on Amazon. They cost more money on eBay and I couldn’t buy them from any sellers with Bitcoin because I didn’t have any (and didn’t want to bother with exchanges) so this seemed like the way to go. The Block Eruptor could run at ~330MHash/s, which is pretty hefty compared to GPU mining and at a fraction of the price. It is also pretty low power, using only 2.5 watts.

ASICminer USB Block Eruptor

ASICminer USB Block Eruptor

So I figured that I would get one of those, but also devised a more complete and formal parts list:

  • 1 x Raspberry Pi
  • 1 x ~4GB SD Card
  • 1 x Micro USB Cable
  • 1 x Network Cable
  • 1 x Powered USB HUB
  • n x USB Block Eruptor

That’s the basics of it. I already had the Raspberry Pi, and the necessary cables and SD card. These were just lying around. I needed to purchase a USB hub, so I bought a 7-port model for about $20. The hub needs to be powered as it will be running both the Raspberry Pi and the USB Block Eruptor. Considering power, the Raspberry Pi claims to draw somewhere around 1-1.2 Amps maximum while the USB Block Eruptor claims to draw 500 milliAmps maximum. I tested things out using my Kill A Watt and found that my setup with the USB hub, Raspberry Pi, and three USB Block Eruptors draws only 170 milliAmps and uses only 12.5 watts! So the projected power usage seems off for me, but I can’t guarantee the same results for you.

After buying my USB Block Eruptor on Amazon, I got it in about a week. The day after I got it and made sure it was working, I ordered two additional units to fill out the hub a little more.

Software

To do anything with Bitcoin, we’re first going to need a wallet and a Bitcoin address. Which wallet software you use is up to you. For desktop apps, there is the original Bitcoin-qt, MultiBit, and other third-party wallets. There are mobile applications like Bitcoin Wallet for Android, and even web-based wallets like BlockChain that store your bitcoins online. Figure out what client works best for you and use it to generate your Bitcoin address. The address is a series of alphanumeric characters that act as a public key for anyone to send bitcoins to. This address is also linked to a private key, not meant to be distributed, which allows the address holder to transfer funds.

In order to use the USB Block Eruptor, we’re going to need mining software. One great thing about using the Raspberry Pi as a platform is that someone has already made a Bitcoin mining operating system called MinePeon, built on Arch Linux. The distribution combines existing mining packages cgminer and BFGminer with a web-based GUI and some nice statistical elements. You’re going to need to download this.

To copy the operating system image file onto the SD card for your Raspberry Pi, insert the card into your computer and format it with the application of your choosing. Since I did this with a Windows system, I used Win32 Disk Imager. It is fairly straight forward: choose the image file, choose the drive letter, hit write, and you’re done.

Win32 Disk Imager

Win32 Disk Imager

Okay, software is ready. Now to set up the Raspberry Pi, insert the SD card into the Pi’s slot. To power the Pi, plug your Raspberry Pi into one of the USB ports via Micro USB cable. Then, plug the USB hub into one of your Raspberry Pi’s free USB ports. Any USB Block Eruptors you have can be plugged into the remaining USB ports on the hub (not the Raspberry Pi directly), but keep heat flow in mind as they get pretty hot. Next, connect the Raspberry Pi to your home network. Finally, plug your hub’s power cord in and let the Pi boot up.

To go any further, you will need to determine your Raspberry Pi’s IP address. If your router allows for it, the easiest way is to log in to it and look for the new device on your network list. Alternatively, plug a monitor or television into your Raspberry Pi and log directly into the system using minepeon as the user and peon as the password. From there, run the ifconfig command to retrieve the internal IP address.

Navigate to MinePeon’s web interface by typing the IP address in your browser. You’ll have to log in to the web interface using the previously defined credentials: minepeon as the user and peon as the password. You should be presented with a screen similar to this (But without the graphs filled in):

MinePeon Status Screen

MinePeon Status Screen

If you receive an in-line error about the graphs not being found, don’t worry. You just need to get mining and they will generate automatically, making the message go away.

Configuration

In order to utilize the software, you will now need to register with one or more Bitcoin mining pools. Mining pools work using distribution. The pool you are connected to will track the progress of each user’s attempt at solving a block for the block chain. On proof of an attempt at solving the next block, the user is awarded a share. At the end of the round, any winnings are divided among users based on how much power (how many shares) they contribute. Why use a mining pool at all? Payout usually only happens for one user when a block is solved. It can be very difficult for a user to mine a bitcoin, even after months of trying as the odds of success are always the same. Mining independently offers the opportunity of a giant payout at some point, but pooled mining offers smaller, more regular payouts.

Mining pools can differ greatly in how the payout is divided. I’d advise that you do some research as to which method works best for you. Alternatively, you could go about setting up your own mining pool, but I wouldn’t advise it without a substantial amount of processing power unless you’re willing to wait for a payout (if it even comes at all).

Anyway, I chose two mining pools: Slush’s pool (my primary) and BTC Guild (my fail-over in case my primary is down).

Registering with a mining pool is as simple as registering with any other website. After completing registration, you will be supplied with a worker name/password and the server address. These credentials can then be pushed into the MinePeon Pools configuration like so:

MinePeon Mining Pools

MinePeon Mining Pools

Next go to the Settings page and change your password for the MinePeon web interface (it’s a good idea), the timezone (this is buggy right now and won’t look like it’s working on the settings page) and any time you want to donate to the MinePeon maintainer (if any).

MinePeon Settings

MinePeon Settings

If everything is configured correctly, within a few hours (or instantly), you should see some activity on your MinePeon Status screen. Additionally, be sure to check your account on the mining pool you signed up with to make sure everything is working as expected.

My MinePeon Pool & Device Status

My MinePeon Pool & Device Status

My Slush's Pool Worker Status

My Slush’s Pool Worker Status

Now, just sit back and let your machine go to town. The only thing you have to do at this point is make sure the USB hub continues to get power (don’t let anyone unplug it) and it should run continuously. On your first day or two, it may take a while before your status update and payout will take even longer.

My mining rig, hub side

My mining rig, hub side

My mining rig, Raspberry Pi side

My mining rig, Raspberry Pi side

Most mining pools offer status tracking for your payout, so you should be able to see how things are progressing fairly quickly. As of this article being published, I receive a payout of 0.01 Bitcoin near every 24-30 hours while running three USB Block Eruptors.

Mining Bitcoin for Fun and (Basically No) Profit, Part 1: Introduction

If you’re anything like myself, you’ve been keeping loose tabs on Bitcoin over the years. When I first read about the cryptocurrency, I thought it was an awesome concept. Now, I had heard about electronic currencies before. The first mental link I made upon hearing about Bitcoin was that it reminded me of e-gold. Founded in 1996, years before Paypal, e-gold was a gold-backed digital currency created by a few guys in Florida. e-gold was the de facto currency for underground transactions, and was recently referenced in Kevin Poulsen’s Kingpin as the choice of the carder market – the collection of online outlets to buy and sell credit card information.

 

egold

egold’s logo

Though it was forged near the tail of e-gold’s run and adopted a similar concept, Bitcoin turned out to be a different beast entirely. While it is still favored for underground transactions, closely integrated with controversial websites like The Silk Road, the currency had striking differences that allowed it to come into its own. Bitcoin is distributed (read peer-to-peer), decentralized, and considered fiat money (as opposed to representative money). There is no central authority to go to with legal matters, you cannot simply flick a switch and shut down the network, and the currency only has value because we give it value – it isn’t backed against gold or silver or another currency.

Bitcoin also has an interesting history. The identity of the creator, who goes by the name Satoshi Nakamoto, is still unknown to the public. Many theories have come up to who the man behind Bitcoin really is. Some speculations range from an academic team to a government agency to a reclusive cryptographer. If you want to see more speculation, there’s an interesting Vice article about the whole thing I’d recommend checking out.

Background

In 2011, I got interested enough in Bitcoin to set up my own wallet, download the block-chain, and set up little donate buttons on a blog or two. The donations never rolled in (and why would they), but my fascination with the technology did. The idea of a monetary system that worked sort of “like BitTorrent” not only held my attention because of the possibility of financial success but also because it made me feel like I was at the forefront of something cool and exciting. I pictured scenes straight out of Serial Experiments Lain or Neuromancer with a dingy apartment somewhere in a dense city. A patchwork of tangled computer cables linking unknown and mysterious hardware together to just run and create money for me while I’m out. Nothing ever sounded both so cyberpunk and actually possible (though probably not as bleakly artistic).

At the time, CPU mining was on its way out as GPU mining was taking over. The internet was flooding with pictures of enthusiasts’ mining rigs. Case-less computers, motherboards with a large amount of PCI slots, each filled with a top-of-the-line graphics card. One of these setups was big, hot, messy, expensive, and beautiful. Usually a person would have a few of these chaotic mining machines all running in the same room and they caught the cyberpunk feel I so badly wanted to create for myself. I wanted the hectic rat’s nest of wires and satisfaction of a successful rig build.

The "Super Rig"

The “Super Rig”

I never got that far. Building a machine to do this was an expensive process and I didn’t want to put a huge investment on the line when I was operating on a limited budget in the first place. So, ultimately, I steered away from mining as a whole.

That didn’t turn me off from the whole technological concept though. I did end up surveying the field to see what people were using Bitcoin for. The possibilities seemed endless. Aside from sales of underground goods, I saw there was gambling, web hosting, and even retails sales (including some coffee shops). Pretty much any type of business that could accept Bitcoin was starting to have outlets that accepted the digital currency. I did what any Bitcoin novice did: got my 0.005 BTC from BitFountain for free (now defunct), and sat on it. No use doing anything with it. One bitcoin was worth around $8 USD at the time, so I had about four cents.

After the GPU mining wave, I next saw the FPGA generation. FPGA stands for Field Programmable Gate Array and is pretty much self-explanatory. An FPGA has a hardware array of logic gates like your typical AND or XOR operations. Sequences of logic gates can be put together to form half-adders and multiplexers and eventually processors (when you chain enough smaller components together). Normally, you would have all of these components pre-determined into some type of integrated circuit called an ASIC (standing for Application Specific Integrated Circuit) which are designed and programmed only for certain unique tasks. Think of an FPGA as a breadboard for the final ASIC design. Both the FPGA and ASIC are programmed in an HDL (hardware description language) such as VHDL or Verilog (or any other ones you might remember from a System Architecture class). Unlike your typical object-oriented or scripting languages, an HDL is more suited for the Electrical Engineer instead of the Software Engineer (me). An HDL allows you to create models and interactions of hardware components as though you had them available physically.

XILINX Spartan-3E FPGA

XILINX Spartan-3E FPGA

As you’d guess, FPGAs were a favorite for Bitcoin mining enthusiasts. Developers would program the boards to mine Bitcoin and leave behind anyone still pushing their GPUs to the limit. For me, FPGAs were still a massive investment. Though likely not as much as an outfit of new GPUs, coupled with enough electricity to power a small town, the amount of money for an FPGA was still a few hundred dollars. On top of that, I’d still have to dust off some of my class notes and program the thing. It would have been fun and a great learning experience but at the time I didn’t want the hastle. Besides, something better was coming soon anyway.

In the summer of 2012, I started discussing with my co-workers the feasibility of having us set up a Bitcoin mining operation. The whole concept was relatively simple: we were all going to throw money in for a new USB connected ASIC chip and run it off of a computer of our own. We did the math to figure out power consumption, our initial investment, mining complexity increase, etc. and the numbers for our break-even point looked pretty good. The company were were looking at for our miner was Butterfly Labs, who boasted they could provide a chip with an incredible hash rate at only a few hundred dollars. Split between a few people, it didn’t seem like too bad of a deal. Then, we started looking into the company. They were plagued with manufacturing delays. When you couple the time delay with the growing mining complexity, your return takes much longer. Couple that with the fact that Butterfly hadn’t delivered anything yet, the whole thing could have been someone’s pie-in-the-sky idea or giant scam. We decided to shut down our little plan and save ourselves the aggravation. This ended up being a wise decision. Butterfly Labs continued to be plagued by delays and people ended up auctioning off their pre-orders. There are still not that many Butterfly Labs ASIC chips out in the wild, even now.

Butterfly Labs ASIC Miner

Butterfly Labs ASIC Miner

After all this, I still wanted to try my hand at Bitcoin mining.

I knew that I wasn’t going to make a lot of money, but I thought it would be fun. If it made me any money, any at all, that would be something. So I got to work doing a little research.

Penetration Testing

Security is important anywhere, but especially so when it comes to our computer systems. If you are interested in security and learning how to protect your systems, or to at least get a better understanding of system vulnerabilities, this is a great resource to get you started.

PentesterLab provides an easy and straightforward way to learn penetration testing. By making disk images of vulnerable systems available, you can learn what to look for and understand what the vulnerabilities are and how to guard them. You have available to you the resources to learn penetration-testing basics with exercises that supplement the material provided. Internet access is not a requirement as you can download the course you want to follow and start learning how to pentest. To learn more go to PentesterLab.

PentesterLabBootcamp

Some of the things you will learn:
Basics of Web and HTTP
Basics of HTTP
Cross-Site Scripting
Directory traversal
Detection of common web vulnerabilities:
File upload
Command, SQL and code injection
XML and LDAP attacks
And more…

Philter – A Philadelphia Aggregator

I needed to undertake a programming project with a graphical user interface, so I decided on something based around Philadelphia. While I live in the suburbs, I find myself going to Philly for school, work, or recreation. Because of this, I end up relying on public transportation and am subjected to the city’s weather, which is often different than that in my town.

I decided to create an aggregator that is broken down into quadrants. One quadrant is for transportation, so it will give you regional rail information, bus information, as well as traffic problems. A second quadrant reports Reddit headlines from r/Philadelphia and some associated information about them. A third quadrant reports weather and forecast information for Philadelphia and surrounding areas. The final quadrant gives tweets pertaining to Philadelphia news as well as SEPTA, PATCO, and NJ Transit information.

Philter

The application in use.

The resulting program is a simple Java Swing application called “Philter” that can be run on any machine with internet access. While you do have to get your own API keys and build the project yourself, the source is freely available and modifiable. A lot of the grunt work in this program is actually carried out by the APIs (six are used in total) which return results to calls in the popular JSON format.

If anything, Philter can be seen as a work in progress as some work can be done to increase functionality (add traffic maps, etc) as well as aesthetics (layout, etc). It’s a good program if you are interested in learning about JSON parsing or how basic GUIs work.

You can currently get the project from its GitHub repository. Feel free to fork or request a pull.