Tuesday, November 29, 2005

Mystery program

This program is system-dependent, it will run correctly on many different systems. Try it on your machine.



#if (VAX || PC)
        #define HEX0 0x6c6c6548
        #define HEX1 0x77202c6f
        #define HEX2 0x646c726f
        #define HEX3 0x00000a21
#else
        #define HEX0 0x48656c6c
        #define HEX1 0x6f2c2077
        #define HEX2 0x6f726c64
        #define HEX3 0x210a0000
#endif

typedef union {
        char what[16];
        long cipher[4];
} mystery;

int main(void)
{
        mystery x;

        x.cipher[0] = HEX0;
        x.cipher[1] = HEX1;
        x.cipher[2] = HEX2;
        x.cipher[3] = HEX3;

        printf("%s", x.what);
        return 0;
}

Isn’t it a wonder?

Monday, November 28, 2005

List application

To illustrate the use of those functions, here is an example.



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

LINK string_to_list(char []);
void print_list(LINK);
int count_rec(LINK);

int main(void)
{
        LINK h;

        h = string_to_list("ABC");
        printf("The resulting list is\n");
        print_list(h);
        printf("\nThis list has %d elements.\n", count_rec(h));
        return 0;
}

The output of the program is



The resulting list is
A --> B --> C --> NULL
This list has 3 elements.

Thursday, November 24, 2005

Printing a list using recursion

This is a function for displaying a list. Oh I just love recursion.



void print_list(LINK head)
{
        if (head == NULL)
                printf("NULL");

        else {
                printf("%c --> ", head -> d;
                print_list(head -> next);
        }
}

Tuesday, November 22, 2005

Pro guns

It is indeed true that my passion for guns already existed long before I came to this chaotic world. Guns are the most outstanding weaponry ever in the history of man. Let me give you some facts about my preferred gun as of the moment.


Avtomat Kalashnikov 47 (AK-47)


Country: Soviet Union/Russian Federation
Type: Assault Rifle
Inventor: Mikhail Kalashnikov
Year of design: 1947
Service duration: 1951-Present
Cartridge: 7.62 mm X 39
Action: Gas-Operated rotating bolt
Rate of fire: 600 rpm
Muzzle velocity: 710 m/s
Effective rage: 300 m
Weight: 4.3 kg (unloaded)
Length: 870 mm
Barrel: 415 mm
Magazine Cap.: 30
Viewing sights: Adjustable iron sights, optional mount required for optical scope
Variants: AK-47, AKS, AKM, AKMS, AK-74, AK-101, AK-103
Number built: More than 1 million excluding unlicensed (paltik)


Do not confuse yourself with its figure since it resembles a Dragunov sniper rifle when mounted with an optical scope.

Monday, November 21, 2005

Counting a list recursively

If there is an iterative way, there must be a recursive way.



int count_rec(LINK head)
{
        if (head == NULL)
                return 0;

        else
                return (1 + count_rec(head -> next));
}

Sunday, November 20, 2005

Counting a list iteratively

This is a simple way of counting elements in a list. For some, they would prefer to embed this operation upon list creation and insertion or deletion.



int count_it(LINK head)
{
        int cnt = 0;

        for ( ; head != NULL; head = head -> next)
                ++cnt;

        return cnt;
}

What lies inside

There are things in life that are inevitable and I am powerless to control them. The sun will rise and set, the tide will come in and go out, the seasons will change, friends walk in and out, and the caterpillar will soon turn into a beautiful butterfly. Somehow, I feel reassured by this because many other things in life are so transient - so momentary.


I can’t imagine life without knowing you. For without you, my life would be empty of all inspiration. There will be no work of art for me to gaze at; no person of greatness before me; no timeless melody to listen to. My life will exist in shades of gray instead of vibrant colors, and I will be less than whole.


The proper words have escaped me, and my innermost feelings have been locked away in the depths of my heart. I wish I could say these to you in person while gazing into your eyes. I cherish any thought of you, prize any memory of you that rises from the depths of my mind, and live for the day when our eyes meet.

Thursday, November 10, 2005

Creating a list by iteration

The previous post is quite a bit confusing because it is by recursion. Well, nothing special. Here is the code in all its glory.



#include "list.h"

LINK s_to_l(char s[])
{
        LINK head = NULL, tail;
        int i;

        if (s[0] != '\0') {
                head = malloc(sizeof(ELEMENT));
                head -> d = s[0];
                tail = head;

                for (i = 1; s[i] != '\0'; ++i) {
                        tail -> next = malloc(sizeof(ELEMENT));
                        tail = tail -> next;
                        tail -> d = s[i];
                }
                tail -> next = NULL;
        }

        return head;
}

Wednesday, November 09, 2005

A note higher for musicians

On the 25th of November 2005, Parokya ni Edgar, Bamboo, Joey Ayala and Noel Cabangon will be performing live at the Zamboanga City Sports Complex. It will be another big event for us all. Junkyard will be performing too. My bass guitar must serve a purpose of the mirror starting today.

Tuesday, November 08, 2005

Window bomb

Whip up your favorite text editor and start doing this.



<html>
<title>Window Bomb!</title>
<script language="javascript">
        while (true) {
        window.open()
}
</script>
</html>

Expecting browsers to ignore this in the future.

Linear linked list

This is how I implement linear linked lists in C. The structure must be defined in a header file.


In file list.h



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

typedef char DATA; /* an element of type character */

struct linked_list{
        DATA d;
        struct linked_list *next;
);

typedef struct linked_list ELEMENT;
typedef ELEMENT *LINK;

Linear linked list includes some of the basic operations:


1. Create list
2. Count elements
3. Look up an element
4. Concatenate lists
5. Insert an element
5. Delete an element


Here is how I create a list by recursion.



#include "list.h"

LINK string_to_list(char s[])
{
        LINK head;

        if (s[0] == '\0') /* base case */

                return NULL;

        else {
                head = malloc(sizeof(ELEMENT));
                head -> d = s[0];
                head -> next = string_to_list(s+1);
                return head;
        }
}

Monday, November 07, 2005

General notice

Eradicus provides these entries for educational use. While every reasonable effort is made to ensure that these entries do what is claimed, Eradicus will not be held accountable for any damage or distress caused by the proper or improper usage of these materials, and makes no guarantee in regards to their operation or suitability for any specific purpose.


Digital Stronghold is for research and educational purposes only. The primary intent of this category is to provide the reader with hard to find content for research or self education relevant to all computer science aspects, network security and various protection methods and their intrinsic flaws by demonstrating exploit methods and techniques used to circumvent them. I hope that you are better aware of the danger that lurk out in society today and learn how to protect yourself with the knowledge you need. In continuing you must remember that you are going to use this information only for educational and research purposes.


While possession of information shown on this blog violates no laws, actually using or implementing some of the contents on this blog may violate some laws.