Centroid.EU Blog
(this blog is mostly encrypted - adults only)
|
Previous Page
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
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
March, 2023
February, 2023
January, 2023
December, 2022
November, 2022
October, 2022
September, 2022
August, 2022
July, 2022
June, 2022
May, 2022
April, 2022
March, 2022
February, 2022
January, 2022
December, 2021
November, 2021
October, 2021
September, 2021
March, 2021
February, 2021
January, 2021
December, 2020
November, 2020
October, 2020
September, 2020
August, 2020
July, 2020
June, 2020
May, 2020
April, 2020
March, 2020
February, 2020
January, 2020
December, 2019
November, 2019
October, 2019
September, 2019
August, 2019
July, 2019
June, 2019
May, 2019
April, 2019
March, 2019
February, 2019
January, 2019
December, 2018
November, 2018
October, 2018
September, 2018
August, 2018
July, 2018
June, 2018
May, 2018
April, 2018
March, 2018
February, 2018
January, 2018
December, 2017
November, 2017
October, 2017
September, 2017
August, 2017
July, 2017
June, 2017
May, 2017
April, 2017
March, 2017
February, 2017
January, 2017
December, 2016
November, 2016
October, 2016
September, 2016
August, 2016
July, 2016
June, 2016
May, 2016
April, 2016
March, 2016
February, 2016
January, 2016
December, 2015
November, 2015
October, 2015
September, 2015
August, 2015
July, 2015
June, 2015
May, 2015
April, 2015
March, 2015
February, 2015
January, 2015
December, 2014
November, 2014
October, 2014
September, 2014
August, 2014
July, 2014
June, 2014
May, 2014
April, 2014
March, 2014
February, 2014
January, 2014
December, 2013
November, 2013
October, 2013
September, 2013
August, 2013
July, 2013
June, 2013
May, 2013
April, 2013
March, 2013
February, 2013
January, 2013
December, 2012
November, 2012
October, 2012
September, 2012
August, 2012
July, 2012
June, 2012
May, 2012
April, 2012
March, 2012
February, 2012
January, 2012
December, 2011
November, 2011
October, 2011
September, 2011
August, 2011
July, 2011
June, 2011
May, 2011
April, 2011
March, 2011
February, 2011
January, 2011
December, 2010
November, 2010
October, 2010
September, 2010
August, 2010
July, 2010
June, 2010
May, 2010
April, 2010
March, 2010
February, 2010
January, 2010
December, 2009
November, 2009
October, 2009
September, 2009
August, 2009
July, 2009
June, 2009
May, 2009
Powered by BCHS
|