[10540] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4133 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 2 17:07:49 1998

Date: Mon, 2 Nov 98 14:01:35 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 2 Nov 1998     Volume: 8 Number: 4133

Today's topics:
        Q:Creating a perl executable w/ a limited lifespan? dtropea@ctron.com
        Raw socket programming in Perl keydet89@yahoo.com
    Re: Reference Safety (Larry Rosler)
    Re: Shell built-in commands in a perl script? <eric.means@louisville.edu>
    Re: unknown problem with writing user input to a file! <piglet@richard.lse.ac.uk>
    Re: unknown problem with writing user input to a file! <gellyfish@btinternet.com>
    Re: VARIABLES DE ENTORNO CGI (Larry Rosler)
    Re: VARIABLES DE ENTORNO CGI (I R A Aggie)
    Re: Version control for Perl Modules <zenin@bawdycaste.org>
    Re: where can I find cgi script for hire <smiles@wfubmc.edu>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 2 Nov 1998 12:28:17 -0800
From: dtropea@ctron.com
Subject: Q:Creating a perl executable w/ a limited lifespan?
Message-Id: <71l4l1$pjt@pdrn.zippo.com>

I am creating a perl script that will generate an executable. I do not
want anyone to run this executable after a certain date (i have not
decided a date yet) - this program has a limited lifespan. What do i need to put
into the perl script that will not allow its generated executable to run after
this date.

Is there some kind of a trigger mechanism i could put into the script
that will signal when the date is reached to no longer allow the
executable to run. All i am giving out is the executable not the
complete program.

Thank you.


------------------------------

Date: Mon, 02 Nov 1998 21:41:58 GMT
From: keydet89@yahoo.com
Subject: Raw socket programming in Perl
Message-Id: <71l8v6$qhc$1@nnrp1.dejanews.com>

I took Miff's code from the fall edition of 2600 and have
been trying to improve it...to turn it into a tool that I
can use for testing firewalls and intrusion detection
packages.

I am using ActiveStates latest build of Perl on NT.  I have
tested the code (posted below), but all that happens is that
two packets get sent (according to NetXRay)...an ICMP packet,
and an IP packet that looks nothing like what I tried to craft.

Any advice would be appreciated...

Carv

#
use Socket;
use strict      qw(refs, subs);

my $target_box = "cyclops.dc.predictive.com";
my $target_port = "139";

my $source_box = "hcarvey-nt.dc.predictive.com";
my $sourc_port = "1025";

tcp_storm($target_box,$target_port,$source_box,$source_port);

###########################################################
# This section sends the packet based on the above params
# NOTE:  No data is being sent.
###########################################################

sub tcp_storm  {
        my ($dest_host,$dest_port,$src_host,$src_port) = @_;

        #set constants:
        my ($PROTO_RAW) = 255;
        my ($PROTO_IP) = 0;
        my ($IP_HDRINCL) = 1;

        $dest_host = (gethostbyname($dest_host))[4];
        $src_host = (gethostbyname($src_host))[4];

        #time to open a raw socket....
        socket(S, AF_INET, SOCK_RAW, $PROTO_RAW) || die $!;

        #raw socket should be open...
        setsockopt(S, $PROTO_IP, $IP_HDRINCL, 1);

         print "Initiating Packet Send \n\n";


         #build a tcp header:
         my ($packet) = build_header($src_host, $src_port, $dest_host,
$dest_port);

	 #bust out the destination...
         my ($dest) = pack('S n a4 x8', AF_INET, $port, $dest_host);

	 #send a packet
         send (S,$packet,0, $dest);

         print "Packet Sent.\n ";
}


############################################################
#  This section creates the headers of the TCP packet
#  Steps
#  1.  Create pseudo TCP header
#  2.  Calculate TCP header checksum
#  3.  Create pseudo IP header
#  4.  Calculate IP header checksum
#  5.  Build packet header
############################################################
sub build_header {

        my ($src_host, $src_port, $dest_host, $dest_port) = @_;
        my $hdr_cksum = 0;
        my $zero = 0;
        my $proto_tcp = 6;

# 20-byte header
        my ($tcplength) = 20;

#############################################################
# Set up the components of the TCP header
#############################################################

	my $seq = 47533;
	my $ack = 0;
	my $tcp_4bit_hdrlen = 5;
	my $tcp_4bit_reserved = 0;
	my $tcp_urg_bit = 0;
	my $tcp_ack_bit = 0;
	my $tcp_psh_bit = 0;
	my $tcp_rst_bit = 0;
	my $tcp_syn_bit = 1;
	my $tcp_fin_bit = 0;
	my $tcp_windowsize = 1024;
 	my $tcp_urgent_pointer = 0;

##################################################################
# Calculate the TCP header checksum
# The TCP checksum covers the TCP header and TCP data
##################################################################
        my ($pseudo_tcp) = pack ('n n N N H H B B B B B B B B n n n',
			$src_port,$dest_port,$seq,$ack,$tcp_4bit_hdrlen,
			$tcp_4bit_reserved,
			$zero,$zero,$tcp_urg_bit,$tcp_ack_bit,$tcp_psh_bit,
			$tcp_rst_bit,$tcp_syn_bit,$tcp_fin_bit,
			$tcp_windowsize,$zero,$tcp_urgent_pointer);

        my ($tcp_chksum) = &checksum($pseudo_tcp);

##################################################################
# Set up the IP header
##################################################################

        my $ip_ver = 4;
	my $ip_hedlen = 5;
	my $ip_tos = "00";
	my ($totlength) = $tcplength + 20;
	my $ip_fragment_id = "31337";
	my $ip_3bit_flags = "010";
	my $ip_13bit_fragoffset = "0000000000010";
	my $ip_ttl = 64;

##################################################################
# Calculate the IP header checksum
##################################################################

	my ($pseudo_ip) = pack('H H B8 n n B3 B13 B8 B8 n N N',
			  $ip_ver, $ip_hedlen, $ip_tos, $totlength,
			  $ip_fragment_id, $ip_3bit_flags,
                          $ip_13bit_fragoffset,$ip_ttl,$proto_tcp,
			  $zero,$src_host,$dest_host);

	my ($ip_chksum) = &checksum($pseudo_ip);

##################################################################
# Assemble packet
##################################################################

  my ($hdr) = pack ('H H B8 n n B3 B13 H H n N N n n N N H H B B B B B B B B
n n n', #########  IP header	     $ip_ver, $ip_hedlen, $ip_tos,
$totlength,			  $ip_fragment_id, $ip_3bit_flags, 
$ip_13bit_fragoffset,$ip_ttl,$proto_tcp,		     
$ip_chksum,$src_host,$dest_host, #########  TCP header			     
  $src_port,$dest_port,$seq,$ack,$tcp_4bit_hdrlen,			 
$tcp_4bit_reserved,		       
$zero,$zero,$tcp_urg_bit,$tcp_ack_bit,$tcp_psh_bit,		       
$tcp_rst_bit,$tcp_syn_bit,$tcp_fin_bit, 		       
$tcp_windowsize,$zero,$tcp_urgent_pointer);

        return $hdr;
}


sub checksum {

    my (
        $msg            # The message to checkfro
        ) = @_;
    my ($len_msg,       # Length of the message
        $num_short,     # The number of short words in the message
        $short,         # One short word
        $chk            # The checkfro
        );

    $len_msg = length($msg);
    $num_short = $len_msg / 2;
    $chk = 0;
    foreach $short (unpack("S$num_short", $msg))
    {
        $chk += $short;
    }                                   # Add some lead
    $chk += unpack("C", substr($msg, $len_msg - 1, 1)) if $len_msg % 2;
    $chk = ($chk >> 16) + ($chk & 0xffff);
    return(~(($chk >> 16) + $chk) & 0xffff);
}


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Mon, 2 Nov 1998 11:38:05 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reference Safety
Message-Id: <MPG.10a7a9fc7709954e989856@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <363DF59F.BEC2C46B@atrieva.com> on Mon, 02 Nov 1998 10:10:39 
-0800, Jerome O'Neil <jeromeo@atrieva.com> says...
> I have been working with large hashes, and am concerned about scoping
> issues when passing their references arround.  If one sub returns a hash
> reference for use in another sub, at what point does the reference fall
> out of scope?  Or am I just being paranoid?

Never.  Yes.

Perl is not C/C++.

As long as the reference is live, so will the data referred to be live.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 2 Nov 1998 15:31:11 -0500
From: "Eric Means" <eric.means@louisville.edu>
Subject: Re: Shell built-in commands in a perl script?
Message-Id: <SCo%1.1505$wl.1515@news.ntr.net>

Steve Goldstein wrote in message <363E0994.41C6@gcg.com>...
>I want to use the shell built-in "source" command in my perl script.
>How do I do it?
>
>If  I use
>    system("source <filename>") or `source <filename>`
>in my script, I get the error message:
>Can't exec "source": No such file or directory...

Try opening a pipe to the shell you want to use.

open(SH_PIPE, "| usr/bin/bash") || die "could not open shell pipe."

print SH_PIPE "source <filename>";

--
Eric Means
Louisville Gas & Electric Co.
eric.means@lgeenergy.com





------------------------------

Date: Mon, 2 Nov 1998 21:01:52 +0000
From: Tim Haynes <piglet@richard.lse.ac.uk>
Subject: Re: unknown problem with writing user input to a file!
Message-Id: <Pine.LNX.4.02.9811022100360.25599-100000@spodzone.demon.co.uk>



On Mon, 2 Nov 1998, Matevz Sernc wrote:

>   (Might be a runaway multi-line "" string starting on line 10)
>         (Missing semicolon on previous line?)

OK, so it's not line 10, but it's close :)

> $filename = "/home/euhost/websearch/urls.txt";
> $ok = "/home/euhost/websearch/ok.html;	<<<<B<I<G<<H<I<N<T<<<<<<<
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

HTH :)

~Tim
 ________________________________________ piglet@richard.lse.ac.uk __________
| Geek Code: GCS dpu s-:+ a-- C++++ UBLUAVHSC++++ P+++ L++ E--- W+++(--) N++ |
| w--- O- M-- V-- PS PGP++ t--- X+(-) b D+ G e++(*) h++(*) r--- y-	     |
| piglet@richard.lse.ac.uk   		   http://www.glutinous.custard.org/ |
`----------------------------------------------------------------------------'

Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQEVAwUBNj4dxBHizYRYZ3MpAQHuiggArjRskZbKqZWqfnfEFT7MSNhNrp/XtnFY
ypDBkWT4elKyytx9Y38vOIoQjep2B3BrEVZ9iz/CG7xFG6TQBcztC0V04D3e5hY+
RJrfBZ0gisRh1Zfxi9vtSMEEeT2TzMuEYWGg27WrZ3RdvQWAUEK6bXhr8oEyLKn2
73SlIu2IAMWg/k4MfilYvv6Oi9/OQEI73oiYUl7FAvlP1hTHIdQMWcqq02NMpC13
kSBLWsbIWtTMAyS/uz3s3HBiJn1Yj0U6K0ovrlETAnir1Zw2fgJd2L/ipc7KRLid
Hobhg8EMQR94zT5ZDFom/fe8A5u0hAXcjs8N5sfkA75bNkF56dJWQw==
=PCVG
-----END PGP SIGNATURE-----



------------------------------

Date: 2 Nov 1998 18:49:27 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: unknown problem with writing user input to a file!
Message-Id: <71kurn$ch$1@gellyfish.btinternet.com>

On Mon, 2 Nov 1998 18:13:14 +0100 Matevz Sernc 
<sernc@mailserv.rz.fh-muenchen.de> wrote:
<snip error>
> Execution of saveurl.cgi aborted due to compilation errors.
> --------- end of error message ----------
> 
> Here is the script:
> 
> #!/usr/local/bin/perl
> 
> $filename = "/home/euhost/websearch/urls.txt";
> $ok = "/home/euhost/websearch/ok.html;

                                       ^ Missing " here.

> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>   ($name, $value) = split(/=/, $pair);
>   $value =~ tr/+/ /;
>   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>   $value =~ s/~!/ ~!/g;
>   $FORM{$name} = $value;
> }
> 
> open(TXT,">>$filename") || die("Can i write a file ? \n\n$!");
> print TXT $FORM{'name'} . " ";
> close(TXT);
> 

Really though you should be using CGI.pm or some other well developed
module.

Whilst its good to see you checking the success of the open you might find
that you want to avoid using 'die' in that way in a CGI program - you could
try using CGI::Carp or one of the hand rolled die_handlers that you will
find if you search DejaNews.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


------------------------------

Date: Mon, 2 Nov 1998 12:07:40 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: VARIABLES DE ENTORNO CGI
Message-Id: <MPG.10a7b0eaedbcfe11989858@nntp.hpl.hp.com>

In article <363DFC69.5CFA690C@email.sps.mot.com> on Mon, 02 Nov 1998 
12:39:37 -0600, Tk Soh <r28629@email.sps.mot.com> says...
> Nicol=E1s Rodr=EDguez wrote:
> > =
> 
> > Desde hace algun tiempo  la variable de entorno REMOTE_HOST me
> > devuelve una cadena vacia cuando deber=EDa devolver la direcci=F3n del
> > proveedor del navegante. =BFPor qu=E9?
> > =
> 
> > Otra pregunta, =BFComo conseguir la direcci=F3n del navegante a partir =
> de
> > la direcci=F3n IP?
> > =
> 
> > Gracias
> > nicolasr@arrakis.es
> 
> Is there a perl module out there that can help translate this post to
> english, or chinese perhaps?

>From <URL:http://babelfish.altavista.com/cgi-bin/translate?>:


For algun time the variable of surroundings REMOTE_HOST has been giving                                    
back to a chain vacia to me when deberia to give back the direction of 
the supplier of the navigator. So that? 

Another question, Like obtaining the direction of the navigator from 
direction IP?


Actually, that's surprisingly comprehensible.  (variable of surroundings 
== environment variable, etc.)  But it isn't a Perl question, so I won't 
answer it. :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 02 Nov 1998 16:35:50 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: VARIABLES DE ENTORNO CGI
Message-Id: <fl_aggie-0211981635500001@aggie.coaps.fsu.edu>

In article <MPG.10a7b0eaedbcfe11989858@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:

+ Actually, that's surprisingly comprehensible.  (variable of surroundings 
+ == environment variable, etc.)  But it isn't a Perl question, so I won't 
+ answer it. :-)

I think you meant to say:

Realmente, eso es asombrosamente comprensible. (variable de la variable de 
entorno del == de los alrededores, del etc.) Pero no es una pregunta del 
Perl, asm que no le contestari. :-)

HTH

James


------------------------------

Date: 02 Nov 1998 20:01:45 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Version control for Perl Modules
Message-Id: <910036856.59143@thrush.omix.com>

mlehmann@prismnet.com wrote:
	>snip<
: What is a good technique for using a source code control system to manage
: changes to the code, but to use the "make install" command to actually install
: the code into the file system?
:
: Is it best to just check the .pm files into the source code control system?

	Consider the module an entire "project" or "module" or whatever your
	VCS calls them.  Check in all the files (*.pm, t/*.t, Makefile,
	etc).  If you aren't using XS, consider the .pm file as the total
	"version", unless you've got some other package version system to
	handle that.  If you are using XS, its version number must match
	the .pm.

	If your VCS creates funky version numbers (eg, 10.20.30), you
	will likely need to parse them into something more useful to
	perl (ie, a float).  This is what I use for CVS and RCS:

	$VERSION = do { my @r = (q$Revision$ =~ /\d+/g); sprintf '%d.%03d'.'%02d' x ($#r-1), @r};

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


------------------------------

Date: Mon, 02 Nov 1998 14:23:35 -0500
From: Steve miles <smiles@wfubmc.edu>
Subject: Re: where can I find cgi script for hire
Message-Id: <363E06B7.1C4F1528@wfubmc.edu>

I'd be interested in writing a script for you. I'm very cheap, fast,
etc... :-)
Just let me know what you would like and I'll get you a quote - FAST!

Steve M.

E-Mail Transponder wrote:

> Hi,
>
> Does any know of a good cgi script writer that I can hire to write a
> script for me?
>
> --Janice



------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4133
**************************************

home help back first fref pref prev next nref lref last post