I revisited another previous project, msnciasm. I hadn’t used it in a while and wanted to again, but it threw up a EXC_BAD_ACCESS error.
The eventual fix was trivial (literally one character):
- mov r14d, [eax]
+ mov r14d, [rax]
However, I had not touch this particular project or assembly in so long it was daunting to know where to start.
Basically like debugging someone else’s code in a language you don’t read.
Fortunately, I had done a lot of reverse engineering binaries for Capture the Flag events, that was helpful to get me stepping through the code to troubleshoot and eventually worked out the fix.
Now I had a new problem, OSX is not a thing anymore, this is macOS. Just enough had changed that the binary wouldn’t build.
Getting a working compile probably took longer than the actual fix. But got there in the end.
I revisited my arduino project that displayed the game of life on an 8x8 display to be slightly more interesting to watch.
Since it starts with a random grid, a lot of games end very quickly and so the display is “off” more than I’d like while it pauses between games.
The new version will still use a random grid, but now will also mix in pre-configured grids with known plays.
To start off the pre-configured grids I found some well-known stable or interesting patterns.
I also poked at the pixels myself to come up with a few custom grids of my own.
I got an 8x8 display for my Arduino without any plan. After displaying some simple shapes,
I remembered my Java-based game of life project from 2006,
and had a go at making it run on the 8x8 display.
Due to the limited size the games end very quickly.
It will detect when the game has ended (everything dying or no further growth) and will reset after a while,
so it will keep itself active.
So there’s this kids app Shopkins Chef Club that uses barcodes on physical toys (purchased separately) to unlock characters in the app.
I don’t really know the value of unlocking the characters, that is not so important to me.
When I saw the functionality I assumed it should be possible to enumerate the code space with some code.
This was just for fun to try out some things I’ve not worked with much (barcodes and GUIs).
I found some example barcodes online and scanned them with a barcode scanner app to see what value was stored.
After trying a few I noticed they use the format [a-zA-Z0-9]{3}.
I guess since they have to print the code on small physical toys
they didn’t have the luxury to use longer codes with more possible combinations.
This project displays a window on a computer screen that will show codes one after another, slideshow style.
It cycles from 000 to ZZZ.
A separate device is pointed at the computer displaying the codes with the ChefClub app loaded and in its scanning mode.
It is hardly practical since the search space contains over 200,000 codes and the app requires about 1 second to recognise a code.
It would take more than two days to verify every code at best.
In reality, the process needs to be monitored by someone to stop when a code is valid and start again after clearing the message in the app.
Requiring a human operator means it’ll require closer to a week.
As part of an effort to teach myself assembly, I created a tiny command-line tool that checks if you are online and sets its exit code appropriately. Then this can be called from scripts that want to know.
The program will perform two tests using Microsoft’s NCSI (Network Connectivity Status Indicator) service.
If the GET request succeeded and the content was correct, it stops there and will exit with 0.
If the GET request succeeded, but the content was not correct, it will perform the second test.
If the second test succeeds, it will stop there and exit with 1 (to differentiate).
Otherwise, it will exit with a non-zero exit status.
The command has no input and provides no output except its exit status. Usage example from a bash script:
if ./msncsi; then echo "I'm online :-)"else echo "I'm offline :-("fi
For work I was going linter crazy, adding linters for all the code in a particular project and wondered, is there was a linter for git messages?
Very quickly I found gitlint.
With this your git messages could be checked and rejected according to your requirements.
However, it didn’t have tests for some issues I was concerned about and I wanted the features!
I reached out to the owner Joris and realised we both worked for Cisco.
In fact, in the same business unit, though we’d not met or worked together yet.
He rightly suggested I create PRs for the changes I want and if they are good enough they’ll get merged.
They were and they did.
My PR added three new tests:
TitleLeadingWhiteSpace - Leading whitespace in the title.
BodyTooShort - Body message doesn’t contain enough detail.
I often need new passwords, for employees, services, servers, VPN pre-shared-keys and so on.
Each have slightly different requirements.
Humans would prefer easy to read/remember/write passwords, while computers can handle longer, less user-friendly passwords.
I’ve created a script to generate a whole bunch of passwords in different formats, letting me pick the one that suits my needs.
The script can also use a wordlist to bash words together with some numbers and symbols.
Plus just randomly selected words - in case I just want to make a password manually.
I use a custom wordlist that has short and very long words removed.
As an extra idea, I also filtered out words that matched the LulzSec password list.
I don’t have these files or the software they are looking for so there was no risk.
But it was starting to clog the logs,
especially since I don’t get much traffic these requests take up the vast majority of the logs.
To do something about it I created a new project:
Bot queries known trigger URL (e.g. /wp-login.php)
.htaccess forwards the request to my logging php script
The script logs the client IP and replies HTTP 200 to mess up their scan results
fail2ban reads the log and adds an iptables entry to deny the IP
I work with iptables a lot to manage firewall rules.
So to help me, I’ve created a script to manage iptables rules - automatically saving and restoring from files.
Too many times I’ve lost rules when the server restarted and I forgot to save the rules first.
So this script will register as a service and save rules automatically when the system shuts down and load them at boot.
Firewall rules are kept in a separate file, /etc/fireloader.conf in iptables-save format.
Allows you to alternate between values. Useful for the common practice of highlighting every other row in data tables. E.g.: <tr class="{cycle values="odd,even"}">
As I’m sure no one has noticed, recently a lot of C++ programming guides and articles have made their way into my del.icio.us bookmarks. My University’s bridging course’s algorithm project made itself the perfect cause to pick up a new language.
After various unfocused dabbling, I sat down to something more adventurous.
So for my big first adventure, I choose to write an implementation Huffman’s Compression.
I had just made my first binary trees and wanted something useful to do with one.
Soon I found a descriptive article on the algorithm (with pictures!).
Actually the pictures really helped, as I didn’t know if I was constructing the tree in a suitable way.
One problem I faced was handling all the bits correctly and how to write a suitable header.
I toyed with the bitset object, but in the end I wrote a wrapper for the string class to handle a stream of binary data in bit form.
I wanted my version to be as much as my own code as possible, so I didn’t consult other people’s while coding.
As such my code almost certainly differs from others and would not be compatible either.
The only other version I have checked out is a python version.
What he does in just 6k blew me away.
Scripting languages have a habit of undermining compiled languages like that.
However my goliath 160k compiled app (24k of code) out performed his in both speed and compression so in the end I wasn’t too put off.
I think his problem with compression was more due to using cPickle to store the header as this makes it quite large.
To store a number, the smallest value C will allow you to write is 1 byte in the form of a char.
This was too much for me, so I expanded my bit buffer class to write numbers even smaller!
The numbers I wanted to store was the length of the character bit code (as it was variable) before the bit code, so I knew how much to use.
The method I ended up using was a tally system, “[multiples-of-5]0[remainder]0”.
The ones act as a tally and zero is the terminator.
So, 1 would be “010”, 6 would be: “1010”, 22 would be “110110” and so on.
This works well at storing small numbers (0 - 25) in less than a byte.
As x86 computers won’t let you write individual bits, you must pad up to the nearest byte.
And since my output dealt with bits, it was likely the output would not round exactly to a byte, so I would need to add some empty space to make the computer happy.
Other implementations put the padding at the very end.
I figured this would require me to know where the body ends and ignore the rest, which might require a byte or two for storing a number.
I instead stuck my padding between the header and body.
I knew where the header ended as I stored how many letters as the first value.
Then if I generate the body early I know it’s length.
Adding the two values together I would know how much padding to pad.
My method was to use 0s, terminated by a 1. When decoding it ignores the 0s, only waiting until it gets a 1 then passes control to the body decoder.
The body decoder can then loop until it runs out of bits, instead of testing for a pseudo EOF.
So, padding of 5 bits would be “00001” and 1 would be “1”.
Sadly, the worse case is if no padding is needed, in this case a whole byte has to be added to provide padding for the 1 bit.
There are quite a few MP3->OGG converters, but I could find no ideal OGG->MP3 converters.
Fortunatly, most of my music I have the original CDs for, so reripping to MP3 to put on
the iPod wasnt such a big deal (with iTunes even less of a deal, one click,
copied from CD to my computer, one more click and it’s on the iPod).
But I have some OGGs that I don’t have the original source for,
namely UT2k3’s soundtrack which was provided as OGG on the CDs,
then there’s music freely available by
Pajama Crisis
and that Swedish band I forget.
Thus, I wrote a Perl script to do the hard work of converting each one for me.
It goes something like this…
ogginfo to get the bitrate and tags (title, album etc)
oggdec to decode to WAV
lame to encode to MP3, using ABR (average bitrate, the same method used by ogg) and the id3v1/2 tags
You too can enjoy the wonders of
ogg2mp3.pl. Requires vorbis-tools and lame.
And speaking of iTunes, as far as I’m concerned it’s very nifty.
It’s ability to manage multiple id3 tags beats all the shareware apps I’ve tried.
Plus having auto complete when filling in tags helps reduce typos.
Since the iPod relys on the tags so much, it’s immensely usful.
And then you can create smart playlists, with SQL like expressions,
which I can plonk onto the iPod (they dont stay smart on the iPod,
they only update when you sync, which is a shame). And that search
gizmo in the top right is hella useful (not to mention damn smart).
My ACPI events handler script
and my ACPI power mode toggler
(call it, it’ll determine what power mode you’re in (using simple test that WFM) and be more power saving accordingly) for use with ACPID.
I have master plans for rewriting my CMS for this site, remove sections I never update (network),
redo sections I never update but get looked at a lot (code) and bring and make WrapDBI, my perl DBI er… wrapper up-to-date with my ASP version.
After playing with HTML::Template I find it’s lack of includes a huge bad point,
keeping multiple templates in sync (eg. the content between to ) a real nightmare if I was to use it in anything more than my test.
I will look into other templating options, there’s still others out there, or write my own, but I’d rather not.
I also have plans to make a ’lite’ theme for my site (for small devices like ipaq, just for
neuro)
and one other which hopefully should look good, if not you’ll never see it :p
This script will open a specified URL into a new Mozilla tab, or if Mozilla isn’t running, it will start it then load the URL.
This overcomes a little oddity where you can’t just call “mozilla $url” and expect it to handle it this way.
I originally created this for my Logitech iTouch keyboard so I something to bind to the “homepage” key.
Save the file with a .pl name, You can then assign keys to it in your Window Manager,
set programs (eg. X-Chat) to use it to load URLs or run it straight from the console. All use the same syntax:
On my Logitech iTouch keyboard I have some “media” buttons, one being mute.
After assigning the keycode for it to XF86AudioMute I then created this little
script to handle the action of turning mute on or off depending on it’s current state.
Then its just a matter of editing your Window Managers key bindings to assining
XF86AudioMute to alsa-mute.pl.
For fluxbox this meant editing “~/.fluxbox/keys” and adding the line:
This program requires Perl to run and ALSA (Advanced Linux Sound Architechture) installed.
You will also need to edit your Window Manager’s key bindings. An excersise left to the reader.
Save the file with a .pl name,
Edit your Window Manager’s key bindings to call it for the key you want,
You can also call this straight from the console:
I haven’t worked on the ExB project half as much as I should have recently.
Today bse asked me wtf SROMMod (a plugin module for the bot) was, and I hadn’t the foggiest,
I racked my brains for a few moments, I knew I had made it, it was the last thing I had done,
but what on earth was it. Just as I loaded up Mozilla to rummage around the
online cvs repository I remembered.
SROMMod, or Sucks-Rules O’Meter, inspired by
this website which fellow workmate
graham pointed me at.
Basically SROMMod finds out what is better of two items.
You give the bot two terms, it then googles them with the words “sucks” and “rules OR rocks”
and counts the results, does a little (flawed) calculation on them and spits out a pretty graph.
I’ve got a new (second hand) pc, which I’ve named Mathilda.
It will probably end up as my fileserver,
but until I can get the network card recognised, it aint gunna be nothing.
And I havent uploaded a screenshot in a while,
so I did (300k) :P.
On the ExB front, I’ve made another module cause I was bored,
a simple 8Ball module, ask it a question and it will answer it with near 100% accuracy :).
Here is a little example of 8BallMod in use, utilising the new IKnowTheAnswer(tm) Technology.
[09:05:43]<Xenith> ExB: does wataru love me?
[09:05:44]<ExB> My reply is no.
[09:05:46]<Xenith> Hmm
[09:05:52]<Xenith> That'd be why I'm not getting email from him
[09:05:59]<Xenith> ExB: do people love me anymore?
[09:05:59]<ExB> Yes.
[09:06:07]<Xenith> ExB: then why aren't they sending me email?
[09:06:07]<ExB> Who knows?
We recently released version 0.2 of ExB, we have big plans for 0.3.
I’m still coding away on the ExB project.
I’ve re-done the site so that it is now powered by PHP and XML.
It was a nice learning experience teaching myself PHP, although it seems something of an odd mix
(eg. the function names are somewhat inconsistant strlen and str_replace, why isnt it str_len or strreplace?).
So Perl still remains my prefered web server side language.
XML is just blooming marvelous.
I’m finding lots of uses for that, Java and PHP have built in support, Perl has some great extensions
(which I havnt tried).
XML is quite simply a file format, just like comma seperated or databases.
Its power lies in the fact its highly portable (it can be used on mulitple operating systems),
is easy to debug (its in plain text, so you can open up a text editor to find any problems),
lots of languages are moving to have built in support.
ExB http://exb.sf.net/ is an IRCbot that’s abilities can be expanded by adding modules.
It’s written entirely in Java, which means it is fully OS independent (a great feature in any program).
I’ve been coding like crazy making modules for this,
which has allowed me to learn a great deal about the Java language,
for which I had no previous experience.
I hope to use Java in the future instead of MICROS~1 Visual Basic.
I’ve created a password list maker that can be used
to replace randomly generated passwords, eg: “j5DxaE”, which are tricky to remember, with bunched up words like “AegeonBagot” that are far easier.
VRML (Virtual Reality Modelling Language) is used to create 3D worlds that can be downloaded and viewed in a web browser, however the technology never really caught on, that did not stop me making a world.
For my Mutlimedia HND (Higher National Diploma) today I made a simplistic model of our solar system.
It is purly to demonstrate VRML, much better things can be achieved with more time. The whole world is 36.8kb so should take about 5-10s to download on a 56k modem.
To view VRML worlds you need a plug-in for your browser.
If you dont already have a VRML (version 1.0 compatible) viewer, and you are using either Internet Explorer or Netscape I recommend you get Cortona (there are others, but this is the best I have found, quick and easy to install).
To get the required parts of Cortona:
First visit this page to get the plug-in (984kb, 2m33s on 56k modem).
Then you need to get it’s 1.0 converter here (32kb, 5s on 56k modem).
Cortona is compatible with VRML 2.0 by default, this 1.0 converter lets it read the older format. The only reason I coded this in 1.0 format is because its quicker to write and learn.