Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    2
    Member #
    15262
    What I am looking to do is provide an online tool (preferably a php script) that will convert a domain name to decimal and then output the result. I have a script in C# which does this but I have very little knowledge of php so there is no chance of me converting this. Is it even possible? Any help would be great and if someone would find the time to convert it for me I would be sure to compensate them in some way! Here is the C# for the script:
    Code:
    private void button1_Click(object sender, EventArgs e)
            {
                string textURL = textBox1.Text; // Assign Text entry String
                IPHostEntry ip = Dns.GetHostEntry(textURL); //DNS lookup of entered Text
                String ipString = Convert.ToString(ip.AddressList[0]); //Text to String
                String[] octet = ipString.Split('.'); //Split IP Address into 4 octects
                double[] octetDouble = new double[4]; //Initialize arrary for octets into Double
                for (int i = 0; i 
                {
                    octetDouble[i] = Convert.ToDouble(octet[i]); //Populate array with converted octets
                }
                double bitstream = octetDouble[3] + octetDouble[2] * 256 + octetDouble[1] * 65536 + octetDouble[0] * 16777216;
                //Convert the octets to a decimal bitstream
                string textBitstream = Convert.ToString(bitstream); //Convert Bitstream to text
                label2.Text = "http://" + textBitstream;  //Replace label with http:// + bitstream
    Thanks alot everyone I appreciate it, and w00t first post!

  2.  

  3. #2
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Hmm, you mean translating from domain name to IP address? I'm not sure for the DNS lookup, but I would imagine that's the only thing to do... are you creating some sort of WHOIS tool?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,733
    Member #
    5580
    Liked
    718 times


  5. #4
    Junior Member
    Join Date
    May 2007
    Posts
    2
    Member #
    15262
    No I do not want to convert the domain name to the IP address. I am assuming that you guys know basic IP address structure.
    The numbers are referred to as ‘octets’. An octet is an eight bit (read as: eight digit) binary number. Eight bits can represent any value from 0 (00000000) to 255 (11111111). All IP addresses are 32 bits long. Four octets (4 x 8) represent these 32 bits. Users and administrators read and write IP addresses in octets because using a stream of ones and zeroes is impractical—and could give your retina serious screen burn!

    Content filters are expecting IP addresses in the standard decimal notation. Instead, we can express the same 32-bit number as one big number, instead of four smaller ones. This will bypass most content filters but because it is just converting the notation it will bypass the filter but do so quicker than a proxy would.

    Here is an example for the math behind this (Sorry if this post is too long!):
    Start by pulling up your scientific calculator.

    In Windows type ‘calc’ into the Run prompt.

    On Linux, type ‘gcaltool’ in the terminal console.

    Once the calculator appears, select ‘Scientific’ from the View menu. This will add lots of buttons and options to your plain old calculator.

    Above the buttons, notices the radial buttons next to each of the number systems: bin (binary), oct (octal), dec (decimal) and hex (hexadecimal). These buttons are used to switch back and forth between the different bases, as well as convert the numbers.

    Follow these steps, using the example IP address of 64.233.167.99:

    Verify that the calculator is in Decimal (‘dec’ should be selected) Type in the first octet of the IP address (64) Convert the number to binary by clicking the ‘bin’ radial button.

    Write this number down.

    The calculator displays ‘1000000’.

    Octets represent EIGHT digits. The result from the calculator shows only seven digits. In order for this technique to work correctly enter each result in eight digits.

    Pad the beginning of the number with zeroes until the octet has eight digits.

    This means you should write down ‘01000000’ Switch the calculator back to Decimal.

    Clear the calculator display.

    Repeat steps 1 through 6 for the remaining octets.

    Your results should be: 233 (11101001), 167 (10100111) and99 (01100011) Switch the calculator to binary.

    Combine the results of your conversion into a single 32-bit number (01000000111010011010011101100011) Notice, if you failed to pad the last number with a zero, the result would be only 31 bits, and the technique would fail.

    Type this number into the calculator and convert it to decimal. This should give you a decimal result of 1208930147.

    In your browser, type http://1089054563 and hit enter.

    Notice that the Google search engine appears.

    A content filter will see a request for a web server named 1208930147. This does not match (1) the name of a banned server, (2) an IP address or (3) a keyword.

    The browser wrote the 32 address into the packet header, but the content filter, which only inspects the HTTP header, doesn’t notice that the server is blacklisted.

    Because this activity is not significant, it will not flag your request. Instead, it will fetch the content that was requested.

    I hope that clarified what I was looking to do a bit. :P

  6. #5
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    In other words, you're getting the IP address, putting them all to one number then turning it to decimal? Shouldn't be so hard. Simply get the IP address, get the 4 numbers, then multiply the first by 224, the second by 216, and the third by 28, then total them all. Yes, pretty much like your C# app there. Now, where do you need help? Getting the IP address, or the calculations?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yeah, your real problem is going to be getting the DNS entry; after that, it's just math. Hit up Google to get some DNS resolves for PHP, then have a glance at [phpfunction]explode[/phpfunction] for expanding an IP string into the relevant octets, then have a glance at [phpfunction]intval[/phpfunction] for converting the strings to integers, realize that PHP supports the shift-left and shift-right operators (which it looks like is what you actually want to do, though multiplication works, too), and do your stuff

  8. #7
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  9. #8
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Hahahahahahahahaha.... Okay, that's what you get for not looking for the obvious first :-D

  10. #9
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    You've gotta admit that tinkering with PHP a lot every day must get to your brain. I never even knew those networking functions existed.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  11. #10
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    And, oh by the way, [phpfunction]checkdnsrr[/phpfunction]


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:51 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com