0

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

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'
JosefZ
  • 28,460
  • 5
  • 44
  • 83