• XSS.stack #1 – первый литературный журнал от юзеров форума

Shellcode hex string to byte array c++

DanteXDark

(L3) cache
Пользователь
Регистрация
28.10.2021
Сообщения
200
Реакции
41
HI people of xss, i need little help in c++, i want to convert hex string string raw="\xb9\xc7\x82\x52\xeb\x37" (containing shellcode) to a byte array like (char shellcode[]= { 0x00, 0xff, ... } ; )

sry this is a very silly question but i searched on internet but didnt got aything that i can use. pls help, THX IN ADVANCE )
 
Python:
if __name__ == '__main__':
    with open('hex.txt', 'r') as hex_data_file:
        hex_data = hex_data_file.read()
        splitted_data = hex_data.split('\\x')[1:]
        
        for i in range (len(splitted_data)):
            splitted_data[i] = '0x' + splitted_data[i]
            
        c_array = 'byte rawData[] = {{ {} }};'.format(', '.join(splitted_data))
            
        with open('out.txt', 'w') as c_arr_out_file:
            c_arr_out_file.write(c_array)

В hex.txt кладёшь строку в формате \xбайт\xбайт\xбайт, на выходе получаешь нужные тебе данные в out.txt.
 
thank you brothers for replying but i think you dont understand what i am saying... i know how to do this in python but the thing is in
C++ i have string like this [ string shellcode="\xb9\xc7\x82\x52\xeb\x37..." ] and now i want to convert this in a byte array so i can use that shellcode to inject or do other stuff

i am decoding my shellcode from some data and getting \xb9\xc7\x82\x52\xeb\x37 this in a string now i want to put this all stuff in char shellcode2[] = {here} in byte array 0x0f etc

hope you understand )
 
Пожалуйста, обратите внимание, что пользователь заблокирован
thank you brothers for replying but i think you dont understand what i am saying... i know how to do this in python but the thing is in
C++ i have string like this [ string shellcode="\xb9\xc7\x82\x52\xeb\x37..." ] and now i want to convert this in a byte array so i can use that shellcode to inject or do other stuff

i am decoding my shellcode from some data and getting \xb9\xc7\x82\x52\xeb\x37 this in a string now i want to put this all stuff in char shellcode2[] = {here} in byte array 0x0f etc

hope you understand )

from what i understand you are decoding a payload and after that you get string shell code and you want a way to inject this shell code ?!

because from what i can see using notepad++ u can easly convert it to a byte array and then use , if you post a snap from you'r code it will be helpful to help you and better understading of your idea
 
HI people of xss, i need little help in c++, i want to convert hex string string raw="\xb9\xc7\x82\x52\xeb\x37" (containing shellcode) to a byte array like (char shellcode[]= { 0x00, 0xff, ... } ; )

sry this is a very silly question but i searched on internet but didnt got aything that i can use. pls help, THX IN ADVANCE )

As I understand, your question is:
How can I convert a Hex String into a BYTE array, in C++?

Did you check this:
https://gist.github.com/arnobaer/973c91a7e8b5088087e20257df3c82d3
or this:
https://stackoverflow.com/questions/17261798/converting-a-hex-string-to-a-byte-array
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх