Hacking – Having fun with sh, perl, and python scripts

Who does not recognize Budi Rahardjo of Indonesia? He’s such a role model among Indonesian hackers. Hackers, in this context, represents a good guy gaining access to a computer without the intention of destroying data or harming the computer. Then, it is a cracker who you might be thinking of–the criminals who destroy and steal. He is also one of the several guys who has helped bringing the Internet to Indonesia. Thanks to his contribution to Indonesia in the early times of Internet. The early period of Internet development in Indonesia left a lot of interesting, yet some funny experience to Budi Rahardjo.

He was studying in Canada by the time HTML rised up. He shared to us a funny incident that once he shouted to his friends, “HTML! Web is the future!”, then his friends replied, “No, we already have ftp!” (lol). Budi loves writing and maintaining blog. He created a blog named gerakan bawah tanah (gbt). He confessed that he populated that blog with high amount of content quantity without making sure the quality of each content. However, since the fact that the blog had still attracted people to visit, he found a motto for himself, which sound quantity is always over quality.

During the session
During the session

Beside blogging, Budi Rahardjo was also active in social media, especially in Twitter. He had done such a social experiment on Twitter. He created two Twitter accounts, named @rahard and @buditweet. Then, he acted in the exact opposite fashion on both accounts; @rahard’s tweet was all about trash talking while @buditweet’s timeline was filled with words of wisdom. The result was (not) surprisingly more people followed @rahard. So then, he jumped right into the conclusion that, people followed others not really because of good content, but simply because they like to. Well, that’s quite interesting experiment, isn’t it?

Going back to Indonesia after finishing his study in Canada, he intended to create a microelectronic company with his fellow, but no one was around, so he decided not to continue. However, that sort of idea still had been successfully executed by Indonesians from Batam. He showed us that his phone was 100% made in Batam, an island in western Indonesia. He was so proud of the achievement and encouraged us, young generation of Indonesia, to stop doubting and start to believe in ourselves.

Since 1999, he initiated his path as serial entrepreneur, creating his own company, one at a time. “Only three out of ten companies I created survive until now”, he told us with no doubt, but a huge amount of enthusiasm. He taught us, the young generation of the nation, not to be afraid to take risks as long as it was meant to have positive impact to the society. After sometime in Indonesia, he continued to get deeper in the field of computer and information security. He started to build the initial infrastructure and community to shape the foundation of information security in Indonesia. ID-CERT (Computer Emergency Response Team) Indonesia is one of his companies in the field of information security. ID-CERT defined itself as a technical coordination team regarding to internet network incident in the whole world. Currently, he’s a lecturer at STEI (Sekolah Teknik Elektro dan Informatika), ITB (Institut Teknologi Bandung). He had decided in his heart that he wanted to contribute to society through teaching.

Shell Script

Shell script was basically a collection of UNIX utilities, for example, file manipulation, program execution, printing text, etc. UNIX shell was first written by Ken Thompshon (called Thompson shell) in 1971. Budi Rahardjo loved shell script since shell was the only one widely-used script in his time. There were several shell varieties known at the time with its own modification to the original shell (sh), for instance, Bourne shell, C shell, zsh, ksh, Bourne-Again shell (bash), etc.

Furthermore, Budi Rahardjo utilized shell script to help create safer yet simple static website. Anyway, do you have any simple idea to build a website and at the same time be sure that the site is safe all the time? Budi Rahardjo had one unique approach–not to use dynamic website but by modification of common structure of static website. The pain of maintaining static website was that we needed to change the code in relatively more (duplicate) code when modification was needed. On the other hand, using bare dynamic web was not a solution too for the dynamic attribute made it prone to cracking. Therefore, he had an idea to utilize shell script to create static web preprocessor. The idea of a preprocessor was to create a modular form of html files. Then, the preprocessor will automatically “compiled” the input files (based on the configuration) to create the final html pages that would be served to the users. In that sense, the code was still static technically, but at the same time, it felt like dynamic to developers. You can check out the code example (with some modification) here.

#!/bin/bash

wd="./src"
t="./template"
o="./output"

fname=$1
ofile=$o/$fname

echo "$ofile"
cat $t/1-head-before-title.html > $ofile
cat $wd/$fname.title >> $ofile
cat $t/2-head-after-title.html >> $ofile
cat $t/3-body-nav-bar.html >> $ofile
cat $wd/$fname.txt >> $ofile
cat $t/4-body-end.html >> $ofile
cat $t/5-core-javascript.html >> $ofile

Perl

Perl script was also one thing that he had no choice but to learn, since at the time C and Perl had been the two most available languages. He played a lot with text processing and since his program had to work within multiple platform such as SunOS, AIX, HPUX (Linux was not even there), Perl was his best friend. He once said, “I love Larry Wall’s sense of humor for his word choices for Perl programming language, such as study, sleep, study, sleep just like college student’s activities and there was also an idiom in the form of do <something> or die() (lol)”. Furthermore, his relationship with Perl did not stop there. He continued to maintain DOS port of Perl.

Explaining the perl script
Explaining the perl script

He had also such a unique and simple program called “topic generator for blogging”. He had found out that the single difficult thing to post a blog post was to decide what the topic would be. So, he created a program that could generate different topic at each execution providing the user with various kind of topic for the blog, for instance, “Explain about seafood, your favorite food?”, “What makes you happy these days?”, “Why are you not happy with your uncle?”, and many more. The audience was absolutely amazed by the magic of this program. We were all wondering how this program can know about all this. The secret was that he had provided all the topics possible in a separate file, so then the program needed to read that topic file and choose the topic randomly (lol). Here’s the code related to project (with some modification).

#!/usr/bin/perl

my $topicdb = 'topic.txt';
open(my $db, '<', $topicdb) or die $!;

my $count = 0;
my %topic;

while(<$db>){
	if($tmp =~ "^--"){
		$count++;
	} else {
		$topic{$count} = $topic{$count} . $tmp;
	}
}

close($db);

$luckyone = int(rand($count));

print STDOUT $topic{$luckyone+1};
exit 1;

Python

Recently, he had an interesting project with his daughter. His daughter is a student in Fakultas Seni Rupa dan Desain (FSRD) Institut Teknologi Bandung (ITB). They called this project hologram client and server. The function of the product was to determine the user’s character based on a set of questions answered. User’s character would then be visualized in a form of hologram video. This product basically consisted of two main components: hologram client and hologram server. The client would build telnet connection with the server and exchanged simple message through the connection, such as play, kill, and various other messages, then the server would parse the message and did the action as had been commanded, for example, play harmony.mp4. He also had imagined future possible development of the product. He’s quite sure that this hologram might be useful for advertising (attract customer’s engagement), simple interactive game, and many more.

End of the session
End of the session

Budi Rahardjo had another hobby other than listening to progressive rock harmony or writing code. It was writing books. He had written a book about Elliptic Curve Cryptosystem, which clearly talked about the highly complex public-key cryptography using the algebraic structure of elliptic curve. Just by listening to the title, we could imagine the intricacy of the concept, couldn’t we? Because of the deep technical knowledge necessary to understand that book, he once thought selling the book along with panadol (drug for headache).