GTK hello world in C (Not with Glade)

#include <gtk/gtk.h>

/*
* This is a callback function. The data arguments are ignored
* in this example. More on callbacks below
*/

static void hello(GtkWidget *widget, gpointer data){
g_print(“Hello World\n”);
};

static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data){
/* If your return FALSE in the “delete_event” signal handler,
* GTK will emit the “destroy” signal. Returning TRUE means
* you don’t want the window to be destroyed.
* This is useful for popping up ‘are you sure you want to quit?’
* type dialogs.
*/

g_print(“delete event occurred\n”);

/* Change TRUE to FALSE and the main window will be destroyed with
* a “delete_event”.
*/

return TRUE;
};

/* Another callback */
static void destroy(GtkWidget *widget, gpointer data){
gtk_main_quit();
};

/* And now the main 😀 */
int main(int argc, char *argv[]){
/* GTkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *button;

/* This is called in all GTK applications. Arguments are parsed
* from the command line and are returned to the application.
*/
gtk_init(&argc, &argv);

/* create a new window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

/* When the window is given the “delete_event” signal (this is given
* by the window manager, usally by the “close” opion, or on the
* titlebar), we ask it to call the delete_event() function
* as defined above. The data passed to the callback
* function is NULL and is ignored in the callback function.
*/
g_signal_connect(G_OBJECT(window), “delete_event”, G_CALLBACK(delete_event), NULL);

/* Here we connect the “destroy” event to a signal handler.
* This event occurs when we call gtk_widget_destroy() on the window,
* or if we return FALSE in the “delete_event” callback.
*/
g_signal_connect(G_OBJECT(window), “destroy”, G_CALLBACK(destroy), NULL);

/* Sets the border with of the window. */
gtk_container_set_border_width(GTK_CONTAINER(window), 10);

/* Creates a new button with the label “Hello World”. */
button = gtk_button_new_with_label(“Hello World”);

/* When the button receives the “clicked” signal, it will call the
* function hello() passing it NULL ad its argument. The hello()
* function is defined above. */
g_signal_connect(G_OBJECT(button), “clicked”, G_CALLBACK(hello), NULL);

/* This will cause the window th be destroyed by calling
* gtk_widget_destroy(window) when “clicked”. Agin the destroy
* signal could come from here, or the window manager. */
g_signal_connect_swapped(G_OBJECT(button), “clicked”, G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));

/* This packs the button into the window(a gtk container). */
gtk_container_add(GTK_CONTAINER(window), button);

/* This final step is to display this newly created widget. */
gtk_widget_show(button);

/* and the window */
gtk_widget_show(window);

/* All GTK applications must have a gtk_main(). Control ends here
* and waits for an event to occur (like a key press or
* mouse event).
*/
gtk_main();

return 0;
};

/*
* Compile: gcc helloworld.c -o helloworld `pkg-config –cflags –libs gtk+-2.0`
*/

Udgivet i Knowledge Base, Linux, Old Base, Programmering | Skriv en kommentar

GTK i C og glade

Hvordan man laver et hello world program i c og glade….
(Der er en fejl i koden der gør man kan lave buffer overrun :S)

http://writelinux.com/glade/

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

Danske Gentoo Mirrors

Danske gentoo mirrors:

http://mirror.uni-c.dk/gentoo/
ftp://ftp.dkuug.dk/pub/gentoo/
ftp://rsync.gentoo.diku.dk


Fra http://www.diku.dk/it-systemerne/nyhedsbrev/nyhedsbrev-2004-08.html

Gentoo mirror på DIKU
I forbindelse med overgangen til Gentoo på DIKU har vi fået vores eget rsync- og distfiles-mirror på henholdsvis rsync.gentoo.diku.dk og ftp.gentoo.diku.dk. DIKUs Gentoo mirror er frit for alle og kan benytte både fra DIKUs interne net og udefra.

rsync-delen synkroniseres en gang i døgnet kl. 1:01 om natten, mens distfiles-delen synkroniseres en gang i døgnet kl. 3:01 om natten. For at benytte DIKUs Gentoo mirrors skal man sætte henholdsvis

SYNC="rsync://rsync.gentoo.diku.dk/gentoo-portage"

og

GENTOO_MIRRORS="ftp://rsync.gentoo.diku.dk/"

i sin /etc/make.conf.
Udgivet i Knowledge Base | Skriv en kommentar

Lave simpel iso med mkisofs

mkisofs -r -o cd_image dir/

Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar

Test your browser for common vulnerabilities

http://bcheck.scanit.be/bcheck/

Udgivet i Knowledge Base, Links, Old Base, Workstation | Skriv en kommentar

Creating chrooting init scripts in gentoo

just create something similar to this:

start() {
ebegin “Starting ${CHROOT:+chrooted }dhcpd”
start-stop-daemon –start –quiet –exec /usr/sbin/dhcpd \
— -pf /var/run/dhcp/dhcpd.pid \
-user dhcp -group dhcp ${DHCPD_OPTS} \
${CHROOT:+-chroot ${CHROOT}} ${IFACE}
eend $?
}

stop() {
ebegin “Stopping dhcpd”
start-stop-daemon –stop –quiet –pidfile \
“${CHROOT}/var/run/dhcp/dhcpd.pid”
eend $?
}

Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar

SSH->Apache HTTP Proxy

mod_proxy must be compiled and loaded.

This redirects every request from free6dating.dk to google.com

ProxyRequests Off

<VirtualHost *:80>
ProxyPass / http://127.0.0.1:1234/
ServerName nagios.metasecurity.dk
</VirtualHost>

212.242.77.76 are the IP of the public machine, on the enclosed/natted machine run the following command:

ssh -R 1234:127.0.0.1:80 212.242.77.76

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar

Sharing the entire X11 Console trough vnc

Emerge x11vnc and start it, whereefter you can vnc connect to localhost and be giving control over the entire X konsole.

Udgivet i Knowledge Base, Networking, Old Base, Workstation | Skriv en kommentar

OS Detecting , ICMP Scanning

http://www.honeynet.org/papers/bots/
http://honeynet.org/papers/honeynet/index.html
http://www.sys-security.com/index.php?page=icmp
http://lcamtuf.coredump.cx/p0f.shtml

Udgivet i Knowledge Base, Links, Networking, Old Base | Skriv en kommentar

Passiv OS Detection

http://lcamtuf.coredump.cx/p0f.shtml

Very effektivt.

130.225.56.8:35381 – Solaris 9 (NAT!)
-> 212.242.77.76:80 (distance 11, link: GPRS, T1, FreeS/WAN)
80.221.95.239:3698 – Windows XP Pro SP1, 2000 SP3
-> 212.242.77.76:135 (distance 17, link: ethernet/modem)
80.221.95.239:3698 – Windows XP Pro SP1, 2000 SP3
-> 212.242.77.76:135 (distance 17, link: ethernet/modem)
80.221.95.239:3698 – Windows XP Pro SP1, 2000 SP3
-> 212.242.77.76:135 (distance 17, link: ethernet/modem)
80.55.217.110:3060 – Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222)
-> 212.242.77.76:135 (distance 16, link: ethernet/modem)
80.55.217.110:3060 – Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222)
-> 212.242.77.76:135 (distance 16, link: ethernet/modem)
80.55.217.110:3060 – Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222)
-> 212.242.77.76:135 (distance 16, link: ethernet/modem)
62.107.32.199:33122 – Linux 2.5 (sometimes 2.4) (4) (up: 21 hrs)
-> 212.242.77.76:80 (distance 12, link: ethernet/modem)
212.10.4.116:49584 – FreeBSD 4.7-5.1 (or MacOS X 10.2-10.3) (1) (up: 11186 hrs)
-> 212.242.77.76:80 (distance 14, link: ethernet/modem)
212.241.83.5:1493 – Windows XP SP1, 2000 SP4 (3)
-> 212.242.77.76:1433 (distance 17, link: ethernet/modem)
212.241.83.5:1493 – Windows XP SP1, 2000 SP4 (3)
-> 212.242.77.76:1433 (distance 17, link: ethernet/modem)
212.241.83.5:1493 – Windows XP SP1, 2000 SP4 (3)
-> 212.242.77.76:1433 (distance 17, link: ethernet/modem)

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar