- Prison Code Breaker Diary -

=> aka: Nhật Kí Code Tù

Categories

My friends wonder how to copy & paste from/to Putty under Linux.

Here the trick:

+ in putty screen, highlight the text you want to copy, move to text application, press middle-button of the mouse to paste it.
+ vice versa, highlight and copy the text you want to paste into Putty, then press the middle-button to paste into Putty.

Have fun!@

I have introduced about GtkVBox in the previous lesson; however, GtkHBox is basically the same as GtkVBox. The only difference is the horizontal arrangement of GtkHBox.
Reference GtkHBox

Things do the same.
So just try to mix GtkHBox and GtkVBox you can do a small application like this:Why not make it a practice?

Detail: an Gtk+ application, like a phone dial

When you done, you can check out my source below, it's pretty handy though...



/*
* @author [JaPh]
* @date August 12, 2009
* @file GtkHVBox_01.c
* @site http://xjaphx.blogspot.com/
*/

#include <gtk/gtk.h>
#include <string.h>

void
gtk_label_append_text( GtkLabel *label, char *s )
{
int len = strlen( gtk_label_get_text( label ));
gchar buf[128];
snprintf( buf, len + 2, "%s%s", gtk_label_get_text( label ), s );
gtk_label_set_text( label, buf );
}

void
btn1_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "1");
}
void
btn2_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "2");
}
void
btn3_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "3");
}
void
btn4_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "4");
}
void
btn5_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "5");
}
void
btn6_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "6");
}
void
btn7_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "7");
}
void
btn8_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "8");
}
void
btn9_clicked_event( GtkButton *btnN, GtkLabel *label )
{
gtk_label_append_text( label, "9");
}

void
btn_clear_clicked_event( GtkButton *btn_clear, GtkLabel *label )
{
gtk_label_set_text( label, " " );
}

int
main( int argc, char *argv[] )
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *hbox1, *hbox2, *hbox3, *hbox4;
GtkWidget *btn1, *btn2, *btn3, *btn4,
*btn5, *btn6, *btn7, *btn8, *btn9;
GtkWidget *btn_clear, *btn_exit;

gtk_init( &argc, &argv );

/* window */
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title( GTK_WINDOW(window), "[JaPh]Lesson 10: GtkHBox & GtkVBox" );
gtk_widget_set_size_request( window, 300, 300 );

/* top level vbox */
vbox = gtk_vbox_new( TRUE, 0 ) ;

/* hbox1: btn1, btn2, btn3 */
hbox1 = gtk_hbox_new( TRUE, 0 );
btn1 = gtk_button_new_with_label("1");
btn2 = gtk_button_new_with_label("2");
btn3 = gtk_button_new_with_label("3");
gtk_box_pack_start( GTK_BOX( hbox1 ), btn1, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox1 ), btn2, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox1 ), btn3, TRUE, TRUE, 5 );

/* hbox2: btn4, btn5, btn6 */
hbox2 = gtk_hbox_new( TRUE, 0 );
btn4 = gtk_button_new_with_label("4");
btn5 = gtk_button_new_with_label("5");
btn6 = gtk_button_new_with_label("6");
gtk_box_pack_start( GTK_BOX( hbox2 ), btn4, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox2 ), btn5, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox2 ), btn6, TRUE, TRUE, 5 );

/* hbox3: btn7, btn8, btn9 */
hbox3 = gtk_hbox_new( TRUE, 0 );
btn7 = gtk_button_new_with_label("7");
btn8 = gtk_button_new_with_label("8");
btn9 = gtk_button_new_with_label("9");
gtk_box_pack_start( GTK_BOX( hbox3 ), btn7, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox3 ), btn8, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox3 ), btn9, TRUE, TRUE, 5 );

/* hbox4: btn_clear, btn_exit */
hbox4 = gtk_hbox_new( TRUE, 0 );
btn_clear = gtk_button_new_with_label("Clear");
btn_exit = gtk_button_new_with_label("Exit");
gtk_box_pack_start( GTK_BOX( hbox4 ), btn_clear, TRUE, TRUE, 5 );
gtk_box_pack_start( GTK_BOX( hbox4 ), btn_exit, TRUE, TRUE, 5 );

/* vbox: hbox1, hbox2, hbox3, hbox4 */
label = gtk_label_new("Click any number button");
gtk_box_pack_start( GTK_BOX( vbox ), label, TRUE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX( vbox ), hbox1, TRUE, TRUE , 5 );
gtk_box_pack_start( GTK_BOX( vbox ), hbox2, TRUE, TRUE , 5 );
gtk_box_pack_start( GTK_BOX( vbox ), hbox3, TRUE, TRUE , 5 );
gtk_box_pack_start( GTK_BOX( vbox ), hbox4, TRUE, TRUE , 5 );

/* add to window */
gtk_container_add( GTK_CONTAINER( window ), vbox );

/* signal connect */
/* window */
g_signal_connect( window, "destroy",
G_CALLBACK( gtk_main_quit ), NULL );

/* btn1->9 */
g_signal_connect( GTK_BUTTON( btn1 ), "clicked",
G_CALLBACK( btn1_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn2 ), "clicked",
G_CALLBACK( btn2_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn3 ), "clicked",
G_CALLBACK( btn3_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn4 ), "clicked",
G_CALLBACK( btn4_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn5 ), "clicked",
G_CALLBACK( btn5_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn6 ), "clicked",
G_CALLBACK( btn6_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn7 ), "clicked",
G_CALLBACK( btn7_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn8 ), "clicked",
G_CALLBACK( btn8_clicked_event ), GTK_LABEL( label ) );

g_signal_connect( GTK_BUTTON( btn9 ), "clicked",
G_CALLBACK( btn9_clicked_event ), GTK_LABEL( label ) );


/* btn_clear */
g_signal_connect( GTK_BUTTON( btn_clear ), "clicked",
G_CALLBACK( btn_clear_clicked_event ), GTK_LABEL( label ) );

/* btn_exit */
g_signal_connect( GTK_BUTTON(btn_exit), "clicked",
G_CALLBACK( gtk_main_quit ), NULL );

gtk_widget_show_all( window );

gtk_main();

return 0;
}

This is my little video guide through the wargame of SmashTheStack.Org

Wargame: SmashTheStack.Org | IO | Level 3
Creator: [JaPh]
Video: [ OGV | Length: 13.38 min | 30.5 MB | Super High Quality ]
Download: Rapidshare
Password: [japh]

Have fun!@

A note on x86 Registers

Intel x86's registers can be divided into several categories:

  • General-purpose registers
  • Segment registers
  • Program flow control registers
  • Other registers.
General-purpose registers include EAX, EBX, ECX, EDX, ESP EBP, ESI, and EDI. They are not all equal in their usage, and some instructions assign them special functionality. Segment registers are used to point to different seg-ments of process address space.Their functions are as follows: CS points to the beginning of a code segment; SS is a stack segment; DS, ES, FS, GS, and various other data segments, for example, the segment where static data is kept. Many processor instructions implicitly use one of these segment registers, so usually we will not need to mention them in our code. If you want to be more precise, instead of an address in memory these registers contain references to internal processor tables that are used to support virtual memory.

EIP: Extended Instruction Pointer. When you call a function, this pointer is saved on the stack for later use. When the function returns, this saved address is used to determine the location of the next executed instruction.

ESP: Extended Stack Pointer. This points to the current position on the stack and allows things to be added to and removed from the stack using push and pop operations or direct stack pointer manipulations.

EBP: Extended Base Pointer. This register usually stays the same throughout the execution of a function. It serves as a static point for referencing stack-based information such as variables and data in a function using offsets.This pointer usually points to the top of the stack for a function.

Reference from:
  • Buffer Overflow Attacks: Detect, Exploit, Prevent (by James C. Foster, Vitaly Osipov, Nish Bhalla, Niels Heinen)

Just several days, I've known that I need to learn more and had better study faster than I did. It's not time for rest or slowly gain, I have to make a jump forward science and technology; but it should be always a good jump. Well, not exactly always but a better frequency.
The proof is I was freaking slow to figure out [smashthestack] wargame level 4....shame on me as a Linux user. The second, level 0 in [overthewire-vortex] wargame took me such a long time to handle bytes received. It's been such a long time I haven't programmed network in perl. How shameful I am!
Thanks God for these events coming up, so that I know what levels of my current skills and abilities. Therefore, I have to train myself more and better.
IT'S A MUST !

This is my little video guide through the wargame of SmashTheStack.Org

Wargame: SmashTheStack.Org | IO | Level 2
Creator: [JaPh]
Video: [ OGV | Length: 12.26 min | 36 MB | Super High Quality ]
Download: Rapidshare
Password: [japh]


Have fun!@

SmashTheStack Wargame Video Guide Series
Creator: [JaPh]


Have you ever heard of SmashTheStack.Org ?
Yeah, they provide really nice wargames for practicing computer skills.
If you have any troubles, I provide this series as a little guide for you.

The IO Wargame

Level 1 - Guide
Level 2 - Guide
Level 3 - Guide
Level 4 - Guide
Level 5 - Guide

[ to be continued ... ]

Have fun!@