.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Frame::Simple 3pm" .TH Net::Frame::Simple 3pm "2012-01-25" "perl v5.18.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Frame::Simple \- frame crafting made easy .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # We build a TCP SYN \& my $src = \*(Aq192.168.0.10\*(Aq; \& my $target = \*(Aq192.168.0.1\*(Aq; \& my $port = 22; \& \& use Net::Frame::Simple; \& use Net::Frame::Layer::IPv4; \& use Net::Frame::Layer::TCP; \& \& my $ip4 = Net::Frame::Layer::IPv4\->new( \& src => $src, \& dst => $target, \& ); \& my $tcp = Net::Frame::Layer::TCP\->new( \& dst => $port, \& options => "\ex02\ex04\ex54\ex0b", \& payload => \*(Aqtest\*(Aq, \& ); \& \& my $oSimple = Net::Frame::Simple\->new( \& layers => [ $ip4, $tcp ], \& ); \& \& # Now, the frame is ready to be send to the network \& # We open a sender object, and a retriever object \& use Net::Write::Layer3; \& use Net::Frame::Dump::Online; \& \& my $oWrite = Net::Write::Layer3\->new(dst => $target); \& my $oDump = Net::Frame::Dump::Online\->new(dev => $oDevice\->dev); \& $oDump\->start; \& $oWrite\->open; \& \& # We send the frame \& $oSimple\->send($oWrite); \& \& # And finally, waiting for the response \& until ($oDump\->timeout) { \& if (my $recv = $oSimple\->recv($oDump)) { \& print "RECV:\en".$recv\->print."\en"; \& last; \& } \& } \& \& $oWrite\->close; \& $oDump\->stop; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is part of \fBNet::Frame\fR frame crafting framework. It is totally optional, but can make playing with the network far easier. .PP Basically, it hides the complexity of frame forging, sending, and receiving, by providing helper methods, which will analyze internally how to assemble frames and find responses to probes. .PP For example, it will take care of computing lengths and checksums, and matching a response frame to the requesting frame. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .IP "\fBraw\fR" 4 .IX Item "raw" Where the packed frame will be stored, or used to unpack a raw string taken from the network (or elsewhere). .IP "\fBtimestamp\fR" 4 .IX Item "timestamp" The frame timestamp. .IP "\fBfirstLayer\fR" 4 .IX Item "firstLayer" We cannot know by which layer a frame begins, so this tells how to start unpacking a raw data. .IP "\fBpadding\fR" 4 .IX Item "padding" Sometimes, frames are padded to achieve 60 bytes in length. The padding will be stored here, or if you craft a frame, you can manually add your own padding. .IP "\fBreply\fR" 4 .IX Item "reply" When the \fBrecv\fR method is called, and a corresponding reply has been found, it is stored here. .IP "\fBlayers\fR" 4 .IX Item "layers" This one is an arrayref. It will store all layers to use within the \fBNet::Frame::Simple\fR object. .IP "\fBref\fR" 4 .IX Item "ref" This is a hashref that stores all layers. The key is the layer type (example: \s-1TCP:\s0 \f(CW$oSimple\fR\->ref\->{\s-1TCP\s0}). If the frame contains multiple layers of the same type, only the one found at upper level will be kept (in fact, the latest analyzed one, aka \s-1LIFO\s0). .SH "METHODS" .IX Header "METHODS" .IP "\fBnew\fR (hash)" 4 .IX Item "new (hash)" Object constructor. You can pass attributes in a hash as a parameter. Also note that when you call it with \fBlayers\fR attribute set, it will automatically call \fBcomputeLengths\fR, \fBcomputeChecksums\fR and \fBpack\fR for you. And when you pass \fBraw\fR attribute, it will call \fBunpack\fR for you too, building layers and storing them in \fBlayers\fR attribute. .IP "\fBnewFromDump\fR (hashref)" 4 .IX Item "newFromDump (hashref)" When \fBNet::Frame::Dump\fR \fBnext\fR method is called, and there is a frame waiting, it returns a hashref with specific values. You can directly use it as a parameter for this method, which will create a new \fBNet::Frame::Simple\fR object. .IP "\fBcomputeLengths\fR" 4 .IX Item "computeLengths" This one hides the manual hassle of calling \fBcomputeLengths\fR method for each layers. It takes no parameter, it will know internally what to do. .IP "\fBcomputeChecksums\fR" 4 .IX Item "computeChecksums" Same as above, but for checksums. you \s-1MUST\s0 call the previous one before this one. .IP "\fBpack\fR" 4 .IX Item "pack" Will pack all layers to to \fBraw\fR attribute, ready to be sent to the network. .IP "\fBunpack\fR" 4 .IX Item "unpack" Will unpack a raw string from the \fBraw\fR attribute into respective layers. .IP "\fBgetKey\fR" 4 .IX Item "getKey" .PD 0 .IP "\fBgetKeyReverse\fR" 4 .IX Item "getKeyReverse" .PD These two methods are basically used to increase the speed when using \fBrecv\fR method. .IP "\fBrecv\fR (Net::Frame::Dump object)" 4 .IX Item "recv (Net::Frame::Dump object)" When you want to search for the response of your probe, you call it by specifying from which \fBNet::Frame::Dump\fR object to search. It then returns a \fBNet::Frame::Simple\fR object if a match is found, or undef if not. .IP "\fBsend\fR (Net::Write object)" 4 .IX Item "send (Net::Write object)" Will send to the \fBNet::Write\fR object the raw string describing the \fBNet::Frame::Simple\fR object. .IP "\fBreSend\fR (Net::Write object)" 4 .IX Item "reSend (Net::Write object)" You can also \fBreSend\fR the frame, it will only rewrite it to the network if no \fBreply\fR has already been found. .IP "\fBprint\fR" 4 .IX Item "print" Prints all layers in human readable format. .IP "\fBdump\fR" 4 .IX Item "dump" Dumps the \fBraw\fR string in hexadecimal format. .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Write, Net::Frame::Dump .SH "AUTHOR" .IX Header "AUTHOR" Patrice Auffret .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (c) 2006\-2012, Patrice Auffret .PP You may distribute this module under the terms of the Artistic license. See \s-1LICENSE\s0.Artistic file in the source distribution archive.