Archive for July, 2007

What is this code?

char*a=" $#,.';:nt",*s="�000at�31r1�20�21�05",*d="215266333
S3�32�04321232L32176233346;346�30J~G200317251373O�01237h
3371C233317211274317371�23364235�33314377221276a360371
f~341342303326361277353~O207307h337365277\"�34o304ygb
3146317333|�33355�03�16�333063773411264�04375�336202a
242~3061",i,j,r=0,b=0;main(){for(i=0;i<98;i++){for(;;){r<<=1;r|=(*(d+i)
>>(7-b++))&1;for(j=0;j<10;j++) if(*(s+j)==r){putchar(*(a+j));r=0;break;}
if(b>=8){b=0;break;}}}}

Eek! Look at all that terrible code. Anyway, main() implements a well-known algorithm. Can you figure out what it is?

DH2C.COM

When I was pursuing a B.Sc. degree in Loyola Academy about 11 years ago, we used DOS and diskless machines with floppies. There was a pretty terrible virus called Die Hard 2 doing the rounds in the labs. We didn’t have a cleaner utility for this virus, and even if the McAfee SCAN.EXE and CLEAN.EXE that we had could detect and clean it (which they couldn’t anyway), they were way too slow to run. Simply loading either off a floppy into memory and program setup took a minute on those 8088 machines and then scanning took what seemed to be forever. It was during this time when I was getting better at assembly and also going through virus disassembly :) . I wrote a program called DH2C.COM (Die Hard 2 cleaner) in 8086 assembly which got used a lot on campus for its high speed, so much so that some people changed strings in it using a hex editor and called it their own. You could clean an entire disk in less time than SCAN.EXE took to load. This was due to DH2C’s use of file truncation and very little disk reading to check for infection.

Here is the program DH2C.COM. I seem to have lost the original source code over the years, but here is a disassembly of it. I don’t know if I can release this disassembler-generated code as free software, but the COM file is released under the modified BSD license or GNU GPLv2 and higher (no warranty, no liability). If time permits, I will comment it in the future but it should be fairly straightforward to anyone who has done DOS programming.

New static website

Last night I wrote a couple of Python scripts to create a static website tree from input XML documents, and switched this website to use it. The blog is also gone and replaced with a date-ordered journal (the title attribute seemed a bit silly). Now I can edit documents in emacs and post—which is far more nicer to use than a website form—and also put the journal in version control. Whee!

Now I hope to put some old programs such as a DOS virus cleaner written in 8086 assembly with source code on the website. Blast from the past!

Thanks to Andreas Nilsson for creating this hackergotchi for me: