Skip to content

Commit

Permalink
Update to 0.28 which uses libhtp-0.5.38.
Browse files Browse the repository at this point in the history
  • Loading branch information
wxsBSD committed Sep 8, 2021
1 parent 9a1e0f6 commit 7c6ef3f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
7 changes: 5 additions & 2 deletions htpy.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 The MITRE Corporation. All rights reserved.
* Copyright (c) 2021 Wesley Shields. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand All @@ -23,13 +24,15 @@
* SUCH DAMAGE.
*/

#define PY_SSIZE_T_CLEAN

#include <Python.h>
#include <structmember.h>
#include "../htp_config_auto_gen.h"
#include "htp.h"
#include "htp_private.h"

#define HTPY_VERSION "0.27"
#define HTPY_VERSION "0.28"

static PyObject *htpy_error;
static PyObject *htpy_stop;
Expand Down Expand Up @@ -784,7 +787,7 @@ static PyObject *htpy_connp_##TYPE##_data(PyObject *self, PyObject *args) { \
const char *data; \
PyObject *ret; \
int x; \
int len; \
Py_ssize_t len; \
if (!PyArg_ParseTuple(args, "s#:htpy_connp_##TYPE##_data", &data, &len)) \
return NULL; \
x = htp_connp_##TYPE##_data(((htpy_connp *) self)->connp, NULL, (unsigned char *) data, len); \
Expand Down
Binary file removed libhtp-0.5.35.tar.gz
Binary file not shown.
Binary file added libhtp-0.5.38.tar.gz
Binary file not shown.
8 changes: 8 additions & 0 deletions request.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
POST /test HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: :)
Host: atarininja.org
Content-Length: 8
Cache-Control: no-cache

QVhTRVJT
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

pathjoin = os.path.join

GITVER = '0.5.35'
GITVER = '0.5.38'
PKGNAME = 'libhtp-' + GITVER
PKGTAR = PKGNAME + '.tar.gz'
BUILDDIR = 'libhtp-' + GITVER
Expand Down Expand Up @@ -51,7 +51,7 @@ def run(self):

setup (# Distribution meta-data
name = "htpy",
version = "0.27",
version = "0.28",
description = "python bindings for libhtp",
author = "Wesley Shields",
author_email = "[email protected]",
Expand Down
35 changes: 35 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import htpy

def uri_callback(cp):
uri = cp.get_uri()
if "path" in uri:
print(uri["path"])
return htpy.HTP_OK

def request_headers_callback(cp):
host = cp.get_request_header("Host")
if host:
print(host)
return htpy.HTP_OK

def request_body_data_callback(data, length):
if not data is None:
print(data)
return htpy.HTP_OK

def request_complete_callback(cp):
print("Request complete.")
print(cp.get_all_request_headers())
return htpy.HTP_OK

print(htpy.HTPY_VERSION)
cp = htpy.init()
cp.register_request_uri_normalize(uri_callback)
cp.register_request_headers(request_headers_callback)
cp.register_request_body_data(request_body_data_callback)
cp.register_request_complete(request_complete_callback)

with open("request.txt", "rb") as f:
req = f.read()

cp.req_data(req)

0 comments on commit 7c6ef3f

Please sign in to comment.