Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jun 2003
    Location
    Utah, USA
    Posts
    412
    Thanks
    39
    Thanked 5 Times in 5 Posts

    Pass a File to a URL

    I know how to add an entry to a context menu ...

    But ... is there a way to pass the file to a URL?

    I am thinking that it would convenient to add a context menu entry to, say *.exe files, that would open VirusTotal.com in a browser window and submit that *.exe to that site.

  2. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,584
    Thanks
    5
    Thanked 1,059 Times in 928 Posts
    That would depend on whether the target site accepts a file name parameter.

    Joe

  3. #3
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    Northern California
    Posts
    326
    Thanks
    15
    Thanked 142 Times in 91 Posts
    Have you checked VirusTotal's documentation page? Sounds like they already do what you want:


    "A set of desktop applications have been developed for the main operating systems so as to make the process of scanning a file as easy as right-clicking on the file of interest."



  4. #4
    4 Star Lounger
    Join Date
    Jun 2003
    Location
    Utah, USA
    Posts
    412
    Thanks
    39
    Thanked 5 Times in 5 Posts
    Sorry for not being clearer ...

    My question is more academic ... is there a way to add an item to a file's context menu to pass it to a URL?

  5. #5
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    While it is possible to write an application that would upload a file to a web site, the application would have to be specifically written for the web site. The reason is that it is not just the file that gets transferred but also various other pieces of information from the web page. So it is nothing like, for example, copying a file to somewhere. This is based on my experiences of writing web applications that allowed users to upload files. You could suggest such an app to the VirusTotal.com people, they might take you up on that (that is, create an app that could be used in a right-click menu to upload a file to their site) as it would be a good feature and make their product easier to use.

  6. #6
    Lounger
    Join Date
    Dec 2009
    Location
    Leiden, Netherlands
    Posts
    30
    Thanks
    2
    Thanked 4 Times in 2 Posts

    Could be done, but it can be more complicated than it looks

    Taking you up on the academic question, I will try to explain what happens from a programmer/scripter's point of view:

    Simply put: Yes, it can be done, but you need some programming skill.

    Basically, for simple UIRLs, it can be done in batch using the command-line tools Curl or wget, and you can call the batch script from the right-click handler, but you'd need to know exactly which form data is expected by the web server to know how to set the (possibly many!) options for these programs, necessary to make the form post correctly.
    Also, you'd need some way to interpret/display the result, but that can be as simple as saving the html to a file and opening it in a browser.
    Note however, that the saved web page could call resources from the web server which can not be resolved from the saved html.

    And, here is where it can (and usually does) get complicated:
    I quickly checked the website of VirusTotal, and by inspecting the timeline and called javascript functions I can determine that it is not performing a simple post of a multi-part form (the usual way of uploading a file to a web server).
    After selecting a file and clicking the Scan button, the webpage first computes a SHA256 hash (this acts like a fingerprint) for the file (on the client computer), which is posted back to the website. so it can quickly check that the file was scanned before, before even attempting to upload the file (thus limiting the bandwidth for the server).

    The SHA256 check is done by the client calling URL /file/upload on the webserver, thus presenting the SHA256 hash to the server:

    $.ajax({

    type: 'GET',
    async: true,
    url: '/file/upload/',
    dataType: 'json',
    data: data,
    context: {'filename': filename},
    cache: false,
    success: function(response){

    If the hash is unknown, the response contains an URL which must be used to upload to file to.
    This is dynamically attached to the form as the form's action, and then the submit function is executed on the form (in the simple case, there is also code to show an upload progress bar, which is slightly more complicated code).
    This results then in the contents of the file being sent to the web server, on the location specificied in the previous response.

    $('#frm-file').attr('action', response.upload_url);
    $('#frm-file').submit();

    So you NEED to simulate this precise interaction to make the upload work... A lot of work without writing a tailor-made application, difficult nearly impossible due to the SHA256 calculation on the client...
    And that is just getting the file on the web server... Checking the result is another problem altogether...

    A good programmer could use a powerful scripting language or programming language to create a script/program to perform these actions, but it is not simple.

    I hope that this answers your academical question, and you can look into curl and wget to download web pages automatically
    Static content can usually be easily retrieved, but when Javascript is used by the web page, this can rapidly get very nasty..

    Kind regards,
    Eelco
    - Eelco

    *** Puzzle me! ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •