Coder Social home page Coder Social logo

gochro's Introduction

gochro

Build Status

gochro is a small docker image with chromium installed and a golang based webserver to interact wit it. It can be used to take screenshots of websites using chromium-headless and convert HTML pages to PDF.

If errors occur the error will be logged to stdout and a non information leaking error message is presented to the user.

This project is currently used on https://wpscan.io for taking website screenshots and to generate PDF reports.

Screenshot

This URL takes a Screenshot of https://firefart.at with a resolution of 1024x768 and returns an image.

http://localhost:8080/screenshot?url=https://firefart.at&w=1024&h=768

PDF

Send a POST request with the HTML you want to convert in the Post body to the following url.

http://localhost:8080/html2pdf?w=1024&h=768

This will return a PDF of the HTML input.

Example:

POST /html2pdf?w=1024&h=768 HTTP/1.1
Host: localhost:8000
Content-Type: application/x-www-form-urlencoded
Content-Length: 119

<html>
<head><title>Test Page</title></head>
<body>
<h1>This is a test</h1>
<p>This is a test</p>
</body>
</html>

Run server

To run this image you should use the seccomp profile provided by Jess Frazelle. The privileges on the host are needed for chromiums internal security sandbox. You can also deactivate the sandbox on chromium (would require changes in main.go) but that's a bad idea and puts your server at risk, so please use the seccomp profile instead.

I included all the necessary steps in the included Makefile to build and run everything

Only build the webserver for non docker use

The following command builds the webserver for non docker use inside the build directory

make all

Only build docker image

To only build the docker image run

make docker-update

This will download the seccomp profile, all needed base images and builds the gochro:dev tagged image.

Run the image

To run the image in interactive mode (docker output will be connected to current terminal) run

make docker-run

This will also build the image before running it. This maps the internal port 8000 to your machine.

Run the image in deamon mode

To run it in deamon mode use the following command. This will launch everything in the background. Be aware that the webserver is rerun on startup of the machine if you don't shut down the container manually.

make docker-run-daemon

Use the docker hub image

You can also use the prebuit image from dockerhub.

To pull the image run

docker pull firefart/gochro

Include in docker-compose

If you want to include this image in a docker-compose file you can use the following example. Just connect the gochronet to the other service so the containers can communicate with each other.

Please note that the 0.0.0.0 in the command only applies to the network inside the docker container itself. If you want to access it from your local machine you need to add a port mapping.

version: '3.7'

services:
  gochro:
    image: firefart/gochro
    container_name: gochro
    security_opt:
      - seccomp="chrome.json"
    command: -host 0.0.0.0:8000
    networks:
      - gochronet

networks:
  gochronet:
    driver: bridge

gochro's People

Contributors

firefart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.