~ overflow ~

Uncategorized

Automatic Backups to gmail

by z3n on Mar.25, 2010, under Uncategorized

Problem:

Gmail is offering a considerable ammount of free space, now, it can be used to do automatic backups, specially if you run a database or something critical.

Solution:

They offer a lot of space … but you can’t get emails bigger than 20mb, so you need to do some tricks,

first a little bash script:

#!/bin/bash
s_ts() { date "+[%H:%M:%S%p]"; }
_dt=`date +%y%m%d`
echo \(c\) z3n - R1V1.06@070509 \(PiD:$$\)
cd /path/to/backup/folder
echo `s_ts` SQL Backup...
mysqldump -pMYSQL_PASSWORD --all-databases > mysql-"$_dt".sql
echo `s_ts` Compressing...
rar a -m5 -inul -s -rr3  -v19750k -df mysql-"$_dt".rar mysql-"$_dt".sql
cd ..;php ma.php mysql-"$_dt".rar

and then a ma.php to email attachments:

// (c) z3n - z3n666@gmail.com

define('from','backup@youdomain.com');
define('to','your.gmail@gmail.com');
define('subject','MySQL Backup - '.date("Y-m-d"));
define('base_path','/path/to/backup/');

set_time_limit(0);
ini_set("memory_limit","1G");

function send_attach_mail($email_from,$email_to,$email_subject,$file) {

	$email_message = $file; // Message that the email has in it 

	$semi_rand=md5(time());
	$mime_boundary="==Multipart_Boundary_x{$semi_rand}x";
	$headers="From: ".$email_from."\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"{$mime_boundary}\"";
	$email_message.="This is a multi-part message in MIME format.\n\n--{$mime_boundary}\nContent-Type:text/html; charset=\"iso-8859-1\"\nContent-Transfer-Encoding: 7bit\n\n".$email_message."\n\n";

	/* First File */
	$fileatt_type = "application/octet-stream"; // File Type
	$fileatt_name = $file; // Filename that will be used for the file as the attachment 

	$rfile = fopen($file,'rb');
	$data = fread($rfile,filesize($file));
	fclose($rfile);
	$data = chunk_split(base64_encode($data));
	$email_message .= "--{$mime_boundary}\nContent-Type: {$fileatt_type};\n name=\"{$fileatt_name}\"\nContent-Transfer-Encoding: base64\n\n".$data."\n\n--{$mime_boundary}\n"; 

	@mail($email_to, $email_subject, $email_message, $headers);
}

if (!isset($argv[1])) {
	die("Usage: ".$_SERVER['PHP_SELF']." <filename>");
} else {
	$argv[1]=str_replace("..","",$argv[1]);
	if (!file_exists(base_path.$argv[1])) { // try to see if this is multipart file
		for ($i=1;file_exists(substr(base_path.$argv[1],0,-3)."part0".$i.".rar");$i++) {
			send_attach_mail(from,to,subject,substr(base_path.$argv[1],0,-3)."part0".$i.".rar");
		}
	} else {
		send_attach_mail(from,to,subject,base_path.$argv[1]);
	}
}

Done!

Leave a Comment :, , more...

Symlinks on Windows

by z3n on Jan.12, 2010, under Uncategorized

Problem:

How to make a symlink or anything similar on windows?

Solution:

According to many sites, windows vista and newer has a built-in hability to do junctions (aka symlink on windows) due it’s new file system, but i don’t want all the gayness of vista, so i’m stuck on xp.

I found out that you can also do junctions on windows xp, although the manual method is not easy. But then i came across this post and found out that sysinternals has a tool to make things easy.

Neat huh?

In case you’re wondering, i’m using this “windows symlink” to freeup space on my o/s drive, since i made (long time ago) a setup with not so much space on that partittion and i don’t want to format, i just did a couple of symlinks to another drive, it worked flawlessly.

Leave a Comment :, , , more...

Using telnet to access pop3 (retrieve emails) and smtp (send emails)

by z3n on Jan.11, 2010, under Uncategorized

Problem:

How to test retrieve and send emails by raw telnet?

Solution:

Retrieving emails (bold lines are the commands, italics are outputs)

telnet mail.yourserver.com 110
Trying 1.2.3.4…
Connected to mail.yourserver.com.
Escape character is ‘^]’.
+OK Dovecot ready.
user your_email@yourserver.com
+OK
pass your_password
+OK Logged in.
list
+OK 1 messages:
1 1133

.

retr 1

message

.

quit

Sending emails:

telnet mail.youremailserver.com 25
Trying 1.2.3.4…
Connected to mail.youremailserver.com.
Escape character is ‘^]’.
220 youremailserver.com ESMTP Postfix

helo yourdomain.com
250 youremailserver.com
auth login
334 VXNlcm5hbWU6
eW91cmVtYWlsQHlvdXJkb21haW4uY29t (youremail@yourdomain.com base64 encoded)
334 UGFzc3dvcmQ6
eW91cnBhc3N3b3Jk (yourpassword base64 encoded)
235 2.0.0 Authentication successful
mail from:youremail@yourdomain.com
250 2.1.0 Ok
rcpt to: someone@somedomain.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: test

hi
.

250 2.0.0 Ok: queued as 8B65ED40075
quit
Note that there’s many different authentication protocols, base64 is the less secure one, some servers may require a better authentication mechanism, or even use an ecrypted port, which will not work with telnet, try open ssl instead.

Leave a Comment :, , , , , more...

Port Scan on Linux

by z3n on Jan.11, 2010, under Uncategorized

Problem:

How to do a port scan on a specific ip/hostname on linux?

Solution:

nc -z <ip> <port-range>

eg.: nc -z 127.0.0.1 1-1024

Source:

ciberciti

Leave a Comment :, , , more...

MySQL importing .sql with accents causing issues

by z3n on Dec.30, 2009, under Uncategorized

Problem:

When importing a .sql with entries with accents, like not regular english, it may lead to issues, like:

São Paulo‘ instead of ‘São Paulo

Solution:

Even mysqld default charset being latin1, sometimes it don’t work with accents, depending on the imports you’re doing.

So you may need to force it to fallback to utf8, on my case i just added this to the beggining of the .sql file i was importing:

charset utf8 \c

and it worked just fine.

Note: If you are using asian chars (japanese/chinese specific), then utf8 might not be enough to cover all chars.

Leave a Comment :, , , , , more...

Dark Skin for Firebug

by z3n on Oct.28, 2009, under Uncategorized

Problem:

Firebug skin is white, it’s annoying and it hurts my eyes.

Solution:

I edited myself a bunch of css files and build up a less annoying version, although there’s a lots of borders that still too light, it’s a real relief for me already.

You can download it here.

You should replace the files on the classic skin, they are located inside the document settings/your user/data something/mozilla/extensions/firebug/skin/

1 Comment :, , , , more...

Ratio Master 1.7.5’s µTorrent 1.8.2 (14458) .client file

by z3n on Feb.24, 2009, under Tips & Hints, Uncategorized

<client name=”uTorrent 1.8.2 build (14458)” author=”z3n” version=”1.1″ processname=”utorrent”>
<query>info_hash={infohash}&peer_id={peerid}&port={port}&uploaded={uploaded}&downloaded={downloaded}&left={left}&key={key}{event}&numwant={numwant}&compact=1&no_peer_id=1</query>
<headers>Host: {host}_nl_User-Agent: uTorrent/1820_nl_Accept-Encoding: gzip_nl_</headers>
<peer_id prefix=”-UT1820-_1″ type=”random” length=”10″ urlencoding=”true” upperCase=”false” value=””/>
<key type=”hex” length=”8″ urlencoding=”false” upperCase=”true” value=””/>
<protocol value=”HTTP/1.1″/>
<hash upperCase=”false”/>
</client>

Leave a Comment :, , more...

Hello world!

by admin on May.15, 2008, under Uncategorized

w00000000t

welcome to the blog

i don’t have much time so i’m not writing a cool custom shiny message.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!