I am writing a code as follows
$ID= 1; #2 octets
$flags = 0; #(For Request value is 0)#2 octets
$QDCOUNT=1; #2 octets
$ANCOUNT=0;#2 octets
$NSCOUNT=0;#2 octets
$ARCOUNT=0;#2 octets
$QNAME= "www.google.com";#16 octets
$QTYPE=23; #(For NAPTR)#2 octets
$QCLASS=1; #(For IN)#2 octet
my $DNS_Request= "$ID$flags$QDCOUNT$ANCOUNT$NSCOUNT$ARCOUNT$QNAME$QTYP
+E$QCLASS";
$MySocket->send($DNS_Request);
Here the problem is that Suppose i am assigning the value $ID=1. How can can i convert it into the hexa value of 2 octets which is '0001' and so for other values with their respective octets.
The $QNAME = "www.google.com". How can i convert it into the hexa value '0377777706676F6F676C6503636F6D00'.
So that Wire shark will decoded it properly without showing malformed packet.
The problem is that if i am sending the $QNAME value diretly (That means without converting into the hexa format). The wireshark decoded it as '7777772e676F6F676C652e636F6D'.Which shows it as a malformed packet.
Plz suggest me a suitable code. So that i can send a DNS request properly.
Regd's
Sanjay
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.