Friday, December 22, 2006

Firefox & Internet Explorer 7

I just found out that there are issues regarding CSS and JavaScript in Firefox. I have to switch to IE7 as of the moment.


Nothing special, I’m gearing up anyway.

Tuesday, December 19, 2006

Protected: Happy Birthday!


This post is password protected. To view it please enter your password below:



Monday, December 18, 2006

Added new memory module

Just extended my RAM to 512mb with heat spreaders attached.



DDR400
Module Size: 512 MBytes
Max. Bandwidth: PC3200 (200MHz)
Part Number: M2G9IAKATT9F0839SD
Manufacturing Date: Week 46, Year 03


Timings Table
Frequency: 200MHz
CAS# Latency: 2.5
RAS# to CAS#: 3
RAS# Precharge: 3
Tras: 8

Friday, December 01, 2006

Protected: For someone


This post is password protected. To view it please enter your password below:



Monday, November 27, 2006

Blog suspended

It has been a long time since I blogged. As for now, I am filing a blog leave. I just want to enjoy the Ateneo Fiesta week. To be honest, I want to savor every moment here in my school where I studied for almost 16 years. At the same time, I should not forget the tasks reflected in the gantt chart of activities of our thesis.


If you want to track down the Ateneo Fiesta event, click here.

Tuesday, November 07, 2006

nVidia & Xorg issues

This entry should have been posted some time ago. Well, I hope this would still serve as a valuable reference. :)


The most annoying part in making your OS work is the X server especially if you are using decade-old displays that can only handle a maximum of 1024x768 @ 60Hz. Worse if its EDID is not being read correctly by the driver. I guess driver writers from nVidia should pay much attention to this issue.


Video Card: GeForce FX5700 128-bit 256mb
Display: DTS CM-14D (Made in China)
Xorg Version: xorg-x11-7.1
nVidia Driver Version: nvidia-drivers-1.0.8776


Setting things for Xorg and nVidia proprietary drivers may not be of much pain for Ubuntites but it is the other way around for Gentooligans.



In Section "Monitor" this line should be appended.



Modeline "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync

In Section "Device" Identifier "nVidia GeForce FX5700" this line should be appended as well.



Option "UseEDID" "false"

In Section "Screen" Subsection "Display" this line is needed.



Modes "1024x768@60"

Other options are pretty straightforward. In case you do not have any idea where these things should be, it’s in /etc/X11/xorg.conf.

Wednesday, November 01, 2006

Ebuilds: media-gfx/f4l

F4L is an open source development environment for Macromedia Flash, a multi-platform format(swf/svg) widely used for web applications and vector animation.


I have found out that there is no existing ebuild yet for this cool project. It is not included in the official Gentoo Portage yet.


Here is the ebuild. Use at your own risk. I assume you already have a working overlay of your local portage.


in file f4l-0.2.1.ebuild



# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit qt3 eutils

DESCRIPTION="F4L is an open source development environment for Macromedia Flash"
HOMEPAGE="http://f4l.sourceforge.net/"
SRC_URI="mirror://sourceforge/f4l/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"

DEPEND="=x11-libs/qt-3.3*"
RDEPEND="${DEPEND}"

src_compile() {
"${QTDIR}"/bin/qmake -o Makefile ${PN}.pro || die "qmake failed"
emake || die "emake failed"
}

src_install() {
dobin bin/${PN}
newicon src/cursor/main_ico1.xpm ${PN}.xpm
make_desktop_entry ${PN} \"Flash for Linux\" ${PN}.xpm Graphics
}

Enjoy!

Tuesday, October 31, 2006

MS Firefox 2007

I find this funny, click here.

Halloween

It is a season when children enjoy collecting candles, jumping around sarcophagi, wearing dirty masks, and scaring other children(smaller/younger). TV shows are fun to watch. In the United States, children usually play snowballs during winter. Well, it is totally a different story here since children play waxballs during Halloween. Not forgetting adults, it is a season for filling stomachs with barrels of beer, bottles of wine, and gallons of coconut-fermented drinks otherwise known as tuba.


I really do not enjoy roaming around burial grounds especially during Halloween for the reasons that, you will see people shouting at each other, throwing punches, showing knives, and trying to boast their clan’s supremacy among others. The fear of ghosts is not a thing to consider here, it is the fear of being unable to withstand adults looking for troubles no matter how hard you try ignoring their fun. This is true to cheap cemeteries that are maintained by the local government unit. Company-owned cemeteries are at least safe.


It would be wise for me to stay at home and offer a prayer for my departed friends and relatives. I do not see myself behind bars in the future. Prevention is better.


Happy Halloween!

Sunday, October 29, 2006

Some updates on my Gentoo box

Get in position and wait for my go. I recompiled the kernel applying Con Kolivas‘ kernel patchset for linux-2.6.18. Accordingly, his patchsets are designed to improve system responsiveness with specific emphasis on the desktop, but suitable to any workload. Feedbacks show that it scales well for a typical desktop use. If you want to try this out, here is a comprehensive walkthrough that will get you on your feet along the way.


I also felt the need of updating my Xorg. I had a smooth shift from Xorg 6.9 to Xorg 7.1. So far so good.


Firefox 2.0 rocks as well! There are obvious improvements so grab yourself one. Currently, it is masked by x86 keyword in the Gentoo Official Portage so just deal with it.

Friday, October 27, 2006

Crackmes: cyrex’s Linux CrackMe

Find the correct password to get the good boy message :) it would be great for an solution how you solve this , and with what i solve this
with the standard GNU Debugger (gdb)


Difficulty: 1 - Very easy, for newbies
Platform: Unix/Linux, etc.
Language: C/C++


[Solving the Crackme]


Solving crackmes is fun but if you screwed up, it sucks big time. Thank goodness, heavy tasks are over. Anyway, let us see what we can do with this.



joset@kee:~/src/crackmes/crackme_01$ ./crackme
-[ Linux CrackMe (Level:2) by cyrex ]-
-[ TODO: You have to get the valid Password ]-
Enter Password: 0x7d7
-[ Ohhhh, your skills are bad try again later ]-
joset@kee:~/src/crackmes/crackme_01$

Do we have to use the debugger first? How about this?



joset@kee:~/src/crackmes/crackme_01$ strings crackme
/lib/ld-linux.so.2
libc.so.6
printf
__deregister_frame_info
strcmp
scanf
_IO_stdin_used
__libc_start_main
__register_frame_info
__gmon_start__
GLIBC_2.0
PTRhP
QVhP
[^_]
-[ Linux CrackMe (Level:2) by cyrex ]-
-[ TODO: You have to get the valid Password ]-
Enter Password:
47ghf6fh37fbgbgj
-[ Good, You’re ready to begin linux reversing ]-
-[ Ohhhh, your skills are bad try again later ]-
joset@kee:~/src/crackmes/crackme_01$

Do you see what I see? What if we will try using that as the password?



joset@kee:~/src/crackmes/crackme_01$ ./crackme
-[ Linux CrackMe (Level:2) by cyrex ]-
-[ TODO: You have to get the valid Password ]-
Enter Password: 47ghf6fh37fbgbgj
-[ Good, You're ready to begin linux reversing ]-
joset@kee:~/src/crackmes/crackme_01$

There’s no protection at all just use the strings command. Trivial.

Wednesday, October 25, 2006

ISP lock-ins

Globe Broadband and Bayantel please invest here as soon as possible. We need the quality of services that you offer. Majority of the broadband subscribers here are not that satisfied. One year contract is not worth it. I have received the first bill already. Does it mean that I will be suffering 11 months more? Geez!


pldc ka kasi tol! ang hina ng broadband mo! ano yan pentium poor? sm*rt broken ata yan eh! [bayantel only] join now! tol, ipconfig /release tapos ipconfig /renew lol!


I can’t even access the website of Mindanao Open Source Society. Damn it.


Hoping for better days.

Wednesday, October 18, 2006

Bad luck

This is a program that simply extracts numbers from buffered input. I do not have any idea why this didn’t work. I got a zero.



input:
mov ah, 0ah ; buffered input sys call
lea dx, strptr ; load effective address
int 21h ; call kernel

mov ah, 02h ; write character to stdout sys call
mov dl, 0ah ; issue carriage-return
int 21h ; call kernel

lea si, string ; set source index to start of string
mov cl, [strlen] ; set loop counter

here:
mov dl, [si] ; place current character in dl
cmp dl, '0' ; compare if below '0'
jb traverse
cmp dl, '9' ; compare if above '9'
ja traverse

mov ah, 02h ; write character to stdout sys call
int 21h ; call kernel
cmp dl, '$' ; check end-of-string sentinel
je exit

traverse:
inc si ; increment source index pointer

loop here

exit:
int 20h ; terminate

strptr label byte
maxlen db 49
strlen db ?
string db 50 dup ('$')

It runs smoothly on my machine. Damn it.

Thursday, October 12, 2006

Happy Fiesta Zamboanga!

Viva! Nuestra Senora del Pilar. Today is the feast of Our Lady of the Pilar, our city’s patron saint.


Here is a description of the city where I live in. A very peaceful place that is.


I guess I won’t be enjoying the feast today since I’ll be finishing our OpenGL project. In my list, it also says that I’ll be writing a simple C program today incorporating Balanced Trees. Well, it’s my own approach to file system writing.

Tuesday, October 10, 2006

Joke?

Now tell me is there something really funny about this?


I did not find a single bit of humor in this video. This man is with his glasses for Pete’s sake!

RX Band Breakout conquered!

We did our best! We burned the stage! A video of our performance will be uploaded in youtube soon. I will post the notification here.


We got the most awards. It was indeed a blessing!


1) Best Bassist - Joset Zamora
2) Best Vocalist/s - Bon Padayhag, Macky Alger
3) Best Drummer - Daryll De Leon
4) 2nd Place - Junkyard


Congratulations to the winners as well. You did great! Thank you Dream Radio RX 93.1!


[Resolution]


No gigs before graduation day. Now it’s time to get the Reiser4 File System Driver for Windoze XP done. Yeah, that’s our thesis. God bless us all.

Saturday, October 07, 2006

Binary Trees

A tree has a finite set of elements called nodes. It has a unique node called the root node, where the remaining nodes are a disjoint collection of subtrees. A binary tree is a tree whose elements have two children at maximum. It is considered as a data structure composed of elements that are characterized by two link fields, left and right children. A leaf node contains 0 children meaning both children point to a NULL value.


A binary search tree is a special type of a binary tree. These terms are sometimes used interchangeably in some articles, so do not be confused. For this purpose, I’ll limit my article to binary trees in general.


First let’s define the structure to be used.



#include <stdio.h>
#include <stdlib.h>

typedef char DATA;

struct node {
DATA d;
struct node *left;
struct node *right;
};

typedef struct node NODE;
typedef struct NODE *BINTREE;

[Creating a Binary Tree]


Dynamic allocation.



BINTREE new_node()
{
return (malloc(sizeof(NODE)));
}

Of course we have to initialize the node.



BINTREE init_node(DATA d1, BINTREE p1, BINTREE p2)
{
BINTREE t;

t = new_node();
t -> d = d1;
t -> left = p1;
t -> right = p2;
return t;
}

We will generate a tree from an array recursively.



BINTREE create_tree(DATA a[], int i, int size)
{
if (i >= size)
return NULL;
else
return (init_node(a[i],
create_tree(a, 2 * i + 1, size),
create_tree(a, 2 * i + 2, size)));
}

[Binary Tree Traversals]


There are several ways to traverse in a binary tree. Luckily, I have leared something during our CS 213 Data Structures class. Thanks to Sir Greg. Here are three ways presented:


Inorder Traversal: Left Node Right (LNR)
Preorder Traversal: Node Left Right (NLR)
Postorder Traversal: Left Right Node (LRN)


The standard way of implementing this of course is again by recursion.


Inorder Traversal



void inorder(BINTREE root)
{
if (root != NULL) {
inorder(root -> left);
printf("%c ", root -> d);
inorder(root -> right);
}
}

Preorder Traversal



void preorder(BINTREE root)
{
if (root != NULL) {
printf("%c ", root -> d);
preorder(root -> left);
preorder(root -> right);
}
}

Postorder Traversal



void postorder(BINTREE root)
{
if (root != NULL) {
postorder(root -> left);
postorder(root -> right);
printf("%c ", root -> d);
}
}

Hope this article will be useful to students taking up Data Structures and Algorithms.

Thursday, October 05, 2006

RX Band Breakout

RX Band Breakout will be on October 9, 2006. It is going to be a tough competition though. Most competing bands are extremely good! So acting like a duck on stage would surely drive you down. We want to burn on stage and fire them up with our solos.


Sad thing is that, I do not have enough time for practice so I searched for bass solo stuffs. I found a lot of cool Brazilian scales incorporated in a bass solo and all that. Which also lead me to rank bassists who happened to be my influences. I wish could play well like them. Here’s my ranking.


1) Victor Wooten - Versatile
2) Bill Dickens - Versatile
3) John Myung (Dream Theatre) - Progressive Rock
4) Romel (Barbie’s Cradle, Freestyle) - Progressive Folk
5) - name - (P.O.T.) - Funk Rock
6) Flea (Red Hot Chili Peppers) - Funk Rock
7) Nathan (Rivermaya, Kapatid, Bamboo) - Rock
8) - name - (Wolfgang) - Rock
9) - name - (Razorback) - Rock
10) Stuart Ham - Jazz


For as long as we’ll be able to burn the stage, it doesn’t really matter whether we’ll bring home the trophy or not.


By the way, thanks to Kamikazee and APO Hiking Society! We’ll be playing one of your songs, Doobidoo. I’m really excited about this!


I hope the weather as well as the power lines would cooperate on that day.


Cheers.

Saturday, September 16, 2006

SFD: FOSS @ Claret College of Isabela

First of all, thank you God for giving me the gift of life and the countless blessings. Many thanks to Ma’am Yolynne Medina for choosing me as a speaker. I am so grateful. As well as RJ Ian Sevilla, thanks man! You did a great job! For the audience, muchas gracias for fighting boredom during my presentation.


Click here to view the FOSS@CCI website.


We left Zamboanga City around 0700H aboard on a fastcraft. It’s a fast craft! I did not take any anti-vertigo tabs. It’s not Rialto anyway. We took the last trip around 1730H on our way back. I will never forget this event. My first time to step on Isabela City, Basilan, will never be an ordinary day for me.

Thursday, September 14, 2006

Bubble sort in C

I’m writing this for someone special. Hope this would help. This is at the same time a review of my past lessons. Assuming i,j and tmp are defined as integers, num[] as an array of integers, and SIZE as a constant.



for (i = 0; i < SIZE - 1; ++i)
for (j = SIZE - 1; j < i; --j)
if (num[j-1] > num[j]) {
tmp = num[j-1];
num[j-1] = num[j];
num[j] = tmp;
}

Here is another way of doing it. This is a demo on how the function works on a particular array of integers. a[] is the array of integers while n is the size of the array.



void swap(int *, int *);

void bubble(int a[], int n)
{
int i, j;

for (i = 0; i < n - 1; ++i)
for (j = n - 1; j > i; --j)
if (a[j-1] > a[j])
swap(&a[j-1], &a[j]);
}

void swap(int *p, int *q)
{
int tmp;

tmp = *p;
*p = *q;
*q = tmp;
}

If you are keen enough to observe, check that we can use the swap arguments presented below.



swap(a + i, a + j);

Getting the idea? Pointer arithmetic! God bless and good day.

Wednesday, September 13, 2006

Recognizing unknown partitions in Windoze

This is the starting point if you are planning to develop an Installable File System Driver (IFSD) for Windoze. You can also use this if you want to format partitions that aren’t visible inside your Windoze box.


First thing’s first, fire up a registry editor. Use regedit or any third party editors. Search for the entry:



HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

If you’re in the right place then, add a new string value. The name should be the drive letter you wish to associate and should be a drive letter that currently isn’t used by your box. The name along with its value should be of the form:



K:
\Device\Harddisk0\Partition1

In Windoze, hard drive numbers start at 0 and partition numbers start at 1. The above example is equivalent to /dev/hda1. You can also verify your partition table without any third party applications such as Partition Magic, GParted, etc. by running diskmgmt.msc on the command line. The drive K: can be replaced with any free drive letter.


Done! No, not yet. Forgetting the Windoze protocol? Restart your machine for it to take effect.

Friday, September 08, 2006

I am created in the image and likeness of God. I am divine. I am born of God. I am a child of God. Everything I have is God’s gift to me. I do not own anything. Everything comes from and returns to God. I am a child of God. Everyone is my brother. Everyone is my sister. I love each person the way I love myself. I am a child of God. God loves me. In Him alone, I place my faith.


This was distributed during our junior’s recollection. I have this posted in my room. I know most of you reading my blog are busied by your jobs and other concerns. I hope this would lighten up your day. Remember, someone out there is ready to back us up especially in times of troubles.

Wednesday, September 06, 2006

Random number generator in 16-bit DOS assembly

Most code for randomizing is not as short as this one. Try to incorporate this procedure in your code and see how it works!



randomize:
in al, 40h ; read micro-clock for initial seed
mov ah, al
in al, 40h
xchg al, ah
or ax, 1
mov rnum, ax
ret

Random number will be stored in rnum. Fairly straightforward isn’t it?


[Edit]


Here’s another solution by sir Eugene Kanindot. This is a 3-digit random number generator.



jmp start

xxx:
mov ah, 02ch
int 21h
and dl, 0fh
cmp dl, 9
ja xxx
add dl, 30h
mov [di], dl
ret

delay:
mov cx, 0

yyy:
mov dx, 0a00h

zzz:
xor ax, ax
dec dx
cmp dx, 0
jne zzz

loop yyy
ret

start:
lea di, numb
call xxx
inc di
call delay
call xxx
inc di
call delay
call xxx
mov ah, 09h
lea dx, numb
int 21h
int 20h

numb db 4 dup('$')

Tuesday, September 05, 2006

Coding therapy

This is what I usually do whenever I am tired and hungry.



#include <GL/glut.h>

void disp(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3d(0.43, 0.12, 1.00);

glBegin(GL_POLYGON);
glVertex3f(-0.75, -0.75, 0.0);
glVertex3f( 0.75, -0.75, 0.0);
glVertex3f( 0.75, 0.75, 0.0);
glVertex3f(-0.75, 0.75, 0.0);
glEnd();
glFlush();
}

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(300,300);
glutInitWindowPosition(0, 0);
glutCreateWindow(argv[0]);

init();

glutDisplayFunc(disp);
glutMainLoop();
}

Redesigned

[Thesis]


Well, it was rejected as expected. Plan B was accepted. Do you know what Plan B is? Look for another project that is.


[Redesigned]


Got nothing to do right now. I tried redesigning my blog. I was executed in The Reincarnation. I failed to defend my country. I didn’t have any time for offensive moves. Opposing guilds were a step ahead. I had 5 fortresses left and 5 attacks went in. I had no choice. I guess it’s time to quit playing. Redesigning the blog as well as the attitude for a big blow.

Friday, September 01, 2006

Protected: Again, for someone special


This post is password protected. To view it please enter your password below:



Thursday, August 31, 2006

Sad

Low grades. Time to say “good bye scholarship.” Anyway, I did my best but I failed. Now I don’t know how to explain this. I really do not want to add any more heartaches to my parents. They’ve spent so much already. I really want to help them. This is really sad. Now they would think again that I’m this irresponsible, careless, and mentally inefficient lad. It’s not too late though. Sad and painful because I did my best then I will just be tagged as irresponsible, careless, you name it.

Sunday, August 27, 2006

A new air-soft rifle

So dad bought a new air-soft rifle. Weeee! Now I have two in my room. The new one can adapt a .22 caliber bullet with an improvised hammer. Its recoil kicks a little stronger than when fired with air. Now even if I will ran out of C02 gas tanks it will not stop the fun. Its far and near sights were calibrated perfectly. Unlike my 15-year old air-soft gun whose (0,0) sight lands at six o’ clock.

Saturday, August 26, 2006

Flashback

Now I can update my Gentoo box even on a daily basis. Using my 30GB USB mass storage device, I can do so even if my prepaid internet account runs zero. Here’s a short guide for those who haven’t tried this one yet.


An emerge –sync alternative would be downloading the latest snapshot on any Gentoo mirror site using a machine with a high-speed connection. You might want to salvage the /usr/portage/distfiles of your machine first before proceeding.



kee ~ # rm -r /usr/portage/
kee ~ # tar -xvjf portage-latest.tar.bz2 -C /usr/
...
kee ~ # update-eix
Reading Portage settings ..
Building database (/var/cache/eix) from scratch ..
[0] /usr/portage/ (cache: metadata)
Reading 100%
[1] /usr/local/portage (cache: none)
Reading 100%
Applying masks ..
Database contains 11268 packages in 149 categories.
kee ~ # env-update
>>> Regenerating /etc/ld.so.cache...
kee / #

Now for downloading packages for emerge.



kee ~ # emerge -fp package ... 2> somefilename.txt

The links are now stored in the text file. Download ‘em on a machine with a high-speed connection. Place all the downloaded files inside /usr/portage/distfiles of your machine then.



kee ~ # emerge package ...

I’m bored. Cheers.

Friday, August 25, 2006

Bin to hex converter in 16-bit DOS assembly

Just a quick code like putting your keyboard where your brain is. There should be another way of doing this. I hate this code.



start:
xor al, al
xor bl, bl
xor cl, cl
mov dl, 4 ; use dl as counter

input:
mov ah, 00
int 16h
cmp ah, 1ch
je exit
cmp al, '0'
jb input
cmp al, '1'
ja input

convert:
mov cl, dl
dec cl ; dl - 1
sub al, 30h ; get original value
shl al, cl ; place in the appropriate bit position
or bl, al ; save in bl
dec dl ; prepare for the next bit
jnz input ; must be 4 bits
cmp bl, 9
ja letter
jbe number

letter:
add bl, 37h ; because 'A' - 37h is 0Ah
jmp here

number:
add bl, 30h ; because '0' - 30h is 00h

here:
call display
jmp start

display:
mov ah, 02h
mov dl, bl
int 21h
ret

exit:
int 20h

Try this out, get the assembler here.

Wednesday, August 23, 2006

Moving on

So I bought my self a 2.5″ hard drive enclosure for about 750 bucks. I wish I have my own tools for constructing a device as such. Instead of going for a 2GB USB flash drive, I chose to salvage the 30GB hard drive of an incapacitated laptop. Cool isn’t it? Though relatively slower than a typical USB flash drive, the storage capacity outweighs it.


[To God]


Thanks for being there always.

Tuesday, August 22, 2006

Hetero-stress experience

I didn’t make the CS 315 (Elementary Computer Graphics w/ OpenGL) midterm examination. Sad, but I have to admit that I am mentally, emotionally and physically disturbed these days. It seems that I am carrying a magnet attracting bad luck. I have turned out restless and confused with almost eveything. From waking up to lying down, I don’t know what to do, I don’t know how to start my day. This is the dullest day of my life.


Stress, pressure. Some thrive on it, others find the spotlight and the responsibility to be too much for them. It distracts and scares them. The fear translates in to a physical stiffness. Mentally they become less focused and more self-conscious. Thus, their performance deteriorates.

Sunday, August 20, 2006

Motion for brain rejuvenation

Confusion, defined by WordWeb as a mental state characterized by a lack of clear and orderly thought and behavior, is infesting my brain. Can someone help me? Is there a cure for that? If serenity is sold in the market then I would pack my self dozens of it. Being a computer science student demands a lot of concentration. I’m on a worst-case scenario. If anyone of you out there knows how to cast a spell for brain rejuvenation, count me as one of your targets.

Thursday, August 17, 2006

Bit masking

I was thinking of the hex to bin converter in the previous post. The fun part there was the extraction of the desired bit. With the knowledge in mind, it resulted me to devise a function in C that uses a mask to print out the bit representation of an integer.



void bitprint(int a)
{
int i;
int n = sizeof(int) * CHAR_BIT;
int mask = 1 << (n - 1);

for (i = 1; i <= n; ++i) {
putchar(((a & mask) == 0) ? '0' : '1');
a <<= 1;
if (i % CHAR_BIT == 0 && i < n)
putchar(' ');
}
}

CHAR_BIT is defined in limits.h and holding a value of 8. Try it, it’s fun. I’m bored, just extending my thanks to beandog for enlisting me in Planet Larry: Gentoo Users’ Blogs.

Sunday, August 13, 2006

Hex to bin converter in 16-bit DOS assembly

You can try this out, get the assembler here. This is just a simple hexadecimal to binary converter, a CS217 exercise and not supposed to be pasted here but just for the sake of having a post. Here it is:



input:
mov ah, 00h
int 16h
cmp ah, 1ch
je exit

number:
cmp al, '0'
jb input
cmp al, '9'
ja uppercase
sub al, 30h
call process
jmp input

uppercase:
cmp al, 'A'
jb input
cmp al, 'F'
ja lowercase
sub al, 37h
call process
jmp input

lowercase:
cmp al, 'a'
jb input
cmp al, 'f'
ja input
sub al, 57h
call process
jmp input

loop input

process:
mov ch, 4
mov cl, 3
mov bl, al

convert:
mov al, bl
ror al, cl
and al, 01
add al, 30h

mov ah, 02h
mov dl, al
int 21h

dec cl
dec ch
jnz convert

mov dl, 20h
int 21h
ret

exit:
int 20h

“And my God will meet all your needs according to His glorious riches in Christ Jesus.” - Philip 4:19

Tuesday, August 01, 2006

Protected: For someone special


This post is password protected. To view it please enter your password below:



Sunday, July 30, 2006

Crackmes: cli3nt’s mycrk

Language C
Linux x86/ELF


Difficulty: 1 - Very easy, for newbies
Platform: Unix/Linux, etc.
Language: C/C++


[Solving the Crackme]


As usual, we have to run the file first.



joset@kee:~/src/crackmes/mycrk$ ./mycrk
Type cd-key: eve
wrong!
joset@kee:~/src/crackmes/mycrk$

From this point we already know what the file needs, a correct key. I immediately disassembled the file without even bothering about its characteristics.



joset@kee:~/src/crackmes/mycrk$ objdump -d mycrk > temp.txt
joset@kee:~/src/crackmes/mycrk$ less temp.txt

The first trick, is to look for the disassembly of the main function. Here’s a portion of it.



...
80483d4: c7 45 fc 67 1e 01 00 movl $0x11e67,0xfffffffc(%ebp)
80483db: c7 45 f8 70 12 5b 00 movl $0x5b1270,0xfffffff8(%ebp)
80483e2: c7 45 f0 06 00 00 00 movl $0x6,0xfffffff0(%ebp)
80483e9: 83 ec 0c sub $0xc,%esp
80483ec: 68 14 85 04 08 push $0x8048514
80483f1: e8 ee fe ff ff call 80482e4 <printf @plt>
80483f6: 83 c4 10 add $0x10,%esp
80483f9: 83 ec 08 sub $0x8,%esp
80483fc: 8d 45 f4 lea 0xfffffff4(%ebp),%eax
80483ff: 50 push %eax
8048400: 68 22 85 04 08 push $0x8048522
8048405: e8 ba fe ff ff call 80482c4 <scanf @plt>
804840a: 83 c4 10 add $0x10,%esp
804840d: 8b 45 f8 mov 0xfffffff8(%ebp),%eax
8048410: 3b 45 f4 cmp 0xfffffff4(%ebp),%eax
8048413: 75 1d jne 8048432 <main +0x6e>
8048415: 8b 55 f0 mov 0xfffffff0(%ebp),%edx
8048418: 8d 45 fc lea 0xfffffffc(%ebp),%eax
804841b: 31 10 xor %edx,(%eax)
804841d: 83 ec 08 sub $0x8,%esp


I am not going to provide a detailed information about this. Let’s observe the line there with a cmp, since lines with cmps usually attract crackers’ eyes at a first glance. ;) It is very obvious that a value is being compared with the content of the eax register and is obtained through a buffered input because the line is preceded with a call 80482c4 <scanf @plt>. How do we get the value of the eax register? Getting the idea? Of course, we will use gdb by setting a breakpoint where the line resides and displaying the value being held by the eax register.



joset@kee:~/src/crackmes/mycrk$ gdb ./mycrk
...
(gdb) b *0x8048410
Breakpoint 1 at 0x8048410
(gdb) r
Starting program: /home/joset/src/crackmes/mycrk/mycrk
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Type cd-key: eve

Breakpoint 1, 0x08048410 in main ()
(gdb) print $eax
$1 = 5968496
(gdb)

Looking back, we can see that it would jump to 8048432 <main +0x6e> if the values didn’t satisfy each other. Let’s see what it does from there.



...
8048432: 83 ec 0c sub $0xc,%esp
8048435: 68 29 85 04 08 push $0x8048529
804843a: e8 a5 fe ff ff call 80482e4 <printf @plt>
804843f: 83 c4 10 add $0x10,%esp
8048442: b8 00 00 00 00 mov $0x0,%eax
8048447: c9 leave
8048448: c3 ret
...

There’s the presence of a call 80482e4 <printf @plt>. We can come up with an assumption that it is the notification being printed if an invalid key is entered. :) Therefore the key is the value being held by the eax register awhile ago. Let’s try it.



joset@kee:~/src/crackmes/mycrk$ ./mycrk
Type cd-key: 5968496
73313
joset@kee:~/src/crackmes/mycrk$

Done.

Saturday, July 29, 2006

A palindrome checker in 16-bit DOS assembly

A good morning to start off is to get this simple program working. This is an improvement of the previous palindrome checker posted. What can we benefit from this anyway? :)



; palindrome checker

start:
mov ah, 0ah
lea dx, strptr
int 21h

lea di, string
lea si, strlen
mov cl, [si]
xor ch, ch
mov bx, cx
lea si, string
shr cl, 1

check:
mov dl, [si]
mov dh, [di+bx-1]
cmp dl, dh
jne notpal
inc si
dec di

loop check

cmp dl, dh
je pal

notpal:
mov ah, 09h
lea dx, msg2
int 21h
int 20h

pal:
mov ah, 09h
lea dx, msg1
int 21h
int 20h

strptr label byte
maxlen db 49
strlen db ?
string db 50 dup ('$')
msg1 db '',10,'string is a palindrome!$'
msg2 db '',10,'string is not a palindrome!$'

“If God’s people which are called by His name, will humble themselves and pray, and seek His face, and turn from their wicked ways; then He will hear from heaven, and will forgive their sins, and will heal their land.” - 2 Chron 7:14

A case inverter in 16-bit DOS assembly

This is a simple case inverter, if you want to try this out download the a86 assembler here. It works like a charm in dosemu-freedos.



; case inverter

start:
mov ah, 0ah
lea dx, strptr
int 21h

lea si, string
mov cl, [strlen]

check:
mov al, [si]
cmp al, 'Z'
ja lowercase
cmp al, 'a'
jb uppercase

lowercase:
cmp al, 'a'
jb traverse
cmp al, 'z'
jbe toupper

uppercase:
cmp al, 'Z'
ja traverse
cmp al, 'A'
jae tolower

toupper:
sub al, 32
mov [si], al
jmp traverse

tolower:
add al, 32
mov [si], al

traverse:
inc si

loop check

mov ah, 02h
mov dl, 10
int 21h

mov ah, 09h
lea dx, string
int 21h
int 20h

strptr label byte
maxlen db 49
strlen db ?
string db 50 dup ('$')

“Fortune favors the prepared mind.” - Louis Pasteur

Tuesday, July 25, 2006

Crackmes: lord’s easy Linux crackme

crackme will print text under certain conditions
what are the conditions? ;) sorry for my bad english
- lord


Difficulty: 1 - very easy, for newbies
Platform: Unix/Linux, etc.
Language: Assembler


[Solving the Crackme]


An initiative would be running the file:



joset@kee:~/src/crackmes$ ./blah
joset@kee:~/src/crackmes$

It didn’t print anything at all. So the conditions aren’t met. I’ve been using gdb and objdump for quite some time now. Since there is no form of corruption in the file, these tools will be more than enough. Here’s the disassembly of the file in objdump:



blah: file format elf32-i386

Disassembly of section .text:

08048094 < .text>:
8048094: 31 c0 xor %eax,%eax
8048096: b8 2f 00 00 00 mov $0x2f,%eax
804809b: cd 80 int $0x80
804809d: 3d ad de 00 00 cmp $0xdead,%eax
80480a2: 75 16 jne 0x80480ba
80480a4: b8 04 00 00 00 mov $0x4,%eax
80480a9: bb 01 00 00 00 mov $0x1,%ebx
80480ae: b9 c4 90 04 08 mov $0x80490c4,%ecx
80480b3: ba 06 00 00 00 mov $0x6,%edx
80480b8: cd 80 int $0x80
80480ba: 31 c0 xor %eax,%eax
80480bc: 40 inc %eax
80480bd: 31 db xor %ebx,%ebx
80480bf: cd 80 int $0x80

The first 3 lines tell us that it will call getgid (47 in /usr/include/asm/unistd.h). The system call returns the group id of the user running the file. The next 2 lines are straightforward. The execution jumps to 0x80480ba if eax is not equal to 0xdead. Here’s what will happen from 0x80480ba onward:


1. eax will be cleared out (eax = 0)
2. eax will have a new value of 1 (exit system call)
3. ebx will be cleared out (ebx = 0)


For a clearer view, try echo $? after running the file and you’ll get a 0. Here’s how I did it. I patched the file. Take a loot at 0x80480a2, we can find the conditional jump there. I just changed the opcodes jne (75) 0x80480ba (16) to nop (90).



joset@kee:~/src/crackmes$ gdb --write -nx -q blah
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) x/x 0x80480a2
0x80480a2: 0x04b81675
(gdb) set {int} 0x80480a2 = 0x04b89090
(gdb) q
joset@kee:~/src/crackmes$

There it is, 1675 to 9090. Now for the final shot,



joset@kee:~/src/crackmes$ ./blah
Okej!
joset@kee:~/src/crackmes$

Try running the file with a user under 0xdead perhaps it would also yield the same result. I haven’t tried it though.

Monday, July 24, 2006

Making you feel loved was the easiest thing I have ever done before. It’s just sad to think that things just changed. I wish I could turn back those days. The times when we sat down under a tree, observed the fading horizon, held hands and stared at the crimsoning sun. I know how destiny fools us. If destiny asserts that we are not for each other, then I would fight destiny just to have you in my arms forever. I love you my everdearest.


I’m sorry for what had happened to the rose. It’s not too late though, I can still take care another bud for you.

Saturday, July 22, 2006

Antidote for insanity

Simple programming stuffs save me from insanity. This a86 assembly program tells if str1 is a palindrome.



start:
cld
mov cx, 7
lea si, str1
lea di, temp

reverse:
mov al, [si+6]
mov [di], al
inc di
dec si
loop reverse

mov ah, 09h
lea dx, temp
int 21h

cld
mov cx, 4

compare:
lea di, temp
lea si, str1
repe cmpsb
jne exit

mov ah, 09h
lea dx, yes
int 21h

exit:
mov ah, 4Ch
mov al, 00
int 21h
int 20h

str1 db 'racecar$'
yes db '',10,'string is a palindrome!$'
temp db 8 dup ('$')

[Middle-East Crisis]


Israel, known as the chosen people of God called a thousand reservists in a possible prelude to a ground offensive against Lebanon. Accordingly, they have to clean up bunkers and tunnels that are invulnerable to air attacks. Isn’t it ironic for the Mossads to be called as the chosen people of God?

Sunday, July 09, 2006

Outdoorsman recall

I can still remember way back then, I was five years old when I had my primary hobbies, hunting, fishing, and shooting-range. Today, we went to Sinubung, a semi-dangerous place located in the far west coast of Zamboanga City and is known for its shore having huge waves and numerous sea urchins. We have gone fishing. It was fun riding my grandfather’s motor-operated vinta again though I am deeply saddened with what had happened today. The last time I set foot on that vinta was 15 years ago. I can still remember my grandfather pulling the nylon with a huge squid hooked up. Of course, the squid fired up a black tint. Because of that black tint, and the times when I threw up while riding the vinta, I have something now which I call memories worth remembering.


Awhile ago, we did the same but no squid and from what I have observed fishes are already scarce! We spent almost three hours, changing position from time to time on the sea. I was the one throwing and pulling the anchor everytime we shift locations but damn no fishes!


A very nice experience. The prize for the experience? Well, a swollen left foot, 5 thorns pierced from black sea urchins. It’s not a big deal though. The prize does not outweigh the experience. Waves were really strong awhile ago. I was a little nervous.


The truth is, I am sad today. It could be that I’ve lost someone very special.

Friday, July 07, 2006

Preparing for Muziklaban

Red Horse Muziklaban is fast approaching. Tomorrow will be the qualification or shall I say audition. One composition down. I am still trying to come up with a nice riff for the adlib. Hoping to impress the judges tomorrow.


[Programming]


I am just messing up with DOS Assembly. I started out programming in 32-bit protected mode, now broadening my knowledge by diving into 16-bit real mode. I have nothing new these days, just reviewing C++.


Signing off through a quote by Albert Einstein


“Information is not knowledge.”

Sunday, July 02, 2006

Victory!

Congratulations Manny Pacquiao!


He was once a singer of a local band in Gen. Santos City. Look at him now, he is the most influential person in our nation and probably one of the most influential persons around the globe. I was really fascinated by his fight with Oscar Larios. He has become faster than ever. Incomparable vigor that is! Raise it up Manny. More power and advertisements ahead.


On the other hand, I pity Oscar Larios, he was a great fighter. I admire his sportsmanship and humility. He is one of the cheerful and honest boxers I’ve ever seen. His courage is a deadly weapon that one shouldn’t take advantage of. Maintaining his mind in equilibrium state could have driven Manny on the floor.


[Globe Telecom]


What is happening? I couldn’t send and receive SMSs. Calling does not solve the issue either. Hoping for better services in the future.

Monday, June 19, 2006

GDT Explained

GDT contains a number of entries, Segment Descriptors. Usually each is 8 bytes long and marks the starting point, length, and access rights of the segment. It is stored in memory of course. The address is stored in a special 48-bit CPU register called Global Descriptor Table Register (GDTR). The lower 16 bits inform the size of the GDT while the upper 32 bits inform the location of the GDT in memory.


The GDT itself is a 64-bit long entries. These entries define whether the current segment that the processor is running is for Ring 0 or Ring 3. Ring levels are restrictions, Ring 0 is for system use while Ring 3 is for application use. Such protection exists to prevent applications from causing the kernel to crash and to tell the processor which instructions are valid.


–snipped–

Thursday, June 15, 2006

Orders received!

ADZU Open Lab will be switching to Edubuntu 6.06 Dapper Drake! Wee! Expecting Ubuntu sovereignty in the University! More power Ubuntu Linux Development Team.


A Freedom Toaster empowered by Shuttleworth Foundation is badly needed in our University.


The network administrator, Sir Greg, also suggested Xubuntu 6.06 in the College Internet Access Area (CIAA). Well, it’s easy as one-two-three.

Tuesday, June 13, 2006

I’m back!

It’s good to be back to one’s abode. I haven’t been blogging lately for the reason that my dad was confined and there were no other who could watch over him except me. Good thing that my dad’s okay now. Got to go, have to finish the enrollment process.


God bless.

Wednesday, May 31, 2006

20!

Twenty factorial?


Thank God for all the blessings especially the gift of life. Thank you mom and dad for taking care of me. Thank you everyone! Happy birthday to me! I am no longer a teenage lad. I could not believe it. Time flies so fast.

Saturday, May 27, 2006

Revamp, an apology

[Previous Post]
Sorry I forgot the private flag because I was in a hurry awhile ago. I hope it didn’t deface Planet Ubuntu-PH.


[OS Development]
Global Descriptor Table conquered! Nothing special, more tasks ahead. So far so good. Linux 0.01 is cool and MiniOS (Minix) too! Hail to you Linus Torvalds and Andrew Tanenbaum.

Jeepney, today - 2

Thinking of the song? No, definitely not Kala’s hit in the Myx Daily Top 10.


It was 31 down 7 o’clock in the evening, the last day of our training. The sky was darkening and the wind blew softly as I walked toward the terminal. Going home later than 6 o’clock in the evening is such a waste of time I heard myself whisper. Before taking the jeepney in line, I have decided to sit down and buy a bottle of coke in a bakery situated near the end of the terminal. While taking a sip, I observed people passing by. Definitely not Manila, whispering to myself and reminiscing the events a year ago. 5 minutes would be long enough for me to begin sipping air so I took a jeepney. I have waited for the jeepney to be filled up. Not exceeding 10 minutes, the wheels started rolling as expected.


This year is going to be the hardest school year ever. Again, talking to myself. Anticipating sleepless nights, hardworks, additional duties or obligations, etc. Then suddenly while thinking of these, my sight landed on the driver. He looked so tired and problematic. What if I am on his shoes? Is he happy with his life? Then I began asking myself, what would be my life a year after wherein I will not be calling myself a student anymore? Will I be able to work in prestigious firms such as NEC, Orange and Bronze, Accenture, etc.? Well, so much for that.


It was time to pay for my fare and step down.


Please hand my fare over, I handed PhP 6.00 (discounted fare for students and senior citizens). Not far from the jeepney, I was wondering why it was not moving and all the passengers were looking at me. It seems that there was a problem. I approached the driver with an idea that he wasn’t happy with my fare. He shouted, how much do you pay to this far?! I replied, PhP 6.00, student. Student?! it’s summer break, no classes these days! My reply, I have summer classes and it does not mean that if it’s summer break then we should follow regular fare. The reasons why students and senior citizens follow the discounted fare are,


[Students]


They are still studying and do not have a job yet.


[Senior Citizens]


Most of them were retired and have no other means of income, some are just depending on their pension plans.


Even if we’ll see face to face in the court you will never triumph. What is the use of having that fare rate there posted on your windshield? Consider Manila, the food is more expensive compared here but the drivers there are disciplined in following the fare matrix provided by the LTFRB. Then with loud voice he began uttering a lot of things like, it should be PhP 6.50! Currently, I do not even have the fee for this jeepney! While he was throwing a lot of harsh words, at the back of my mind, I was already thinking of giving all extra coins in my bag. I was reflecting during that moment and have realized that I have relatives who survive through the same profession, driving, I know how hard it is to suffice the needs of one’s family especially if one does not own a jeepney. I slowly opened my bag and got all the coins there, then with smile I gave all those to the driver. We understand your situation, here take these coins, you might be needing it badly for your family. He replied in low tone, thank you child, please do understand us. Then with smile I replied, okay sir, no problem about that. Then the jeepney started rolling. While walking down the street to our house, I have felt an extraordinary happiness.


Being happy is a choice that we make. Never forget this. Everytime we wake up in the morning, it is us who chooses whether to be happy or not. Being happy is not being rich, it is being content with what we have.


Pro Deo et Patria

Monday, May 22, 2006

Kernel head

This is a late post. Simply explains how the kernel sits in after grub.



[BITS 32]

global _start
extern kernel_entry

PAGEALIGN equ 1<<0
MEMORYINFO equ 1<<1
HEADERFLAGS equ PAGEALIGN | MEMORYINFO ; 0x3 that is
HEADERMAGIC equ 0x1BADB002
CHECKSUM equ -(HEADERMAGIC + HEADERFLAGS)
STACKSIZE equ 0x4000

section .text
ALIGN 4 ; section must be 4 byte-aligned
multibootheader ;
dd HEADERMAGIC
dd HEADERFLAGS
dd CHECKSUM

_start:
mov esp, stack+STACKSIZE
push eax
push ebx
call kernel_entry
jmp $

; GDT here

; ISRs here

section .bss
ALIGN 4
stack resb STACKSIZE ; 16KB of memory

I’m just sad tonight, that’s why I decided to post this out of nothing. Well I guess keeping myself busy would be wise enough.

Sunday, May 21, 2006

Sunday, sad discovery

[Da Vinci Code]


I have been to the movie house recently and watched this controversial film. The book, despite its ever-growing popularity, did not interest me that much since I equate my faith with a sword mightier than Tireal’s Azurewrath. I was saddened deeply when I reached the movie house and saw numerous people there oozing with their teenage curiosity. First of all, have they been to church? It’s Sunday for pete’s sake. Why would they prioritize watching a film that is against their religion without even thinking that they have their obligations? Dan Brown’s manuscript is really a work of art and no question about that but people should remember it as a fiction book and nothing beyond.


To all those who have read the book or have watched the film, try reading The Da Vinci Code Decoded written by a Jesuit priest.


[OS Development]


Do not write your own operating system. An information available globally that could be considered as a blackhole where operating system developers might fall. I am one of those enlightened hobbyists who fell into that hole while searching for a supplementary reading about the Global Descriptor Table. Developing your own OS is just reinventing the wheel. Straightforward as it may sound. Yeah right. We want to learn here and reinventing the wheel does not only mean to reinvent. Go grab your processor’s fan, detach it, and power on for a decent devastation.

Wednesday, May 17, 2006

Early take-off

I have emerged vim-7.0-r2 just recently.


Preparing a lot for our college thesis. Not excluding the amount of food intake. Reading the intel manuals from hell. Heavy bondings with bochs, vim, nasm, gcc, ld, strace, objdump, hexedit, as, etc.


Requesting a divine intervention for strength.

Wednesday, May 10, 2006

Making C++ behave like Java

I was sidetracked from my C++ programming (Battle for Wesnoth) by the school’s Senior Summer Trainings 2006. After MySQL and PHP, and a week OJT at Zamboanga Freeport (OMED IT Solutions), the dark side of the force has arrived, Java Programming. We are currently being trained by Ma’am Ebony Domingo and some CS upperclasses who already received their respective diplomas last March of this year. Their spirits of magis uplift my morale and drive me to be more optimistic especially in dealing with a language that I’m not quite familiar with.


Java is known for its being a platform independent language, equipped with an auto garbage collection mechanism, etc. (I don’t want to elaborate more on these).


What I am trying to point here out is that, one of Java’s assets, which is the auto garbage collection, is also possible in C++ using an auto pointer. Now, how is this possible?


What an auto pointer does is, it owns a dynamically created object and automatically performs a cleanup when the object is no longer needed.


First, we have to consider how they normally do it (without auto pointer).



void function()
{
sophie *s(new sophie);
/* do something here */
delete s;
}

A classic memory leak would occur if there’s no delete.


Here’s how it’s being done using an auto pointer.



void function()
{
auto_ptr<sophie> s(new sophie);
/* do something here */
}

Beyond this scope, the object frees automatically.


God bless us all!

Tuesday, April 25, 2006

Unanticipated

Summer vacation days are even more tiring than the usual school days! I have thought of decreased loads in my TO-DO list but I was wrong. Good day.

Wednesday, April 19, 2006

Locked and loaded

Today is the second day of the Senior Summer Trainings 2006. Yesterday, we have started off MySQL running on Ubuntu. We did just simple exercises but very worth-doing even if I had previous experiences with the subject.


To Ma’am Flisha Fernandez, thanks a lot. The Ateneo Spirit of Magis has a way of rewarding people like you.


[Kernel]


Please welcome “The Instrument of Doom” linux-2.6.14-kee-innovative with nVidia support. I have purchased a second-hand graphics card (GeForce FX 5700 256mb 128bit) from a friend. Good to go!


[Gig]


I hope the training will end up earlier than the usual time. I have to warm up for the gig tonight at Park 88.

Monday, March 27, 2006

Getting the feel of the groove

Junior year’s over. New daily schedule has emerged. In a day there must be at least 2 hours of bass exercises which include music bass theory, scales, funky bass lines, and jamming sessions. 6 hours of programming (right after this sissy FoxPro RDBMS project). In weekends, there must be at least 2 jamming sessions with my band for compositions and reviews. Play at different bars at night, for pleasure and income. My top priority for this summer break is to code some modules for our final project ahead. Of course, schedule is subject to change due to unpredictable and uncontrollable forces such as heavy household chores, family affairs, family business, or anything that concerns morality.

Sunday, March 26, 2006

Palindrome syndrome

I really do not enjoy coding in MS Visual FoxPro but I have no choice. Damn! I swear not to use it any longer after this RDBMS project.


I was asked by a friend to code a simple program to check if a string is a palindrome. I miss coding in C and assembly a lot! So to satisfy my urge, I tried to do it in a different manner. A timed coding session!



#include<stdio.h>
#include<string.h>

#define MAXSTRING 50

int main(void)
{
int i;
int ctr = 0;
char c;
char string[MAXSTRING] = "\0";
char temp[MAXSTRING] = "\0";

printf("Enter a string: ");
for (i = 0; (c = getchar()) != '\n'; ++i)
string[i] = c;
string[i] = '\0';

for (--i; i >= 0; --i){
temp[ctr] = putchar(string[i]);
++ctr;
}
if (!strcmp(string, temp))
printf("\nString is a palindrome!\n");
else
printf("\nNot a palindrome!\n");
return 0;
}

I finished coding in 4 minutes and 37 seconds. Not a good record though. So sad.

Tuesday, March 14, 2006

LPT1 stepper motor control

Last Sunday, I was coding some modules for our RDBMS project and playing Dungeon Siege: Legend of Aranna (quite old but it would be a waste of time if I did not) in parallel. I received a phone call asking a favor to write a program for sending signals through the parallel port. It sounds a little scary at first because I did not have any idea on parallel port interfacing.


Let me explain the project.


The project is a Car Control System. They have 2 bipolar stepper motors. One is responsible for the forward-reverse function and the other one is for the left-right function.


Signals recognized by the floppy drive stepper motor:


Clockwise 18-degree turn


1001      or      0x9
0110 or 0x6

Counterclockwise 18-degree turn


0110      or      0x6
1001 or 0x9

Now, how is it possible to send these signals using the parallel port? Not all 25 pins are needed. For this project, only the data pins are needed.


Pin         Function
2 D0
3 D1
4 D2
5 D3
6 D4
7 D5
8 D6

LPT1 is usually 0x378; having this knowledge, everything comes in trivial.


In file lptcontrol.c


#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
short data;

if(argc<2) {
printf("Usage\n\n");
printf("lptcontrol.exe [option] [data]\n\n");
return 0;
}

/* a read function is not necessary for this project
included for additional info */

if(!strcmp(argv[1],"read")) {
data = _inp(0x378);
printf("Data from parallel port: ");
printf("%d",data);
}

if(!strcmp(argv[1],"write")) {
_outp(0x378,atoi(argv[2]));
printf("Data written to parallel port: ");
printf("%s",argv[2]);
}
return 0;
}

If you want a constant turn you can achieve it through a loop.



while(1) {
_outp(0x378, 0x9);
_outp(0x378, 0x6);
}

This will result to a motor spinning clockwise. C program above is written for Windows OS.

Wednesday, March 08, 2006

Ethical hacking, a glimpse of my Philo paper

Is hacking ethical? It is if viewed within the context of the three definitions offered: hacktivist, hobbyist and researcher. We have the right in this country to protest, and if our activism takes a digital or electronic form, we have the right to do so. But don’t take my word for it.


Who are ethical hackers? These early efforts provide good examples of ethical hackers. Successful ethical hackers possess a variety of skills. First and foremost, they must be completely trustworthy. While testing the security of a client’s systems, the ethical hacker may discover information about the client that should remain secret. In many cases, this information, if publicized, could lead to real intruders breaking into the systems, possibly leading to financial losses. During an evaluation, the ethical hacker often holds the “keys to the company,” and therefore must be trusted to exercise tight control over any information about a target that could be misused. The sensitivity of the information gathered during an evaluation requires that strong measures be taken to ensure the security of the systems being employed by the ethical hackers themselves: limited-access labs with physical security protection and full ceiling-to-floor walls, multiple secure Internet connections, a safe to hold paper documentation from clients, strong cryptography to protect electronic results, and isolated networks for testing.


Ethical hackers typically have very strong programming and computer networking skills and have been in the computer and networking business for several years. They are also adept at installing and maintaining systems that use the more popular operating systems (e.g., GNU Linux, BSD Unix or Windows NT) used on target systems. These base skills are augmented with detailed knowledge of the hardware and software provided by the more popular computer and networking hardware vendors. It should be noted that an additional specialization in security is not always necessary, as strong skills in the other areas imply a very good understanding of how the security on various systems is maintained. These systems management skills are necessary for the actual vulnerability testing, but are equally important when preparing the report for the client after the test.


Finally, good candidates for ethical hacking have more drive and patience than most people. Unlike the way someone breaks into a computer in the movies, the work that ethical hackers do demands a lot of time and persistence. This is a critical trait, since criminal hackers are known to be extremely patient and willing to monitor systems for days or weeks while waiting for an opportunity. A typical evaluation may require several days of tedious work that is difficult to automate. Some portions of the evaluations must be done outside of normal working hours to avoid interfering with production at “live” targets or to simulate the timing of a real attack. When they encounter a system with which they are unfamiliar, ethical hackers will spend the time to learn about the system and try to find its weaknesses. Finally, keeping up with the ever-changing world of computer and network security requires continuous education and review.


One might observe that the skills we have described could just as easily belong to a criminal hacker as to an ethical hacker. Just as in sports or warfare, knowledge of the skills and techniques of your opponent is vital to your success. In the computer security realm, the ethical hacker’s task is the harder one. With traditional crime anyone can become a shoplifter, graffiti artist, or a mugger. Their potential targets are usually easy to identify and tend to be localized. The local law enforcement agents must know how the criminals ply their trade and how to stop them. On the Internet anyone can download criminal hacker tools and use them to attempt to break into computers anywhere in the world. Ethical hackers have to know the techniques of the criminal hackers, how their activities might be detected, and how to stop them.


Given these qualifications, how does one go about finding such individuals?


The best ethical hacker candidates will have successfully published research papers or released popular open-source security software. The computer security community is strongly self-policing, given the importance of its work. Most ethical hackers, and many of the better computer and network security experts, did not set out to focus on these issues. Most of them were computer users from various disciplines, such as astronomy and physics, mathematics, computer science, philosophy, or liberal arts, who took it personally when someone disrupted their work with a hack.


One rule that IBM’s ethical hacking effort had from the very beginning was that we would not hire ex-hackers. While some will argue that only a “real hacker” would have the skill to actually do the work, we feel that the requirement for absolute trust eliminated such candidates. We likened the decision to that of hiring a fire marshal for a school district: while a gifted ex-arsonist might indeed know everything about setting and putting out fires, would the parents of the students really feel comfortable with such a choice? This decision was further justified when the service was initially offered: the customers themselves asked that such a restriction be observed. Since IBM’s ethical hacking group was formed, there have been numerous ex-hackers who have become security consultants and spokespersons for the news media. While they may very well have turned away from the “dark side,” there will always be a doubt.


I believe hackers have a lot to offer. They provide a balance of power by virtue of their creativity and technical skills. I think we need to protect and recognize them and find ways of working together.


Yes, I do believe that hacking — when properly defined — is an ethical activity. And yes, I do believe that understanding our freedom and rights and protecting all that’s good in our society while preventing all that’s bad is the right approach.

Sunday, February 26, 2006

A change-gas

The danger of reading Randall Hyde’s book, The Art of Assembly is that it contains addictive substances. Yesterday, I have decided to



joset@kee $ su -c "emerge -C nasm"

After cleaning up, a tune-up followed



.data

msg:
.ascii "A small step for me is a big leap for... me!\n"
len = . - msg

.text

.global _start

_start:

# write string to stdout

movl $len, %edx
movl $msg, %ecx
movl $1, %ebx
movl $4, %eax
int $0x80

# exit

movl $0, %ebx
movl $1, %eax
int $0x80

Now I have finally made a change-gas. Expecting a lot of maintenance work to follow.

Thursday, February 23, 2006

ADZU openlab scutworks

I really do not enjoy network administration a lot but the tasks listed below are rewarding. Let optimism light the path.


0] Tweak and secure box
1] Video screen capture
2] ADZU Debian repository
3] OpenAFS and Kerberos
4] IPv6
5] Honeypot
6] SETI


Expect postponement of blog posts. Everything will be documented here upon completion.


Signing off through a quote by Mr. Oscar Wilde


Experience is one thing you can’t get for nothing.

Sunday, February 19, 2006

Verify user in /etc/passwd

This is a product of wonder.


In file verify.c



#include <stdio.h>
#include <string.h>

#define MAX_LENGTH 1024

int is_local(char *user)
{
FILE *fd;
char line[MAX_LENGTH];
int local = 0;

if(!(fd = fopen("/etc/passwd", "r"))) {
puts("Can't read /etc/passwd, exiting.");
exit(1);
}

while(fgets(line, MAX_LENGTH, fd) > 0) {
if(!strncmp(line, user, strlen(user))) {
local = 1;
break;
}
}
fclose(fd);
return local;
}

Use at your own risk.


Disclaimer: Please refer to my first post ‘General notice’


Posted using Scott Yang’s mtsend.py python script. Thanks to Niel for his cool vim mappings.

Saturday, February 18, 2006

A hidden post made visible

I was afraid to make this available in public. When I tried to browse some counterpart of it in other distros, I have realized that there are a lot of similar topics found even in the official forums of major distros. There are many people doing this already. So for people ranging from lowerclass to middleclass, who can not afford a digital subscriber line, here is a wiser alternative.


If you have a Smartlink chipset winmodem in possession, then you are a bit luckier than those who own a Conexant chipset winmodem. Smartlink drivers are available for free eversince. Conexant drivers (lin*xant) were freely distributed during the 2.4 series era. This means, 2.4 kernels can still abuse the driver’s full-functionality.


Bad news for 2.6 starters, 2.4-2.6 shifters, and 2.4 starters who hold Conexant chipset winmodems. Why?


1. Free drivers for 2.4 series are no longer available in the official repository.
2. Drivers for 2.6 are free but limit your bandwidth to 14.4kbps. Free isn’t it?


So keep your 2.4 kernels, move to 2.6, and enjoy the modem’s irregulated downstreams and upstreams. Here is how:


Whip up a hexeditor and do stuffs below the belt.

Tuesday, February 14, 2006

Test mtsend

mtsend.py is a command line tool written in python. It uses Movable Type’s XML-RPC interface. It appears that it also works with WordPress’ XML-RPC interface. So I have decided to give it a try.


In file ~/.mtsendrc



[global]
default=eradicus

[site-blogsome]
url=http://eradicus.blogsome.com/xmlrpc.php
username=*****
password=*****
encoding=UTF-8

[blog-eradicus]
site=blogsome
blogid=1

It works!



joset@kee$ ./mtsend.py -B blogsome
+----+-----------+-------------------------------+
| ID | Blog Name | URL |
+----+-----------+-------------------------------+
| 1 | Sophie | http://eradicus.blogsome.com/ |
+----+-----------+-------------------------------+

joset@kee$ ./mtsend.py -C
+----+----------------------+
| ID | Category Name |
+----+----------------------+
| 5 | Healthy Vices |
| 2 | Of Love and Romance |
| 1 | Progressive Studies |
| 3 | Uncategorized |
| 6 | Unsolicited Opinions |
+----+----------------------+

joset@kee$ ./mtsend.py -V
Version 1.1

Massive blogging ahead!

Sunday, February 05, 2006

Queued tasks

Hopefully these features would be added on the game soon.


1. Nick completion
2. Default turn time limit 300/150
3. Display number of players
4. Notify if a player leaves
5. Sortable columns in lobby


The root of all evil in programming starts at early optimization in coding.
- Donald E. Knuth

Thursday, February 02, 2006

Wesnoth terrain

How are maps created? How are terrains organized? These questions are no way different from asking how GNU/Linux works. The brief explanation is, it is very complicated!


Conceptually it works like this:


Terrains are defined in terrain.cfg. They get assigned ID, name, char, etc.


A snippet of terrain.cfg



# Terrain configuration file. Defines how the terrain _work_ in the game. How
# the terrains _look_ is defined in terrain_graphics.cfg .

# NOTE: terrain id's are used implicitly by the in-game help:
# each "[terrain] id=some_id" corresponds to "[section] id=terrain_some_id"
# or "[topic] id=terrain_some_id" identifying its description in [help]

[terrain]
symbol_image=void
id=shroud
name= _ "Shroud"
char=" "
[/terrain]

[terrain]
symbol_image=fog
id=fog
name= _ "Fog"
char="~"
[/terrain]

[terrain]
symbol_image=ocean
id=deep_water
name= _ "Deep Water"
char=s
submerge=0.5
unit_height_adjust=-3
[/terrain]

[terrain]
symbol_image=coast
id=shallow_water
name= _ "Shallow Water"
char=c
submerge=0.4
unit_height_adjust=-4
[/terrain]

--snip--

In terrain-graphics.cfg the char gets assigned to the actual gfx files and given rules for how it is to be placed, layered, transitioned, etc. A normal type terrain gets a base image assigned and optionally several alternative tiles which will be distributed according to a given percentage. Then, it will be fed into the macro responsible for layering and transitioning against other terrains. Multihex terrains use their own custom macros to be assembled and placed (either on top of other terrains or with no background). Castles have their own macros, some terrains are also drawn using the castle macro.


A snippet of terrain-graphics.cfg



# The following flags are defined to have a meaning
#
# * base : the corresponding tile has already graphics for the terrain
# base. No other one should be added.
# * transition-$direction : the corresponding tile already has the transition
# in the given direction (or should not have one). No other one should be
# added.
# * keep-of-$castle : castle being a tile letter. The corresponding tile is the
# keep correspoding to the given castle tile

# The following should be kept on top of the file {terrain-graphics}
#-----------------------------------------------------------------
# Forest< ->Castle|Encampment special cases
#-----------------------------------------------------------------

#define FORESTADJCASTLEA FID ID PROB TILE
[terrain_graphics]
map="
1
* 1
2
* *
*"

[tile]
pos=1
type={ID}
[/tile]

[tile]
pos=2
type={FID}
no_flag="overlay"
set_flag="overlay"
[/tile]

probability={PROB}
rotations=n,ne,se,s,sw,nw

[image]
name={TILE}
position=vertical
base=90,144
[/image]

[/terrain_graphics]
#enddef

--snip--

All sorts of stuff like rotation, precedence, mutual-exclusiveness, ordering, layering, positioning, etc. are the macro’s area of responsibility. You have total control of the game’s interface using the right macro. Ayin made a very powerfull and flexible system, but very complex indeed!


Thanks to freim for the help.

Tuesday, January 24, 2006

Unix half-duplex pipes

The pipe ‘|’ is a type of inter-process communication. Its facilities provide a method for multiple processes to communicate with one another.


Simply putting a pipe in between is a method of connecting the standard output of one process to the standard input of another.



joset@kee$ ls -l | grep -i foo

In the example above, the output of ls is written to the input of grep. Obviously, the output of grep is written to the standard output of the shell, the screen.


Here is how a pipe works.



#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>

int main(void)
{
int fd[2], n_bytes;
pid_t child;
char string[] = "Hello, world!\n";
char readbuf[80];

pipe(fd);

if ((child = fork()) == -1){
perror("fork");
exit(1);
}

if ((child == 0)){
/* child process closes up input side of pipe */
close(fd[0]);

/* send "string" through the output side of pipe */
write(fd[1], string, strlen(string));
exit(0);
}

else{
/* parent process closes up output side of pipe */
close(fd[1]);

/* read in a string from the pipe */
n_bytes = read(fd[0], readbuf, sizeof(readbuf));
printf("Received string: %s", readbuf);
}
return 0;
}

Monday, January 23, 2006

GNU recursive naming convention

Eradicus Redefines All Deprecated Information Creatively Upon Scanning (ERADICUS).

Sunday, January 22, 2006

A legal alien?

Yesterday, I was triggered by my ego to attend a session of WMSU’s review for the incoming ICT proficiency exam. Each student spent a total of Php 460.00 for the review and test fee. It started last week. Passers of the said exam are guaranteed to be certified ICT professionals as noted by NCC. I was curious about how the review was being held. I was able to set myself in the classroom without catching much of the professor’s attention. It was my first attempt. I was somehow excited at first, but as the review went on, the professor did not talk that much and started filling up the chalkboard. The topic was about data structures. I was surprised with what I have found out. I bet you have the idea.

Tuesday, January 10, 2006

A sticky lesson

With a dial-up connection reaching 14kbps at max, an ‘emerge-delta-webrsync’ consuming only 5 minutes of your uptime, a free access from 0000H - 0800H, and a script that does nasty things like disconnect after ‘emerge -f foo’ and switch to ‘init 0′, You will not be able to resist the clamor for an up-to-date box.


The lesson began here:



root@kee# emerge =sys-devel/gcc-3.4.4

This does not mean dirty!



joset@kee$ eix -e gcc

* sys-devel/gcc
...
Installed: 3.3.6 3.4.4-r1
Homepage: http://www.gnu.org/software/gcc/gcc.html
...

Found 1 matches
joset@kee$

Not realizing that having multiple GCCs installed is normal, and without following the upgrading-gcc-guide, a stupid action followed.



root@kee# emerge -C =sys-devel/gcc-3.3.6

Bang! libstdc++.so.5.0.6, where the hell are you? All programs linked dynamically to this library were paralized! My intention was to clean up gcc-3.3.6 since I have emerged gcc-3.4.4 recently.


After abusing /dev/ppp0’s abnormal upstream and downstream rates, I have finally learned my lessons.

Luckily, my box was revived!
The solution found in http://gentoo-wiki.org proved its worth.

Sunday, January 01, 2006

Love is an essential inspiration

Unrequited love, is, something that you should not take away from the person offering you. It is willing to stay to you forever. It will grow on every assault. The longer it takes, the stronger it gets. Unrequited love finds justice if not being deprived of it having expressed.