How to pass \x00 as argument to program?

前端 未结 6 1367
温柔的废话
温柔的废话 2021-01-05 19:51

I have a small program where I wish to pass shellcode as argument. In the shellcode, there is a necessity to pass \\x00. I tried the following command:

./pro         


        
6条回答
  •  长情又很酷
    2021-01-05 20:21

    You can try putting the shellcode in a file and then read it back and pass it to the executable.

    something like:

    $ cat shellcode.txt
    \xb5\x06\x40\x00\x00\x00\x00\x00
    
    $ perl -e ' $a = `cat shellcode.txt`; chomp($a); print $a x 10; '
    \xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00
    \x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00
    \xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00
    \x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00\xb5\x06\x40\x00\x00\x00\x00\x00
    

    use the above perl cmdline as argument to the program

    $ ./program $(perl -e ' $a = `cat shellcode.txt`; chomp($a); print $a x 10; ')
    

提交回复
热议问题