Archive

Author Archive

Bash http_proxy: from a user environment to sudo one

October 14, 2010 9 comments

Hi. Sometimes you can’t connect directly to internet, because you have to go through a proxy (i.e. working environment).
Did you ever have to set up an http proxy on linux shell in order to (i.e) download a new package or manually update your distribution with a packet manager?
If so, you need to be a superuser. If you use the “sudo” command, you will probably stumbled across the inability to export variables from the user environment to the “sudo” one.
Read more…

Categories: Bash, GNU/Linux Tags: , , ,

Win32 API: Passing Socket with IPC method

October 13, 2010 1 comment

Hi. In this post I talk to you how to correctly pass a socket created in a parent process to a child process in Microsoft 9x systems.
If you have ever written a multi-process concurrent server in a Unix environment, you may have noticed that the passage of the socket between parent and son processes takes place directly. That is, the child inherits the variables of his parent, also including the file descriptor associated with the socket.

Read more…

Hello World! – Brain mode

October 12, 2010 5 comments

Hi. How can we write an “hello world!” in brain-mode?
When we want to greet someone, the brain is activated and set as a greeting a phrase known to us: in our case, “hello world!”.
Read more…

Categories: Bullshit, C/C++ Tags: ,

Debian Release Name

October 9, 2010 Leave a comment

Hi. Today Today I leardned about the relationship between the name of the Debian’ releases and the names of the characters of “toy Story”. So I want to explain it to you.
The names of the Debian’ releases come from “Toy Story”, the famous Pixar’s film (link). This is true since the release 1.1, released in the 1996. By this time, Bruce Perens had taken over leadership of the Project from Ian Murdock and Bruce was working as system programmer at Pixar.
Read more…

Categories: Bullshit, GNU/Linux Tags: , ,

Timeout on Named Pipes

October 8, 2010 1 comment

Hi. In this post, I will show you how make a timeouted namedpipe with the WIN32 API: the msdn’s manual doesn’t explain how to do it.
The named pipes are an IPC’s method by which we can send data to an other process (like a son process).
Read more…

Using SHA1() function

October 6, 2010 9 comments

Hi. I’ ll show you how to convert any string into a SHA1 hash using the openssl library.
To use this library you must include in your codes this:

#include <openssl/sha.h>

Moreover you have to compile the source with the “-lssl” flag.
The following code takes in input a string (argv[1]) and generates an hash string through the SHA1() function. The value of “SHA_DIGEST_LENGTH” is 20 bytes, that is the dimension of SHA1 output.
This function stores the value computed in “temp” variable.
Then in the for loop, I copy the value of “temp” into “buf”, according to the standard format of SHA1 strings.

#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

int main(int argn, char *argv[]) {

	int i = 0;
	unsigned char temp[SHA_DIGEST_LENGTH];
	char buf[SHA_DIGEST_LENGTH*2];

	if ( argn != 2 ) {
		printf("Usage: %s string\n", argv[0]);
		return -1;
	}

	memset(buf, 0x0, SHA_DIGEST_LENGTH*2);
	memset(temp, 0x0, SHA_DIGEST_LENGTH);

	SHA1((unsigned char *)argv[1], strlen(argv[1]), temp);

	for (i=0; i < SHA_DIGEST_LENGTH; i++) {
		sprintf((char*)&(buf[i*2]), "%02x", temp[i]);
	}

	printf("SHA1 of %s is %s\n", argv[1], buf);

	return 0;

}

We can compile and run it as follows:

$ gcc sha.c -lssl -o sha
$ ./sha asd
SHA1 of asd is f10e2821bbbea527ea02200352313bc059445190

If you want know something else of SHA1() function you can use the manpages:

man 3 sha1

Or look up in openssl website: link

Thinkpad IBM audio buttons

October 6, 2010 Leave a comment

Hi.
Do you have an ibm thinkpad?
Do you have gnome?
Do you have ubuntu?
You can not associate the hardware audio buttons with the volume indicator?
The most likely solution is to add ONE of the following lines to the “/etc/rc.local” file:

cp /sys/devices/platform/thinkpad_acpi/hotkey_all_mask /sys/devices/platform/thinkpad_acpi/hotkey_mask

Or:

echo 0x00ffffff > /proc/acpi/ibm/hotkey

… and, maybe, the buttons will work… :)

Piracy VS Theft

October 6, 2010 Leave a comment

Because the piracy is not theft…

Piracy-vs-Theft

Categories: Bullshit

India’s Code

October 5, 2010 1 comment

Hello. I do not remember where I found the code that follows, so I don’t know who was the real
owner of this beauty (all rights to the original creator).
It is an obfuscated code in C language:

#include <stdio.h>

void main()
{
   
   int a, b = 10, c;
   int count = 1;
   
   for (b=c=10; a="- FIGURE?, UMKC,XYZHello Folks,\
		  TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
		  UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
		  NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
		  HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
		  T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
		  Hq!WFs XDt!" [b+++21]; )
		  
     for(; a-- > 64 ; )
       putchar ( ++c=='Z' ? c = c/ 9:33^b&1);
}

Try to run it… amazing, is not it?

Read more…

Follow

Get every new post delivered to your Inbox.