GithubHelp home page GithubHelp logo

gormw's People

Contributors

amyangfei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gormw's Issues

Example not working

Hello!
I'm trying to use goreplay & middleware while processing pcap. I just simple want to log requests/responses to stderr. I slightly modified your example in readme.
run command:
gor --input-raw my.pcap:80 -output-http "http://server:8080" --output-http-track-response --middleware "middleware_gor.py" --input-raw-track-response --input-raw-engine "pcap_file"
Middleware file is bellow:

# coding: utf-8
import sys
from gor.middleware import AsyncioGor

def log(msg):
    """
    Logging to STDERR as STDOUT and STDIN used for data transfer
    @type msg: str or byte string
    @param msg: Message to log to STDERR
    """
    try:
        msg = str(msg) + '\n'
    except:
        pass
    sys.stderr.write(msg)
    sys.stderr.flush()


def on_request(proxy, msg, **kwargs):
    log("fromtype:1 id: {}".format(msg.id))
    proxy.on('response', on_response, idx=msg.id, req=msg)


def on_response(proxy, msg, **kwargs):
    log("fromtype:2 id: {}".format(msg.id))
    proxy.on('replay', on_replay, idx=kwargs['req'].id, req=kwargs['req'], resp=msg)


def on_replay(proxy, msg, **kwargs):
    log("fromtype:3 id: {}".format(msg.id))
    

if __name__ == '__main__':
    proxy = AsyncioGor()
    proxy.on('request', on_request)
    proxy.run()

What am I doing wrong?

如果接口是上传文件,会报错

如果接口是上传文件,比如上传图片,body内容在decode的时候,不能转成字符串,就会报错了
" 'utf-8' codec can't decode byte 0x89 in position 715: invalid start byteTraceback (most recent call last):
File "/Users/rc/Library/Python/3.9/lib/python/site-packages/gor/base.py", line 70, in parse_message
payload = binascii.unhexlify(line.strip()).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 715: invalid start byte

I cant get the http message via the demo

step 1:
I use the command to start goplay

gor --input-raw :8000 \
 --output-stdout \
 --output-file request.log \
 --input-raw-track-response \
 --output-http-track-response \
 --prettify-http \
 --output-tcp diferencia:8081 \
 --http-disallow-header 'User-Agent: Gor'

step 2:
and use the demo code to start the goplay middleware

# coding: utf-8
import sys
from gor.middleware import AsyncioGor


def on_request(proxy, msg, **kwargs):
    proxy.on('response', on_response, idx=msg.id, req=msg)

def on_response(proxy, msg, **kwargs):
    proxy.on('replay', on_replay, idx=kwargs['req'].id, req=kwargs['req'], resp=msg)

def on_replay(proxy, msg, **kwargs):
    replay_status = proxy.http_status(msg.http)
    resp_status = proxy.http_status(kwargs['resp'].http)
    if replay_status != resp_status:
        print('replay status [%s] diffs from response status [%s]\n' % (replay_status, resp_status))
    else:
        print('replay status is same as response status\n')
    sys.stderr.flush()

if __name__ == '__main__':
    proxy = AsyncioGor()
    proxy.on('request', on_request)
    proxy.run()

when I send http message to goplay by curl,But I can`t get message from the middleware?

I need help

这个项目目前还会继续维护吗?

最近在看goreplay的middleware部分,发现了这个包,感觉还是比较好用的,在使用过程中,我感觉还有一些方法可以提供,现在的获取header,获取查询参数都需要加name参数,作者有考虑过写几个直接返回所有header,所有参数的方法吗,在使用过程中,可能会需要将请求划分为url,params,headers,method这样的部分,所以有一些能够直接将msg解析为通用请求结构的方法会好一点

If the response of replay is returned first, the on_replay method cannot be called normally

# coding: utf-8
import sys
from gor.middleware import AsyncioGor


def on_request(proxy, msg, **kwargs):
    proxy.on('response', on_response, idx=msg.id, req=msg)

def on_response(proxy, msg, **kwargs):
    proxy.on('replay', on_replay, idx=kwargs['req'].id, req=kwargs['req'], resp=msg)

def on_replay(proxy, msg, **kwargs):
    replay_status = proxy.http_status(msg.http)
    resp_status = proxy.http_status(kwargs['resp'].http)
    if replay_status != resp_status:
        sys.stderr.write('replay status [%s] diffs from response status [%s]\n' % (replay_status, resp_status))
    else:
        sys.stderr.write('replay status is same as response status\n')
    sys.stderr.flush()

if __name__ == '__main__':
    proxy = AsyncioGor()
    proxy.on('request', on_request)
    proxy.run()

replay_resp appears earlier than origin_resp, and on_replay depends on on_response. on_replay method is not registered at the time of replay_resp's appearance

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.