Author Archives: ragnar0k

Some considerations on finance, security and Apple, JP Morgan and Sony attacks

Filed under Generic, Security

There is a side that seems to be unnoticed everytime there is a big attack that made me write this article – I wanted to do some considerations on how finance securitity and latest Sony attacks (but not only) are linked.

It seems that lately, big, widespread attacks make it on the news more often, and are becoming increasingly aggressive. Although I can make some technical considerations on this (and will do an an article later next week), I saw something strange in how the markets react to security breaches (and will go more into why companies should – and probably will – invest more on security later on).

Let’s start with JP Morgan.
The data of as many as 76 milion households and 7 milion businesses leaked – to an unknown extend (account details?). This will certainly expose those individuals/entities to easy social engineering attacks, which will be extremely hard to relate to the attack. So, what was the answer of the market to the attack?

None. Yes, that spike down later on might have been related to the attack, but as you have seen was soon recovered.

Let’s go a bit back in time to another story that made it on the headlines: Apple data leakage.
The attack involved hundreds of well known individuals in the end of August. Did the market react to this? Well, yes, for a period, but then again, no substantial loss.

Now, moving to Sony. Sony has faced issues with their security sistems since years. From the Playstation Network to Sony attacks, there is never an end.
Watching the Sony chart, it seems that the cause of the drop was not really related to the attack, but certainly that didn’t help for the future outlook. And the latest attack, didn’t seem to affect the market (see pointing up in the last tick).

I can do these examples for a while, but point is, it seems that attacks, at least in the short term, don’t affect the companies considerably. Is this then a good reason to reduce the costs of security?

Well, here are some considerations from my side:

  • Stock market seems to react more on the generic feeling of insecurity than a quantitative loss of customers/income given by the attack. This, I assume, is because it is extremely hard to quantitatively define the extent of the loss.
  • There are discussions, even driven by Wall Street, to improve cyber security regulations. The process might take a while to consolidate as it is a fairly new concern – the extent of attacks we have seen this year were seldom seen before. Litigations and regulatory fines will help Wall Street to quantify losses and protect investors.
  • Last but not least, the actual cost impact should be considered. A generic estimate considers the data leakage cost (including regulatory fines, fees, legal costs and so on) to be somewhere between 90$ to 300$ per user. In the case of JP Morgan, a conservative estimate would be 150$ * 80000000, accounting for an astonishing 12B$ loss.

Companies should be more concerned than ever on security as this is bound to become a huge topic in the future, particularly given the fact that 0 days vulnerabilities are extremely hard to tackle. But as always, only time will tell how the market will evolve in that sense…

…One side note…
JP Morgan announced it will double its spending on security since 2015 moving to 500M/year – good news. But then again, will those money be spent in the right places?

Hacking samba shares and attacking my Qnap (without Metasploit)…

Filed under Security, Systems

So, it has been a while since I made an article, unfortunately I spent (and probably will spend) too much time trying to recover my old V40 PC… Can’t wait to give it a hard drive 30 years later!

Back to hacking samba shares now (and my qnap server).
Let’s try to get some info on the server, nmap is always a good start

the Qnap server is not exactly ‘closed’ – but after all, it is a system for sharing, and is quite secure by itself when up to date. Let’s get some info on the HTTP side – netcat can help us.

So, it is running PHP 5.3.29. This version of PHP by itself has some remote vulnerabilities, but let’s move forward. They are hiding the Apache version! Bad for us but good job.

Let’s run nmap again and let’s see if we find something interesting. This time though, we run a serious scan with:
nmap -A -T4

Amongst the various info, I get to know the server is running kernel 3.4.6 and samba 3.6.4 – in particular this is interesting:

Ah – using guest on samba shares works! Let’s do a bit of tests on samba then. No need for a password when using guest usually

Unfortunately, none of those shares (except for IPC$, which is very limited) lets me connect as guest.

Let’s take another approach. Nmap is always our best friend (and the script smb-enum-users).

Good job nmap! :) Now we can do some good old bruteforce! Let’s target TestUser, which I created with a decently weak password. For this to work, we need a good dictionary of passwords, and the owner of the smb-brute redirects us here.
Unfortunately I wasn’t able to specify the password file to bruteforce the samba share using nmap + smb-brute, so had to create a script on my own… If you know how to please drop me an email!

Here is the script I created:

Few seconds after running the script:
./ “//victimHost/TestFolder” TestUser /home/ragnar0k/twitter-banned.txt
Login successful using password password123

To conclude – how to secure are samba shares?
This depends on how far you want to take your security – and mainly some common sense:

  • Make sure the minimum password complexity, retries and password expiration are enforced (works well with a centralized system such as Active Directory and Kerberos)
    • minimum password requirements: a meta character and numbers. This alone might not help you against a brute force attack
    • retries: after three wrong passes, an account should be locked. It is possible though to create tools that wait for the account to be unlocked and continue – if the pass is in the beginning of a dictionary, blocking accounts after a few retries alone won’t help
    • password expiration: if a tool is waiting for accounts to be unlocked, maybe after three or one year of daily unlocks, it might eventually guess the password (though I would become suspicious after a week…). Setting a pass expiration might help there (unless the user chooses the password next in schedule by the hacker).
  • If the user uses an external GUI to set the password (i.e. SSO), the validation form should first verify the password is not in the known passes list (from the link above). A good way to create a password database is to merge all the pass files in into one (cat * >> main_passes), and maybe import them in a database
  • Make sure passes are not repeated within 2 or 3 years



Are your devices secure? Firmware hacking

Filed under Arduino, Security

How to hack your firmware – this might seem like a complex topic. In some cases it is, but nowadays, this is not always the case.
Some unix skills and just a bit of social engineering might be enough to make your company or home insecure.
There are several ways through which a company or a person might have received a compromised device:

  • A company receives a demo hardware from the company in the mail, why not trying it?
  • The guy in the shop decided he wants to monitor his customers, how about quickly removing the seal and compromise the firmware?
  • The website sending firmware updates has been compromised (either from your side, for example through dns poisoning) or on their page
  • The firmware was downloaded from a strange internet source

There might be a few reasons more, but let’s get hands on and see how easy firmware hacking could be!I am trying this on my Arduino Yun, as it is using OpenWRT + squashfs. Squashfs is nowadays very used (see for example dd-wrt compatible devices).What we need is:

  • The firmware (in our case the Yun firmware is openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin)
  • A Linux box. For this blog entry I will use Debian, but I guess the same will work under ubuntu and other debian based distros

It is worth noting at this point that I fully support Arduino’s choice of using an open solution such as OpenWRT, and squashfs is not the problem. Hacking firmwares is still possible even using proprietary formats, as long as the source of the firmware (or person handling the device before you) is not trusted.

Let’s first install the right tools. As root, run:
aptitude install squashfs-tools

The tools we need: unsquashfs and mksquashfs.Now, let’s get some information on the file:
unsquashfs -s openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin

This should give an output such as below:
Found a valid SQUASHFS 4:0 superblock on openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin.
Creation or last append time Sun Nov  9 01:25:00 2014
Filesystem size 7799.69 Kbytes (7.62 Mbytes)
Compression xz
Block size 131072
Filesystem is exportable via NFS
Inodes are compressed
Data is compressed
Fragments are compressed
Always_use_fragments option is not specified
Xattrs are compressed
Duplicates are removed
Number of fragments 130
Number of inodes 2083
Number of ids 1

In particular “Compression xz” will be useful to us when rebuilding the package.
Let’s now decompress the filesystem in a working directory:
unsquashfs openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin

A new directory should now be present: squashfs-root. It will contain all the files of the router. The purpose of this article is of course only to demonstrate how we could compromise a firmware so will only create a simple example. Let’s create something that, at boot, will write under /tmp a file

First we go in /etc/init.d and create the script, which we will call “hackTest”.
The file will contain:
echo “This might be a virus :)” > /tmp/virusTest

Let’s make it executable now
chmod +x hackTest

…And link it to the correct start sequence in /etc/rc.d. In my case, I decided to set it to S94:
ln -s ../init.d/hackTest S94hackTest

Now all is good to go – let’s pack our squashfs. Go back to the folder containing squashfs-root and create the new firmware:
mksquashfs squashfs-root openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin -comp xz

Note “-comp xz”, this is the compression that was specified on the file info above.
All is now ready. Update the Arduino, wait for the reboot.

Now, I understand that someone might think: isn’t it easier to just modify the system once booted up?
Well, this is true but on a factory reset things will go back to normal. Also, most of those devices provide a limited set of  read/write directories, so searching for issues if someone gets suspicious is a lot easier.

So what is the solution?
Well, make sure once the firmware is downloaded that the MD5 is correct using a different source to get the md5 strings (for example, your desktop). If your firmware was however modified, chances are it will not upload the firmware or might automatically modify the firmware during the install. This is quite a difficult matter to resolve, and if we are ever going to go back to a mainframe architecture in the future (i.e. Chromebook) this will become an ever bigger issue, and making the firmware proprietary is not the solution (see the various iOS hacks).

Arduino Yun VS Raspberry PI B+

Filed under Arduino

Why Arduino Yun VS Raspberry PI B+? It is always good to have a direct comparison I think, and although I believe they cover two different areas (Yun remains solid on its Arduino foundations, while the Raspberry PI wants to be more like a mini-linux desktop)

I won’t go through the specs in detail, there are plenty of blogs for that. Suffice to say the arduino has basically one RJ45 ethernet port, one USB port, one micro-USB port (for programming and power); it can also connect through WI-FI.
The raspberry PI instead tries a bit harder to be a desktop, with 4 USB ports, one RJ45, one HDMI, headphone jack (with microphone) but no WI-FI. Both have a micro SD card slot. For this test I will use the same card type on both

SDHC card

What makes this test interesting is comparing a 700Mhz ARM platform (RPI) against a 400Mhz MIPS platform (Yun). The latter is slower on paper but OS is much more lightweight…


The Raspberry PI is definitely bigger, which is understandable given the additional ports.

Yun comparison

Arduino uses its standard linux distribution based on OpenWrt, much slimmer than the Raspberry PI Raspbian

The data
So, introduction gone, let’s do a bit of work. Python is present on both machines PI and Yun, but I decided to use perl, as I can also port it well on my e450. Yes, I will add my Sun e450 to the tests – and since I am at it, I will also add my Macbook retina.

First test: dd if=/dev/zero bs=40M count=1; sync


Second test: dd if=/dev/urandom bs=40M count=1; sync

Third test: calculate md5 of 394748 strings (separately)

Now, what comes out of it other than the E450 is almost getting beaten by small and embedded devices?
Well, the PI is generally faster than the Yun. But I don’t think being very fast was always the goal of the Yun. Yun provides all infrastructure for Arduino separately, but now it can be controlled from a separate linux system. Despite the linux part being “secondary” or a controller, if you wish, of the old arduino interface, it still manages to put up a decent performance. Yun’s linux is very basic in fact; even to use perl I had to upgrade the firmware and install the perl packages.
To conclude, if you would like to have a small PC with ok performance, PI would be for you. If instead you would like an arduino with an external linux controller that could influence certain loops in your system, then Yun is for you, just don’t expect a full-fledged linux system – it is just not what Yun was made for.

Sun e450 refresh guide [Part 1]

Filed under Systems

So it’s been a while as I have been on holiday – I am planning lots of things, and hopefully soon I will be able to dedicate some more time to security as I will dive more in security research (have lots of ideas on tools to write, maybe a re-code of annfid)
Now, amongst the various things, before the holidays I bought two Sun e450 (or enterprise 450) and thought about writing a proper Sun e450 refresh guide. I know what you are thinking – “your smartphone is more powerful”, but well, why would people buy commodores then?
Those things were quite pricey 10 years ago, but now I bought one with hard drives, all four CPUS for less than 100$ – so I bet then I am not the only one buying them.
This will be part one, I’ll write something more later with more screenshots.

So, here are a few tips:

This is the first issue you will find. NVRAM is probably dead!
You can say this from two things:
– The host id is something like ff:ff:ff:ff:ff (might have some ‘e’s or something else – it doesn’t matter)
– You type setenv and after a reboot it doesn’t pick it up.

Now, you will find online some guides to DIY fix the NVRAM; I honestly don’t think the site is a fake, but I can say the NVRAM mod did not work for me


There is no specific differences amongst NVRAMs that I know of, so I can’t see why a 450 would not take a modified NVRAM. In any case, there is a shop on ebay that can sell NVRAM for a decent amount of money; might be worth taking a look there as it worked for me straight away and could save quite some time (soldering the cables on the small NVRAM power pins is quite a challenge)!

If you are wondering where the NVRAM is, it is that PIC on top of the PCI slots with a yellow sticker/stripe. It is on top of a socket that is very easy to pull from the sides, I’ll put a screenshot when I have some time.

Maintenance light blinking
This is not a serious issue. The sun e450 owners manual (which is seriously worth reading if you are just getting started) suggests that unless there is a steady light, it is not an issue. Most times, by default, the system will enter in OBDiag (Open Boot Diagnostics), which can last for quite a while. In my case, it can take up to 10 minutes for the machine to start!

Default net boot
If your machine has been blinking until now, it will probably also boot the diagnostic device. Usually, the default boot device is set in the variable ‘boot-device’, you might want to put cdrom or disk there. But if the device boots after diagnostics, it will use the ‘diag-device’ variable. Just do a setenv diag-device disk and it will boot from disk. If you are stuck on the net boot, just press Stop + A to get to the Ok prompt.

Oracle being Oracle
Before you start you might want to know this: as I write, to get patches from Oracle you need to be approved as a client, so forget fixes (well, unless you are a company with a contract of course). Also starting from Solaris 11 our beloved Sparc II is no longer supported. Solaris 10 is the best we can get (which is not too bad actually); maybe you might want to install a Debian there or remove the hardware and use it as a funny PC case.

End of part 1

By the way, for cold winters, E450s are great heaters!


Arduino Pulsesensor review (with Arduino micro)

Filed under Uncategorized

So, in the previous post I said I am interested in hacking the human being…
Now, biohacking is not a new topic, there are plenty of websites and blogs on this, and I will surely cover the topic in more detail later.

Amongst the various topics (galvanic response, brainwave sensors and so on…) I think one good indicator is heartbeats. Heartbeats can increase or decrease under stress, so can be an excellent feedback mechanism. Fortunately, the company offers a little arduino pulse sensor exactly for this.
The sensor will use light reflection to track changes in our skin; those changes can be used to track the heartbeat (a similar mechanism is also used to track blood oxygenation).



The website claims this is a plug and play sensor for arduino… Not quite, I found (though the device is still quite impressive).

The sensor is quite small and fits well under the index finger – here it is next to the arduino micro I used for testing:

Pulsesensor + Arduino Micro

Pulsesensor + Arduino Micro

So, let’s plug it on our breadboard with arduino: pink cable on A0 (analog port), red on V3 and black on ground.

Arduino Pins

Arduino Pins

It is important first to isolate well the sensor, a plastic sticker is given to prevent moisture from interfering (should be applied on the “heart logo” part) and some insulation is due also at the bottom. Once this is done, let’s move to the code.

The website here is a bit confusing. The tutorial points to the version 1.1 of the code, which is not compatible with the latest amped version. I suggest to download the 1.2 code before anything from their code page.

At this point some customization is needed, as the code is written by default using an Arduino uno, whilst here I will be using an Arduino micro. Make sure both the interrupt.ino and PulseSensorAmped_Arduino_1dot2 are on the same arduino project (drag and drop the missing file) and move to interrupt.ino.
The first part to change (as noted on their tutorial instructions) is the interruptSetup part. Here are my entries for the arduino Micro:

The default code is pre-compiled for the arduino uno, hence the default values will not work. The second value to change is ISR(TIMER2_COMPA_vect), which on arduino micro is ISR(TIMER0_COMPA_vect)

Code can now be uploaded.
The second part now is for processing data. If you are not familiar with processing, just download it from their website and run the code downloaded from the pulsemonitor page.
Make sure the serial is correct there. Although comments say “get the arduino”, the tool will simply parse the first com port:

Fortunately this will also print the list of serials on the console; in my case I had COM1 and COM3, so my correct entry is the second:

Now all is set, let’s fire up the processing tool clicking on play…

Pulsesensor processing

Pulsesensor processing

And it works!

The heartbeats are way too high – I roughly think they are twice as many, so dividing the output by two will do until I have some more time; not sure if this is related to the arduino timer or the processing tool.

So, overall, this wasn’t exactly easy to setup, it is not very plug and play, but it really gets the heartbeats accurately (with the default code, the light on the arduino will blink on each heart beat), so will definitely investigate further…

Google XSS game

Filed under Security

Well, this has been covered widely but can’t stop from writing about it in my blog, as I just had some time to play with it:
Google XSS game
It actually brought me back to the time when I had fun with text only games (good old MUDs!) :)

Now, if you haven’t tried it, I strongly suggest to give it a go – the aim is to make an alert() pop up in different scenarios.
I have to admit, I seriously struggled with #4 (like, hours), but it was well worth it. And reading the tips on the site is not cheating, they are just useful enough.

For #6, feel free to use mine ( – won’t spoil with details, just make sure certificate is ok on your machine before you use it) :)
And yes, it is safe I just put alert() in it!


Why Facebook experiment doesn’t surprise me

Filed under Generic
Tagged as

I don’t generally express opinions, this is not the scope of my blog. But I have always been fascinated as social engineering was always seen as part of the “hacking” process. First hackers used social engineering quite a lot; anyone found of security read the story of Kevin Mitnik when young? A lot of his work involved social engineering, rather than pure hacking. And how not to mention the controversial Stanford experiment?

Many similar stories I am sure can be told and I won’t go through them here, but human manipulation is an extremely fascinating topic (though spooky): hacking the human being. 

Now, the discussion is around the latest research made by Facebook on how emotions can be ‘propagated’ and Facebook, by filtering negative emotions (friends posts), can manipulate the mood of the readers.

Why could this worry some?

Facebook is perceived as some kind of big brother (not going there, many sites expand on the topic), and this kind of manipulation is considered ‘evil’. The way I see it, this could be an ingenious way to improve sales.

Mood manipulation has always been used for sales – from the car salesman, to tv adverts – showing an image to the possible buyer that pleases him/her (like, an unlikely grateful kid because the mom used a new washing powder, or the car salesman asking the possible buyer to imagine him/herself driving the new car with all comforts). Putting people in a good mood helps selling in general; making people panic could help selling some other products (say, a pepper spray).

The problem here is that whenever we see an advert, or go and buy a car, we go in “defensive mode” so, we are expecting to be tricked. This time this happened without us being ‘conscious’; but are we sure this is news?

Let’s think now about something very common in Hollywood: product placement (i.e. when the cool, main character opens the fridge and drinks a fresh cola). Isn’t this the same principle?

As TV viewers decline, this is where the big bucks are, and I see Facebook research as just the next, logical step to product placement. After all, for the new generations, Facebook and youtube are the new TV, only this time product placement can be more emotional, personalised – hence more effective. 

So, is avoiding Facebook the answer? This is up to the reader.

Facebook will just have more ‘manipulation’ power, as the filtered information will come from our friends; but thinking that the problem is and will be limited to Facebook would be naive. Cookies and IP addresses are continuously collected, and our information is gathered online regardless of Facebook. All in all, it is important for the user to limit the shared information and remember that internet as a whole is mined by advertising. So, next time we want to hear an unbiased opinion, it might be best to just ring our friend, and just expect, whenever we switch on a monitor or a tv, to be bombarded by ads…

Protonmail security review

Filed under Security

Note: Protonmail is still in beta, so things might change

Protonmail promises to deliver security to the mail world, accessible without any kind of monitoring from their side. As I write, their project on has 27 days to go and already reached 128% of the goal.
So, after all the media coverage received by Protonmail, is it really going to be the next alternative to gmail?
But most importantly, is it as secure as it is advertised?
Let’s look into some of its features…



The interface is very simple, no fuss. Gladly, no advertising so far based on “anonymous data” collected from our mail context. That is a good start I think.
As promised, the javascript side is not compressed, leaving a bit of transparency to the user, but I’ll get to it in a bit…

The interface to compose mails is also very simple; would be comparable to any standard webmail client, if it wasn’t for the encryption features on the right:

We can encrypt the mail and give it an expiration. I am not quite sure why would an email expire when saving the contents for offline reading would be very easy, but let’s move on…

Debugging a little bit, seems clear that we use our public key client side to encrypt our mail:

So, the base encryption is AES256.

I believe arguments are then built within #totalpackage and sent (where the pgp part is added for * emails):

Then the draft is created:

This is good news – they are using the openpgp.js library to encrypt the messages, so it really happens all on the client side. Ok, but actually, this can be done using thunderbird too or most mail clients. That said, having it javascript based will give me the opportunity to have my pgp data always with me, even on someone else’s device.

Anyway, I clicked in the beginning to send the document encrypted externally. It seems to me that this part:

is responsible for encrypting outbound messages. It looks to me this will encrypt only the message with an hashed AES256 pass (see encryptMessage function in the code above). Keep this in mind, we will get into it in a bit.

We then receive the email from protonmail. Obviously no receiver PK is checked since we don’t know it (and I can’t find a way to add them)


The question at this point is…

Are external mails kept just encrypted using a sha256 of our password using AES256?
It might seem like an OK solution now, but I bet in 5 years time hacking a sha256 won’t take so long. Even now with supercomputers won’t take long to break this SHA256. I personally don’t think at this stage protonmail offers an adequately secure external email.

In addition to that, answering to external emails now is impossible, but this might change.

Now, let’s forget about the AES256 scenario for a while. What are the other issues?
Well, there are no signature and no certificate authorities here, so anybody with access to the mail and the password (let’s assume someone is sniffing chats + mails) can actually get the data.
Ultimately, not using public keys, will lead to an additional exchange of keys, which in turn leads to a less secure solution.

All in all, this is a well thought system, though I think little privacy is offered with externally encrypted emails (which – in theory – can be decrypted by the server owners), and even our local emails might not stand the test of times (also, how scalable is it? Will we be able in the future to change algorithms without rebuilding the whole inbox?)

Never the less, my support goes to the guys, it is a great step forward to what we had before and even though there is room for improvement (and well, it is always possible my analysis has some flaws so welcome to comment) this I think is one way to make cryptography really accessible to anyone.

…Just one last heads-up. There are some pretty heavy limitations (in particular if you are used to Gmail space):
Screenshot - 21.06.2014 - 02:10:25

Neural networks: anger!

Filed under Neural networks

I really love neural networks – they can do really everything, and I am convinced they will be more and more part of our future; from big data to site suggestions, I can see them trying to catch up…

But I can’t help but being annoyed sometimes when working with nets. I managed to write some time ago Annfid using entirely nets (Encog), which I think is great for forensic investigations, but then sometimes you might get stuck on little things, and that is where the pain starts.

So, I wanted to write a little article here on how to get going with neural networks, and here the disappointment comes. I fed the nets with some data like:

1 + 1 = -4

2 + 2 = -2

3 + 3 = 0

4 + 4 = 2

5 + 5 = 4

on 6 it becomes spooky, but here is more or less the baseline: all numbers are actually n = n – 3. This means that 3 = 0, and the results turn out normal. Strangely enough, neural networks could not resolve the simple pattern! Now, I have to admit for this code I used a new version of encog, but never the less, the net gets stuck during the training.
I write the code below, in case someone reads and might have some ideas…

By the way… new RequiredImprovementStrategy() is really a great idea (resets the net if there is no improvement >1% after the specified number of cycles)!

After this post I wrote on the encog forum. The project owner (Jeff Heaton, he actually answers on the forum!) pointed out that activation sigmoid requires an input between 0 and 1.
So, here is the corrected code, where 1 is 0.1 and 9 is 0.9, results are much better (sorry, wrote it in C# this time)!