GithubHelp home page GithubHelp logo

dcoh's Introduction

dcoh

What is this

This software use proxy to deceive the communication of HTTP(S).
The reason for making is to debug API and hack API to do.

Getting Started

This project was created to deceive the communication of HTTP(S).
To use this project so see "Installing" and "Usage" section.

Requirements (Confirmed)

  • Python 3.7 / 3.8 / 3.9
  • OpenSSL 1.0.2 or 1.1.1

Installing

To usage so clone the repository and set up the CA root.
Enter the bellow command line to installing.

git clone https://github.com/fealone/dcoh
cd dcoh
pip install -r requirements.txt
cd CA
./init.sh # Setup the CA root

Default DN is this.

C = "JP"
ST = "Tokyo"
L = "Minato-ku"
O = "dcoh"
OU = "dcoh"

If you need to change DN then change settings.py.

Usage

To using try to enter the bellow command line.

python main.py

How to deceive

Create the contents you want to deceive.
If a path has an end of a slash then, add "index.html" to the end.

dcoh/contents/{domain}/{url}

For example

dcoh/contents/www.google.com/index.html

How to use custom script

Create the Python script you want to change response and request.
The path to deploy is to add extension ".py" to the contents path.
Also, different from the content is if a path has an end of a slash then, it doesn't add "index.html" to the end.

For example

  • Path

dcoh/contents/www.google.com/.py

  • Script
from typing import Any, Dict, Generator

from lib.content_object import ContentObject
from lib.delegate_object import DelegateObject
import requests


class Delegate(DelegateObject):

    # Can change requests if you need to deceive to request.
    # This method is optional.
    def get_request(self) -> requests.Request:
        if self.request_payload:
            req = requests.Request(self.headers["method"],
                                   f"{self.protocol}://{self.target}{self.headers['url']}",
                                   headers=self.header,
                                   data=self.request_payload)
        else:
            req = requests.Request(self.headers["method"],
                                   f"{self.protocol}://{self.target}{self.headers['url']}",
                                   headers=self.header)
        return req

    # Can change responses if you need to deceive to a response.
    # This method is optional.
    def get_response(self, response: requests.Response) -> "ResponseObject":
        return ResponseObject(response, self.header)


class ResponseObject(ContentObject):

    # Can use this property if you need to change any headers.
    # This property is optional.
    @property
    def headers(self) -> Dict[str, Any]:
        return self.res.headers

    # Can use this property if you need to change the status code.
    # This property is optional.
    @property
    def status_code(self) -> int:
        return self.res.status_code

    # Can use this method if you explicitly specify content size.
    # This property is optional.
    def size(self) -> int:
        # If return content size then selected "Content-Length".
        return self.res.headers["Content-Length"]
        # If return None then selected "Transfer-Encoding: chunked".
        return None

    def stream(self) -> Generator[bytes, None, None]:
        for line in self.res.raw:
            yield line

Also, a script has priority over content.

How to use proxy in Google Chrome

If you use in Google Chrome then set options this.

--proxy-server="https=127.0.0.1:8443;http=127.0.0.1:8080"

You can divide a session if you use these options.

--user-data-dir="{UserConfigDirectory}"

Authors

  • fealone

See also the list of contributors who participated in this project.

License

This project is licensed under the GPLv3 License - see the LICENSE file for details

dcoh's People

Contributors

fealone avatar

Stargazers

Takashi MIMA avatar kairi avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

kairi003

dcoh's Issues

Support retry of request.

Cannot retry of request because not support seeks in payload object.
To support a retry of a request by support seeks in payload object.

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.