ÿØÿà JFIF    ÿÛ „ !.%+&8&+/1555$;@;4?.451 4,$,44444444444414444444444444444444444444444444444444ÿÀ  á á" ÿÄ     ÿÄ ?    !1AQaq"2‘¡±ÁðBRbrÑá#‚’¢²3S CñÿÄ   ÿÄ !    !1QAa‘2ÿÚ   ? 5˜Z¯V¦cø)›t/? z¨±>Õ5€¶‹Á¤·¼z¼Ü¬+ñ®v¤¨_ˆR­BFn©—˜ý®ç̝P8gýt·ÉSTŦˆìät?þé¼íìN/Þa)ì–í6ô… Ï¿øÃj´¿KÇü]ÿ ªô¹-eKànëÕHTx}ýSÜ›ÿ ”7Ø×&µ<¦  ¥ÑO¶[Ù¯ä¨ÞÃÿ PZ-¬;#õ|•oaÿ ©CìÞz3˜öː/¤­ñTûIØ}š^ mÓ%ªxˆ¥ÉŸu=Z+ISe¿45™¼u;ú&WØ÷€æßQ™®{|íx*TC“#ZŠìZ§²‹ 6pv…³¿¡äª*áZÐ%ÒOáˆo"x«OHk w±æ+¬V(kMúŸ5Vö«$ ÁrÏbàb57/luR ¸ÑÛj Òµì`Мq­û žICÀÊ•©4€Âcà¨Ï€O´<èÐ:›ù(Ë^L8þ‘ÍÌ#¸Ð_Ì©ÙK(Öz 4¬û+¸;ü’V’84‘¬ÃŽ:[â‡ÔÌáõp¢~§ªlæ£ö{®G>J¼"°‡7¯ÆÉèßû ‹É‹§ÁòÃýâßî ^ƾÙõ‹×óH#«LP½ïX=xÑÍ$|W?•~• îëÔ©ª‹ {ÝT…Kÿ ”hûâá)J*ö˜–ÔU;iÇ€/ ÆþjóZ\ýwØ=Ìm ºèËL9 ýèÆð/¨’¥öo=nË.%Îì ŽÕ¯È|{Oj²ƒE6e/ßdÄõ²Ìâ1O®ò×TsəԸhOMýíMˆ¿¼H˜l²,7Â¥#MF/Úf°Ö½± ¸–dr‹NýÊ íjqx{œÉ ä-È ¦ øÄër¨q°ð †nцýÑÄÆ’mä…n<0È™;ÁÝá¯ÁZƒ7FÀmì­ É&9ˆîéi¶ùN§Y• ÃZãAâ?•‡©‰ , ó¾IŸŠc1 4â&y­&pŠ­6;M À 0¹qç»p.á …ŸÅáK@%6·y6ƒ‰3?”úºŽ‰éX5ªPT §µ!=Mž«Ú½‹ÅgÂSâÉaþÓoö–¯ÁÔìR>5éÿ üs¶ÆUcÌ kÇR ]ÿ ù¬¼«VŽ;Â|‡~¢¦”ÏŰæ {L™Õ°Óv¹ò¸írޡעCÃ!íVÕ {¶»sŒNPg/ "uÕbkm²“$ďå¿é¹§°½æz¯6 †s¿!s–wÚÝ“™Œ °.ûj>·+™Òa…©Œ&rÝÎtÛë긪Ît’LAVp%c Úý[ÄzJ¾ÇàXXç@˜ó<êL]·T˜¾¥1Ó©V‡g´æ½¦Ý@¹óø!_@´ÞâSÁ —S3™•& ]@JHÚý©ZŽ €×æÔr»Áf!‡yÞ4Mv*èÓã_{‘åóUuљØ«Oïé*®EvÑ Œ÷‡U \"㪒ÍK+À 4“M¡ï:0¥5í!'<@î´”>Ç»&Z–ïCCV˜Ì5Šo&îhè.žû |ÓK©h$s6KìŒëã)¹hI¦GïOåóI;ììü#É$Š0…Ææ¥TØ.5­¾gn´ “ÂÖ\:hœ89G)J@„}œ:’Ò{/Š"¦_Æ×7Æ3VÇŠÊa]ÚŒÙ€Ä–=®uÁßâACZƒ§§£ Qnâ:«,×{tyø¬iÛcœÜÄ€H½ÄÍCk´÷šß .W'b¤Íåh]÷€=,Žv×cÚEÚHXJX¶îo¨FÒtèöŸ>ªª6[J®Fµ£sGÁeqõfe\íjÒÐïÄÐGˆe1Ø‹.Ø”‘Ëuø Y­ˆÜ ŽG|zùªüMpDnQWÄ”%JŠ™)â*p@Örš«ÕT2Ð%ˆG#ª„ ·¤!°ŸOTÂT¸aÚ%4&h™LµšØüÐ.F¿²ÐÞ_Ç‚¾ÅÃaÜ÷09Æ q€öy˜v‡85õN÷]¬äѼóS{°_MެúÔ#°Ç¸0åÞè2ëôPcvÆw9®ií1Ä8F™˜à‰´+‰Ik1òÝ7“Ñ×ÒsÝ\x‚h`ÞÑ`ó"|µEcý£n˜h`}GÞ !±ù²Ápü²ß6 0ïi󜵩SÈÇ7˜-ÕURO˜¦´f$ªž-Í6(œ}<„ éc øs]ŽŽ„*—¾ ìdŽ„)méª\¿êÎIg¾ØÞ~I#C/¼¼´EÁÈŽi8“©õådô·>euä ƒ'Ê×लR1ÉJE1ÐAát`t;ÇР%Ý<‡¥„ÍÆ`×Oyó)õiI€ñQaŸ4Ûù\áàaÃÔ¹HÃu¹*k€¦<„e S‡&õÏ B!ŽhüÞ`yj}mªf×\¿ Ç~æ­9‡û\՞Ǖg²1Žû5V7 !àöšm° c`ܬøÇìµÒ'P"?…´Ö,"§^•õލsÔ)6˜sæéÍR¼ ò|Sl”‹7 nPW Gòú÷½§O¯‡„l¡kSÞŒr½PÊ@æ¢pŽ-mÿ #Ÿ˜Àº¶Áä¦;ïÔæ$1££`“Õ>„—·ž)ßð³ñ#Ï Ô$¶œ‰ÊE‹À;÷º ¯«P:Ñ”8–IÊtpÞ3ª“>ê“þës4ò2OÏÕ­±zô†Õ§‰.÷ä¸;¿˜“'œ›žª}«Œ{ª±Ì 9ÔóÞÕ‡0 $íWV3Üì¬ —@kÝ4@¿r¼±½¬™›?øØæ´'Áé®CË3-g$˜ö‡×auÚi´Žp/êÛ æF›Ú2v‹ã¿¿,nB1̨ƃqÞa5͝@&Æû“él÷ \C²½UÍc ¯k×¢U ÖéQå™—-r wô ÞÏ<Ò=&=ÿ Ôê Òêˈt,i—;LîÜ á¸*ÚÃ1$êL•LÍ <É)ýÐà’ ;F™{ƒ™˜€&'}‚ãÄK`¡ÞT@I;®žZóè‚s’7®°›+§O­Åq©é»²9<Ô J ¼9O’HL»Ùïì¸rk¼Ž_ý‘TŸu[²ßÚŒ·ü÷B%¯E ŸÔX5êO´ Ç•€’I0 ÉJX` ñ¹õ%;µŸD‘«´€àwÒ™U ûئžÖö\×®×´8 ½‡ºÐÆÓ§?Àkmœ=;d5*@-ì0F Rªýš[Ü6âö̃ڸr*KA9· u*µæ£?U¸Âêí†8@¦X4 e-ò„0s{ HâUpU?¼mñRa°®a%Ð'tÉ×’\¾ÊÉ]t›h>·(Ë@R¼¡Ãt h}’O÷au<+nT…Ö…MӐ??Óe95 q>í/;&JSû °¯ÊéÞ øƒ*Ã2½Ài&:nôUl=¾¿5eˆ3”ñc|Ú2V”>„»&eE;«ÚäC p¢Û úy 9š[ŒÌx¼擼A&DåÒ¯ˆ¤ÀÌ;"˜ ÏQä¸åhÊ}Ûq«Û0WžÒ|»€ø®öCm5•\ÇÀ§Pe3£]0ÃàLDÉ‰1øªxjgwT‚÷¿LΨK‹›ùs—xˆÜ±µ kæ¸f‰‰ÜGk/LÛØ6d9ò¶ùA{ƒA3š/¬D¬khÓk‰`˜"㯒r¿±Óã jx‡°e}<Ñø\3y:'À•/h½Í€Ç4~g ?Û(¼]v‘ªlKÎâ~?O‚W%{Ì:“'©úNq¾›úo(X’¥¯ˆ nFê{Ç€ü?º'ë ø‹ì Þ09ŒÌç9Æ —ËC`j@ÓÄ(+a‹un¸#ÂꟋ{K`‘ÑÍÍ'à´»/Û,KW;Þ4²þð ï Nm|~fGÏ(…³Ã)«1ö­Õ ¥‡¨©ƒÃ™ü-s=à=U66Ï«Ýc蓦W¹íž®›nÔ%êÇìŒ<#Ü×84ån®Ð ÒåOC` ñânÑs‡¢ç 1õ%Îhì½Ã½® e:ݼUZo™`  ÅZŸŒÊ«ê1ÏÄo$q¹Þ€©ˆhÐÉä¯ñ[!…Ú˜àJ:x2$Íß&PåT£6ç— ‡Í*4Ýšçjÿ ‰É nófÐ ó(L5C•åÆ\rMÒ@ò }y-W}™üýVù—ú¢=Ù”c®‘< M ž ´Phr ¦©TD ‘ù.$´÷O‡‘V2Æò.=IUŒ=ž‡â¬i™aþÓåÙ?òUø'ØÖ•.~* šTŒ!•-×áºTâ®ä#õü'´ eýlYÅÓeÕKÂrT"CÚ@u!Óxƒ{š3€}1¿(r}%«nËamjÑ%ÑNEò v ˜à  σöK³,*º.àzù¨™Ó ÚçâU¦*¿ 9{%Ö¹ njûdaXöb) kÛÆ±ûÓ\°M7ˆÂ=û›ç¿Ã‚­V»Cg–8ÙêE- j)k$º`Ã-ùEýeBÆÇ]c¡°ñty&Òd0nõ'¡W+ƒ*|–øµFa\GQªEAÔp5\Ǽ·¼Ç8·õ -â§Ú[ ‡ uZeÖ 3}×d'+¹:ð+K†Û®s!Ï$úe€<Û”x)1»a­¡LC]¸µík…ÚàA»AYº{†ªS[¦5HÒ7ù --,ísòDØ€èk ÞÀîÜ ò@â( ËNˆë›4ô½•/¦o‡€Û7 ê•ÆêòðÜy'Án½µ á˜ݦ ndeo…[ì¶Ê,¥R³Ä=À±—–ß;£™´ñSâ*g§”ïaið‘Jå~™ÓÞ ß³Õ¢»8x埒²52>AÊb&-÷\7´éÄù€T˜,w;3{ï˜k…à¹ÄqÀ«œ{€\ ˆ¾[´¨јr &Úé„Ívˆ±8†¿]|¬ņ4I×pÞS1ÈÖz‰#Ìv‡G!YNògñ:màTz¢Ý1ô©^O=~ë|5Bã™ç•¼µõ•bÆ@úÕS¬ÈŒ#¬zünrŸ û” Z²•èðV"ÁHÚý©wÝ €7¼Ìu1hÑa3Éä û f$o¿É ™Ú›ÝçnpÒ3äÌ3†Í§,Äï]$‰/pê †«À¼¸e9­Æê_C]žƒ·ý·frÁN«, E=›Çq -‰öŒ:aÏ¿±í&£Í:-} 84‘ÿ eƒQÑeëSsuiA ³g㟥ú£?ÿ ʼn*”“÷aühe:ÊWa@ÒÞk±eØ] F Ô—r.åä˜ @ö¥ªZoÐýYL·¥S²G/‡ñ <~*ZÆ´è>JlòàÛÆ½ÿ 窘ìGN¢:I®KšJp/`íIÁÀõ#Ä-€ö­šµŒoF4|ÆQØÆ@Ì|£Ô…¢À{9˜è½Üó›€ôYÒÎYsið;ís¤€à²ˆ‚4qÉVŒI$ ‰"° æµ8cXGjœˏ¡Aâý•ËÜ¢ûï e·çLx']á"oÅÎê3¯Ç—¹”ó0nå‚âg{Œñ> S´˜îè°g238‚ãköÝfÚd´6Ò€;ò÷±¢™¼›º ¢Æ'¥Ðx'e¬ç ]bÈÆV¢ó‹kýBO ðÊâ$Ÿ!×T 3Mýמ žìٍàÌü‘8÷€àæØ8æ©6‰©L´«…oãpð„~Çk‰!ñ;‹”ÛžÍ àž±z Ÿôû øŸÝužÏ;ÿ #|u6™Þ¬ÚˆÐõA4¶â|ôl|Ê2ŽÇ¤ÝÅÇY.<#Aí.k§hóF‚”Y; M½Ö4hŸ4&›­¿tès´%FìL¥£Ãk‰ÇT¤haÁ¤ÚxfÉ`ÑìË›>i 3t‚:,–+^÷´–{Û–Nxi"x‘Ûg î¨>¥Õ܁ùZH,2Û“:8xÊ¢Çí9.É-Ìâã-=çjwµS˜dütžçwýGòú®®ûº_ˆýx$–¡ãøO EÚÛÏ÷R„×w+3£Á£öUMyR²¹âŒ°š›¸Ñãò9§Ó_Dl+Ùßc›úšGÅÌc†Ž!Ko=¶.‘Îÿ c²(2®V mª.ÿ ¹B›¹å ù„öŸSV>™ü¯$y:G¢Z×àøúdî¹û­·ýÇ´:•c LÍõi_‹ö+ÎæGÊè>OŠ•äž´§Þ{X}¨1ÚTc›»Qþ•êô°t¿OP?eæ~É{5]•ÙR£r5†nZ\ã@ &îJõ ¾àC°þV>fé¥/ü5ñÊIº_é5 ;e­h<@ Ä&æÃëE%;X,ÒãÆÞ`Oò¦kŸm#˜!ÀyÄ¢| óLšò¥Ä` ¶R=|ÈCâh5ò3DˆïF†ðÒ#ÅìÛœ?¸yhBãœí ZxßÎÄhºRK„`Þödvײ™ÀÈÑÒgŒuY w³%†ƒÓzõ ÖÏp‚dH®¦A´ù§»ÓÇMæ~)ˆð‡û:ù&Ä •vGD´À n ݇¼Ö8Fö óáà£~Ë¥x`oK|Ä?fxiØü%pìR>éò+Û±éÎ>núlFŤ'tq8LZÏvÃ?„¡ß±È⽆¯³íü@x|PöUäèØã¡ð‚ŒAìÏ"vÍwóŸÍ{ ý0.z È•Ö{,N¡£¡ŸKÕÙž>Ýœþ ÍÀ°<×EA!Å‚D™IúOÍ¡>ôG}Â` ÍßkÜL™Ž Þð™ {IøF²¹òQ3&!ÃÂÞz.d&Ï-sH¸,Ôõ˜ŽP€ 77ˆÝ¼ÊëÜw =cÕ Ú,ØÐ5ÎYÐ)ì´öœgŒ[¤ßv㙑8心>h]§µháYš£²ºÑ.{Ï7Sð•?´~×SÃKýJÛ˜ ™Íäiúu<µX¶1õ^kâçIÑ£sZ4h>j*ÔšD:4­¿_ ÷¸ Õxæÿ ¸?Mù _•­ÊÐ ä ÷ý ÑwL œ­ïnTkÛUÍN©ë:¦fV ¶ÜÔÜMªÅâA½–¿R×TXš-%iTÊT•‡Ù‚JôϐZxWÑè‰f‰òG º ×Õû2aZ7OU3[“×AT–ÞŒ…-‘¤”Ì ì&(ˆ¿­•ƒkï’:ðY¦W‘ Å)“†‘˜³Åtcø˜ñTÂwÚÇ4|üLÇªí–v- qˆèU qPE.†â‘˜µ Æ,ÐÅs]8¾„oúÑ i>ÜxxÈó)ƒ ´æÁâØ$À‰vžŸf$Ž |ãw;ÀÁIJ»b` {¦Ó¤Ú$©YÀ‘n@Óïž«9J¼êG m¤ ܯ¹ÌW4€ÐÒÅÛ‡#褕Ÿn-?í|с¥÷Ú¹¬'´ÞÜ9ÓK `hê£SÄSà?7—Wí_´…óB›»:=Ãïq`<8ñÓŒÑlú2d¬ê³£hÖ[l|$vÝro~'R®‰§°ñmY ͧäP |PUª¹·:3Œ[Û{Xÿ ºâ@‚W–Äé u‚ ¯´*=íή.pûÒdt @G‰¬ s¸ ëÉücr ÞæÑ¨Ê@>¤¢Ö±. Þ'¯°ÌME[YéïĵÂCå½ Ué©Áû'Ê9%eÔðNU”ë‘ÌsD3/®+UI˜9h.WC”빓$#:pz:YÓ ¿xž* ³$Í +$kñAŠ‹†¢ Uê>¸)_š¬÷©ßAÂÔb9ÇU ¯¾á•9¯ÏÏ÷O÷¼¼Fähal1‰3Ì[Ïr•´UCksNÐ] R‘¸¥H+§Šé†c©vÖÞ0iÓ76s†î!§=ß ¼~Ô'°Ãmäoäš³ªøi1úÉ)³yV8 CLÄØÁ‘WYïi€H6ÖÑiámø^ÈY´°Ñ7¥Û*—Ñ©L«Qƒï—Ùrÿ ›£Ð*š¸ˆL©ˆ$ˆ ÷¾D§9È®«qbqC)–ˆïv´çñsÑVT­Ø, <àïºÀO«Jý·õ àfPìð .wFšir´þ’2_Y *Æ€x\« ì€9š@ Ž|F⇥ˆkZ@hÖÄ0t¿-<“‹qµ¾*ZL¤Ú)&BJpÓF5=$„at*Zš$’ÑtdûÝRI1 2މ$€$I$#‰SÞ’Hë¬ï;Á$¡t$’`<(ñÇt)$‡Ð.Êf¢X’Kt=Éé$‚ˆªè¢oÝëòI%Rgcª÷ŠyI%¡‰ÿ !ñ)´õ $¤ Ô’IIGÿÙ--- -- Minimalistic DHCP6 (Dynamic Host Configuration Protocol for IPv6) -- implementation supporting basic DHCP6 Solicit requests The library -- is structured around the following classes: -- * DHCP6.Option - DHCP6 options encoders (for requests) and decoders -- (for responses) -- * DHCP6.Request - DHCP6 request encoder and decoder -- * DHCP6.Response - DHCP6 response encoder and decoder -- * Helper - The helper class, primary script interface -- -- The following sample code sends a DHCP6 Solicit request and returns a -- response suitable for script output: -- -- local helper = DHCP6.Helper:new("eth0") -- local status, response = helper:solicit() -- if ( status ) then -- return stdnse.format_output(true, response) -- end -- -- -- @author Patrik Karlsson -- local datetime = require "datetime" local ipOps = require "ipOps" local math = require "math" local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" local table = require "table" _ENV = stdnse.module("dhcp6", stdnse.seeall) DHCP6 = {} -- DHCP6 request and response types DHCP6.Type = { SOLICIT = 1, ADVERTISE = 2, REQUEST = 3, } -- DHCP6 type as string DHCP6.TypeStr = { [DHCP6.Type.SOLICIT] = "Solicit", [DHCP6.Type.ADVERTISE] = "Advertise", [DHCP6.Type.REQUEST] = "Request", } -- DHCP6 option types DHCP6.OptionTypes = { OPTION_CLIENTID = 0x01, OPTION_SERVERID = 0x02, OPTION_IA_NA = 0x03, OPTION_IAADDR = 0x05, OPTION_ELAPSED_TIME = 0x08, OPTION_STATUS_CODE = 0x0d, OPTION_DNS_SERVERS = 0x17, OPTION_DOMAIN_LIST = 0x18, OPTION_IA_PD = 0x19, OPTION_SNTP_SERVERS = 0x1f, OPTION_CLIENT_FQDN = 0x27, } local DHCP6_EPOCH = os.time({year=2000, day=1, month=1, hour=0, min=0, sec=0}) -- DHCP6 options DHCP6.Option = { [DHCP6.OptionTypes.OPTION_ELAPSED_TIME] = { -- Create a new class instance -- @param time in ms since last request -- @return o new instance of class new = function(self, time) local o = { type = DHCP6.OptionTypes.OPTION_ELAPSED_TIME, time = time, -- in case no time was created, we need this to be able to -- calculate time since instantiation created = os.time(), } setmetatable(o, self) self.__index = self return o end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local data if ( self.time ) then data = string.pack(">I2", self.time) else data = string.pack(">I2", (os.time() - self.created) * 1000) end return string.pack(">I2s2", self.type, data) end, }, [DHCP6.OptionTypes.OPTION_CLIENTID] = { -- Create a new class instance -- @param mac string containing the mac address -- @param duid number the duid of the client -- @param hwtype number the hwtype of the client -- @param time number time since 2000-01-01 00:00:00 -- @return o new instance of class new = function(self, mac, duid, hwtype, time) local o = { type = DHCP6.OptionTypes.OPTION_CLIENTID, duid = duid or 1, hwtype = hwtype or 1, time = time or os.time() - DHCP6_EPOCH, mac = mac, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_CLIENTID]:new() local pos opt.duid, pos = string.unpack(">I2", data, pos) if ( 1 ~= opt.duid ) then stdnse.debug1("Unexpected DUID type (%d)", opt.duid) return end opt.hwtype, opt.time = string.unpack(">I2I4", data, pos) opt.mac = data:sub(pos) opt.time = opt.time + DHCP6_EPOCH return opt end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local data = string.pack(">I2I2I4", self.duid, self.hwtype, self.time) .. self.mac return string.pack(">I2s2", self.type, data) end, }, [DHCP6.OptionTypes.OPTION_SERVERID] = { -- Create a new class instance -- @param mac string containing the mac address -- @param duid number the duid of the client -- @param hwtype number the hwtype of the client -- @param time number time since 2000-01-01 00:00:00 -- @return o new instance of class new = function(...) return DHCP6.Option[DHCP6.OptionTypes.OPTION_CLIENTID].new(...) end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(...) return DHCP6.Option[DHCP6.OptionTypes.OPTION_CLIENTID].parse(...) end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(...) return DHCP6.Option[DHCP6.OptionTypes.OPTION_CLIENTID].__tostring(...) end, }, [DHCP6.OptionTypes.OPTION_STATUS_CODE] = { -- Create a new class instance -- @param code number containing the error code -- @param msg string containing the error message -- @return o new instance of class new = function(self, code, msg) local o = { type = DHCP6.OptionTypes.OPTION_STATUS_CODE, code = code, msg = msg, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_STATUS_CODE]:new() local pos opt.code, pos = string.unpack(">I2", data) opt.msg = data:sub(pos) return opt end, }, [DHCP6.OptionTypes.OPTION_DNS_SERVERS] = { -- Create a new class instance -- @param servers table containing DNS servers -- @return o new instance of class new = function(self, servers) local o = { type = DHCP6.OptionTypes.OPTION_DNS_SERVERS, servers = servers or {}, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_DNS_SERVERS]:new() local pos, count = 1, #data/16 for i=1,count do local srv srv, pos = string.unpack(">c16", data, pos) table.insert(opt.servers, srv) end return opt end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local data = {} for _, ipv6 in ipairs(self.servers) do data[#data+1] = ipOps.ip_to_str(ipv6) end data = table.concat(data) return string.pack(">I2s2", self.type, data) end }, [DHCP6.OptionTypes.OPTION_DOMAIN_LIST] = { -- Create a new class instance -- @param domain table containing the search domains -- @return o new instance of class new = function(self, domains) local o = { type = DHCP6.OptionTypes.OPTION_DOMAIN_LIST, domains = domains or {}, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_DOMAIN_LIST]:new() local pos = 1 repeat local domain = {} repeat local part part, pos = string.unpack("s1", data, pos) if ( part ~= "" ) then table.insert(domain, part) end until( part == "" ) table.insert(opt.domains, table.concat(domain, ".")) until( pos > #data ) return opt end, }, [DHCP6.OptionTypes.OPTION_IA_PD] = { -- Create a new class instance -- @param iad number containing iad -- @param t1 number containing t1 -- @param t2 number containing t2 -- @param option string containing any options -- @return o new instance of class new = function(self, iaid, t1, t2, options) local o = { type = DHCP6.OptionTypes.OPTION_IA_PD, iaid = iaid, t1 = t1 or 0, t2 = t2 or 0, options = options or "", } setmetatable(o, self) self.__index = self return o end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local data = string.pack(">I4I4I4", self.iaid, self.t1, self.t2) .. self.options return string.pack(">I2s2", self.type, data) end, }, [DHCP6.OptionTypes.OPTION_IA_NA] = { -- Create a new class instance -- @param iad number containing iad -- @param t1 number containing t1 -- @param t2 number containing t2 -- @param option table containing any options -- @return o new instance of class new = function(self, iaid, t1, t2, options) local o = { type = DHCP6.OptionTypes.OPTION_IA_NA, iaid = iaid, t1 = t1 or 0, t2 = t2 or 0, options = options or {}, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_IA_NA]:new() local pos opt.iaid, opt.t1, opt.t2, pos = string.unpack(">I4I4I4", data) -- do we have any options while ( pos < #data ) do local typ, len, ipv6, pref_lt, valid_lt, options typ, len, pos = string.unpack(">I2I2", data, pos) if ( 5 == DHCP6.OptionTypes.OPTION_IAADDR ) then local addr = { type = DHCP6.OptionTypes.OPTION_IAADDR } addr.ipv6, addr.pref_lt, addr.valid_lt, pos = string.unpack(">c16I4I4", data, pos) table.insert(opt.options, addr) else pos = pos + len end end return opt end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local data = string.pack(">I4I4I4", self.iaid, self.t1, self.t2) -- TODO: we don't cover self.options here, we should probably add that return string.pack(">I2s2", self.type, data) end, }, [DHCP6.OptionTypes.OPTION_SNTP_SERVERS] = { -- Create a new class instance -- @param servers table containing the NTP servers -- @return o new instance of class new = function(self, servers) local o = { type = DHCP6.OptionTypes.OPTION_SNTP_SERVERS, servers = servers or {}, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_SNTP_SERVERS]:new() local pos, server repeat server, pos = string.unpack(">c16", data, pos) table.insert( opt.servers, ipOps.str_to_ip(server) ) until( pos > #data ) return opt end, }, [DHCP6.OptionTypes.OPTION_CLIENT_FQDN] = { -- Create a new class instance -- @param fqdn string containing the fqdn -- @return o new instance of class new = function(self, fqdn) local o = { type = DHCP6.OptionTypes.OPTION_CLIENT_FQDN, fqdn = fqdn or "", } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local opt = DHCP6.Option[DHCP6.OptionTypes.OPTION_CLIENT_FQDN]:new() local pos = 2 local pieces = {} repeat local tmp tmp, pos = string.unpack("s1", data, pos) table.insert(pieces, tmp) until(pos >= #data) opt.fqdn = table.concat(pieces, ".") return opt end, } } DHCP6.Request = { -- Create a new class instance -- @param msgtype number containing the message type -- @param xid number containing the transaction id -- @param opts table containing any request options -- @return o new instance of class new = function(self, msgtype, xid, opts) local o = { type = msgtype, xid = xid or math.random(1048575), opts = opts or {} } setmetatable(o, self) self.__index = self return o end, -- Adds a new DHCP6 option to the request -- @param opt instance of object to add to the request addOption = function(self, opt) table.insert(self.opts, opt) end, -- Converts option to a string -- @return str string containing the class instance as string __tostring = function(self) local tmp = (self.type << 24) + self.xid local data = {} for _, opt in ipairs(self.opts) do data[#data+1] = tostring(opt) end return string.pack(">I4", tmp) .. table.concat(data) end, } -- The Response class handles responses from the server DHCP6.Response = { -- Creates a new instance of the response class -- @param msgtype number containing the type of DHCP6 message -- @param xid number containing the transaction ID new = function(self, msgtype, xid, opts) local o = { msgtype = msgtype, xid = xid, opts = opts or {}, } setmetatable(o, self) self.__index = self return o end, -- Parse the data string and create an instance of the class -- @param data string containing the data as received over the socket -- @return opt new instance of option parse = function(data) local resp = DHCP6.Response:new() local tmp, pos = string.unpack(">I4", data) resp.msgtype = (tmp & 0xFF000000) resp.msgtype = (resp.msgtype >> 24) resp.xid = (tmp & 0x00FFFFFF) while( pos < #data ) do local opt = {} opt.type, opt.data, pos = string.unpack(">I2s2", data, pos) if ( DHCP6.Option[opt.type] and DHCP6.Option[opt.type].parse ) then local opt_parsed = DHCP6.Option[opt.type].parse(opt.data) if ( not(opt_parsed) ) then table.insert(resp.opts, { type = opt.type, raw = opt.data }) else table.insert(resp.opts, { type = opt.type, resp = opt_parsed, raw = opt.data }) end else stdnse.debug2("No option decoder for type: %d; len: %d", opt.type, #(opt.data or "")) table.insert(resp.opts, { type = opt.type, raw = opt.data }) end end return resp end } -- Table of option to string converters -- Each option should have its own function to convert an instance of option -- to a printable string. -- -- TODO: These functions could eventually be moved to a method in its -- respective class. OptionToString = { [DHCP6.OptionTypes.OPTION_CLIENTID] = function(opt) local HWTYPE_ETHER = 1 if ( HWTYPE_ETHER == opt.hwtype ) then local mac = stdnse.tohex(opt.mac):upper() mac = mac:gsub("..", "%1:"):sub(1, -2) local tm = datetime.format_timestamp(opt.time) return "Client identifier", ("MAC: %s; Time: %s"):format(mac, tm) end end, [DHCP6.OptionTypes.OPTION_SERVERID] = function(opt) local topic, str = OptionToString[DHCP6.OptionTypes.OPTION_CLIENTID](opt) return "Server identifier", str end, [DHCP6.OptionTypes.OPTION_IA_NA] = function(opt) if ( opt.options and 1 == #opt.options ) then local ipv6 = ipOps.str_to_ip(opt.options[1].ipv6) return "Non-temporary Address", ipv6 end end, [DHCP6.OptionTypes.OPTION_DNS_SERVERS] = function(opt) local servers = {} for _, srv in ipairs(opt.servers) do local ipv6 = ipOps.str_to_ip(srv) table.insert(servers, ipv6) end return "DNS Servers", table.concat(servers, ",") end, [DHCP6.OptionTypes.OPTION_DOMAIN_LIST] = function(opt) return "Domain Search", table.concat(opt.domains, ", ") end, [DHCP6.OptionTypes.OPTION_STATUS_CODE] = function(opt) return "Error", ("Code: %d; Message: %s"):format(opt.code, opt.msg) end, [DHCP6.OptionTypes.OPTION_SNTP_SERVERS] = function(opt) return "NTP Servers", table.concat(opt.servers, ", ") end, } -- The Helper class serves as the main interface to scripts Helper = { -- Creates a new Helper class instance -- @param iface string containing the interface name -- @param options table containing any options, currently -- timeout - socket timeout in ms -- @return o new instance of Helper new = function(self, iface, options) local o = { iface = iface, options = options or {}, } setmetatable(o, self) self.__index = self local info, err = nmap.get_interface_info(iface) -- if we fail to get interface info, don't return a helper -- this is true on OS X for interfaces like: p2p0 and vboxnet0 if ( not(info) and err ) then return end o.mac = info.mac o.socket = nmap.new_socket("udp") o.socket:bind(nil, 546) o.socket:set_timeout(o.options.timeout or 5000) return o end, -- Sends a DHCP6 Solicit message to the server, essentially requesting a new -- IPv6 non-temporary address -- @return table of results suitable for use with -- stdnse.format_output solicit = function(self) local req = DHCP6.Request:new( DHCP6.Type.SOLICIT ) local option = DHCP6.Option req:addOption(option[DHCP6.OptionTypes.OPTION_ELAPSED_TIME]:new()) req:addOption(option[DHCP6.OptionTypes.OPTION_CLIENTID]:new(self.mac)) local iaid = string.unpack(">I4", self.mac:sub(3)) req:addOption(option[DHCP6.OptionTypes.OPTION_IA_NA]:new(iaid, 3600, 5400)) self.host, self.port = { ip = "ff02::1:2" }, { number = 547, protocol = "udp"} local status, err = self.socket:sendto( self.host, self.port, tostring(req) ) if ( not(status) ) then self.host.ip = ("%s%%%s"):format(self.host.ip, self.iface) status, err = self.socket:sendto( self.host, self.port, tostring(req) ) if ( not(status) ) then return false, "Failed to send DHCP6 request to server" end end local resp, retries = {}, 3 repeat retries = retries - 1 local status, data = self.socket:receive() if ( not(status) ) then return false, "Failed to receive DHCP6 request from server" end resp = DHCP6.Response.parse(data) if ( not(resp) ) then return false, "Failed to decode DHCP6 response from server" end until( req.xid == resp.xid or retries == 0 ) if ( req.xid ~= resp.xid ) then return false, "Failed to receive DHCP6 response from server" end local result, result_options = {}, { name = "Options" } local resptype = DHCP6.TypeStr[resp.msgtype] or ("Unknown (%d)"):format(resp.msgtype) table.insert(result, ("Message type: %s"):format(resptype)) table.insert(result, ("Transaction id: %d"):format(resp.xid)) for _, opt in ipairs(resp.opts or {}) do if ( OptionToString[opt.type] ) then local topic, str = OptionToString[opt.type](opt.resp) if ( topic and str ) then table.insert(result_options, ("%s: %s"):format(topic, str)) end else stdnse.debug2("No decoder for option type: %d", opt.type) end end table.insert(result, result_options) return true, result end, } return _ENV;