731 points · by ndiddy · 2y ago · 97 comments
A random 2048-bit integer has a moderate chance of being trivially factorizeable (I don't know the precise odds but we can infer that it's roughly on the order of 2^-32 (for some definition of trivial) without doing any real math). Presumably, they wrote code that did something like this:
while true:
randomly tweak/increment 4 bytes of the public modulus
spend 1 millisecond trying to factor it
did it work? if yes, we're done here.
else, try again.
The resulting public modulus likely has lots of smaller factors (it should be possible to verify this, if anyone knows where I can find the "habibi public key"?). Although an RSA modulus normally has exactly 2 prime factors, the math still works out if you have more (as long as e is coprime).EDIT: Wikipedia says "The structure of the RSA public key requires that N be a large semiprime (i.e., a product of two large prime numbers), that 2 < e < N, that e be coprime to φ(N), and that 0 ≤ C < N." and later "the same algorithm allows anyone who factors N to obtain the private key."
which in the contest of the Xbox hack means that if you force N to be divisible by the prime 3, then the other prime which is used for generating the private key has to be N/3 => You have successfully factored it.
EDIT2: Here's code for signing with the Habibi key: https://github.com/XboxDev/xbedump/blob/b8cd5cd0f8b1cbc4e64f...
As you can see, it'll replace the last 4 bytes with 0x89, 0x9c, 0x90, 0x6b and then start by dividing it by 3 and using that to generate a suitable private key.
Here's the original public modulus as an integer: http://factordb.com/index.php?query=207401193272587237602760... (which can't be factored, at least not any time soon)
And here's the patched version: http://factordb.com/index.php?query=173718524353649322341982...
And exactly as you say, it's divisible by 3, leaving behind a single large prime (so I was wrong about there being more factors)
https://www.usenix.org/system/files/conference/usenixsecurit...
The chance is way, way, WAY larger than 2*-32. Consider the following code:
primes = [2, 3, 5, 7, ..., 499]
def miller_rabin(n, k): ... # your fast primarity test of choice
def is_prime_trivial(n):
for p in primes:
while n % p == 0:
n //= p
if n == 1:
return True
return miller_rabin(n, 20)
It fully factors a random 2048bit integer in around 100 tries, for me.Xbox 360...._softmod_.... via the park name on a Tony Hawk game.
24 segment ROP chain :')
His rightful lamentation for the hypervisor, concise functional write up, and immediate thoughts of an x360 botnet make this the greatest xbox 360 nostalgia gut-punch of all time.
kudos++
it really ought to have been strncpy, I'm sure Tony Hawk who's lauded for his advocacy of safety gear would prefer to be associated with safer string copying
basically you should almost never use strncpy; it's specifically for fixed-size fields like this:
struct dirent { unsigned short inode; char name[14]; };
and in those cases more often than not the pad byte should be a space rather than a nulstrncpy should never have been added to the standard library
The real issue I've ran into is that "strncpy" assumes the source is null-terminated.
Or move up from the 1970's Bell Labs, adopt C++ with the respective compiler switches to have bounds checking enabled for operator[]().
Better yet, use something else instead of one of those two, pick whatver is your fancy.
if (!addrparse(arg)) { err_syntax(); return; }
flagbarf = bmfcheck();
seenmail = 1;
if (!stralloc_copys(&rcptto,"")) die_nomem();
if (!stralloc_copys(&mailfrom,addr.s)) die_nomem();
if (!stralloc_0(&mailfrom)) die_nomem();
out("250 ok\r\n");
basically you have a struct with buffer-pointer, length, and capacity fields, like a golang slice, and you modify it with a small number of functions which reallocate the buffer if it isn't big enough. the ones you see here are stralloc_copys, which sets the buffer contents to the contents of a nul-terminated string, and stralloc_0, which appends a nul to the buffer. there are also functions for appending an arbitrary byte, for copying one stralloc to another, for copying counted strings into strallocs, and for concatenation, for determining whether one is a prefix of another, etc., but depending on the application, you may or may not need to implement thesethe whole stralloc library is 97 lines of k&r c, so reimplementing the part you need for a given program is pretty trivial. it's in the public domain
for most programs, a disadvantage of the particular way that stralloc is implemented in qmail is that you have to check every single copy or concatenation operation for an out-of-memory error, as you see above. this makes your code a lot longer. many applications are better off just aborting inside the memory allocation function if they run out of memory; getting out-of-memory handling correct is very difficult, especially if you don't devote a massive amount of effort to testing out-of-memory conditions (because they won't occur often enough just by chance to test your error-handling path)
(another disadvantage of the way stralloc is implemented is that you probably don't really want to use unsigned int for the two length fields on lp64 platforms)
for some applications you might prefer just using strdup() (or xstrdup()) or non-owning string-view types (a pointer and a length, perhaps into an input file you've mapped into memory), or lisp-style symbol interning (plus some kind of buffer management probably). arena allocation, if you can afford it, makes dynamic memory allocation for strings a much more reasonable thing to do: no risk of a memory leak, fast allocation, instant deallocation. but again some applications do poorly with arena allocation
but please don't fill your program with fifty zillion string buffers of arbitrarily chosen sizes and then try to separately pass the right size in seventy zillion string-processing function calls. your code will be hard to read, buggy, and probably insecure. factor string buffer length handling into a small part of your program so that most of your code never has to think about string buffer lengths
In this case, StringCchCopyW(), or StringCbCopyW() would be a better choice than strcpy.
https://m.youtube.com/watch?v=ob0dI05Xz8s
Koston did not invent the thing but has been a major popularity contributor to it.
https://www.surfertoday.com/skateboarding/why-do-skateboarde...
The mod itself is over 10 years old now, and I think the original developers are gone, explaining why no one was interested in fixing it when Ryan reported it. But this means that now the mod is unusable, no one is going to want to risk a full privilege exploit taking over their PC.
Hopefully this article reaches someone who's a bit more interested in patching the mod.
A question I have is where/when/how the corresponding private habibi key was released/leaked, if the story about it being used exclusively by the linux console group to prevent pirated content from being used is true. OP clearly was able to patch the four byte difference between the MS key and the habibi key to then run "unsigned" (but, actually, signed with the habibi private key) executables, so they clearly got their hands on it.
I've been doing some PSX decompiling and there are lots of similar things there as well. Interestingly, something like `memmove` is linked in using an SDK library[0], but `strcpy` is a function provided by the BIOS. Later version of the SDK could patch that out for a library version, but as late as 1997 it hadn't been.
0 - https://github.com/Xeeynamo/sotn-decomp/blob/master/src/main...
Now there are the N64 games being ported to PC with decompilers, I can only hope. Inb4 "there are native PC versions of these, you know"... most recompiled N64 games with the FX's being 'deshaderized' to pure textures (or simpler FX's) can be run in toasters such as cheap netbooks from 2009 and nearly anywhere.
They even ported Super Mario 64 to the 3DFX API. I know, the most complex games accesing the N64 framebuffer with complex FX will require OpenGL 3.3 to mimic that microcode; but, as I said before, when the engines run uber-fast on anything post Pentium III, is not something difficult to 'mimic' these in software while the rest it's running GL 2.1 accelerated.
That's... not surprising. UltraHLE ran SM64 like a dream, and the HLE bit referred to the fact that the emulator translated 3D calls to the Glide API rather than attempting to emulate the 3D hardware directly.
Once your run the games at 1024x768 and up that doesn't matter at all:
sm64ex, perfectdark, zeldaoot for PC...
Great article!
(Completely separate from that, consoles shouldn't be treating users as the adversary, but given that they do, games are failing to have a security mindset consistent with that stance.)
I would 100% agree with this when talking about a normal computer, but I kind of feel differently about consoles. How do you prevent cheating in online games if you don't restrict what users can do?
2) Group players by apparent capability and observed behavior, such that cheaters end up only playing with other cheaters.
2. is a research project that will probably never pan out.
A single cheater can often ruin games for hundreds or even thousands of players very easily. For experienced players, seeing a single flying aimbot shithead in your lobby just means there are 10 other cheaters in the lobby too -- ones using subtle ESP/wallhacks that can be extremely difficult to detect, by design. Shady websites like G2A or GMG that sell keys (which are almost 100% hot keys, to really make it all come full circle) mean that even if you get banned, buying new keys for a new copy of the game is extremely cheap, especially when many of these games have items that can be sold for IRL cash in various ways, games like Rust. For many parts of the world, selling/trading rare items to players can net you plenty of actual income -- and getting banned means nothing as a result. Instant banning cheaters the second they are confirmed leaks information to the cheater and cheat creator, today most games like Warzone or Destiny have to play psyops and shroud their exact detection techniques in part by doing "ban waves" only when they accumulate a mass amount of confirmed cheaters. The cheater that ruined your top score may, necessarily and by design, be allowed to run free for a while.
The net result of all this is that designers and -- importantly, even though people on Hacker News don't want to hear it -- PLAYERS tend to overwhelmingly prefer prevention instead of reaction. They are both needed. Players are not morons who love installing rootkits. But on the whole, preventative measures tend to be more valuable to players and creators than reactionary ones, even if they are all ultimately imperfect.
In a funny twist, games like Tarkov and Rust do have a gameplay mechanic that reduces the long-term psychological devastation of cheaters and is not invasive at all: they reset all content in the game to "neutral" every once in a while, so basically all your stuff gets deleted, and everyone starts over again. (This non-permanence is probably one of the reasons players stick with the game, despite cheaters, which are incredibly infuriating.)
Can I ask if you seriously play any online competitive games, at a high level or otherwise? Because I do, and I'll be honest: I've been hearing it all for 20 years. These types of approaches have had success (CS's player review system, certain shadowban systems, "trip wires" that trigger on impossible game behavior), but there is no single approach that has proven itself to be the ultimate universal solution. There is no universal, wibbly wobbly bullshit stats algorithm you run on your servers to "solve" this. These problems are not solved. I don't like it. I don't run certain games with certain forms of anticheat. But it is what it is.
(Which is presumably "the first recorded" but I'm guessing if someone had done it, they'd have been shouting about it and -probably- the only kind of person who could pull it off would be a pro skater anyway?)
The rarity of seeing a 720 or above has as much to do with the fact that most skaters don’t skate vert - instead skating street or smaller transition - as the trick’s difficulty. Outsiders tend to imagine large spins are the holy grail of skate moves but almost all skaters aren’t interested in them for aesthetic reasons among others.