fortyseven

Hacking Reality to Save the Princess

2020-09-13 

Came across this over on Hacker News this morning and left a brief thought on it over there (that I’m sure has been ripped to shreds by now). (EDIT: Not so much. But we did reach similar endpoints. Thanks, guys!)

Long story short, even shorter: player manipulates and aligns glitches to basically rewrite the code’s stack to force the game ending sequence to execute. Goes from title screen to prince rescued in ~3 minutes.

From a hacker perspective, this kind of thing is — πŸ˜˜πŸ‘Œ — excellent. Even if the player didn’t consciously decide to manipulate the stack but happened to stumble onto a combination to make it work, it’s still super cool to break it down, which is what this video does.

Originally this post was a reflection on the ethics of this kind of thing being considered a ‘world record’, and how I’d rather see them split this out into it’s own category.

Instead of investigating first, I just vomited out all my thoughts and feelings without actually seeing how the world decided to handle this. I ran on an assumption. And it was wrong.

Because they DO break it out by category:

Here’s how they break it down — and they are NOT fucking around:

100%

Beat the game, entering and completing every stage and Hammer Bros. fight.

  • Time starts on pressing Start on the title screen.
  • Time ends on entering the door after defeating Bowser.

This category includes:

  • All action stages (numbered stages, fortresses, airships, plants, hands…)
  • All overworld Hammer Bros. (including their Boomerang, Fire and Sledge Bros. variations)

Important notes:

  • Do not forget the Fire Bros. behind the rock in world 2, the two plants in world 7 and the three hands in world 8!
  • If you accidentally transform some Hammer Bros. into a coin ship, you must either beat the coin ship or die on purpose during the coin ship to transform it back into Hammer Bros. and then defeat them.
  • Mushroom houses, card games, roulette games and overworld pipes are allowed but not required.

Banned emulators: ZSNES (any version), SNES9x 1.4x

Any% Warpelss

Beat the game as quickly as possible without using any wrong warps or warp whistles. Warp whistles may be collected but not used.

Time starts on pressing Start on the title screen.
Time ends on entering the door after defeating Bowser.

Banned emulators: ZSNES (any version), SNES9x 1.4x

Any% (No Wrong Warp)

Beat the game as quickly as possible without using any wrong warps.

Time starts on pressing Start on the title screen.
Time ends on entering the door after defeating Bowser.

Banned emulators: ZSNES (any version), SNES9x 1.4x

Any%

Time starts on pressing Start on the title screen.

Time ends when Mario is visible in the princess’ chamber. If the game crashes, the run is invalid.

Banned platforms: Virtual Console, NESClassic, BizHawk (QuickNES core)Note that BizHawk with the NESHawk core is allowed.

And these are just the Super Mario Bros. 3 specific rule sets. Other games have different rules.

For instance, Portal has “Out of Bounds” (any and all tricks allowed), “Inbounds” (camera and portals cannot leave the map), “Glitchless” (use none of the officially recognized glitches), and “Inbounds No SLA” (Save/Load Abuse).

Even something like bloody Cookie Clicker has a whole bunch of rule sets: “1 Million Cookies“, “Neverclick” (bake 1 million cookies without clicking the cookie <= 15 times), “True Neverclick” (bake 1 million cookies without clicking the cookie at all), “Hardcore” (bake 1 billion cookies without upgrades), “40 Achievements” (guess), “1 Heavenly Chip” (πŸ™).

Finding this out was pretty amazing. Not only were my concerns alleviated, but I’ve actually found a brand new level of respect for the speedrunning. πŸ™‚

And I was able to salvage a lengthy post, and turn it into something positive. Everyone wins!

Gangster Computer God Worldwide Secret Containment Policy

I didn’t go over every word of this, but I’m fairly sure these are the reenacted insane ramblings of Francis E. Dec. Besides, the phrase “Gangster Computer God” is pretty much his THING. πŸ˜‰

Francis E. Dec (January 6, 1926 – January 21, 1996) was an American lawyer and outsider writer who was best known for his typewritten diatribes that he independently mailed and published from the late 1960s onward. His works are characterized by highly accusatory and vulgar attacks on various subjects, often making use of phrases like “Mad Deadly Worldwide Communist Gangster Computer God” to slander hierarchies that he believed were engaging in electronic harassment against him.

Here’s a sample of his… work… 🀯

One Blog Too Many

2020-09-06 

Decided I needed to have a place for random, dumb junk. And I’ll keep BytesTemplar.com specific to projects and coding.

I’ve taken this opportunity to explore other flat-file CMS..es…CMSes… (πŸ€”)

Sluggish Gravy

I migrated BT.com from WordPress to Grav at the start of the year. It’s not bad, and at the time I was quite pleased with it… until I uploaded it to my shared Dreamhost account. Despite not using MySQL, and despite being a simple ‘drop in and go’ system, it still had these absolutely weird moments of slowness. Pages would take 3-5 seconds to load. Same for the admin.

This didn’t happen on my development VM. It was a bit of a surprise.

I spent hours trying to debug the issue, but eventually I had to just concede that it was some mysterious Dreamhost magic getting in the way, and let it be.

Woof

So, this week I took a look at some others, and this time I’d install it on Dreamhost first to see how it performs. And, long story shorter: Bludit did the job. Fast, uses a clean WYSIWYG editor, but you can also flip over to Markdown. Feels mostly solid, and has a decent backup plugin.

The downsides are that there isn’t really an easy to use plugin/theme system. And one of the plugins is broken so badly that it ate a lengthy post I’d written because I saved without a post title… Thankfully it’s a completely unnecessary one that I quickly jettisoned once I realized it was a bug in the plugin, not the CMS.

Onward

So, got all this setup in an evening. Manually moved over some goofier posts from BT.com.

I feel like I’m spreading my interests thin — BT for generic development? This for random junk? Another blog (elsewhere) for infosec?

I don’t know what the hell I’m thinking. I need to clean this up and unify.

The Worm Is Back!

2020-04-02 

NASA says the worm is back!

The original NASA insignia is one of the most powerful symbols in the world. A bold, patriotic red chevron wing piercing a blue sphere, representing a planet, with white stars, and an orbiting spacecraft. Today, we know it as “the meatball”. However, with 1970’s technology, it was a difficult icon to reproduce, print, and many people considered it a complicated metaphor in what was considered, then, a modern aerospace era.

Enter a cleaner, sleeker design born of the Federal Design Improvement Program and officially introduced in 1975. It featured a simple, red unique type style of the word NASA. The world knew it as “the worm”. Created by the firm of Danne & Blackburn, the logo was honored in 1984 by President Reagan for its simplistic, yet innovative design.

NASA was able to thrive with multiple graphic designs. There was a place for both the meatball and the worm. However, in 1992, the 1970s brand was retired – except on clothing and other souvenir items – in favor of the original late 1950s graphic.

Until today.

The worm is back. And just in time to mark the return of human spaceflight on American rockets from American soil.

This excites me to no end!

Now, okay, I’ll admit, I’m probably biased towards the ‘worm’ design because it’s the one I grew up with. And I know “the meatball” — the older style logo — has just as many fans. Enough to bring it back in the 90s.

I never understood that roll back.

NASA!  Space! The Future!!

The “worm”, to me, embodies that spirit. It’s a simple, yet futuristic logo. It used to fill my mind with amazing visions back then.

When I see the “meatball”, I think… backwards. Old. A lack of progress. Quaint sci-fi rocket ships. Black and white footage. Pre-moon landing era.

But! I know the “meatball” means a great deal to other people, too. So I thought, why not merge them? Put the “worm” on top of the “meatball”? Best of both worlds!

And, as usual, that means it’s already been done.πŸ˜‰

Check out the “New Heritage” design:

Wow!

I don’t know who the creator is that did the edit (hit me on Twitter if you know and I’ll update this), but it’s exactly what I’d imagined. This fusion would be perfection to me. It pays tribute to the past, while integrating the future.

But, in the meantime, I’m going to giggle excitedly to myself now that they’re moving… back to the future. πŸ˜‰

Prenatal ACF Data Insertion (…or “that’s the most boring title I’ve ever written.”)

2020-02-02 

Just wanted to document an interesting issue I had with Advanced Custom Fields recently…

Don’t get me wrong, I swear by ACF on all of my WordPress projects. I consider it an absolute necessity. It’s powerful, easy to use, and is priced reasonably.

It’s when you go outside the standard usage of ACF that things get a bit… thorny…

Into the weeds

Normally, you’d create a field group. And you’d assign that field group based on a set of criteria (a particular page template, or a custom post type, etc.).

Then you create a new post, and you’re presented with your custom fields. You enter your data, and it’s attached to the post when you save. And accessing that data is trivial from templates.

But what happens if you create a post with custom fields, but you’re doing it from inside a PHP function, using wp_insert_post?

What if you want to add content to a field in that post immediately afterward? Surprise! Your standard update_field or add_row code will silently fail. According to the documentation, you need to reference the field name using the field key in that situation.

The field’s key should be used when saving a new value to a post (when no value exists). This helps ACF create the correct β€˜reference’ between the value and the field’s settings.

Let’s unpack that

ACF stores all of it’s custom field values inside standard WordPress meta fields inside the post. In fact, you could just as easily use get_post_meta to retrieve ACF field values under many circumstances. Or even write it back.

But ACF is much more than just a key/value pair, of course. Each field has a whole host of information associated with it. Label name, conditional display logic, field type, etc.

In the post’s meta data, ACF creates two different values: the field name, and a field key reference.

Let’s say I have a custom, basic Text-type field called “Title”.

Inside the post, there will be a title meta data field; this holds the actual value of the field. And then there’s a _title field. The underscore means it’s a field key reference. The value of that looks something like field_123456. Each field group entry gets it’s own unique field key name that looks like that.

Internally, when you call get_field('title') ACF looks up the post meta with an underscore — _title — and uses that to pull up the details in the custom field group entry.

If you call get_field('field_123456'), in fact, it will work as well. ACF will reference the field group info, and return the appropriate post meta that way.

Both are valid ways to work with ACF field content.

A brand new post, inserted with wp_insert_post is completely blank. It has no post meta data, outside of the usual timestamp and creation info.

So if you try to run update_field('title', 'My Title', 9999), it does nothing. As if it doesn’t exist. Because as far as ACF is concerned, it doesn’t.

Not yet.

There’s no _title for it to reference for guidance.

But if you update_field('field_123456', 'My Title', 9999), it WILL work. ACF knows right where to go to get it’s field details, and it works as normal.

Now here’s where it gets tricky

That’s all well and good for a simple Text field type.

But what if I have something more complicated? What if I have a Group type, with a Repeater inside that?

Let’s say I have a Group called “Vehicles” and a Repeater inside that called “Trucks”. (And presumably a “Cars”, “Motorcycles”, etc, but let’s keep it simple!)

And each row inside “Trucks” has a “Model” Text field, and a “Mileage” Number field.

Under normal circumstances I could do:

add_row('vehicles_trucks', ['model'=>'Bigfoot', 'mileage' => '50000'], 9999).

(Note the special, barely documented vehicles_trucks underscore selector notation for these nested fields.)

But if I’ve just inserted the post, none of those key field references exist!

The vehicles_trucks selector doesn’t work. But the previous fix, using the raw key field reference… say, add_row('field_902100'..., well, that doesn’t work either! Because which field key reference makes sense in this situation? The one for Vehicles? The one for Trucks?

If you use the key_ field key for Vehicle, it fails. Vehicle is a Group type. Nothing happens.

If you use the key_ field key for Trucks, however, something weird happens. Instead of creating a _vehicles_trucks key reference, it creates a _trucks reference…

At this point it’s important to note that ACF is smart and slick… right up until the point it is not.

From what I’ve discovered, there is no shortcut to adding a new row to a Repeater field nested inside a Group if you’ve created the post inside PHP, before someone had a chance to hit ‘Save’ on it from the admin.

If you try to get clever, you might fairly think that underscore notation might apply here. Maybe stick the two together, like field_111111_ field_22222.

But you’d be wrong

No, we have to manually create all of ACF’s key references ourselves before we can do anything:

 update_post_meta(9999, '_vehicle', 'field_111111');
 update_post_meta(9999, '_vehicle_truck', 'field_222222');

THEN we can add_row('vehicles_trucks', ... and insert our data programmatically as expected.

This holds true for even deeper nested content, but at that point maybe you want to rethink what you’re doing. πŸ˜‰

I was surprised by just how little information about this specific use case exists. Hopefully this helps somebody out there!

Hit me up on Twitter if I’ve made an error anywhere in here.

Conspiracy Guy Recounts Area 15 Encounter

2019-07-16 

In a private tape recorded interview unearthed circa 2016, an emotionally exhausted Conspiracy Guy recounts his harrowing experience at Area 51 back in the 1940s.

(Actually, this is just some lame improv I recorded from 2016. Felt like the right time to clean it up and finally post it, considering the pending Area 51 invasion!)

Sectional PHP Highlighting in VSCode

 

So, my eyes were glazing over some WordPress PHP in my editor of choice, VSCode.

The weaving in and out of <?php, <?= and ?> tags, bouncing between PHP and HTML contexts was making my head spin.

I kept having fantasies of a time when I could highlight the PHP (or HTML) context using a different background color… but there didn’t seem to be anything like that for VSCode, at least. It’s possible I was thinking of PHPStorm, but that was a lifetime ago.

So I powered through, cleaning up the twisty templates, trying to make them as readable as possible. But I finally hit my breaking point and started looking around… and I think I found a good solution. Whether it’s a good long term solution, well, that remains to be seen.

The Highlighter extension for VSCode is where the magic happens.

This extension allows you to define custom highlighting rules to regex matches in your code.

You can probably see where this is going.

After some futzing around, I wound up with these rules in my VSCode settings config:

"highlight.regexes": {
&lt;a href="https://clips.twitch.tv/JoyousEnthusiasticSpaghettiVoHiYo"&gt;https://clips.twitch.tv/JoyousEnthusiasticSpaghettiVoHiYo&lt;/a&gt;    "(&lt;\?php)((.|r|n)+?)(\?&gt;)": [
        { "color": "#FF00FF", "backgroundColor": "#FF00FF40" },
        { "backgroundColor": "#FF00FF40" },
        { "color": "#FF00FF", "backgroundColor": "#FF00FF40" }
    ],
    "(&lt;\?=)((.|r|n)+?)(\?&gt;)": [
        { "color": "#FF00FF", "backgroundColor": "#FF00FF40" },
        { "backgroundColor": "#FF00FF40" },
        { "color": "#FF00FF", "backgroundColor": "#FF00FF40" }
    ]
}

Your color preferences will vary, of course, but do at least note that I’m using the extended alpha value in the hex (the final octet), so you can blend your background color into your theme’s existing color!

(And yes, you can combine that down into one regex. Go ahead and do that.)

(IMAGE MISSING; SORRY…)

(The rainbow colored indents are part of the terrific indent-rainbow extension!)

I haven’t bounced on this very hard, so you might find some quirks here and there.

For instance, if you don’t include the closing PHP tag, ?>, it won’t match the regex. You could make the closing tag optional, but that might be undesirable…

But in any event, this seems to get me 9/10th of the way to the functionality I want, so I’m pretty happy. 😏

Reincarnation

2019-07-15 

I don’t have a link to it, but I remember reading about how some people essentially “reinvent” themselves multiple times over the course of their lives. They are constantly learning new things and switch careers to some other focus every decade or so, in an attempt to live a rich, varied life free of stagnation.

An interesting idea, if you can pull it off. After all, typically, people are married and have a family to take care of. And if not for a family, one’s own finances need to be secure.

Now, I’m not planning on quitting my job any time soon, mind you (I love it quite a bit), but I think the basic idea could at least be applied to one’s hobbies…

Since I was in high school in the 90s, I’ve always had a thick interest in game development. Skipping past the boring self-analysis, I came close to doing it professionally a couple times in the last decade, but otherwise it’s mostly stayed a hobby. But it was one I actively participated in during my off hours… I could cite various reasons, but suffice it to say that despite my dreams of ‘going pro’, it never took off.

Other, recent events have soured the milk on game development even further. It was probably for the best, though. All it ever did was remind me of unfinished projects, and planning for a future that wasn’t going to exist. Never mind the increasing number of horror stories from inside the industry, as people begin to feel safe about opening up about corporate abuse and general misery.

So, over the last couple months I’ve decided to pack up my game development hobby and put it into a little box in the closet. Sure, I’ll still keep tabs on industry news and people’s fun indie projects and stuff, but it’s no longer a primary interest.

What will fill the void?

Well, over the last couple years I’ve been, off and on, attending the B-Sides information security conferences along the east coast. I always had fun, but felt a bit weird going to them. It wasn’t my field. I felt like an outsider, even though it was stuff I could potentially apply to my day job. But as time went on, the wheels of further interest started turning…

Network security has always been a major weak point in my computer education. Compiler internals, hardware, software development? Sure, I love that stuff. But network administration? Server security? Subnet masks? OSI layers? I’ve had, more or less, only a scattered, surface level understanding. (No worries — I had a good handle on what to do, and what not to do, when it comes to security when working on software projects, so no worries there at least …mostly. I mean, as far as I know. Oh god, now I’m paranoid.)

So, I’ve been taking courses. I’m going all-in on educating myself about all of it. Taking part in CTF challenges. Pentesting my own internal network. Breaking into vulnerable virtual machines. (Already taught me a ton about WordPress security. Cough.) And I’ve been taking extensive notes as I go.

And you know what? I’m addicted. This is seriously fulfilling stuff. And my interest has only increased the further in I get. It’s like an infinite box of puzzles that keeps my brain active.

So now I have a primary hobby that is not only good for me, good for helping others, but also helps my day job.

I don’t want to say it’s goodbye forever to game development, but it’s going to be a long time, if ever, before that flame is reignited. And hey, maybe I’ll write up some more educational stuff here and there to help others, like me, along the way. I’d be down for that. 😎