Centroid.EU Blog

(this blog is mostly encrypted - adults only)
  

Previous Page


Goodbye Source!

April 1st, 2013

A large company's spokesman has approached me and offered 100,000 dollars for my source code found here . I'm going to buy a tablet with that money, and possibly getting rid of all my computers that have a keyboard.

0 comments

Next wednesday is SVP Radio's 2nd year anniversary

March 30th, 2013

Do a search for "anniversary", we've been doing this two years now. This time there isn't as many pictures as last anniversary but it's also our second and not the first.

0 comments

My sorta first ruby program

March 30th, 2013

I was watching "the bourne identity" last night and during the breaks I programmed on my first ruby program, here it is:

#!/usr/local/bin/ruby -w

#
# this program reads from argv and takes a name argument it then says hello
#

if ARGV.size == 1
        input = ARGV[0]
else
        exit 1
end

#
# ok we got a name lets do something with it
#

if input == "peter"
        puts "hello peter, nice of you to come back to me"
elsif input == "jason"
        puts "mr bourne, you're still in paris?"
else
        puts "hello " + input + ", how are you?"
end

#Process.kill("ABRT", Process.pid)

exit 0
A friendly person in an efnet channel made a 1 liner out of this:
#!/usr/local/bin/ruby -w

puts ({ "peter" => "nice of you to come back to me peter", \
"jason" => "still in paris mr bourne?" })[ARGV.shift]

Process.kill("ABRT", Process.pid)
I later added the SIGABRT's in order to look at the size of the memory image and his has a larger memory footprint than mine. I guess size is misleading.

0 comments

OpenBSD has released it's 5.3 Song

March 25th, 2013

OpenBSD the OS that strives for best security has released it's most recent media, the 5.3 song. They are also doing pre-orders for the 5.3 release at OpenBSD.org. If you've been using OpenBSD and downloading it from the Internet, consider buying a copy once in a while. It makes all the difference.

0 comments

Switched emea to FreeBSD

March 24th, 2013

I have switched my EMEA vps to FreeBSD. It took all day as I had to configure jails in it, but I think I'm mostly done. I'm just watching the 1st backup of it go through to my online storage.

0 comments

First day of Spring! Goodbye Winter!

March 20th, 2013

Just like the Hooray! that I let out in 2011, I'm very excited that this winter is gone. I'm hoping we get blue skies this spring as well. BTW that link when you click it has a picture with an Analemma on it. I made a mistake with the equinoxes they are in fact further down and not at the joint of the figure eight. Oh well, I can't always have correct astronomy, astronomy is a learn cycle, based on wrong assumptions and proofs (although I didn't proof the analemma I just read about it in a astronomy magazine, which proofed me wrong).

0 comments

Equinox in 2 days

March 18th, 2013

The Northward Equinox is upon us again in 2 days on March 20th, 11:02 AM UT. This is also called the March Equinox or for a northern hemispherer the Spring Equinox. Have fun with this information!

0 comments

An era ends?

March 10th, 2013

In 1999 or so I switched globalserve.net's relay mail servers to postfix, taking the load off sendmail. Today I switched my main mail servers to OpenSMTPD, ending 14 years of loving postfix. I still run postfix at work but in time we'll be able to switch it as well, I hope.

0 comments

Ordered two books

March 8th, 2013

I have ordered two books, hoping they'll help me.

  • The Ruby Programming Language - David Flanagan, Yukihiro Matsumoto
  • Ruby Cookbook - Lucas Carlson and Leonard Richardson
I like how these aren't C like languages because I like to keep a seperation from my C knowledge and other languages.

0 comments

My first libssh program

March 7th, 2013

I have made a libssh program to sftp a file from standard input to a file on an sftp site. I use strato hidrive cloud storage for my backups and that is what I use this file for. I pipe it through openssl and another one time pad program to make sure strato can't look at my stuff. I want to share the code, here it is:

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

#include 

#define FTPUSER         "secret"
#define FTPPASS         "extrasecret"


int
main(int argc, char *argv[])
{
        ssh_session sess;
	sftp_session sftp;
	sftp_file file;

        char *user = FTPUSER;
        char *pass = FTPPASS;

        char buf[512];
        u_char md5buf[16];
        char timebuf[32];
	u_char *hash = NULL;

        int ch, fd, rc;
        int len;
	int state, hlen;
        int checksum = 0;
	int nwritten;

        struct tm *tm;
        MD5_CTX ctx;
        time_t now;

        while ((ch = getopt(argc, argv, "mp:u:")) != -1) {
                switch (ch) {
                case 'm':
                        checksum = 1;
                        break;
                case 'u':
                        user = optarg;
                        break;
                case 'p':
                        pass = optarg;
                        break;
                }
        }

        argc -= optind;
        argv += optind;

        if (argv[0] == NULL || argv[1] == NULL) {
                perror("args -> IP file");
                exit(1);
        }

	/* log in here */

	if ((sess = ssh_new()) == NULL) {
		perror("ssh_new");
		exit(1);
	}

	ssh_options_set(sess, SSH_OPTIONS_HOST, argv[0]);
	
	if ((rc = ssh_connect(sess)) != SSH_OK) {
		fprintf(stderr, "error connecting to %s: %s\n", argv[0],
			ssh_get_error(sess));
		ssh_free(sess);
		exit(1);
	}	

	state = ssh_is_server_known(sess);
	hlen = ssh_get_pubkey_hash(sess, &hash);

	if (state != SSH_SERVER_KNOWN_OK) {
		fprintf(stderr, "something was wrong with the session "
			"state, to be sure I'll just exit here..\n");
		ssh_disconnect(sess);
		ssh_free(sess);
		exit(1);
	}
		
	if ((rc = ssh_userauth_password(sess, user, pass)) != SSH_AUTH_SUCCESS) {
		fprintf(stderr, "error authenticating...\n");
		ssh_disconnect(sess);
		ssh_free(sess);
		exit(1);
	}
	
	
	if ((sftp = sftp_new(sess)) == NULL) {
		fprintf(stderr, "Error allocating SFTP session: %s\n",
			ssh_get_error(sess));

		ssh_disconnect(sess);
		ssh_free(sess);
		exit(1);
	}
	
	if ((rc = sftp_init(sftp)) != SSH_OK) {
		fprintf(stderr, "Error initializing SFTP session: %s\n", 
			sftp_get_error(sftp));	
		sftp_free(sftp);
		ssh_disconnect(sess);
		ssh_free(sess);
		exit(1);
	}	

	snprintf(buf, sizeof(buf), "/home/pjp/%s", argv[1]);

	file = sftp_open(sftp, buf, O_WRONLY | O_CREAT | O_TRUNC, 0600);
	if (file == NULL) {
		fprintf(stderr, "can't open file for writing: %s\n", 
				ssh_get_error(sess));
		sftp_free(sftp);
		ssh_disconnect(sess);
		ssh_free(sess);
		exit(1);
	}

        if (checksum) {
                (void)MD5_Init(&ctx);
        }


        while ((len = read(STDIN_FILENO, &buf, sizeof(buf))) > 0) {
                if (checksum) {
                        (void)MD5_Update(&ctx, buf, len);
                }               

		nwritten = sftp_write(file, buf, len);
		if (nwritten != len) {
			fprintf(stderr, "can't write/append data to file: %s\n",
				ssh_get_error(sess));
			sftp_free(sftp);
			ssh_disconnect(sess);
			ssh_free(sess);
			exit(1);
		}
        }

	rc = sftp_close(file);
	if (rc != SSH_OK) {
		fprintf(stderr, "can't close the written file: %s\n", 
			ssh_get_error(sess));
	}
	
	sftp_free(sftp);

	/* ssh cleanup */

	ssh_disconnect(sess);
	ssh_free(sess);

	/* end checksumming */

        if (checksum) {
                (void)MD5_Final((u_char *)md5buf, &ctx);
                
                fd = open("/root/history.md5", O_WRONLY | O_CREAT| O_APPEND, 0600);
                if (fd < 0) {
                        perror("open");
                        exit(1);
                }
                now = time(NULL);
                tm = localtime(&now);
                strftime(timebuf, sizeof(timebuf), "%F", tm);
                snprintf(buf, sizeof(buf), 
"%s %s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", 	
			timebuf, argv[1], 
                        md5buf[0] & 0xff, md5buf[1] & 0xff, md5buf[2] & 0xff,
                        md5buf[3] & 0xff, md5buf[4] & 0xff, md5buf[5] & 0xff,
                        md5buf[6] & 0xff, md5buf[7] & 0xff, md5buf[8] & 0xff,
                        md5buf[9] & 0xff, md5buf[10] & 0xff, md5buf[11] & 0xff,
                        md5buf[12] & 0xff, md5buf[13] & 0xff, md5buf[14] & 0xff,
                        md5buf[15] & 0xff);

                write(fd, buf, strlen(buf));
                close(fd);
	}

	exit (0);
}

The program has hardcoded passwords, not optimal but it works. Also the key must match or it bails immediately (or should). Have fun with this!

0 comments

Next Page

Search

RSS Feed

Click here for RSS

On this day in

Other links

Have feedback?

By clicking on the header of an article you will be served a cookie. If you do not agree to this do not click on the header. Thanks!

Using a text-based webbrowser?

... such as lynx? Welcome back it's working again for the time being.

Older Blog Entries


Powered by BCHS