1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Convert Javascript code To Vb.net

Discussion in 'Visual Basic .NET' started by kill4, Jan 13, 2014.

  1. kill4

    kill4 Regular Member

    Joined:
    May 11, 2009
    Messages:
    243
    Likes Received:
    42
    Location:
    Texas
    ok, would appreciate some help i dont know javascript, but looking at the javascript code i can get some of whats going on.

    Code:
    
    <script language="javascript">
        setInterval(function () {
            var form = document.getElementsByTagName('form')[0];
            var key = document.getElementById('recaptcha_challenge_field').value;
            if (!document.getElementsByName(key)[0]) {
                var arr = key.split('').sort().join('').substring(20, 40).split('');
                var value = '';
                while (arr.length) {
                    value += arr.splice(Math.floor(arr.length*Math.random()), 1)[0];
                }
                var container = document.getElementById('submitContainer');
                container.innerHTML = container.innerHTML + '<input type="hidden" name="' + key + '" value="' + value + '" />';
            }
        }, 2000);
    </script>
    
    
    Looks like they are getting the recaptchachallenge field and, then splitting it up, and getting the recaptchafield substring starting at 20, to 40 then doing some random values and some other stuff, kinda get lost there. for example the recaptchachallengefield would be this

    Code:
    03AHJ_VuuiiZdo6MpOlJHmmHFLZB6-GGUnBJxadjLhk4J25j_tU1g2dry2LJAO6f0di3Q3mh7BdPbyXkGkDBchwzPKKrU66aLc7DrBaazGFG-tlwNjTHFRxsc81cf6LT_1xQ0qzmEuKXUMNWZhIWsVyoYdmIuGZFDclEK2TnIJVprlThyo1bo4VMA
    

    and the end result of the code would output this

    Code:
    76AAB76ED8B66BBDDB6A
    
    Anyone with javascript, and vb.net knowledge that could convert this javascript code to vb.net? Your help would be appreciated :)

    Thanks..
     
    • Thanks Thanks x 1
  2. mypmmail

    mypmmail Junior Member

    Joined:
    Jan 31, 2008
    Messages:
    111
    Likes Received:
    27
    The logic of this code goes something like this

    - convert the whole string of characters into individual character
    - sort the characters in order
    - get the 20th to 40th characters (result - 20 character)
    - get a random character out of this 20 character (repeat this for 20 times)
    - put this value into a hidden field to be submitted together with the form

    hth