All Projects → spatie → Mixed Content Scanner

spatie / Mixed Content Scanner

Licence: mit
Scan a HTTPS-site for mixed content

Labels

Projects that are alternatives of or similar to Mixed Content Scanner

Chameleon
Customizable honeypots for monitoring network traffic, bots activities and username\password credentials (DNS, HTTP Proxy, HTTP, HTTPS, SSH, POP3, IMAP, STMP, RDP, VNC, SMB, SOCKS5, Redis, TELNET, Postgres and MySQL)
Stars: ✭ 230 (+183.95%)
Mutual labels:  https, scan
Acme client
Java ACME Client application
Stars: ✭ 77 (-4.94%)
Mutual labels:  https
Go Mitmproxy
mitmproxy implemented with golang. 用 Golang 实现的中间人攻击(Man-in-the-middle),解析、监测、篡改 HTTP/HTTPS 流量。
Stars: ✭ 61 (-24.69%)
Mutual labels:  https
Dave
A totally simple and very easy to configure stand alone webdav server
Stars: ✭ 69 (-14.81%)
Mutual labels:  https
Titanium Web Proxy
A cross-platform asynchronous HTTP(S) proxy server in C#.
Stars: ✭ 1,122 (+1285.19%)
Mutual labels:  https
Papermerge
Open Source Document Management System for Digital Archives (Scanned Documents)
Stars: ✭ 1,177 (+1353.09%)
Mutual labels:  scan
Clojurl
An example Clojure CLI HTTP/S client using GraalVM native image
Stars: ✭ 59 (-27.16%)
Mutual labels:  https
Redirect Ssl
Connect/Express middleware to enforce https using is-https
Stars: ✭ 81 (+0%)
Mutual labels:  https
Alternc
AlternC Hosting Panel
Stars: ✭ 75 (-7.41%)
Mutual labels:  https
Free Web Books
Learn books from TCP/IP | HTTP(s) | HTML、JS、JQuery | PHP | Web
Stars: ✭ 69 (-14.81%)
Mutual labels:  https
Reverseproxy
a minimalist http/https proxy library for golang
Stars: ✭ 67 (-17.28%)
Mutual labels:  https
Docker Letsencrypt Certgen
Docker image to generate, renew, revoke RSA and/or ECDSA SSL certificates from LetsEncrypt CA using certbot and acme.sh clients in automated fashion
Stars: ✭ 64 (-20.99%)
Mutual labels:  https
Radarview
🍳 RadarView for Android 是一个雷达扫描动画后,然后展示得分效果的控件。
Stars: ✭ 73 (-9.88%)
Mutual labels:  scan
Low Latency Android Ios Linux Windows Tvos Macos Interactive Audio Platform
🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
Stars: ✭ 1,121 (+1283.95%)
Mutual labels:  https
Okurl
OkHttp Kotlin command line
Stars: ✭ 77 (-4.94%)
Mutual labels:  https
Zinc
Zinc HTTP Components is an open-source Smalltalk framework to deal with the HTTP networking protocol.
Stars: ✭ 60 (-25.93%)
Mutual labels:  https
Esa Restlight
ESA Restlight is a lightweight and rest-oriented web framework.
Stars: ✭ 67 (-17.28%)
Mutual labels:  https
Merecat
Small and made-easy HTTP/HTTPS server based on Jef Poskanzer's thttpd
Stars: ✭ 69 (-14.81%)
Mutual labels:  https
React Native Fingerprint Identify
Awesome Fingerprint Identify for react-native (android only)
Stars: ✭ 81 (+0%)
Mutual labels:  scan
Lunik Torrent
Web torrent downloader and cloud storage.
Stars: ✭ 79 (-2.47%)
Mutual labels:  https

Scan your site for mixed content

Latest Version on Packagist Tests Check & fix styling Total Downloads

This package contains a class that can scan your site for mixed content.

Here's an example of how you can use it:

use Spatie\MixedContentScanner\MixedContentScanner;

$logger = new MixedContentLogger();

$scanner = new MixedContentScanner($logger);

$scanner->scan('https://example.com');

MixedContentLogger is a class containing methods that get called when mixed content is (not) found.

If you don't need a custom implementation but simply want to look for mixed content using a command line tool, take a look at our mixed-content-scanner-cli package.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/mixed-content-scanner

How it works under the hood

When scanning a site, the scanner will crawl everypage. On the retrieve html, these elements and attributes will be checked:

  • audio: src
  • embed: src
  • form: action
  • link: href
  • iframe: src
  • img: src, srcset
  • object: data
  • param: value
  • script: src
  • source: src, srcset
  • video: src

If any of those attributes start with http:// the element will be regarded as mixed content.

The package does not scan linked .css or .js files, nor does it take inline <script> or <style> and shortlinks into consideration.

Usage

use Spatie\MixedContentScanner\MixedContentScanner

$logger = new MixedContentLogger();

$scanner = new MixedContentScanner($logger);

$scanner->scan('https://example.com');

That MixedContentScanner accepts an instance of a class that extends \Spatie\MixedContentScannerMixedContentObserver. You should create such a class yourself. Let's take a look at an example implementation.

use Psr\Http\Message\UriInterface;
use Spatie\MixedContentScanner\MixedContent;
use Spatie\MixedContentScanner\MixedContentObserver;

class MyMixedContentLogger extends MixedContentObserver
{
    /**
     * Will be called when mixed content was found.
     * 
     * @param \Spatie\MixedContentScanner\MixedContent $mixedContent
     */
    public function mixedContentFound(MixedContent $mixedContent): void
    {
    }

    /**
     * Will be called when no mixed content was found on the given url.
     * 
     * @param \Psr\Http\Message\UriInterface $crawledUrl
     */
    public function noMixedContentFound(UriInterface $crawledUrl): void
    {
    }

    /**
     * Will be called when the scanner has finished crawling.
     */
    public function finishedCrawling(): void
    {
    }
}

Of course, you should supply a function body to these methods yourself. If you don't need a function just leave it off.

The $mixedContent variable the mixedContentFound class accept is an instance of \Spatie\MixedContentScanner\MixedContent which has these three properties:

  • $elementName: the name of the element that is regarded as mixed content
  • $mixedContentUrl: the url of the element that is regarded as mixed content. For an image this can be the value of src or srcset for a form this can be the value of action, ...
  • $foundOnUrl: the url where the mixed content was found

Customizing the requests

The scanner is powered by our homegrown Crawler which on it's turn leverages Guzzle to perform webrequests. You can pass an array of options to the second argument of MixedContentScanner. These options will be passed to the Guzzle Client.

Here's an example where ssl verification is being turned off.

$scanner = new MixedContentScanner($logger);
$scanner->scan('https://laravel.com', ['verify' => 'false']);

Filtering the crawled urls

By default, the mixed content scanner will crawl all urls of the hostname given. If you want to filter the urls to be crawled, you can pass the scanner a class that extends Spatie\Crawler\CrawlProfile.

Here's the content of that class:

namespace Spatie\Crawler;

use Psr\Http\Message\UriInterface;

abstract class CrawlProfile
{
    /**
     * Determine if the given url should be crawled.
     *
     * @param \Psr\Http\Message\UriInterface $url
     *
     * @return bool
     */
    abstract public function shouldCrawl(UriInterface $url): bool;
}

And here's how you can let the scanner use your profile:

use Spatie\MixedContentScanner\MixedContentScanner;

$logger = new MixedContentLogger();

$scanner = new MixedContentScanner($logger);

$scanner->setCrawlProfile(new MyCrawlProfile);

Customizing the crawler

The scanner is powered by our homegrown Crawler. You can call any methods on the crawler before the crawling process starts by calling configureCrawler on a MixedContentScanner.

use Spatie\Crawler\Crawler;
use Spatie\MixedContentScanner\MixedContentScanner;

$scanner = (new MixedContentScanner($logger))
    ->configureCrawler(function(Crawler $crawler) {
        $crawler->setConcurrency(1) // now all urls will be crawled one by one 
    });

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

The scanner is inspired by mixed-content-scan by Bram Van Damme. Parts of his readme and code were used.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].