skip to Main Content

Let’s say we have a deceptive URL. A browser shows an alert window saying that "Deceptive site ahead", while file_get_contents() returns the original content and cannot detect if that URL actually shows the alert window to a visitor.

How can I get that alert via PHP? I want to get the same content a visitor sees.

Deceptive URL example: lumaalchema*com

enter image description here

2

Answers


  1. There are many different browsers and they each implement their own safety measures. If they are open-source, then you can download/clone them and find where this was implemented. So you can engineer the same logic in your PHP code and then you could check for the files the user requested via the browser’s source-code.

    Yet, this may sound very simple, but the fact that browsers change with each of their version and users are using multiple browsers complicate things a bit. In order to find out what browser the user is using you can use get_browser in PHP. If you have the code that emulates the check for deceptive sites for the browser the user visited with, then you can trigger it and make your own check. Sure thing, you will need to check for versions as well, so this is not very easy to manage, as you will occasionally need to pull newer versions and potentially keep multiple copies of this logic for different versions.

    Surely, you can use a web driver, such as Selenium too, like How do you run Selenium headless in PHP? if that does the trick.

    Login or Signup to reply.
  2. file_get_contents can only get the contents of the URL, not the contents of the warning window. If you want to get the contents of the warning window, then you can do this.

    1. Manually store the URL you accessed into the database.
    2. Use file_get_contents to access the URL, go to the database to match whether the URL has warning data, if so, then return the warning data.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search