Skip to content


Some hard drive management tips and tools (on Linux)

Remember why this is called a notepad? Well, now is the time. 😉

To run some disk testing:
– quick tests (1 or a few minutes): smartctl -d ata -t short /dev/sda
– long tests (several hours, stops at first error): smartctl -d ata -t long /dev/sda
To read the results of said testings: smartctl -a /dev/sda

NB: usually smartctl is already installed on the distribution, but in case your provider ships a minimalist OS (this is the case of EUserv, for instance), you’ll need to install it yourself: simply run apt-get install smartmontools.

Another testing tool (haven’t really used it yet): badblocks /dev/sda

To reassign a block (although as far as I tested, this doesn’t work on ext4):
dd if=/dev/zero of=/dev/sda1 bs=4096 count=1 seek=3778301
sync

(cf http://www.gra2.com/article.php/20041015232512624 for more boring/tedious details, notably on how to compute the “seek” position)

Apparently, hdparm can be used to write to arbitrary sectors too, cf http://serverfault.com/questions/461203/how-to-use-hdparm-to-fix-a-pending-sector.

Finally a great combo to erase empty space on a partition, although this probably shouldn’t be used on a live machine because it will fill up the partition with a huge, random file, beore overwriting it several times:
dd if=/dev/urandom of=/some/file.name bs=4M
shred -uvz -n 7 /some/file.name

Source for this combo.
Note that /dev/urandom can be very slow on a cheap CPU, in which case it might be wiser to use /dev/zero as a source of data (since the file will be overwritten several times anyway). Check the documentation of shred, it’s interesting and short.

Posted in Linux.


aToaD #9: OsmAnd (and some other things)

Offline maps for Android/Cyanogenmod

It took me a while to finally get a proper “smart”phone. The main reason for that was that I wanted it to have some real features and power, not just to be some kind of pumped up cell phone, at a reasonable price (600€ for a phone, seriously?). And the other reason was that I had a feeling I’d miss Nokia Maps from my previous phone. I really didn’t want to turn to Google Maps. Or actually, to any other online map service, since mobile internet speed is usually quite abysmal. After a bit of searching, I found that quite a few apps provide offline maps abilities, although they are usually limited in their Free version. I haven’t given them a lot of tries, so maybe my pick will change, but for the moment my personal favorite would be OsmAnd, for the following main reasons:
– open source (not gratis, though: the free version is limited to 10 files, I guess this means 10 countries simultaneously installed)
– based on OpenStreetMap data
– can be downloaded without going to some horrible app store in general or to the Google Play store in particular
– offers both a “standard” map view and GPS guidance views distinctly designed for car, bike and pedestrians

In my search, I first found MapsWithMe, which is a close source equivalent but without the GPS guidance mode. The interesting thing with this one isn’t about the software itself but about the downloads they offer: they list a fairly large amount of app stores, among which SlideME, which is one of the rare of its kind to offer manual downloads from a PC browser (the only other I know for the moment is F-Droid, which only lists open source apps).

Posted in A Tool A Day.


How to install Tor on OpenSUSE compiling it yourself

First a note about the quality and level of detail of this guide: I never really had the time to complete it. I’ve been running a Tor node (currently halted because of its host’s new policy about Tor) on OpenSUSE, and because it wasn’t very clear whether or not the RPM repositories provided by Torproject were appropriate for OpenSUSE, I preferred to compile my own version. Doing so, I took notes, hoping to turn this into a proper tutorial at a later point. But I never got the time, and at the moment the server is kind of a mess requiring a reinstallation (don’t worry, it’s a test server, not the server where this site is served from ;)). So I’m quickly skimming through the notes, completing them with the help of the stuff still installed on the server, in order to quickly publish something working yet maybe lacking details, and to be able to wipe the server. The OpenSUSE version I used was 12.2.

The first step is to install required stuff, that is devel versions of libevent, openssl and zlib (zypper install libevent-devel openssl-devel zlib-devel).

Then get the latest Tor source, either stable or alpha/beta/RC (at the moment it’s 0.2.4.16-rc), untar it, open its folder, configure and build:
wget https://www.torproject.org/dist/tor-0.2.4.16-rc.tar.gz
tar xf tor-0.2.4.16-rc.tar.gz
cd tor-0.2.4.16-rc
./configure
make

As far as I understood, it’s generally recommended to avoid make install, but the choice is ultimately up to you. If you don’t make install, you’ll simply have to launch Tor manually: once compiled, the Tor executable is in src/or/. To launch it, just run ./tor in screen (since it’s not installed as a service/daemon, you need to run it in screen).

You’ll also need to create the torrc configuration file
torrc: create it as /usr/local/etc/tor/torrc (a sample torrc for a good starting point can be found in src/config/). See the previous post about Tor about what to configure in there.
When you modify the configuration, you can’t use /etc/init.d/tor reload or an equivalent since it doesn’t exist (again, because it’s not installed as daemon), but you can just use ARM (see at the end how to install it): in ARM, just press ‘x’ twice to reload the config.

To avoid some ARM warnings, here are some extra options worth configuring in torrc:
Add DisableDebuggerAttachment 0 at the end
Set DataDirectory, for instance if you want to use the default, DataDirectory /home/[usernam]/.tor
Set a control password. First hash your password, like ./tor --hash-password mypassword, then copy the result into torrc, like HashedControlPassword 16:872860B77453A77D60CA2BB8C1A70420A2093276A3D701AD684053EC4C

FInally, to install arm:
zypper install python-curses
wget http://www.atagar.com/arm/resources/static/arm-1.4.5.0-1.rpm
rpm -ivh arm-1.4.5.0-1.rpm

Posted in Linux, Tor.


Sorry for yet another downtime…

This site has been down so often lately that I feel obliged to provided at least a little explanation. The previous downtime occurred due to some obscure server crash, which our host’s “monitoring” service, if we may call this crap this way, took over 6 hours to DETECT, even though the server had totally and brutally stopped all traffic (it took us 5 minutes to fix it, once we noticed the issue…). Tonight’s downtime was due to our host “upgrading” its network, which apparently went very wrong. AGAIN, the host did NOT notify us of the issue, which we discovered via our own, manual “monitoring”…

I was planning to move the site to another host, I just did it now. Hopefully there should be no more of such problems now… And we’re back in Germany 🙂 which sounds like a good thing with all the privacy-killing crap going on in France. Feel free to suggest any decent third-party monitoring tool, I think I’ll set up one of those…

Posted in site news.


How to make Piwik more block-resilient

Sometimes I like to be able to track stats of my things on sites that I don’t control. For instance (just as an illustration, I actually haven’t used eBay in ages), putting some Piwik tracking code on an eBay auction of mine. A site with good security will prevent you from adding JavaScript, so your tracking data will be limited, but they will usually allow you to insert external pictures. Sometimes with very strict checks (e.g. only picture extensions allowed), but more usually with no or few checks (like, any extension but .php/.asp). I recently had the case of a site that enforced a new policy to replace all “.php” by “.p”. That’s weird, but enough to be a minor PITA. Here is how to bypass such extension-based limitation.

The concept is simple:
1) turn an allowed extension into executed PHP
2) create a PHP file with said extension, and which will redirect traffic to the proper piwip.php file

To do this, you’ll need access to the HTTP server configuration files (probably you won’t be able to do that on shared hosting). Here I’ll show how it’s done with Apache.

Go to your Apache configuration files. For the sake of consistency (directives can be placed about anywhere, but better make it coherent), find the file linking PHP to .php extension (it contains SetHandler application/x-httpd-php). For me (Apache 2.2) it was /etc/apache2/mods-available/php5.conf. You’ll find something like:

    <FilesMatch "\.ph(p3?|tml)$">
	SetHandler application/x-httpd-php
    </FilesMatch>

After it, add the extension you want to support, for instance in my case I wanted to add .p, so it was like:

    <FilesMatch "\.p$">
	SetHandler application/x-httpd-php
    </FilesMatch>

NB: if the extension you want is already used, for instance if it’s a picture (like, .png), maybe you’ll have to remove a previous definition of .png. I didn’t check for that. You can always try without cleaning said used extension first, maybe it will work.

So, now the server will send .p files (or whatever extension you chose) to the php parser. Well, you’re almost done. All you need to do now is to create a redirecting php file, pointing to your piwik.php. Like:

<?php
header('Location: http://example.com/piwik.php?'.$_SERVER['QUERY_STRING']);
?>

As you can see, it can even redirect to another domain.

Better yet, if the service you are “targetting” also strips GET parameters, you can just add them here yourself, like:

<?php
header('Location: http://www.example.com/piwik.php?idsite=1&rec=1';
?>

Sounds quite unstoppable. Except with a most unlikely white-list.

Posted in web development.

Tagged with .


The Armed Republic of Bannannas: day 30

I think I’m starting to get the hang of this now… I still haven’t managed to get back to the economical level I had at the very beginning (for some reason the choices I made on the first dilemmas turned out to have quite a massive and unexpected negative impact), but I’ve had no unexpected decrease in the attributes of interest to me since the last report. Even the political freedom increased, leading to a change from “Benevolent Dictatorship” to “Libertarian Police State” 🙂

I believe the key to success is a massive use of issue dismissal, every time you’re not too sure the game will rate the offered solutions the same way you would. Another lesson is not to worry too much about the taxes, unless it is one of your objective to achieve a specific value for them: they are handled in a totally buggy way (although this is probably actually a feature). Like, a government can provide efficient support in numerous fields while having 0% of taxes (where the money comes from is a mystery), and on the opposite a country can still live with a good economy while having 100% of taxes (how the companies and people survive is a mystery). Similarly crime doesn’t seem to carry any negative economical impact. Still I wish I got some dilemmas allowing me to fix that a bit, that’s getting a bit messy. Anyway, here’s the current situation:

Category: Libertarian Police State
Civil Rights: Superb
Economy: Very Strong
Political Freedoms: Rare

The Armed Republic of Bannannas is a very large, socially progressive nation, renowned for its keen interest in outer space. Its hard-nosed, hard-working, cynical population of 112 million are proud of their wide-ranging civil freedoms, and those who aren’t tend to be dragged off the streets by men in dark suits and hustled into cars with tinted windows.

There is no government in the normal sense of the word; however, a small group of community-minded, liberal individuals is effectively ruled by the Department of Defence, with areas such as Religion & Spirituality and Social Equality receiving almost no funds by comparison. Citizens pay a flat income tax of 6%. A robust private sector is led by the Uranium Mining industry, followed by Cheese Exports and Retail.

Most of the military’s funding goes into researching space-age weaponry, the mining industry is making inroads into environmentally sensitive areas, citizens must pay to enjoy Bannannas’s pristine beaches, and Saturday morning cartoons feature full frontal nudity. Crime — especially youth-related — is crippling, and the police force struggles against a lack of funding and a high mortality rate. Bannannas’s national animal is the Ape, which is also the nation’s favorite main course, and its currency is the Bannanna.

Posted in funnies, Totally pointless.

Tagged with .


Looks like Facebook doesn’t perform idiot checks…

A few days ago (but for some reason this only reached the French IT press today), there’s been this story about this Khalil Shreateh guy, who seems to be currently freelancing as a security researcher.
To summarize it briefly, he reported a security issue to Facebook through the Facebook whitehat program, but his 2 reports were rejected (the second reply he got being “I am sorry this is not a bug” (!)). So he performed a proof a concept on Suckerberg’s Zuckerberg’s account, and now suddenly this became a valid bug: his account was temporarily locked until he contacted the bug report crew to sort things out. But they told him they wouldn’t pay for the bug (the whitehat program is supposed to give away rewards of 500$ or more per reported vulnerability), precisely because… he performed the apparently needed proof of concept. For the sake of clarity, the bug was that anyone could post on any other person’s timeline (a feature normally reserved to friends of the person owning the timeline)

The reason why I’m posting about this here (you may have noticed this is not usually a newspaper ^^) is because the few articles I read about it terrible. Oh yeah, and also because the vulnerability seemed to be trivial (hence the post title). The guy made a blog post explaining, I believe in good faith an accurate details, all what happened. If you’re (somewhat) used to bug reporting and basic security practices in web development and have a bit of time, just read his post. Otherwise, here’s a quick summary:

  1. the guy speaks poor English. I don’t mean this as a criticism, just as a fact that contributed to:
  2. his “reports” being indeed quite poor: they massively lacked explanations. A usual bug/vulnerability report is supposed to at least describe (even briefly) the steps to generate the issue. His just described the result, what’s more
  3. he chose a private (hidden) profile to perform the demonstration, so the engineer who received the report didn’t have access to the posting (and despite all the nasty things going with the NSA, and Facebook’s terrible privacy in general, it seems that, surprisingly enough, engineers are not allowed to access private posts). But at that point (first report),
  4. the Facebook security guy just replied he couldn’t see the post instead of asking for more accurate details (and perhaps a POC on a test account). A poor reply leading to another,
  5. Khalil’s second report was basically the same as the first one plus a screenshot,
  6. yet the issue, although (very) poorly described, was quite obvious.
  7. Still, the security guy’s second response was clear: “this is not a bug”.
  8. Khalil then performed the exploit on Zuckerberg’s wall (just to post a description of the exploit itself), to give it the attention that it should have gotten in the first place. He should have performed that on a test account though.

So, he made poor reports, and targeted a couple of real accounts for his demonstrations. Still, the vulnerability was real and the demonstrations were made in good faith, with no intention to harm. The second one was made on Zuckerberg’s account in order to tell Facebook about the problem, after the communication issue with the security idiot guy. The first one, well I believe maybe it was made accidentally during the discovery of the vulnerability. I think so mainly because of the choice of sarah.goodin in as target account. She’s not a famous person (a least not that I know of), he likely doesn’t know her, but she was a very early user of the site. More specifically her account number is 33. I think there’s a possibility that he typed that number at random when probing for the vulnerability.

Which leads me to my last point, the vulnerability itself. At the end of his post, Khalil posted a video (warning: Youtube) showing how the exploit is performed. Although, just like his vulnerability reports, the video fails at showing all the steps, it shows enough to assume with a fair degree of certainty that the vulnerability only involves some trivial manipulation of the wall posting source code. I checked the current code: it contains the user ID of the wall you are posting on. Probably the hack was just to replace that ID with the ID of your target and voilà. I don’t remember very accurately, but probably this was one of the first exercise on hackthissite.org when I used to play around (just had a quick look, lots of sad news on the front page at the moment :/). All this to say: this was a trivial vulnerability. The only reason it was hard to find is because it is such an obvious malpractice that you would assume that a big brother site such as Facebook would know better than this. Well, it turns out they don’t. And they don’t even pay up when someone comes and does the idiot check they should have done themselves in the first place…

PS: Ok, that was quite poorly written. In my defense it’s getting late here, and still it’s much better written than the original bug reports 😉

Posted in security, web development.


The Armed Republic of Bannannas: day 20

Some decisions have unexpected negative impacts on civil rights and economy… Like, refusing to subsidy some dying industry from the past can worsen economy, and refusing tax cuts to religion can lower civil rights… The reason for choosing dictatorship was to try and reduce the amount of election-related dilemmas. I think it didn’t work, but that probably helped achieve the top 5% for the world’s most extreme award ^^

Category: Benevolent Dictatorship
Civil Rights: Superb
Economy: Strong
Political Freedoms: Outlawed

The Armed Republic of Bannannas is a large, socially progressive nation, renowned for its irreverence towards religion. Its hard-nosed, hard-working, cynical population of 50 million enjoy great individual freedoms in everything except elections, which, where they exist at all, are populist shams for a dictatorship government that has no intention of ever giving up power.

The tiny, liberal, pro-business government devotes most of its attentions to Defence, with areas such as Religion & Spirituality and Social Equality receiving almost no funds by comparison. Citizens pay a flat income tax of 10%. A healthy private sector is led by the Uranium Mining industry, followed by Cheese Exports and Retail.

Psychological disorders are a taboo subject, major archaeological findings are frequently bulldozed to make way for new buildings, religious organizations are being forced to leave the country or pay income taxes like everybody else, and Bannannas is notorious for its citizens’ infidelity. Crime — especially youth-related — is crippling, and the police force struggles against a lack of funding and a high mortality rate. Bannannas’s national animal is the Ape, which is also the nation’s favorite main course, and its currency is the Bannanna.

Posted in funnies, Totally pointless.

Tagged with .


Where to download official Firefox APKs?

The main reason why I installed Cyanogenmod over my phone’s manufacturer’s Android was to get rid of all Google spying apps. Unfortunately, Android is tightly, militarily organized around Google tracking services. Notably, a huge majority of applications can only be obtained via the Google Play Store, because for some reason most developers don’t bother mirroring their APKs on their own.

Generally speaking, grabbing the APKs from Google Play is a game of cat and mouse, where the APK downloader extension for *cough* Chrome (works with Iron too, might be worth trying with Opera also, now that it’s turned into yet another Chrome clone) is the mouse regularly updated to bypass Google Play’s attempts at blocking it. In the case of Firefox, however, the APK can be found by searching through Mozilla’s FTP. If you try to get the Aurora version, you’ll notice that unlike stable and beta it’s not hosted on Google Play but on Mozilla’s servers. If you then browse around those, you’ll eventually also find APKs for beta and stable. For instance, the lasted stable version (at the moment Firefox 23) is available in this folder: https://ftp.mozilla.org/pub/mozilla.org/mobile/releases/latest/android/en-US/ (it’s the fennec-23.0.en-US.android-arm.apk file).

Note that F-Droid (a Google Play replacement with only open source apps, offering both automatic installation and APK downloads) is also a fine place to get APKs. And they do have Firefox stable there.

Posted in Cyanogenmod.


Full guide to install CyanogenMod 10.1.2 on LG Optimus G (part 1)

I’ve had a lot of trouble installing CyanogenMod on my LG Optimus G. The main reason for it was that most “guides” focus only on the ROM installation once the phone is prepared, which is trivial: preparation is the hard part. Quite frankly, some of those guides are so terrible that I suspect their authors didn’t even apply them… So, here is an all-inclusive guide (although maybe some steps aren’t as detailed as they could), from someone who actually did it. More specifically, my exact model is an E975.AFRABL, with stock ROM E97510B_00, quickly upgraded to E97510D_00 because I had to fix a soft brick.
I first thought I’d publish it at once, but since writing it takes longer than expected, I’ll split it in 2 parts. Here’s the first, let’s hope I’ll be able to write the second within a reasonable time frame.

First things first, an overview of what we’ll be doing:

  1. Number 1, and this is the most important part: installing a custom ROM voids the warranty of your device and may render it useless. This is also referred to as “bricked”. Soft bricked is when you can still access download mode for a chance to fix things (we’ll cover that later). Hard bricked is when nothing at all happens when you push the buttons of your phone, or any combination thereof (in this case, the phone is about as good as lost, although some skilled hardware ninjas might be able to do something to save the day if you manage to find – and pay – some).
    Long story short: this is a risky operation, proceed at your own risks. Also, make sure your battery is >90% before “doing stuff”.
  2. First we’ll provide a very brief overview of the phone buttons (like, how to boot in recovery)
  3. Then we’ll learn how to fix a soft brick, because that’s something quite likely to happen (I had one) if you mess something up at some point
  4. Then we’ll actually proceed to installing CyanogenMod, which can be described as a 3 steps procedure: 1. root your phone, 2. install a custom recovery (if you’re new to this, you can say it’s a bit like a bootloader or a BIOS), 3. actually install CyanogenMod

We will assume that you are doing this on a brand new phone, as I did, so we won’t take care of creating a backup of the data. However, if you do have valuable data that you want to keep (contacts, Angry Birds highscores – yeah that shocked me too but some people have that as “critical” data -, etc), you SHOULD REALLY REALLY make a backup of them, as a lot of installation/boot issues are fixed by wiping old data that may be incompatible with the newly install ROM.

Also, no matter what you do with your phone, you’ll need to install the USB drivers for the phone (currently LGUnitedMobileDriver S4981MAN38AP22 ML WHQL Ver 3.8.1.exe), which can be found on the LG support site (sorry I can’t link to the page, it’s region-dependent).

Brief overview of the phone buttons for booting

Basically, all revolves around the few “real” buttons, ie the power and volume buttons.

Obviously, power turns on the phone. When the phone is running normally, briefly pressing power locks the screen. Pressing it for a couple of seconds brings the shutdown/reboot screen. Pressing it for like 8 seconds shuts off the phone immediately.

When the phone is off:
– holding volume down + power for around 6-8 seconds should boot into recovery. I say “should” because this is one of the things I found the hardest to achieve. Really, this has been a major PITA to me. Note that on the stock ROM, there isn’t really a recovery: all this combination does is load the factory reset sequence (don’t worry, you’ll need to confirm it twice).
– holding volume up + power for some time should boot into fastboot. I have yet to find a guide explaining what’s the use of this… So as you can guess, I didn’t need to use that function, but if at some point you find a guide telling you to boot into fastboot, now you now how to do it.
– holding volume down + volume up (yes, both at the same time) + power for some time will boot into download mode. That’s actually the special boot mode I found the easiest to reach. Download mode lets you flash the phone with, most notably, a factory ROM.

How to fix a soft brick

I put this here in the tutorial because I believe it’s important to be ready to fix a soft brick before going further. Notably, it’s important to make sure that the tools I present here are still online, and if not, that you can find equivalents. So that if a soft brick happens, you can deal with it in a relaxed and swift way. But, as with the rest of this guide, the call is yours to make.
As far as I understood, soft brick means you can’t boot the phone normally nor in recovery mode. I believe I experienced a soft brick, although it’s possible that I just failed to reach the recovery (as I already mentioned, reaching recovery has always been a PITA to me in this process). Anyway, to fix a soft brick, you need to boot into download mode and reinstall a factory ROM:

  • First, get this tool, Original LG Firmware.rar. It will allow you to download the current official factory firmware for your specific phone (for this you’ll have to provide your phone model – E975 -, and CASE-SENSITIVE serial number).
  • Download said firmware using said tool. You’ll get a KDZ file (mine is E97510D_00.kdz), which should be around 1 GiB. Warning here : if this file is larger than 1 GiB (1 GiB, not 1 GB – 1GiB = 1024 MiB), some people have reported issues with flashing. I don’t know more about it, as mine is less than 1 GiB (it’s 1,031,733,248 bytes, which is 983 MiB)
  • Then (or while the KDZ is downloading), get this package KDZ_FW_UPD_EN.rar. It contains a tool to flash the KDZ to the phone, plus satellite tools to make it work. Extract the rar, then install msxml.msi, and launch Windows Enabler.exe: the latter will add an icon to the Windows taskbar. Click it, and it should read “On” (note that in my own fixing, I forgot to turn it on this way but it still worked…)
  • Once the KDZ is done downloading, launch your phone in download mode (volume down + up + power), then plug it to USB
  • Launch KDZ_FW_UPD.exe, and configure it as follow:
    Type: 3GQCT
    Phone Mode: CS_Emergency
    KDZ file: [go select the KDZ file you downloaded]
  • Then click “Launch Software Update”. It will first unpack the KDZ, then flash it on the phone. It should take about 10 minutes (I don’t remember exactly the time, but it was less than 10 minutes). During the process, you’ll see progress messages ending with IParam = XX, where XX is an incrementing number. When you see IParam = 90, the phone will reboot, but you should not touch it yet. Patiently wait until you see IParam = 1 again. And then maybe wait a bit to be sure it’s over, and you can then close the flashing program and unplug the phone.

The phone should be booted successfully, just like it was when you first bought it, although maybe updated a bit, since the only KDZ you can download, as far as I know, is the latest version. If it doesn’t you may need to wipe your data: to do so, just boot into recovery (holding volume down + power): on the stock ROM, the “recovery” only has the option to reset to factory settings (which wipes all data). If you need some more details on this (you shouldn’t, but just in case), see this post.

And this concludes part 1 (all strongly advised preparations), stay tuned for part 2 (actual installation: rooting, custom recovery, and flashing Cyanogenmod).

Edit: and here is finally part 2 🙂

Posted in Cyanogenmod, LG Optimus G E975.