Programming the Network with Perl - Wiley 2002.pdf
(
987 KB
)
Pobierz
155126534 UNPDF
Paul Barry
Institute of Technology, Carlow, Ireland
Copyright ©2002 John Wiley & Sons Ltd
Bans Lane, Chichester,
West Sussex PO19 1UD, England
National
01243 779777
International
(+44) 1243 779777
e-mail (for orders and customer service enquiries): cs-books@wiley.co.uk
Visit our Home Page on http://www.wileyeurope.com or http://www.wiley.com
All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval
system, or transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, scanning or otherwise, except under the terms of the Copyright, Designs and
Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency
Ltd, 90 Tottenham Court Road, London, UK W1P 0LP, without the permission in writing of
the Publisher with the exception of any material supplied specifically for the purpose of
being entered and executed on a computer system for exclusive use by the purchaser of
the publication.
Neither the author nor John Wiley & Sons, Ltd accept any responsibility or liability for loss
or damage occasioned to any person or property through using the material, instructions,
methods or ideas contained herein, or acting or refraining from acting as a result of such
use. The author and publisher expressly disclaim all implied warranties, including mer-
chantability or fitness for any particular purpose. There will be no duty on the author or
publisher to correct any errors or defects in the software.
Designations used by companies to distinguish their products are often claimed as trade-
marks. In all instances where John Wiley & Sons, Ltd is aware of a claim, the product names
appear in capital or all capital letters. Readers, however, should contact the appropriate
companies for more complete information regarding trademarks and registration
Library of Congress Cataloging-in-Publication Data
(applied for)
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
ISBN 0 471 48670 1
Typeset in 9.5/12.5pt Lucida Bright by T
&
T Productions Ltd, London.
Printed and bound in Great Britain by Biddles Ltd, Guildford and Kings Lynn.
This book is printed on acid-free paper responsibly manufactured from sustainable
forestry in which at least two trees are planted for each one used for paper production.
Dedicated to Deirdre,
for continuing to put her ambitions on hold
while I pursue mine.
Contents
Preface
xiii
1 Meet Perl
1
1.1
Perl’s Default Behaviour
1
1.1.1
Our first Perl program
2
1.1.2
Perl’s default variable
3
1.1.3
The strange first line explained
3
1.2
Using Variables in Perl
4
1.2.1
One of something: scalars
5
1.2.2
A collection of somethings: arrays and lists
6
1.2.3
Hashes
8
1.2.4
References
9
1.2.5
Built-in variables
12
1.2.6
Scoping with
local
,
my
and
our
12
1.3
Controlling Flow
13
1.3.1
if
13
1.3.2
The ternary conditional operator
14
1.3.3
while
15
1.3.4
for
15
1.3.5
unless
16
1.3.6
until
16
1.3.7
foreach
16
1.3.8
do
17
1.3.9
eval
17
1.3.10 Statement modifiers
18
1.4
Boolean in Perl
19
1.5
Perl Operators
20
1.6
Subroutines
21
1.6.1
Processing parameters
21
1.6.2
Returning results
22
1.6.3
I want an array
23
1.6.4
In-built subroutines
23
1.6.5
References to subroutines
26
1.7
Perl I/O
26
1.7.1
Variable interpolation
28
1.8
Packages, Modules and Objects
29
1.8.1
Modules
30
1.8.2
Objects
30
1.8.3
The joy of CPAN
31
1.9
More Perl
32
1.10 Where To From Here?
32
viii
Contents
1.11 Print Resources
32
1.12 Web Resources
33
2 Snooping
35
2.1
Thank You, Tim Potter
36
2.2
Preparing To Snoop
37
2.2.1
Installing
NetPacket::*
37
2.2.2
Installing
Net::Pcap
38
2.2.3
Installing
Net::PcapUtils
39
2.2.4
Online documentation
39
2.2.5
Configuring your network interface
40
2.3
Building Low-Level Snooping Tools
41
2.3.1
loop
=
open
+
next
42
2.3.2
Optional parameters:
loop
and
open
43
2.3.3
Optional parameters: the callback function
45
2.3.4
Ethernet Analysis
45
2.3.5
EtherSnooper (v0.01)
48
2.3.6
EtherSnooper (v0.02)
52
2.3.7
EtherSnooper (v0.03)
55
2.3.8
Displaying IP addresses
58
2.4
Snooping IP Datagrams
63
2.4.1
EtherSnooper (v0.05)
64
2.4.2
EtherSnooper (v0.06)
67
2.5
Transport Snoopers
69
2.5.1
Preparing to snoop UDP
70
2.5.2
Preparing to snoop TCP
70
2.5.3
The TCP and UDP gotcha!
71
2.5.4
Application trac monitoring
75
2.5.5
EtherSnooper (v0.07)
81
2.6
The Network Debugger
83
2.6.1
Processing command-line parameters
85
2.6.2
Storing captured results
85
2.6.3
The NetDebug source code
86
2.7
Where To From Here?
95
2.8
Print Resources
95
2.9
Web Resources
96
3 Sockets
99
3.1
Clients and Servers
99
3.1.1
Client characteristics
100
3.1.2
Server characteristics
101
3.2
Transport Services
101
3.2.1
Unreliable transport
102
3.2.2
Reliable transport
103
3.3
Introducing the Perl Socket API
104
3.4
Socket Support Subroutines
105
3.4.1
inet_aton
and
inet_ntoa
105
3.4.2
Socket addresses
105
3.4.3
getservbyname
and
getservbyport
106
3.4.4
getprotobyname
and
getprotobynumber
106
3.4.5
gethostbyname
and
gethostbyaddr
107
3.5
Simple UDP Clients and Servers
108
3.5.1
Testing with
localhost
108
3.5.2
The first UDP server
108
3.5.3
The first UDP client
111
Plik z chomika:
musli_com
Inne pliki z tego folderu:
Advanced Perl Programming.pdf
(5210 KB)
CoursPerl.pdf
(7969 KB)
Beginning Perl - Wrox 2000.pdf
(4033 KB)
Bioinformatics Biocomputing and Perl - Wiley 2004.pdf
(3442 KB)
apprenez-a-programmer-en-perl.pdf
(1163 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin