Skip to content

Commit

Permalink
First attempt
Browse files Browse the repository at this point in the history
Issue #5
  • Loading branch information
damies13 committed Apr 7, 2023
1 parent 3be63f5 commit f327077
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
73 changes: 73 additions & 0 deletions src/modules/h2r_base64.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,81 @@
# base64 Module - encoding and decoding base64 encoded values
import base64

class h2r_base64():
"""docstring for ."""

def __init__(self, parent):
# super(, self).__init__()
self.parent = parent

#
# Register Encoders
#

b64 = "03:self.h2r_base64.base64_encode"
if b64 not in self.parent.encoders:
self.parent.encoders[b64] = {}
self.parent.encoders[b64]["robottranscode"] = "self.h2r_base64.base64_decode"

#
# Register Decoders
#

b64 = "03:self.h2r_base64.base64_decode"
if b64 not in self.parent.encoders:
self.parent.decoders[b64] = {}
self.parent.decoders[b64]["robottranscode"] = "self.h2r_base64.base64_encode"

#
# Register Paersers
#

#
# Register processors
#


#
# Encoders
#

def base64_encode(self, s):
try:
s_bytes = s.encode('utf_8')
base64_bytes = base64.b64encode(s_bytes)
base64_s = base64_bytes.decode('utf_8')
return base64_s
except Exception:
return s

#
# Decoders
#

def base64_decode(self, s):
try:
# s_bytes = s.encode('utf_8')
s_bytes = s.encode()
dec_bytes = base64.b64decode(s_bytes)
# dec_s = dec_bytes.decode('utf_8')
dec_s = dec_bytes.decode()
return dec_s
except Exception:
return s


#
# Paersers
#



#
# processors
#





#
4 changes: 2 additions & 2 deletions src/modules/h2r_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def response_headers(self):
estep = self.parent.find_estep(resp, ekwname)

# check headers
self.parent.debugmsg(6, "is searchval in headers:", searchval)
self.parent.debugmsg(7, "is searchval in headers:", searchval)
for h in e["response"]["headers"]:
if h["value"] == searchval and h["name"] in searchkeys:
hkey = h["name"]
Expand Down Expand Up @@ -209,7 +209,7 @@ def response_cookies(self):


# check Cookies
self.parent.debugmsg(6, "is searchval in cookies:", searchval)
self.parent.debugmsg(7, "is searchval in cookies:", searchval)
for c in e["response"]["cookies"]:
if c["value"] == searchval and c["name"] in searchkeys:
ckey = c["name"]
Expand Down

0 comments on commit f327077

Please sign in to comment.