Archive

Posts Tagged ‘perl’

Send Fake Mail

December 5th, 2008

Send Fake Mail

Remember is very posible the mail was arrived on Junk Box.

#!/usr/bin/perl
# Script: fakemail.pl, Version 1.0  [2008-12-04]
# Author: Albertux (Alberto Isaac Ayala Esquivias)
# Web Author: http://Albertux.AyalaSoft.com
# FeedBack:
# Description: Send fake mail.
# Licence: GPLv3
 
use strict;
use warnings;
 
# Chouse the host to connect on port 25
my $host='localhost'; 
 
# The vars
my @raw_data=;
my ($mail1, $mail2, $name1, $name2, $subject, $data );
 
print "Fake Mail: ";
chomp($mail1 = <>);
print "Destiny Mail: ";
chomp($mail2 = <>);
print "Fake Name: ";
chomp($name1 = <>);
print "Destiny Name: ";
chomp($name2 = <>);
print "Subject: ";
chomp($subject = <>);
print "Data: ";
chomp($data = <>);
 
foreach(@raw_data) {
	$_ =~ s/MAIL1/$mail1/g;
	$_ =~ s/MAIL2/$mail2/g;
	$_ =~ s/NAME1/$name1/g;
	$_ =~ s/NAME2/$name2/g;
	$_ =~ s/SUBJECT/$subject/g;
	$_ =~ s/DATA/$data/g;
	$_ =~ s/\\n/\n/g;
}
 
print "mail send.\n";
 
open(STDOUT, "| telnet ".$host." 25 > /dev/null 2>&1");
foreach (@raw_data) {
	print STDOUT $_;
}
 
1;
 
__DATA__
mail from: MAIL1
rcpt to: MAIL2
data
From: NAME1
To: NAME2
Subject: SUBJECT
DATA
.
quit

develop, network, security ,

TODO LIST 2009

December 1st, 2008

TODO LIST 2009

Read/Learn/Practice:

Python 2.6 (What’s New)

Perl 5 (Modules, Packages)

PHP (Changes, and news)

COBOL

.NET (C#, LINQ, (ok VB but not much))

Java (Im interested on Mobil Applications)

Haskell

Ruby (Im interested on Rails)

Parrot and Pugs

Gnu/Linux (Services and Bash)

BSD and OpenSolaris

Personal Projects 2009:

BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com)

Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx)

Forming one’s own business

And others ….

Lambda Functions on PHP 5.3.0:

 $lambda = function () { echo "Hello World!\n"; };

Parrot “Hello World” example:

.sub main
      print "Hello World!\n";
.end

COBOL “Hello World” example:

* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
	IDENTIFICATION DIVISION.
	PROGRAM-ID.    hello.
	ENVIRONMENT DIVISION.
	DATA DIVISION.
 
	PROCEDURE DIVISION.
		DISPLAY "Hello ," WITH NO ADVANCING
		DISPLAY "World!"
		STOP RUN.

Haskell “Hello World” example:

putStrLn "Hello World!"

develop, unix/linux, web, windows , , , , , ,

SQL File to PHP5 Classes (sql2class)

November 25th, 2008

SQL File to PHP5 Classes (sql2class)

(shell prompt) perl sql2class.pl database.sql > classes.php

Download sql2class-0.2.tar.gz sql2class-0.3.tar.gz

I have little time programming in Perl hope to expand this script to support other languages in the future

With this post I dismissal from 2008 until January 2009.

database, develop , ,

Using Windows ? Don’t kill Yourself

October 27th, 2008

Using Windows ? Don’t Kill Yourself

Supose you are Linux user and you have a Windows system.

Alternatives: Cygwin, Mingw or Colinux

You need some (or all) of this interpreters:

Perl, PHP, Python and Ruby

Modify the %PATH%

Example you have a bin dir, on C:\ to include the executables on the %PATH% do this:

set PATH=%PATH%;C:\bin\

On Windows Vista, you can use your mouse:

computer > properties > Advances system settings > (continue) > Advanced > Enviroment Variables > System Variables > Path (edit)

Example run Kompozer on cmd.exe but no modify %PATH%

: kompozer.bat save on %WINDIR%
@"C:\Program Files\Kompozer\kompozer.exe"

Doble click on your scripts to run:

: Perl Scripts
 assoc .pl=Perl.File
 ftype Perl.File=C:\strawberry\perl\bin\perl.exe "%1" %*
 set PATHEXT=%PATHEXT%;.pl
: Python Scripts
 assoc .py=Python.File
 ftype Python.File=C:\Python26\python.exe "%1" %*
 set PATHEXT=%PATHEXT%;.py

Note:

On Windows Vista you need run cmd.exe as Administrator don’t work as normal user

Apache, PHP and MySQL ?

XAMPP and Server2Go

Notes:

XAMPP: simple, quick and easy install.

Server2Go: is great to make CD demo of a Web Application.

Using Perl or Python as CGI on Windows ?

Using Python 2.6

#!\python26\python.exe

Using Strawberry Perl:

#!\strawberry\perl\bin\perl.exe

Now your script works on http://localhost/cgi-bin/script.cgi

develop, unix/linux, windows , , , , ,

PDF Libraries

October 2nd, 2008

PDF Libraries

Sometimes we need create or export data into a PDF:

.NET:

http://www.pdfsharp.com, http://www.codeplex.com/Print2Pdf

C++:

http://libharu.org

Perl:

http://search.cpan.org/~markusb/PDF-Create/lib/PDF/Create.pm

sudo perl -MCPAN -e 'install PDF::Create'

PHP:

http://www.fpdf.org, http://www.digitaljunkies.ca/dompdf, http://pear.php.net/package/File_PDF

Python:

http://www.reportlab.org

wget -c http://www.reportlab.org/ftp/ReportLab_2_2.tgz
tar xvzf ReportLab_2_2.tgz
cd ReportLab_2_2
sudo python setup.py install

Java:

http://www.lowagie.com/iText, http://www.pdfbox.org

Ruby:

http://ruby-pdf.rubyforge.org/pdf-writer

sudo gem install pdf-writer

develop , , , , , ,

YouTube++ Download and Converter

September 15th, 2008

YouTube++ Download and Converter

you need: Perl, wget, ffmpeg and this script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use LWP::Simple;
print "YouTube++ (URL's to MP3's) By Albertux\n[http://albertux.ayalasoft.com]\n";
 
$total = @ARGV;
 
if ($total==0) {
 
	print "\nExample: ~\$ youtube\+\+ url1 url2 url3 ...\n";
 
} else {
 
	foreach(@ARGV) {
 
		$URL = $_;
		$aux = index($URL,"?v=");
		$a = substr $URL,$aux+3,11;
		$content = get($URL);
		@lines = split("\n",$content);
 
		foreach(@lines) {
			my $aux = index($_,"&t=");
			if ($aux > -1) { 
				$t = substr $_, $aux+3,32;
			}
		}
		system "wget -c -O \"$a.flv\" \"http://youtube.com/get_video?video_id=$a&t=$t\"";
		system "ffmpeg -i \"$a.flv\" -ab 128k \"$a.mp3\"";
	}
}
print "\nFeedback to: <albertoi7\@gmail.com>\n";

Example you have one file with urls of some videos (YouTubeUrls.txt):

http://www.youtube.com/watch?v=-j39ABZyzek
http://www.youtube.com/watch?v=5cGvzApDZKI
http://www.youtube.com/watch?v=w1mgEQTMVB8
...

This script download all flv files and convert to mp3.

youtube++ `cat YouTubeUrls.txt`

unix/linux, web ,

Safe and Dirty Remote XMLHttpRequest

August 27th, 2008

Safe and Dirty Remote XMLHttpRequest Sometimes we need XMLHttpRequest work on diferents domains (cross domains) a simple solution, you need JavaScript and Perl:

The XMLHttpRequest(); example:

var req = new XMLHttpRequest() // IE7, Firefox, Safari, Opera
req.open('GET', 'http://localhost/cgi-bin/remote.pl?url='+url, false);
req.send(null);

To make the remote request work, use remote.pl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
use LWP::UserAgent;
use CGI qw(:standard);
print "Content-type: text/plain\n";
my $url = param ('url');
$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/8.0");
$req = HTTP::Request->new(GET => $url);
$req->header('Accept' => 'text/html');
$res =$ua->request($req);
if ($res->is_success) {
	$page = $res->content;
} else {
	$page = "error";
} print $page;

This is only a example:

The remote.pl could be much better implement (GET and POST methods, params and theirs values).

develop, web ,