Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About demo #8

Open
MTFAlpha1 opened this issue Jan 7, 2021 · 1 comment
Open

About demo #8

MTFAlpha1 opened this issue Jan 7, 2021 · 1 comment

Comments

@MTFAlpha1
Copy link

Would you please share the html JS and py file of the online demo? Thank you very much.

@silentsilas
Copy link

silentsilas commented Jun 15, 2021

The javascript is inlined and unobfuscated, so it should be relatively easy to create your own version of the site.

JS function to validate input before sending the POST request via an HTML form submission:

    function alg_updated() { 
        var value = $("#steg_method").val(); 
        $("#arithmetic_param").css("display", "none"); 
        $("#huffman_param").css("display", "none"); 
        $("#bins_param").css("display", "none"); 
        $("#"+value+"_param").css("display", "table-row");
    }

    function validate_options(src) {
        var steg_method = $("#steg_method").val();
        if (steg_method == 'arithmetic') {
            var x = $("#temp").val();
            if (isNaN(x)) {
                alert('Temperature not a number');
                return false;
            }

            if (x < 0.5 || x > 1.3) {
                alert('Temperature must be within [0.5, 1.3]');
                return false;
            }
        }

        var context_len = $("#context").val().length;
        if (context_len > 800) {
            alert("Context length too long, > 800 characters");
            return false;
        }

        if (src == 'enc') {
            var message_len = $("#message_text").val().length;
            if (message_len > 800) {
                alert("Message text too long, > 800 characters");
                return false;
            }
        } else if (src == 'dec') {
            var cover_len = $("#cover_text").val().length;
            if (cover_len > 5000) {
                alert("Cover text too long, > 5000 characters");
                return false;
            }
        }

        $("#submit").prop("disabled", true)
        $("#submit").val("Please Wait...")

        return true;
    }

Example POST request URL parameters to the /encrypt endpoint:

context=Washington+received+his+initial+military+training+and+command+with+the+Virginia+Regiment+during+the+French+and+Indian+War.+He+was+later+elected+to+the+Virginia+House+of+Burgesses+and+was+named+a+delegate+to+the+Continental+Congress%2C+where+he+was+appointed+Commanding+General+of+the+nation%27s+Continental+Army.+Washington+led+American+forces%2C+allied+with+France%2C+in+the+defeat+of+the+British+at+Yorktown.+Once+victory+for+the+United+States+was+in+hand+in+1783%2C+Washington+resigned+his+commission.%0D%0A%0D%0A%0D%0A&message_text=Hello+there&enc_method=arithmetic&steg_method=arithmetic&temp=0.9&trunc=3&bins=3

Though I'd recommend using JSON and the Fetch API instead of a traditional HTML form submission.

Edit: And as for replicating the web server, your best bet would be to use run_single.py as a reference to implement your own encrypt and decrypt functions, and run them as a shell command in your web backend of choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants