User Tools

Site Tools


Sidebar

en:objects:browser:external_params:set_canvas_todataurl

set_canvas_toDataURL

set_canvas_toDataURL($toDataURL="",$jsChangeNoise=""); - Used for setting Browser Canvas Finger Print (Available from version 4.10.9)

The function accepts parameters as input:

  • $noise - Any number or string is passed as a parameter based on which "noise" is created for a picture with text. Since Studio 7.0.43.
  • $jsChangeNoise - contains an algorithm for changing a picture using JS. Thus, if you can use your own image processing algorithms. Since Studio 7.0.45.

    After testing, the function returns the result of its work to the script. you can view the result here :
  • true – successfully set
  • false – failed to set

    PHP example:

    <?php $xhe_host = "127.0.0.1:7024";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> browser->".basename(__FILE__)."</font> <hr>";
     
    $browser->enable_fonts(false);
    //$raw->enable_all_streams(true);
    //$raw->add_disabled_response_url("canvas.js ");
     
    //10 random canvas finger print
    for($i = 0; $i <2; $i ++)
    {
    //1
    echo "1.Let's set information about the screen sensor:";
    echo $browser->set_canvas_toDataURL("data:".$submitter->generate_random_text(4168,1))."<br>" ;;
     
    //2
    echo "2.Go to the browser detection page:";
    echo $browser->navigate("http://browserleaks.com/canvas", false)." n";
    $element->get_by_inner_text("Signature")->focus();
    sleep(1);
    }
     
    //3
    echo "3.Let's set the default screen sensor information:";
    echo $browser->set_canvas_toDataURL()."<br>";
     
    //4
    echo "4.Let's go to the browser detection page:";
    echo $browser->navigate("http://browserleaks.com/canvas", false)." n";
    $element->get_by_inner_text("Signature")->focus();
    sleep(1);
     
    //five
    echo "5.Via JS manually - set any changes:";
    $js = "for(var i = 1; i <height-1; i ++)
        {
            for(var j = 1; j <width-1; j ++)
            {
                var n =((i *(width * 4)) +(j * 4));
                imageData.data [n + 0] = imageData.data [n + 0] + 150;
                imageData.data [n + 1] = imageData.data [n + 1] + 150;
                imageData.data [n + 2] = imageData.data [n + 2] + 150;
                imageData.data [n + 3] = imageData.data [n + 3];
            }
        } ";
    echo $browser->set_canvas_toDataURL(1, $js)." n";
     
    //6
    echo "6.Let's go to the browser detection page:";
    echo $browser->navigate("http://browserleaks.com/canvas", false)." n";
    $element->get_by_inner_text("Signature")->focus();
    sleep(1);
     
    //7
    echo "7.Via JS using Canavas' saved array:";
    $Js = "var imgDateArrayEncoded = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2 YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA//9mAP//ZgD//2YA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/ZgD//2YA//9mAP//ZgD//2YA//9mAP/

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
     
    browser.enable_fonts(false)
    raw.enable_all_streams(true)
    raw.add_disabled_response_url("canvas.js")
     
    # 10 random canvas finger print
    for i in range(0.9):
    # 1
    echo("1.Set information about the screen sensor:")
    echo(browser.set_canvas_toDataURL("data:" + submitter.generate_random_text(4168,1)), "<br>")
    # 2
    echo("2.Let's go to the page for browser detection:")
    echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable"), "<br>")
    anchor.click_by_name("showFingerprintLink2")
    sleep(1)
    td.get_by_inner_text("Hash of canvas fingerprint", false) .focus()
    sleep(7)
    browser.navigate("about: blank")
    browser.navigate("https://browserleaks.com/canvas", false)
    sleep(7)
     
    # 3
    echo("3.Set the default screen sensor info:")
    echo(browser.set_canvas_toDataURL(), "<br>")
     
    # 4
    echo("4.Go to the browser detection page:")
    echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable"), "<br>")
    anchor.click_by_name("showFingerprintLink2")
    sleep(1)
    td.get_by_inner_text("Hash of canvas fingerprint", false) .focus()
    raw.enable_all_streams(false)
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7010";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> browser.set_app_info </font> <hr>");
     
    //10 random canvas finger print
    for(int i = 0; i <10; i ++)
    {
    //1
    echo("1.Let's set information about the screen sensor:");
    echo(browser.set_canvas_toDataURL("data:" + submitter.generate_random_text(10,1)) + "<br>");
     
    //2
    echo("2.Let's go to the page for browser detection:");
    echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable") + "<br>");
    anchor.click_by_name("showFingerprintLink2");
    sleep(1);
    td.get_by_inner_text("Hash of canvas fingerprint", 0).focus();
    sleep(7);
    browser.navigate("about: blank");
    }
     
    //3
    echo("3.Set the default screen sensor information:");
    echo(browser.set_canvas_toDataURL() + "<br>");
     
    //4
    echo("4.Let's go to the page for browser detection:");
    echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable") + "<br>");
    anchor.click_by_name("showFingerprintLink2");
    sleep(1);
    td.get_by_inner_text("Hash of canvas fingerprint", 0).focus();
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7022";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> browser.send_get_query </font> <hr>");
     
    //10 random canvas finger print
    for(var i = 0; i <10; i ++)
    {
       //1
        echo("1.Let's add distortion to the canvas:");
        echo(browser.set_canvas_toDataURL("data:" + submitter.generate_random_text(10,1)) + "<br>");
     
       //2
        echo("2.Let's go to the page for browser detection:");
        echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable") + "<br>");
        anchor.click_by_name("showFingerprintLink2");
        app.sleep(1);
        td.get_by_inner_text("Hash of canvas fingerprint", false) .focus();
        app.sleep(7);
        browser.navigate("about: blank");
    }
     
    //3
    echo("3.Set the default screen sensor information:");
    echo(browser.set_canvas_toDataURL() + "<br>");
     
    //4
    echo("4.Let's go to the page for browser detection:");
    echo(browser.navigate("panopticlick.eff.org/results?&t=111&dnt=111&a=111#fingerprintTable") + "<br>");
    anchor.click_by_name("showFingerprintLink2");
    app.sleep(1);
    td.get_by_inner_text("Hash of canvas fingerprint", false) .focus();
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/browser/external_params/set_canvas_todataurl.txt · Last modified: 2026/08/05 22:32 (external edit)