Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

The Spudgun

by MrCromeDome (Deacon)
on Jul 16, 2002 at 18:04 UTC ( #182184=CUFP: print w/ replies, xml ) Need Help??

Ladies, gentlemen, and others, today I (proudly?) introduce you to the first invention produced by Jason's Laboratory of Useless Perl Things. . . the Spudgun!

You'll laugh, you'll cry, or perhaps even hurl at this most wonderous (?) thing. Use it to annoy your spouse, boss, coworkers, family, and friends. All you have to do is pass the Spudgun your e-mail address, your name, the e-mail address of your victim, and the name of your victim, and the Spudgun will do the rest! Having a boring workday? You can even spud yourself!

All that peppy mumbo-jumbo aside. . . this is actually the Perl adaptation of a C-program I wrote some time ago to illustrate some of the cool things that can be done programatically with strings. Once I wrote it in C, the Spudgun seemed potentially far more beautiful thing in Perl, and so I ported it.

Replace $smtp with the name (or IP) of the mailserver that you want to use to send the Spudgun output. You can tweak $max_spuds and $rand_max to your preference. . . raise the number of spuds though and you can really tick off some of your loved ones ;) @how, @where, and @what can also be added to. . . In fact, if anyone comes up with some clever ones that I missed, I'd be interested in hearing them =)

For your spudding convenience, I wrapped some CGI code around this and posted the result to here for you to play with.

Thank you for letting me waste your time ;) Happy spudding to you!

MrCromeDome

#!/usr/bin/perl use strict; use warnings; use Mail::Sender; use Email::Valid; # Get some parameters my ($from_email, $from_name, $to_email, $to_name) = @ARGV; # Die if we don't have valid e-mail addresses die "From e-mail is not a valid address!" unless Email::Valid->address +($from_email); die "To e-mail is not a valid address!" unless Email::Valid->address($ +to_email); # SMTP server my $smtp = "your.mailserver.com"; # Spud settings my $max_spuds = 50; my $rand_max = 60000; my @how = qw(smashed shot bopped hit splattered slammed nailed creamed + bonked smacked clobbered); my @where = qw(face hand thumb arm gut eye leg chin gut butt skull hea +d ass groin nads boob ear toe foot); my @what = ("a potato", "a flying spud", "a high velocity spud", "a rocketing potato", "a deadly spud", "a potato of death", "the Mother of All Potatoes", "a hot potato", "a sweet potato"); # What message are we sending? my $message = "$to_name, $from_name has just shot you with a spudgun!! +!\n\n"; # Seed the random number generator srand($$|time); # Fire in the hole! my $times = 1 + rand($rand_max) % $max_spuds; for(my $which = 1; $which <= $times; $which++) { $message .= sprintf("You get %s in the %s by %s.\n", $how[rand($rand_max) % (scalar @how)], $where[rand($rand_max) % (scalar @where)], $what[rand($rand_max) % (scalar @what)]); } $message .= "\nYour friend,\nMrCromeDome at perlmonks.org\n"; # E-mail the damage (new Mail::Sender)->MailMsg( { smtp => $smtp, from => $from_email, to => $to_email, subject => "You've just been spudded!", msg => $message }); # Generate a response message print "Thank you, $from_name, for using the spudgun. Happy spudding t +o you!\n";

Comment on The Spudgun
Download Code
•Re: The Spudgun
by merlyn (Sage) on Jul 16, 2002 at 18:26 UTC
    $how[rand($rand_max) % (scalar @how)], $where[rand($rand_max) % (scalar @where)], $what[rand($rand_max) % (scalar @what)]);

    Much simpler, and more traditional, to write these as:

    $how[rand @how], $where[rand @where], $what[rand @what];

    -- Randal L. Schwartz, Perl hacker

      Thank you =) I was blinded by my C way of doing things.

      MrCromeDome

Re: The Spudgun
by Aristotle (Chancellor) on Jul 17, 2002 at 18:50 UTC
    Quick note I didn't know either before it was pointed out to me: Perl will seed the RNG with a good value on its own. You needn't do that yourself. See perldoc -f srand.

    Makeshifts last the longest.

Re: The Spudgun - full auto, no safety mod
by meta4 (Monk) on Jul 18, 2002 at 00:27 UTC

    OOOO!! I think I can have a little fun with this.

    #!/usr/bin/perl use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $VictimEmail = shift; # The Victim's E-mail Adress {evil cackle} my $ClipSize = shift; # How many E-mails you want to send for( my $i = 0; $i < $ClipSize; $i++ ) { my $req = POST( 'http://www.cromedome.net/cgi-bin/spudgun.cgi', [ from_name => 'A very bad man', from_email => 'AVeryBadMan@BadPeople.com', to_name => 'Sucker!', to_email => $VictimEmail, ] ); $ua = LWP::UserAgent->new; my $result = $ua->request($req)->as_string; die"%*#%! spudgun, That didn't work! \n$result" unless $result =~ /You have just fired your spudgun/; sleep( 5 ); # try not to overload the server. }

    Now, where's the PHB's email address... Let's fill up his inbox...

    DISCLAIMER: For educational purposes only. Neither Perlmonks nor meta4 advocate waisting resources just to mail bomb your PHB, or anyone else, anonymously. This really is just a demonstration of how to use HTTP::Request::Common. Or, uh... This is just a demonstraion of how someone (surely not me) could get creative and abuse a CGI script by not calling it from a browser.

    Bad meta4! Bad, bad!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://182184]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-04-20 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls