Hey! I'm David, a security consultant at Cryptography Services, the crypto team of NCC Group . This is my blog about cryptography and security and other related topics that I find interesting.

# Big Numbers

## posted February 2015

An amazing story by Scott Aaronson on Big Numbers.

Keywords: exponential growth, NP-complete problems, Ackermann sequence, Turing Machine, Halting Problem, Busy Beaver,

some quotes :)

In an old joke, two noblemen vie to name the bigger number. The first, after ruminating for hours, triumphantly announces "Eighty-three!" The second, mightily impressed, replies "You win."

Consider, for example, the oft-repeated legend of the Grand Vizier in Persia who invented chess. The King, so the legend goes, was delighted with the new game, and invited the Vizier to name his own reward. The Vizier replied that, being a modest man, he desired only one grain of wheat on the first square of a chessboard, two grains on the second, four on the third, and so on, with twice as many grains on each square as on the last. The innumerate King agreed, not realizing that the total number of grains on all 64 squares would be 264-1, or 18.6 quintillion—equivalent to the world’s present wheat production for 150 years.

Rado called this maximum the Nth "Busy Beaver" number. (Ah yes, the early 1960’s were a more innocent age.)

To solve the Halting Problem for super machines, we’d need an even more powerful machine: a ‘super duper machine.’ And to solve the Halting Problem for super duper machines, we’d need a ‘super duper pooper machine.’

If we could run at 280,000,000 meters per second, there’d be no need for a special theory of relativity: it’d be obvious to everyone that the faster we go, the heavier and squatter we get, and the faster time elapses in the rest of the world. If we could live for 70,000,000 years, there’d be no theory of evolution, and certainly no creationism: we could watch speciation and adaptation with our eyes, instead of painstakingly reconstructing events from fossils and DNA. If we could bake bread at 20,000,000 degrees Kelvin, nuclear fusion would be not the esoteric domain of physicists but ordinary household knowledge.

But do people fear big numbers? Certainly they do. I’ve met people who don’t know the difference between a million and a billion, and don’t care. We play a lottery with ‘six ways to win!,’ overlooking the twenty million ways to lose. We yawn at six billion tons of carbon dioxide released into the atmosphere each year, and speak of ‘sustainable development’ in the jaws of exponential growth.

comment on this story

# Using crypto to replace database access.

## posted February 2015

A pretty fresh article on how you could use crypto to replace a lot of complicated schemes you might use on your website like password reset or mail confirmation:

tl;dr: instead of creating a table for tokens, you could create the password reset url like this:

and at the place of the token you would put the output of a MAC. Checking the MAC again after receiving the url would confirm that YOU created that url and it has not been modified. Remember, MAC provides integrity and authentication. The author also provides a way to only render this usable once: use the original hashed password as a nonce.

comment on this story

# Babun, Cmder and Tmux

## posted February 2015

I've used Cmder for a while on Windows. Which is a pretty terminal that brings a lot of tools and shortcuts from the linux world. I also have Chocolatey as packet manager. And all in all it works pretty great except Cmder is pretty slow.

I've ran into Babun yesterday, that seems to be kind of the same thing, but with zsh, oh-my-zsh and another packet manager: pact. The first thing I did was downloading tmux and learning how to use it. It works pretty well and I think I have found a replacement for Cmder =)

Here is a video of what is tmux:

# Implementation of Coppersmith attack (RSA attack using lattice reductions)

## posted February 2015

I've implemented the work of Coppersmith (to be correct the reformulation of his attack by Howgrave-Graham) in Sage.

You can see the code here on github.

I won't go too much into the details because this is for a later post, but you can use such an attack on several relaxed RSA models (meaning you have partial information, you are not totally in the dark).

I've used it in two examples in the above code:

## Stereotyped messages

For example if you know the most significant bits of the message. You can find the rest of the message with this method.

The usual RSA model is this one: you have a ciphertext c a modulus N and a public exponent e. Find m such that m^e = c mod N.

Now, this is the relaxed model we can solve: you have c = (m + x)^e, you know a part of the message, m, but you don't know x. For example the message is always something like "the password today is: [password]". Coppersmith says that if you are looking for N^1/e of the message it is then a small root and you should be able to find it pretty quickly.

let our polynomial be f(x) = (m + x)^e - c which has a root we want to find modulo N. Here's how to do it with my implementation:

dd = f.degree()
beta = 1
epsilon = beta / 7
mm = ceil(beta**2 / (dd * epsilon))
tt = floor(dd * mm * ((1/beta) - 1))
XX = ceil(N**((beta**2/dd) - epsilon))
roots = coppersmith_howgrave_univariate(f, N, beta, mm, tt, XX)

You can play with the values until it finds the root. The default values should be a good start. If you want to tweak:

• beta is always 1 in this case.
• XX is your upper bound on the root. The bigger is the unknown, the bigger XX should be. And the bigger it is... the more time it takes.

## Factoring with high bits known

Another case is factoring N knowing high bits of q.

The Factorization problem normally is: give N = pq, find q. In our relaxed model we know an approximation q' of q.

Here's how to do it with my implementation:

let f(x) = x - q' which has a root modulo q.
This is because x - q' = x - ( q + diff ) = x - diff mod q with the difference being diff = | q - q' |.

beta = 0.5
dd = f.degree()
epsilon = beta / 7
mm = ceil(beta**2 / (dd * epsilon))
tt = floor(dd * mm * ((1/beta) - 1))
XX = ceil(N**((beta**2/dd) - epsilon)) + 1000000000000000000000000000000000
roots = coppersmith_howgrave_univariate(f, N, beta, mm, tt, XX)

What is important here if you want to find a solution:

• we should have q >= N^beta
• as usual XX is the upper bound of the root, so the difference should be: |diff| < XX
comment on this story

# Nothing up my sleeve numbers

## posted February 2015

Why does the round constants in sha1 have those specific values?

Kt is the round constant of round t;

from SH1-1 - Wikipedia:

The constant values used are chosen to be nothing up my sleeve numbers: the four round constants k are 230 times the square roots of 2, 3, 5 and 10. The first four starting values for h0 through h3 are the same with the MD5 algorithm, and the fifth (for h4) is similar.

In cryptography, nothing up my sleeve numbers are any numbers which, by their construction, are above suspicion of hidden properties. They are used in creating cryptographic functions such as hashes and ciphers. These algorithms often need randomized constants for mixing or initialization purposes. The cryptographer may wish to pick these values in a way that demonstrates the constants were not selected for a nefarious purpose, for example, to create a backdoor to the algorithm. These fears can be allayed by using numbers created in a way that leaves little room for adjustment. An example would be the use of initial digits from the number π as the constants. Using digits of π millions of places into its definition would not be considered as trustworthy because the algorithm designer might have selected that starting point because it created a secret weakness the designer could later exploit.

# gwern trying to crack DPR's PGP

## posted February 2015

After some evidences of the Silk Road trial got out, Gwern noticed a PGP key was in here...

This is the ASCII-armored private key of the main DPR public key, the one he signed forum posts with and messaged with people. I was surprised to see it screenshotted like that, and I thought it would be hilarious if I could take the private key and announce that I was actually the real DPR by signing it with his key (since I've occasionally been accused of it).

more on the story here

comment on this story

# Vim cheatsheets

## posted February 2015

I'm using cmder on windows, it's pretty and it comes with a lot of unix tools (cat, ls, bash, ssh, more, grep...) and pipes and streams and... I can use vim in the console. Not emacs, vim. I do have emacs on windows but I don't think I can do a emacs -nw to just use it from the console. So let's go back to learn vim, because I hate being slow. And here is a nice way of doing it!

http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html

you can find several pictures of a keyboard aiming at teaching you step by step how vim works. This is all I needed!

comment on this story

# Flint vs NTL

## posted February 2015

I'm digging into the code source of Sage and I see that a lot of functions are implemented with Shoup's NTL. There is also FLINT used. I was wondering what were the differences. I can see that NTL is in c++ and FLINT is in C. On wikipedia:

It is developed by William Hart of the University of Warwick and David Harvey of Harvard University to address the speed limitations of the Pari and NTL libraries.

Although in the code source of Sage I'm looking at they use FLINT by default and switch to NTL when the modulus is getting too large.

By the way, all of that is possible because Sage uses Cython, which allows it to use C in python. I really should learn that...

EDIT:

This implementation is generally slower than the FLINT implementation in :mod:~sage.rings.polynomial.polynomial_zmod_flint, so we use FLINT by default when the modulus is small enough; but NTL does not require that n be int-sized, so we use it as default when n is too large for FLINT.

So the reason behind it seems to be that NTL is better for large numbers.

comment on this story

## posted February 2015

Silk Road's trial just closed and I ran into this old (?) journal of Ross Ulbricht that contains quite a bunch of interesting passages. I think this will turn into a movie.

03/25/2013
server was ddosed, meaning someone knew the real IP. I assumed they obtained it by becoming a guard node. So, I migrated to a new server and set up private guard nodes. There was significant downtime and someone has mentioned that they discovered the IP via a leak from lighttpd.

03/28/2013
being blackmailed with user info. talking with large distributor (hell's angels).

03/29/2013
commissioned hit on blackmailer with angels

04/01/2013
got word that blackmailer was excuted created file upload script started to fix problem with bond refunds over 3 months old

04/02/2013
got death threat from someone (DeathFromAbove)

04/04/2013
withdrawals all caught up made a sign error when fixing the bond refund bug, so several vendors had very negative accounts. switched to direct connect for bitcoin instead of over ssh portforward received visual confirmation of blackmailers execution

04/06/2013
gave angels go ahead to find tony7

04/08/2013
sent payment to angels for hit on tony76 and his 3 associates

04/21 - 04/30/2013
market and forums under sever DoS attack. Gave 10k btc ransom but attack continued.

05/04/2013
attacker agreed to stop if I give him the first $100k of revenue and$50k per week thereafter. He stopped, but there appears to be another DoS attack still persisting

05/07/2013
paid $100k to attacker 05/22/2013 paid the attacker$50k

05/29/2013
rewrote orders page paid attacker $50k weekly ransom$2M was stolen from my mtgox account by DEA

09/19 - 09/25/2013
red got in a jam and needed $500k to get out. ultimately he convinced me to give it to him, but I got his ID first and had cimon send harry, his new soldier of fortune, to vancouver to get$800k in cash to cover it. red has been mainly out of communication, but i haven't lost hope. Atlantis shut down. I was messaged by one of their team who said they shut down because of an FBI doc leaked to them detailing vulnerabilities in Tor.

09/30/2013
Had revelation about the need to eat well, get good sleep, and meditate so I can stay positive and productive.

All of this sounds so surreal. He is making a huge amount of money for sure. A million dollars doesn't seem much for him. He is constantly buying servers and he seems to be coding a lot. He also seem like a normal dude.

And here's a funny thread on who's Variety Jones

comment on this story

# Magma vs Sage vs Pari

## posted February 2015

I was looking for a way to know what are the real differences between magma, sage and pari. I only worked with sage and pari (and by the way, pari was invented at my university!) but heard of magma from sage contributors.

From the sage website: The Sage-Pari-Magma ecosystem

The biggest difference between Sage and Magma is that Magma is closed source, not free, and difficult for users to extend. This means that most of Magma cannot be changed except by the core Magma developers, since Magma itself is well over two million lines of compiled C code, combined with about a half million lines of interpreted Magma code (that anybody can read and modify). In designing Sage, we carried over some of the excellent design ideas from Magma, such as the parent, element, category hierarchy.

Any mathematician who is serious about doing extensive computational work in algebraic number theory and arithmetic geometry is strongly urged to become familiar with all three systems, since they all have their pros and cons. Pari is sleek and small, Magma has much unique functionality for computations in arithmetic geometry, and Sage has a wide range of functionality in most areas of mathematics, a large developer community, and much unique new code.

I also noticed that Sage provides an interface to Shoup's NTL through ntl. functions. Good to know!

1 comment

# A Brief History of NSA Backdoors.

## posted February 2015

here's an entertaining piece about NSA backdoors through history: http://ethanheilman.tumblr.com/post/70646748808/a-brief-history-of-nsa-backdoors

1997 Lotus Notes: The NSA requested that Lotus weaken its cryptography so that the NSA could break documents and emails secured by Lotus notes. This Software was used by citizens, companies and governments worldwide.

comment on this story

# Get settled in Bordeaux: the true guide.

## posted February 2015

I'm leaving soon for Chicago and I haven't found the "let's give you a crash course of the city's inside" kind of guide I was looking for. I've also wanted for a long time to write a no bullshit guide on how to manage moving to Bordeaux. So here it is. It's gonna be short, concise and maybe not very ethical.

# Apartment

• avoid the only hostel of the city at all cost
• avoid the kind of agencies where you have to pay a fee (more than 100€ usually) to be able to visit places.
• if you are looking for an apartment during July, August, September... you're in for a bad time. Don't bother finding a real place, just find a sublet for a couple months until things calm down.
• how to find a place? Go on leboncoin (and nowhere else). check "particuliers" to have only landlords, refresh the page and call asap. Always have plenty of documents on you because if you find the place of your dream you might have to fill and sign on the spot. If you don't know what documents you need ask the first landlord you call.
• If you can't have a garant (guarantor) then check out Clé Acquitaine
• need furniture ? cutlery? a bike? Wait for periods when people are leaving: December/January or May/June. People dump free stuff in the streets (really) or sell them for an incredible low price. The Erasmus facebook group of the current year is where it's at. Don't hesitate to bargain, and take your time.
• see the map I posted here? You want to live in the yellow or the orange. The city is pretty small so the other colors should be ok as long as you don't go too far. Never go to the other side of the river though.

# Transports

• you should buy a bike. Not too expensive because you will probably get it stolen.
• don't pay for a pass, you will never see ticket inspectors. And if you meet one, be sure to have one ticket on you so that you can get a 50% discount on your fine!
• need to go to the airport ? Take the line 1 at Quinconces.

# Food

• Never go to KFC and subway. Nobody go there and it's never fresh. Avoid 2€ kebabs. People will tell you about the Coluche being the best kebab place of the city but you will want to avoid this as well. L'Entrecôte and Fufu have huge lines but they are not that special. Go check out Santosha and Pitaya, amazing thaï/vietnamese places.
• check Del'ice n'coffee or Verde Nero.

# Drinks

• iBoat should be a safe bet. Although it might be a bit selective and far away. La Plage is the biggest club I've been in France, it's close to the center, it's free on Thursday and it's full of girls.
• There are quizzes everyday in Bordeaux. Just ask your favorite bars. Avoid Place de la Victoire. Try not to always go to Charles Dickens or HMS or...
• La Maison du Vin. Go to this place. As much as you can. It's cheap, classy and the wine is very, very, very good. Try some Sauternes or some Loupiac or some Montbazillac.
• There are other more expensive places you can drink wine at. Check La Bbelle Campagne or in the same street rue des bahutiers.
• I said earlier never to go to the dark side of Bordeaux (across the river), but you can go if you want to see Darwin. It's a place with many things to do and I won't spoil it for you.
• If you need to buy alcohol late. There is a casino that sells until 10pm near the tram tracks between Victoire and Musée d'Acquitaine. Other small shops Cours Victor Hugo or Cours de l'Yser might as well. After 10pm check around Place du Parlement and you will find some shops selling illegally.

# Internet & Phone

• every year in june/july/august/september even november. When people move and need to subscribe to a new internet company, you usually have extremly cheap offers where you would pay like 2€/months for a year instead of 20. Check vente-privee.com this is where everything is at.
• still on vente-privee.com, and during the same periods, you will find mobile company doing the same agressive offers. This is the moment to get real cheap plans. It really doesn't matter what company, they are all the same. Although you might not have a great internet connection with "Free".
comment on this story

# Firefox Time Tracker : update 2

## posted February 2015

I shipped!

You can get the .xpi on the github repo. Just open it with Firefox and no restart is needed! (Ctrl+O in firefox)

For now it's very basic. You will see this icon next to the close button:

Yes I know I should create a custom icon :D but I was too busy coding. You will then see some basic statistics of the day.

I'm now working on making this page nice with pretty graphics and more statistics (week, month, tracking of the most visited website of the week...).

So if you want to try my plugin, know that it works (so far)! And that you should pay this blog a visit because I'm planning on updating it.

comment on this story

# A tutorial on how to get into an admin account on ANY windows.

## posted February 2015

A step by step tutorial showing you how to get admin credentials on a windows machine: http://imgur.com/gallery/H8obU

tl;dr:

• reboot in start-up repair mode
• thanks to notepad replace sethc 1 with cmd
• so now when you press 5 times on shift it will call cmd instead of sethc 1
• you know have a shell, use command net localgroup Administrators to get a list of the admins
• type net user <ACCOUNT NAME HERE> * to change one account's password.

If you're looking for a "fix", microsoft advise you to turn off sticky keys all completely

And here's another exploit for windows 98

Note that as soon as you can access the hard drive, you don't need to use the first trick and can switch around programs in system32 as you wish (except if windows is encrypted with bitlocker). For example you can do this with an ubuntu live cd and swap cmd with the magnifier tool and you will be able to do the same thing.

comment on this story

# Firefox Time Tracker

## posted February 2015

I always thought I could reduce the amount of time slacking if I could track my time on facebook, reddit, hackernews... like I track my calories intake to reduce my weight. I couldn't find a good firefox plugin for that so I decided to make one.

I'm opensourcing the code right here: https://github.com/mimoo/FirefoxTimeTracker

I'm pretty surprised with Firefox SDK and it's actually easier than what I thought to build a browser plugin. It might also help that everything Mozilla documents is clear and pretty.

At the moment the code successfully logs the time passed on different websites across sessions. It just lacks nice graphs. If you want to try it just wait a couple days until I ship.

comment on this story