Hex Entity Encoding in SQLmap

522 views Asked by At

I am using SQLmap and want to hex-entity-encode the input before SQLmap sends it to the server.

For example, hex-entity-encoding of "abc" should return abc

I know that I should use a python tamper script which should hex-entity-encode the given input. But I don't know how I could hex-entity-encode data in Python.

May someone can help?

1

There are 1 answers

0
JosefZ On

Apply formatted string literals (also called f-strings for short) e.g. as follows:

a_string = 'abc Trường An Tô Nguyễn'
''.join([f'&#x{ord(ch):x};' for ch in a_string])
# 'abc Trường An Tô Nguyễn'

or e.g. (see Format Specification Mini-Language)

''.join([f'&#x{ord(ch):04x};' for ch in a_string])
#'abc Trường An Tô Nguyễn'